Multitoken
Multitoken serves as the foundation for bookkeeping in Multiswap, enabling precise tracking of reserves, collateral, liquidity positions, staking, governance, and reward distribution all in the same contract. Multitoken introduces subaccounts using a hierarchical tree data structure with native support for both debit accounts (asset) and credit accounts (liabilities and equity) in support of double-entry accounting making it suitable for advanced large-scale DeFi applications.
As an example, the diagram below illustrates the hierarchy for Multiswap's Staking Rewards model.
Key Features
- Each independent tree with its own root represents a distinct token.
- Each token can have multiple subaccounts organized in a hierarchical structure.
- Each account, including root tokens, can have their own names.
- Supports both debit accounts (assets) and credit accounts (liabilities and equity) for native double-entry accounting.
Conclusion
The Multitoken contract provides a versatile and scalable foundation for next-generation DeFi applications. By leveraging hierarchical subaccounts, multi-token support, and doube-entry accounting, it enables efficient bookkeeping for reserves, scale, staking, governance, and rewards while maintaining flexibility for future expansions.