pool state

This page documents the on-chain Pool account used by the constant-product AMM (x·y = k). Each pool is uniquely identified by its base/quote mints and owns two SPL token vaults that hold reserves.


PDA & Seeds

  • Pool PDA: ["pool", base_mint, quote_mint]pool (The program sets and verifies this relationship in instructions.)

  • Vault PDAs (owned by pool):

    • Base vault: ["vault", pool, base_mint]base_vault

    • Quote vault: ["vault", pool, quote_mint]quote_vault


Struct (on chain)

#[account]
pub struct Pool {
    /// Global Config
    pub config: Pubkey,

    /// Mints
    pub base_mint: Pubkey,           // token you receive on buy (base)
    pub quote_mint: Pubkey,          // token you pay on buy (quote)

    /// Vaults (SPL Token Accounts, owner = pool PDA)
    pub base_vault: Pubkey,
    pub quote_vault: Pubkey,

    /// LP token mint (SPL)
    pub lp_mint: Pubkey,

    /// Pool authorities
    pub creator: Pubkey,
    pub token_creator: Pubkey,       // used when creator fees apply

    /// Reserves (current balances reflected in x·y=k)
    pub base_reserve: u64,           // x
    pub quote_reserve: u64,          // y

    /// LP accounting
    pub lp_supply: u64,

    /// Cumulative trade accounting
    pub cumulative_volume_base: u128,
    pub cumulative_volume_quote: u128,
    pub cumulative_fees_base: u128,
    pub cumulative_fees_quote: u128,

    /// Lifecycle & migration
    pub state: u8,                   // 1 = LIVE (required by buy/sell)
    pub migrated_from_launch: bool,

    /// Time & invariant snapshot
    pub last_update_timestamp: i64,  // unix seconds
    pub k_last: u128,                // snapshot of x*y (used for fee/analytics)

    /// PDA bump
    pub bump: u8,

    /// Reserved for future upgrades (zeroed)
    pub reserved: [u64; 16],
}

Last updated