Account model

Account model

Core accounts

Pool (PDA)

  • Holds the pool configuration, authorities, price cache, vault addresses, LP mint, fee parameters, pause bits, and bookkeeping totals.

  • PDA seeds (as in IDL):

pool_pda = PDA(
  seeds = ["pool", base_mint, quote_mint]
)

Key fields to understand from the IDL:

  • Authorities: admin, config_authority, pause_guardian, fee_withdraw_authority

  • Mints + vaults: base_mint, quote_mint, base_vault, quote_vault, fee vaults, lp_mint

  • Price: price_q64_64, and bin control: initial_bin_id, active_bin

  • Fee config fields mirrored into Pool: base_fee_bps, creator_cut_bps, split microbps fields

  • Safety: pause_bits, plus version for upgrade compatibility

PairRegistry (PDA)

  • Prevents duplicate pools for the same pair configuration.

bin_pda = PDA(
  seeds = ["bin", pool_pda, bin_index]
)
  • Bounds (lower_bound_q64_64, upper_bound_q64_64) mainly for sanity/analytics

  • Actual reserves at that bin’s fixed price: reserve_base, reserve_quote

  • Fee growth accumulators: fee_growth_base_q128, fee_growth_quote_q128

Token accounts (vaults and user accounts)

Pool vaults (PDAs)

These are SPL token accounts used to hold liquidity and fees.

Liquidity vaults:

Fee vaults:

LP mint

  • A mint created per pool. Depositors receive LP tokens as “shares”.

  • Withdrawals burn LP shares.

User token accounts

  • For deposit and withdrawal: user_base, user_quote, and user_lp.

  • For swaps: user_source and user_destination.

Liquidity locking model

LiquidityLock (PDA)

  • A per-user record that enforces time-based withdrawal restrictions.

escrow_lp

  • SPL token account owned by the pool PDA that holds locked LP tokens.

  • lock_liquidity transfers LP tokens from user_lp into escrow_lp and writes lock metadata.

Withdrawal path checks for locks:

  • withdraw_user accepts liquidity_lock as an UncheckedAccount and validates if it exists.

  • Error ActiveLock (6034) stops withdrawal until the lock expires.

Last updated