Skip to content

Mouazzama-dev/Index-Contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

DMAC: Decentralized Managed Asset Composition

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."

🚀 Overview

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.

Key Features

  • 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.

🏗 Architecture

The program relies on several distinct account types to manage the lifecycle of an index:

  1. ProgramState: Global configuration and admin authority.
  2. IndexInfo: Stores the metadata, token weights, total value (USD), and total supply of a specific index.
  3. SwapToTkn/SwapToSol Info: Temporary "progress" accounts that track which tokens in the basket have been successfully swapped during a buy or sell cycle.
  4. Program Authority PDA: The vault that holds the underlying assets for the index.

🛠 Instructions

For Administrators

  • 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.

For Users

  • 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.

The "Crank" (Automated Swaps)

  • 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_tokens bit-array is complete.
  • swap_to_tkn_end / swap_to_sol_end: Finalizes the process, distributes fees, and transfers the final assets to the user.

🔧 Technical Requirements

  • 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

⚠️ Security & Implementation Notes

  • Fixed-Point Math: While the current version uses f64 for 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 ComputeBudgetProgram during the swap phases.
  • Authority Seeds: The program uses a PDA derived from the index_mint and PROGRAM_AUTHORITY_SEED to ensure isolated vaults for every index created.

📜 License

Internal / Proprietary

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors