Skip to main content

🏗️ Architecture


The Baskets Protocol is governed by a set of on-chain programs written in Rust using the Anchor framework. This section provides a high-level overview of the key accounts and their roles.

Program State

A singleton account that stores global configuration for the entire protocol, such as:

  • The authority (the admin wallet).
  • The treasury wallet address.
  • The protocol's swap fee percentage.

Index State

This is the main account for each individual basket. It stores all the critical information about a specific basket, including:

  • The creator's public key.
  • The basket's name and ticker symbol.
  • A list of the assets within the basket and their target weights.
  • Timestamps for creation, last rebalance, and last fee accrual.
  • Status flags (e.g., is_active, is_rebalancing).

Vaults & Escrows

The protocol uses a hybrid model for token management to maximize both security and compatibility:

  • Main Asset Vaults: Each asset within a basket is held in a standard Associated Token Account (ATA). The authority for these vaults is a Program Derived Address (PDA), giving the smart contract full control over the funds. Using ATAs ensures compatibility with the broader Solana ecosystem.
  • Temporary Escrows: For user-specific actions like deposits and redemptions, the protocol creates single-use PDA escrow accounts. This isolates user funds during a transaction, ensuring that even if a complex multi-step transaction fails, the funds are held securely and can be recovered by the user via a rescue function.