Skip to content
The programArchitecture

The program

Architecture

One Anchor program (programs/mandate, Anchor 0.30.1) owns every pool. There is no off-chain component the pool depends on: no oracle, no keeper with special rights, no admin key over pool funds.

Accounts

AccountSeedsHolds
Config["config"]the quote mint (USDC on mainnet), the treasury owner, the upgrade authority at init
Pool (zero-copy)["mandate", author, id as u64 LE]mints, vaults, reserves, glide anchors, covenant, fee state, index and high-water mark
LP mint["lp", pool]the fund share; decimals equal the quote mint's; mint authority is the pool
Vaultsassociated token account of the pool per mintthe assets, under the SPL Token or Token-2022 program of each mint
DeferredClaim["deferred", pool, owner]units owed to a holder who exited while an asset could not move

One pool exists per (author, id): a second publish with the same pair fails on the PDA.

Pool state that matters

pub reserves: [u64; MAX_ASSETS],      // the invariant runs on these, never on vault balances
pub w_from: [u64; MAX_ASSETS],        // glide anchors, WAD (1e18)
pub w_to: [u64; MAX_ASSETS],
pub glide_start: i64,
pub glide_end: i64,
pub index_ema: u64,                   // oracle-free index, 1-day smoothing
pub index_hwm: u64,                   // its global high-water mark
pub caps_bps: [u16; MAX_ASSETS],      // covenant: written by publish, never again
pub cash_floor_bps: u16,
pub gamma_min_bps: u16,
pub gamma_max_bps: u16,
pub royalty_bps: u16,
pub gamma_bps: u16,                   // the current fee

Life of a pool

sequenceDiagram
  participant A as Author
  participant P as Program
  participant T as Trader
  participant H as Holder
  A->>P: publish(weights, fee, covenant, glide?)
  A->>P: seed(amounts) -> status ACTIVE, 1,000 base units locked
  H->>P: deposit(shares, max_amounts)
  T->>P: update(deltas) accepted only if invariant grows by the fee
  A->>P: revise(to_bps, end, fee) inside the covenant, at most 2 points a day
  H->>P: withdraw(shares, min_amounts)

Fixed point

Weights, logarithms and ratios use WAD = 10^18. The trade check runs in the log domain: ln_wad evaluates a 13-term atanh series after range reduction, and an accepted update must clear INVARIANT_MARGIN = 1e-14 above zero, two orders above the measured error of the whole check.

Compute

Measured on SBF during the spike for the invariant check alone, transaction overhead included: 38,867 CU with 3 assets, 58,679 with 5, 89,126 with 8.