API reference

Program: Anchor 0.31. Seeds are byte strings; band is one byte.

Once, signed by the program's upgrade authority.

create_pool(mint_set: [u8; 32])

AccountNotes
payersigner
poolinit, seeds ["pool", mint_set]
remaining2 to 16 mints, strictly ascending

Errors: AssetCount, MintOrder, MintSetMismatch, DecimalsMismatch, MintProgram, MintExtension.

open_position(band: u8)

AccountNotes
ownersigner, pays rent
pool
positioninit, seeds ["position", pool, owner, band]

band is 0 to 7 (see Overview). Error: BandIndex.

add_liquidity(radius: u128, max_amounts: Vec<u64>)

Accounts: owner (signer), pool, position, token_program; remaining accounts, for every coin in order: mint, the pool's vault, the owner's token account.

Pays the band's share of every coin for radius, rounded up, at most max_amounts[k] of coin k. Errors: AmountCount, Slippage, CapExceeded, Insolvent.

remove_liquidity(radius: u128, min_amounts: Vec<u64>)

Same accounts. Pays the share of every coin, rounded down, at least min_amounts[k]. Fees stay in the position. Errors: PositionTooSmall, Slippage.

collect_fees(coin: u8)

Accounts: owner, pool, position, mint, vault, owner_account, token_program. Error: NothingToCollect.

close_position

Returns rent once the position holds no radius and no fees. Error: PositionNotEmpty.

swap(coin_in: u8, coin_out: u8, amount_in: u64, min_out: u64)

See Integration for the account list. Errors: CoinIndex, ZeroAmount, CoinAccount, Slippage, ZeroOutput, ExceedsLiquidity, NegativePrice, TooManySegments, NoInteriorLiquidity, Insolvent.

State layouts

Pool (zero-copy): mints[16], vaults[16], mint_set, reserves[16], lp_fees_pending[16], tau, bands[8], bump, n, decimals.

Band: beta, gamma, mu, sigma, radius (each a u128 stored as two u64 words), fee_growth[16], boundary.

Position: pool, owner, band, bump, radius, fee_checkpoint[16], fees_owed[16].

Next: Error reference