DMAC is an Anchor-based Solana program that allows for the creation and management of decentralized index funds. It enables administrators to define a basket of assets (Token-2022 or Standard SPL) and allows users to gain exposure to that basket by minting a single "Index Token."
The program utilizes a State Machine architecture to handle the complexity of multi-token swaps via Jupiter. Since swapping a SOL deposit into 5+ different tokens can exceed transaction compute limits, DMAC breaks the process into an initialization phase, a sequence of individual swaps, and a finalization phase.
- Weighted Baskets: Define up to 100% weight distribution across multiple assets.
- Jupiter CPI Integration: Real-time swaps using the Jupiter Aggregator.
- Pyth Price Feeds: Real-time SOL/USD valuation for accurate index minting.
- Token-2022 Ready: Full support for modern Solana token standards and metadata.
- Multi-Collector Fees: Programmable fee distribution to multiple stakeholders.
The program relies on several distinct account types to manage the lifecycle of an index:
- ProgramState: Global configuration and admin authority.
- IndexInfo: Stores the metadata, token weights, total value (USD), and total supply of a specific index.
- SwapToTkn/SwapToSol Info: Temporary "progress" accounts that track which tokens in the basket have been successfully swapped during a buy or sell cycle.
- Program Authority PDA: The vault that holds the underlying assets for the index.
- initialize: Set up the global program state.
- create_index: Deploy a new index mint, set weights, and define fee collectors.
- rebalance_index_start: Initiate a change in the weight distribution of the basket.
- mint_index: (Admin only) Initial supply seeding.
- buy_index: Deposit SOL to initiate the acquisition of index tokens.
- sell_index: Burn index tokens to initiate a withdrawal of the underlying value back to SOL.
- swap_to_tkn / swap_to_sol: These instructions are called iteratively (usually by a backend bot) to execute the Jupiter swaps for each token in the index basket until the
swapped_tokensbit-array is complete. - swap_to_tkn_end / swap_to_sol_end: Finalizes the process, distributes fees, and transfers the final assets to the user.
- Anchor Framework:
^0.30.1(or your specific version) - Solana Toolsuite:
^1.18.0 - Pyth Receiver SDK: Used for SOL/USD price feeds.
- Jupiter Program:
JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4
- Fixed-Point Math: While the current version uses
f64for UI-friendly calculations, production environments should ensure precision handling to avoid rounding "dust." - Compute Budget: Multi-token indices require requesting additional compute units via the
ComputeBudgetProgramduring the swap phases. - Authority Seeds: The program uses a PDA derived from the
index_mintandPROGRAM_AUTHORITY_SEEDto ensure isolated vaults for every index created.
Internal / Proprietary