Build
Program reference
The una program: its address, every account and field, every instruction with its arguments, accounts and errors, and every event.
Una is one Anchor program, una, at BAP8m3hSZnrkpJij3Pmya12LvKNLCseq8c441qHFQB2F. It has 23 instructions, 9 kinds of account, 42 errors and 22 events. The SDK and the API build every transaction a wallet needs; this page is for reading the program's accounts directly and for calling it from your own code.
Conventions
| Thing | How the program holds it |
|---|---|
| A price | u128, Q64.64, lamports per atom of the token. The integer stands for itself divided by 2^64. |
| A limit | u128, Q64.64, atoms of the buy token per atom of the sell token. |
| A fill fraction | u64 out of FILL_ONE, 2^63. |
| A rate | u16, basis points. |
| Time | Slots. |
| A token | Its index, a u16 given in listing order. wSOL is 0. |
| Bond | Lamports. A liquid staking token counts at its SPL Stake Pool's total_lamports / pool_token_supply, rounded down. |
Tokens of the SPL Token program and of Token-2022 are both accepted; every transfer is a checked transfer. Payments go to the owner's associated token account, which must exist.
The first 8 bytes of every account are its Anchor discriminator. Config, Pair, Batch, Solver and Stake are zero-copy: after the discriminator their fields sit in the order listed, in C layout. Token, Order, Position and Cover are Borsh.
Events are emitted through a self-call (emit_cpi!), so each one is an inner instruction of the transaction and survives log truncation. That is why every instruction takes event_authority and program last.
Addresses
Every account is a program-derived address of the program.
| Account | Seeds | What it is |
|---|---|---|
| Config | "config" | The one configuration account. It is also the authority of every vault. |
| Batch | "batch", batch id as u64 LE | One per batch. Batch 1 is created by init, each next one by seal_batch. |
| Token | "token", token index as u16 LE | One per listed token. |
| Token vault | "token_vault", token index as u16 LE | The token account that holds a listed token: sell amounts, liquidity and fees not yet claimed. |
| Pair | "pair", pair index as u16 LE | One per pair. |
| Order | "order", owner, nonce as u64 LE | One per order. The nonce is any number the owner has not used. |
| Position | "position", owner, pair index as u16 LE, lower tick as i32 LE, upper tick as i32 LE | One per owner, pair and range. |
| Solver | "solver", operator | One per operator. |
| Stake | "stake", solver, owner, bond mint index as u8 | One per staker, solver and bond mint. |
| Solver vault | "solver_vault", solver, bond mint index as u8 | The token account that holds a solver's stake in one bond mint. |
| Cover | "cover", batch id as u64 LE | One per slashed batch. |
| Cover vault | "cover_vault", batch id as u64 LE, bond mint index as u8 | The token account that holds a slashed batch's cover in one bond mint. |
Limits
| Limit | Value |
|---|---|
| Listed tokens | 32 |
| Pairs | 64 |
| Tokens in one batch | 16 |
| Fill fractions in one batch | 16 |
| Initialized ticks on one pair | 64 |
| Bond mints | 4 |
| Ticks | -443,636 to 443,636 |
Accounts
Config
The protocol's settings and its two counters of batches. Zero-copy.
Config
batch_window_slotsu64- The batch window, in slots.
clearing_timeout_slotsu64- How many slots after sealing a batch may be rolled if no solver has cleared it.
proof_window_slotsu64- The proof window, in slots, counted from the slot of
clear_batch. unstake_cooldown_slotsu64- The unstake cooldown, in slots.
current_batch_idu64- The number of the open batch.
next_clear_batch_idu64- The number of the oldest sealed batch not yet cleared or rolled. Batches are cleared or rolled in order.
adminpubkey- The key that may send
set_config,list_tokenandcreate_pair. fee_recipientpubkey- The wallet whose token accounts receive the protocol share of the clearing fee.
dev_attesterpubkey- A key read only by a localnet build of the program.
sp1_vkey_hash[u8; 32]- The SP1 verification key hash of the guest program: the first public input of every proof.
bond_mints[BondMintConfig; 4]- The mints a stake can be in, 4 at most. See BondMintConfig.
groth16_vk[u8; 512]- SP1's Groth16 verifying key, in gnark's compressed form, in a 512-byte buffer.
groth16_vk_lenu16- How many bytes of
groth16_vkare the key. band_bpsu16- The price band, in basis points of the last proven price. Below 10,000.
clearing_fee_bpsu16- The clearing fee, in basis points of each filled order's output. Below 10,000.
protocol_fee_share_bpsu16- The share of the clearing fee paid to the fee recipient, in basis points. At most 10,000.
token_countu16- How many tokens are listed, 32 at most.
pair_countu16- How many pairs exist, 64 at most.
bond_mint_countu8- How many entries of
bond_mintsare in use. bumpu8- The bump of the account's address.
_pad[u8; 2]- Padding. Always zero.
Token
A listed token: its mint, its vault and its last proven price.
Token
indexu16- The token's index, in listing order. wSOL is 0.
mintpubkey- The token's mint.
token_programpubkey- The token program that owns the mint: SPL Token or Token-2022.
vaultpubkey- The token's vault.
decimalsu8- The mint's decimals.
last_priceu128- The last proven price as Q64.64, in lamports per atom. Set at listing, then only by
prove_batch. wSOL's is always 2^64. pairsu64- A bit for each pair the token is in, by pair index.
bumpu8- The bump of the account's address.
vault_bumpu8- The bump of the vault's address.
Pair
Two tokens with concentrated liquidity between them, up to 64 initialized ticks. Zero-copy.
Pair
sqrt_priceu128- The square root of the pair's price as Q64.64. The price is atoms of the second token per atom of the first.
liquidityu128- The liquidity active at the current price.
fee_growth_global_xu128- Fees and surplus credited per unit of liquidity since the pair was created, in the first token, as Q64.64.
fee_growth_global_yu128- The same in the second token.
ticks[PairTick; 64]- The initialized ticks, in ascending order. The first
tick_countentries are in use. See PairTick. ticki32- The tick the current price is in.
indexu16- The pair's index, in creation order.
token_xu16- The index of the pair's first token, the lower index.
token_yu16- The index of the pair's second token.
fee_bpsu16- The pair's liquidity fee, in basis points. Below 10,000.
tick_spacingu16- Ticks of a range on this pair are multiples of this.
tick_countu8- How many ticks are initialized, 64 at most.
bumpu8- The bump of the account's address.
in_flight_batchu64- The number of the cleared batch that last moved the pair and is not yet proven or slashed, or 0. While it is set, liquidity cannot be removed from the pair.
_pad[u8; 8]- Padding. Always zero.
Batch
One batch from open to its outcome: its input hash, what its orders offer, and after clearing its prices, fees, fill fractions, solver and bond. Zero-copy. Arrays indexed by token hold one slot per batch token, in ascending token index.
Batch
prices[u128; 16]- The cleared price of each batch token as Q64.64, in lamports per atom.
pair_active_liquidity[u128; 16]- For each batch pair, the larger of its active liquidity before and after the clearing. It sets a position's share of the cover.
band_lo[u128; 16]- For each batch token, the lowest price its band allowed when the batch was cleared.
band_hi[u128; 16]- For each batch token, the highest price its band allowed when the batch was cleared.
batch_idu64- The batch's number. Batches count from 1.
open_slotu64- The slot the batch opened in.
seal_slotu64- While open, the slot the window ends at. Once sealed, the slot it was sealed in.
clear_slotu64- The slot
clear_batchlanded in. proof_deadline_slotu64- The last slot
prove_batchis accepted in. proven_slotu64- The slot
prove_batchlanded in. bond_lockedu64- The bond locked behind the batch, in lamports. Equal to
value_moved. value_movedu64- The value the program measured the clearing to move, in lamports.
offered[u64; 16]- For each batch token, the total of order amounts selling it. Kept as orders are placed, cancelled and moved in.
fees[u64; 16]- For each batch token, the clearing fee its buyers pay in this batch, in its atoms.
pair_moved_value[u64; 16]- For each batch pair, what its liquidity paid out, in lamports at the cleared price.
fills[BatchFillSlot; 16]- The fill fractions of the rationed directions. The first
fill_countentries are in use. See BatchFillSlot. input_hash[u8; 32]- The running hash of the batch's input.
state_hash[u8; 32]- The hash of the state the clearing was solved against.
result_hash[u8; 32]- The hash of the posted prices, fees and fill fractions.
solverpubkey- The solver that cleared the batch.
tokens[u16; 16]- The indexes of the batch tokens, ascending. The first
token_countentries are in use. pairs[u16; 16]- The indexes of the batch pairs. The first
pair_countentries are in use. order_countu32- How many orders were placed in or moved into the batch.
clearing_fee_bpsu16- The clearing fee rate the batch was cleared with.
settle_orderpays every order of the batch at this rate. token_countu8- How many batch tokens there are, 16 at most.
pair_countu8- How many batch pairs there are.
fill_countu8- How many fill fractions there are, 16 at most.
statusu8- 0 open, 1 sealed, 2 cleared, 3 proven, 4 slashed, 5 rolled.
bumpu8- The bump of the account's address.
_pad[u8; 5]- Padding. Always zero.
payerpubkey- The account that paid the batch account's rent: the sender of the
seal_batchthat created it, or the admin for batch 1.close_batchreturns the rent to it. open_ordersu32- How many orders are still in the batch, neither settled nor cancelled nor moved on.
_pad2[u8; 12]- Padding. Always zero.
Order
One order. amount shrinks to the remainder each time the order moves to a later batch.
Order
ownerpubkey- The wallet that owns it.
nonceu64- The number the owner chose for the order's address.
batch_idu64- The batch the order is in now.
origin_batch_idu64- The batch the order was placed in.
expiry_batch_idu64- The last batch the order may clear in.
sell_tokenu16- The index of the token sold.
buy_tokenu16- The index of the token bought.
amountu64- Atoms of the sell token the order offers in its current batch.
limitu128- The limit as Q64.64: least atoms of the buy token per atom of the sell token.
statusu8- 0 open, 1 settled, 2 cancelled.
cover_claimedbool- Whether the order has claimed its share of a slashed batch's cover.
bumpu8- The bump of the account's address.
Position
Liquidity of one owner on one pair over one range.
Position
ownerpubkey- The wallet that owns it.
pair_indexu16- The pair's index.
tick_loweri32- The lower tick of the range.
tick_upperi32- The upper tick of the range.
liquidityu128- The position's liquidity.
fee_growth_inside_last_xu128- The fee growth inside the range when the position was last brought up to date, in the first token.
fee_growth_inside_last_yu128- The same in the second token.
tokens_owed_xu64- Fees and surplus earned and not yet paid out, in atoms of the first token.
tokens_owed_yu64- The same in the second token.
last_cover_batch_idu64- The last slashed batch the position claimed cover from.
bumpu8- The bump of the account's address.
Solver
A registered solver: its stake by bond mint, its locked bond and the fees it has earned. Zero-copy.
Solver
reward_per_share[u128; 32]- For each token index, clearing fees credited to stakers per lamport of stake weight, as Q64.64, since the solver registered.
operator_commission[u64; 32]- For each token index, commission earned and not yet claimed, in the token's atoms.
bond_pool_amounts[u64; 4]- For each bond mint, the atoms staked behind the solver.
bond_pool_shares[u64; 4]- For each bond mint, the shares issued against those atoms.
pending_unstake_lamportsu64- Stake in cooldown, valued in lamports. It does not count as free bond.
bond_locked_lamportsu64- Bond locked behind cleared batches awaiting proof.
total_bond_weightu64- The sum of its stakes' reward weights, in lamports.
batches_clearedu64- How many batches the solver has cleared.
batches_provenu64- How many of them it has proven.
operatorpubkey- The wallet that runs the solver.
slash_countu32- How many of them were slashed.
commission_bpsu16- The part of the solver's share of clearing fees the operator keeps, in basis points. At most 10,000.
activeu8- 1 for a solver that may clear.
bumpu8- The bump of the account's address.
_pad[u8; 16]- Padding. Always zero.
Stake
One staker's shares of one solver's stake in one bond mint, with its rewards. Zero-copy.
Stake
reward_debt[u128; 32]- For each token index, the solver's
reward_per_sharewhen the stake was last brought up to date. pending_rewards[u64; 32]- For each token index, rewards earned and not yet claimed, in the token's atoms.
sharesu64- Shares staked and not in cooldown.
unstake_sharesu64- Shares in cooldown.
unstake_unlock_slotu64- The slot the cooldown ends at.
unstake_lamports_reservedu64- The lamport value of the shares in cooldown, as measured when unstake was requested.
reward_weightu64- The stake's weight in the solver's rewards: the lamport value of its deposits at the time each was made.
solverpubkey- The solver account.
ownerpubkey- The wallet that owns it.
bond_mint_idxu8- The index of the bond mint in
Config.bond_mints. bumpu8- The bump of the account's address.
_pad[u8; 6]- Padding. Always zero.
Cover
The bond taken from a solver when a batch is slashed, and what has been claimed from it.
Cover
batch_idu64- The batch's number. Batches count from 1.
vault_amounts[u64; 4]- For each bond mint, the atoms moved into the cover.
claimed_amounts[u64; 4]- For each bond mint, the atoms claimed so far.
total_weightu64- The batch's value moved, in lamports. A claim's share is its weight over this.
claimed_weightu64- The weight claimed so far.
bumpu8- The bump of the account's address.
Types inside accounts
BondMintConfig
One entry of Config.bond_mints.
BondMintConfig
mintpubkey- The token's mint.
stake_poolpubkey- The SPL Stake Pool that issues the mint. The default address for wSOL.
token_programpubkey- The token program that owns the mint: SPL Token or Token-2022.
decimalsu8- The mint's decimals.
activeu8- 1 while stakes in this mint are accepted.
_pad[u8; 6]- Padding. Always zero.
PairTick
One initialized tick of a pair.
PairTick
liquidity_neti128- The change in active liquidity when the price crosses the tick upward.
liquidity_grossu128- The liquidity of all positions that start or end at the tick. The tick is removed when it reaches 0.
fee_growth_outside_xu128- Fee growth on the far side of the tick from the current price, in the first token.
fee_growth_outside_yu128- The same in the second token.
ticki32- The tick.
initializedu8- 1 for a tick in use.
_pad[u8; 11]- Padding. Always zero.
BatchFillSlot
One fill fraction of a cleared batch.
BatchFillSlot
phiu64- The fill fraction, out of
FILL_ONE, 2^63. sellu16- The index of the token the direction sells.
buyu16- The index of the token the direction buys.
_pad[u8; 4]- Padding. Always zero.
Instructions
Each instruction lists its arguments, the accounts it takes in order, the events it emits and the errors it can raise.
Order instructions
place_order
Creates an order in the open batch and moves amount of the sell token from the owner's associated token account to the token's vault. The order's record is folded into the batch's input hash and amount is added to what the batch offers of the sell token. The first order into a batch whose window has already passed starts the window again from the current slot.
Sent by: The owner of the order.
Arguments
nonceu64- Any
u64the owner has not used for another order. It is a seed of the order's address. amountu64- Atoms of the sell token. Above 0.
limitu128- The limit as Q64.64: least atoms of the buy token per atom of the sell token.
expiry_batch_idu64- The last batch the order may clear in. At least the open batch.
| Account | Writable | Signer | What it is |
|---|---|---|---|
owner | yes | yes | The owner. Signs. |
config | The Config account. | ||
open_batch | yes | The open batch. | |
sell_token | The Token account of the token sold. | ||
buy_token | The Token account of the token bought. | ||
order | yes | The Order account. | |
sell_mint | The mint of the token sold. | ||
owner_sell_ata | yes | The owner's associated token account for the token sold. | |
sell_vault | yes | The vault of the token sold. | |
sell_token_program | The token program of the token sold. | ||
system_program | The System program. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
After the listed accounts, any number of writable Batch accounts. When the batch passed as open_batch has sealed by the time the transaction lands, the order is placed in the one of them that is the open batch.
Emits OrderPlaced.
| Error | Raised when |
|---|---|
BatchAlreadySealed | Neither the batch passed nor any Batch account after the listed ones is open. |
OrderExpired | expiry_batch_id is before the open batch. |
SameTokenOrder | The sell token and the buy token are the same. |
ZeroLiquidity | amount is 0. |
CapacityExceeded | The batch already holds 16 tokens and the order would add another. |
InvalidConfig | limit is 0. |
MathOverflow | An amount does not fit its integer type. |
OrderTooSmall | The order's sell amount is worth less than 100,000 lamports, 0.0001 SOL, at the sell token's last proven price. |
cancel_order
Cancels an order whose batch is still open, folds a cancel record into the batch's input hash, and returns the sell amount to the owner's associated token account.
Sent by: The owner of the order.
| Account | Writable | Signer | What it is |
|---|---|---|---|
owner | yes | The owner. Signs. | |
config | The Config account. | ||
order | yes | The Order account. | |
batch | yes | The batch. | |
sell_token | The Token account of the token sold. | ||
sell_mint | The mint of the token sold. | ||
sell_vault | yes | The vault of the token sold. | |
owner_sell_ata | yes | The owner's associated token account for the token sold. | |
sell_token_program | The token program of the token sold. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits OrderCancelled.
| Error | Raised when |
|---|---|
OrderNotCancellable | The order's batch has sealed. |
Unauthorized | The signer is not the order's owner, or the token account is not the owner's associated token account. |
OrderNotOpen | The order is already settled or cancelled. |
settle_order
Settles an order against its batch once the batch is cleared, proven, slashed or rolled. For a cleared or proven batch it computes the fill from what the batch stored when it cleared, its prices, fill fractions, band bounds and clearing fee rate, and pays the bought tokens, less the clearing fee, to the owner. A remainder moves into the open batch as the same order with the smaller amount, if the open batch is not past the order's expiry and the remainder is worth at least 100,000 lamports at the sell token's last proven price. Otherwise it returns to the owner and the order is settled. In a slashed batch the whole sell amount returns. In a rolled batch the whole amount moves into the open batch, or returns if the order has expired.
Sent by: Anyone. The owner need not sign; payment goes only to the owner's associated token accounts.
| Account | Writable | Signer | What it is |
|---|---|---|---|
config | The Config account. | ||
order | yes | The Order account. | |
order_batch | yes | The batch the order is in. | |
open_batch | yes | The open batch. | |
sell_token | The Token account of the token sold. | ||
buy_token | The Token account of the token bought. | ||
sell_mint | The mint of the token sold. | ||
buy_mint | The mint of the token bought. | ||
sell_vault | yes | The vault of the token sold. | |
buy_vault | yes | The vault of the token bought. | |
owner_sell_ata | yes | The owner's associated token account for the token sold. | |
owner_buy_ata | yes | The owner's associated token account for the token bought. | |
sell_token_program | The token program of the token sold. | ||
buy_token_program | The token program of the token bought. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits OrderSettled.
| Error | Raised when |
|---|---|
BatchAlreadySealed | The open batch passed is no longer open. Send again with the current one. |
OrderNotSettleable | The order is already settled or cancelled, or its batch is still open or sealed. |
Unauthorized | A token account passed is not the owner's associated token account. |
CapacityExceeded | The open batch already holds 16 tokens and the remainder would add another. |
MathOverflow | An amount does not fit its integer type. |
InvalidIndex | The batch did not price one of the order's tokens. |
Liquidity instructions
add_liquidity
Adds liquidity to a position over a range, creating the position on first use, and moves the token amounts that liquidity takes at the pair's current price from the owner to the vaults. Amounts are rounded up.
Sent by: The owner of the position.
Arguments
tick_loweri32- The lower tick of the range.
tick_upperi32- The upper tick of the range.
liquidity_deltau128- The liquidity to add. Above 0.
max_amount_xu64- The most atoms of the first token to pay.
max_amount_yu64- The most atoms of the second token to pay.
| Account | Writable | Signer | What it is |
|---|---|---|---|
owner | yes | yes | The owner. Signs. |
config | The Config account. | ||
pair | yes | The Pair account. | |
position | yes | The Position account. | |
token_x | The Token account of the pair's first token. | ||
token_y | The Token account of the pair's second token. | ||
mint_x | The mint of the first token. | ||
mint_y | The mint of the second token. | ||
owner_ata_x | yes | The owner's associated token account for the first token. | |
owner_ata_y | yes | The owner's associated token account for the second token. | |
vault_x | yes | The vault of the first token. | |
vault_y | yes | The vault of the second token. | |
token_program_x | The token program of the first token. | ||
token_program_y | The token program of the second token. | ||
system_program | The System program. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits LiquidityAdded.
| Error | Raised when |
|---|---|
InvalidTickRange | The lower tick is not below the upper, a tick is outside -443,636 to 443,636, or a tick is not a multiple of the pair's tick spacing. |
ZeroLiquidity | liquidity_delta is 0. |
SlippageExceeded | The liquidity takes more than max_amount_x or max_amount_y. |
Unauthorized | The position at that address belongs to another owner. |
CapacityExceeded | The pair already has 64 initialized ticks and the range needs a new one. |
MathOverflow | An amount does not fit its integer type. |
remove_liquidity
Removes liquidity from a position and pays the token amounts it holds at the pair's current price to the owner. Amounts are rounded down. Fees earned so far stay owed to the position.
Sent by: The owner of the position.
Arguments
liquidity_deltau128- The liquidity to remove. Above 0 and at most the position's.
min_amount_xu64- The least atoms of the first token to accept.
min_amount_yu64- The least atoms of the second token to accept.
| Account | Writable | Signer | What it is |
|---|---|---|---|
owner | yes | The owner. Signs. | |
config | The Config account. | ||
pair | yes | The Pair account. | |
position | yes | The Position account. | |
token_x | The Token account of the pair's first token. | ||
token_y | The Token account of the pair's second token. | ||
mint_x | The mint of the first token. | ||
mint_y | The mint of the second token. | ||
owner_ata_x | yes | The owner's associated token account for the first token. | |
owner_ata_y | yes | The owner's associated token account for the second token. | |
vault_x | yes | The vault of the first token. | |
vault_y | yes | The vault of the second token. | |
token_program_x | The token program of the first token. | ||
token_program_y | The token program of the second token. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
When the pair's in_flight_batch is not 0, the Batch account of that batch follows the listed accounts. The removal goes through once that batch is proven, slashed or rolled, or its account has been closed, and the pair's in_flight_batch is then set back to 0.
Emits LiquidityRemoved.
| Error | Raised when |
|---|---|
InvalidTickRange | A tick is outside the tick range the program supports. |
ZeroLiquidity | liquidity_delta is 0 or more than the position holds. |
SlippageExceeded | The liquidity returns less than min_amount_x or min_amount_y. |
Unauthorized | The signer does not own the account, or an associated token account passed is not the owner's. |
InvalidBatchAccounts | The accounts after the listed ones are missing, out of order or not the expected addresses. |
MathOverflow | An amount does not fit its integer type. |
PairInFlight | The pair was moved by a cleared batch that is not yet proven or slashed, or that batch's account was not passed. |
collect_fees
Brings the position's earnings up to date and pays everything owed to the owner.
Sent by: The owner of the position.
| Account | Writable | Signer | What it is |
|---|---|---|---|
owner | yes | The owner. Signs. | |
config | The Config account. | ||
pair | The Pair account. | ||
position | yes | The Position account. | |
token_x | The Token account of the pair's first token. | ||
token_y | The Token account of the pair's second token. | ||
mint_x | The mint of the first token. | ||
mint_y | The mint of the second token. | ||
owner_ata_x | yes | The owner's associated token account for the first token. | |
owner_ata_y | yes | The owner's associated token account for the second token. | |
vault_x | yes | The vault of the first token. | |
vault_y | yes | The vault of the second token. | |
token_program_x | The token program of the first token. | ||
token_program_y | The token program of the second token. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits FeesCollected.
| Error | Raised when |
|---|---|
NothingToClaim | The position is owed nothing in either token. |
Unauthorized | The signer does not own the account, or an associated token account passed is not the owner's. |
settle_position
The same payment as collect_fees, sent by anyone. It succeeds when nothing is owed.
Sent by: Anyone. Payment goes only to the owner's associated token accounts.
| Account | Writable | Signer | What it is |
|---|---|---|---|
config | The Config account. | ||
pair | The Pair account. | ||
position | yes | The Position account. | |
token_x | The Token account of the pair's first token. | ||
token_y | The Token account of the pair's second token. | ||
mint_x | The mint of the first token. | ||
mint_y | The mint of the second token. | ||
owner_ata_x | yes | The owner's associated token account for the first token. | |
owner_ata_y | yes | The owner's associated token account for the second token. | |
vault_x | yes | The vault of the first token. | |
vault_y | yes | The vault of the second token. | |
token_program_x | The token program of the first token. | ||
token_program_y | The token program of the second token. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits PositionSettled.
| Error | Raised when |
|---|---|
Unauthorized | The signer does not own the account, or an associated token account passed is not the owner's. |
Batch instructions
seal_batch
Seals the open batch once its window has passed and it holds at least one order, fixing its input hash, and creates and opens the next batch. The sender pays the next batch account's rent and is recorded as its payer.
Sent by: Anyone.
| Account | Writable | Signer | What it is |
|---|---|---|---|
payer | yes | yes | Whoever sends the instruction. Pays the rent of the account it creates. |
config | yes | The Config account. | |
open_batch | yes | The open batch. | |
next_batch | yes | The next batch, created here. | |
system_program | The System program. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits BatchSealed.
| Error | Raised when |
|---|---|
BatchAlreadySealed | The batch is not open. |
BatchWindowNotElapsed | The current slot is before the batch's seal slot. |
MathOverflow | An amount does not fit its integer type. |
BatchEmpty | The batch holds no order. A batch with no orders stays open. |
clear_batch
Posts the clearing of the oldest sealed batch. The program checks every price against its token's band, recomputes the state hash from the live token and pair accounts and compares it with the one posted, moves every batch pair to the cleared price and marks it in flight, computes the value moved, and locks that much of the solver's free bond. The batch stores each token's band bounds and the clearing fee rate it was cleared with. The batch becomes cleared and its proof deadline is set to the current slot plus the proof window.
Sent by: The operator of an active solver.
Arguments
paramsClearBatchParams- See the type below. See ClearBatchParams.
| Account | Writable | Signer | What it is |
|---|---|---|---|
operator | yes | The solver's operator. | |
config | yes | The Config account. | |
batch | yes | The batch. | |
solver | yes | The Solver account. | |
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
After the listed accounts: the Token account of each entry in params.tokens, in order; then the Pair account of every pair whose two tokens are both in the batch, in ascending pair index, n_pairs of them; then the stake pool account of each bond mint the solver holds stake in that has one, in bond mint order. A solver's free bond is its stake valued in lamports, less bond already locked and less stake in cooldown.
Emits BatchCleared.
| Error | Raised when |
|---|---|
BatchNotSealed | The batch is not sealed. |
BatchAlreadyCleared | The batch has already been cleared. |
BatchAlreadyProven | The batch is already proven. |
BatchAlreadySlashed | The batch is already slashed. |
StateHashMismatch | The state hash posted differs from the hash of the live accounts: a pair or a price changed since the solver read it. Read again and solve again. |
PriceOutOfBand | A price is 0 or outside its token's band. |
InsufficientBond | The solver's free bond is less than the value the clearing moves. |
Unauthorized | The solver is not active. |
OutOfOrderBatch | An older sealed batch has not been cleared or rolled yet. |
InvalidBatchAccounts | The arrays differ in length, the tokens are not strictly ascending, a token the batch's orders touch is missing, or the token and pair accounts are not exactly the ones the batch needs, in order. |
CapacityExceeded | More than 16 tokens or 16 fill fractions were posted. |
InvalidConfig | A fill fraction is above FILL_ONE, or the fill fractions are not ascending. |
InvalidStakePool | The stake pool account is not the bond mint's, is not an SPL Stake Pool, or holds no stake. |
MathOverflow | An amount does not fit its integer type. |
InvalidIndex | A token index is 32 or more. |
prove_batch
Verifies the Groth16 proof of a cleared batch against its 104 bytes of public values, on or before the proof deadline. On success each batch token's last proven price becomes its cleared price, the solver's bond is released, and each token's clearing fee is split: the protocol share is transferred to the fee recipient, and the rest is credited to the operator's commission and the stakers' rewards.
Sent by: Anyone holding a valid proof.
Arguments
proofbytes- The 260-byte SP1 Groth16 proof.
| Account | Writable | Signer | What it is |
|---|---|---|---|
prover | yes | Whoever sends the proof. Any key. | |
config | The Config account. | ||
batch | yes | The batch. | |
solver | yes | The Solver account. | |
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
After the listed accounts: the Token account of each batch token, in order; then, for each batch token with a protocol share above 0, four accounts: its mint, its vault, the fee recipient's associated token account for it, and its token program. The protocol share is rounded down. If the solver has no stake weight, the whole of its share is credited as commission.
Emits BatchProven.
| Error | Raised when |
|---|---|
BatchNotCleared | The batch is not in the cleared status. |
BatchAlreadyProven | The batch is already proven. |
BatchAlreadySlashed | The batch is already slashed. |
ProofWindowExpired | The current slot is past the batch's proof deadline. |
InvalidProof | The proof is not 260 bytes, was made for another verifying key, or does not verify against the batch's public values. |
Unauthorized | Raised only by a localnet build of the program. |
InvalidBatchAccounts | The accounts after the listed ones are missing, out of order or not the expected addresses. |
InvalidFeeRecipientAta | A fee account is missing or is not the token's mint, vault, token program or the fee recipient's associated token account. |
MathOverflow | An amount does not fit its integer type. |
roll_batch
Marks the oldest sealed batch as rolled once the clearing timeout has passed since it sealed with no clearing. Its orders keep their sell amounts; settle_order moves each into the open batch or returns it.
Sent by: Anyone.
| Account | Writable | Signer | What it is |
|---|---|---|---|
config | yes | The Config account. | |
batch | yes | The batch. | |
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits BatchRolled.
| Error | Raised when |
|---|---|
BatchNotSealed | The batch is not sealed. |
BatchAlreadyCleared | The batch has already been cleared. |
BatchAlreadyProven | The batch is already proven. |
BatchAlreadySlashed | The batch is already slashed. |
ClearingTimeoutNotElapsed | Fewer than clearing_timeout_slots slots have passed since the batch sealed. |
OutOfOrderBatch | An older sealed batch has not been cleared or rolled yet. |
MathOverflow | An amount does not fit its integer type. |
slash_batch
Slashes a cleared batch whose proof deadline has passed. It takes the batch's locked bond, or all of the solver's stake if that is less, from the solver's vaults in proportion to each bond mint's lamport value, and moves it into the batch's cover. Shares are not burned, so every stake behind the solver, including stake in cooldown, is worth less by the same proportion.
Sent by: Anyone. The sender pays the rent of the cover account and its vaults.
| Account | Writable | Signer | What it is |
|---|---|---|---|
payer | yes | yes | Whoever sends the instruction. Pays the rent of the account it creates. |
config | The Config account. | ||
batch | yes | The batch. | |
solver | yes | The Solver account. | |
cover | yes | The Cover account. | |
system_program | The System program. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
After the listed accounts, five for each bond mint the solver holds stake in, in bond mint order: the mint, the solver's vault, the cover's vault, the token program, and the stake pool account (any account for wSOL).
Emits BatchSlashed.
| Error | Raised when |
|---|---|
BatchNotCleared | The batch is not in the cleared status. |
BatchAlreadyProven | The batch is already proven. |
BatchAlreadySlashed | The batch is already slashed. |
ProofWindowOpen | The current slot is not past the batch's proof deadline. |
InvalidBatchAccounts | The accounts after the listed ones are missing, out of order or not the expected addresses. |
InvalidStakePool | The stake pool account is not the bond mint's, is not an SPL Stake Pool, or holds no stake. |
MathOverflow | An amount does not fit its integer type. |
claim_cover
Pays one participant its share of a slashed batch's cover, once. An order's weight is its sell amount valued at the batch's cleared price of the sell token, rounded up. A position's weight is what its pair paid out in the batch, in lamports, times the position's liquidity over the pair's active liquidity. The claim is paid weight / total_weight of each cover vault, rounded down, to the claimant's associated token account for that bond mint.
Sent by: The owner of an order or a position that was in the slashed batch.
| Account | Writable | Signer | What it is |
|---|---|---|---|
claimant | yes | The owner of the order or position. | |
config | The Config account. | ||
batch | The batch. | ||
cover | yes | The Cover account. | |
participant | yes | The Order or Position the claim is for. | |
ref_account | For an order, the Token account of its sell token. For a position, its Pair account. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
After the listed accounts, four for each bond mint the cover holds, in bond mint order: the mint, the cover's vault, the claimant's associated token account, and the token program.
Emits CoverClaimed.
| Error | Raised when |
|---|---|
NothingToClaim | The share rounds to 0 in every bond mint. |
Unauthorized | The participant is not an order or position of this program, the claimant does not own it, or a token account is not the claimant's associated token account. |
InvalidBatchAccounts | The accounts after the listed ones are missing, out of order or not the expected addresses. |
MathOverflow | An amount does not fit its integer type. |
InvalidIndex | A token or pair index does not match the account passed. |
CoverAlreadyClaimed | The order or position has already claimed from this batch. |
NoCoverWeight | The order is not in the slashed batch or the batch did not price its sell token, the position has no liquidity or its pair paid nothing out in the batch, or the weight rounds to 0. |
BatchNotSlashed | The batch is not slashed. |
close_batch
Closes the account of a batch that is proven or rolled and has no orders left in it, and returns its rent. A slashed batch stays, for its cover claims.
Sent by: Anyone. The rent goes to the account that paid it.
| Account | Writable | Signer | What it is |
|---|---|---|---|
config | The Config account. | ||
batch | yes | The batch. | |
payer | yes | The account that paid the batch's rent. It receives the rent back. |
| Error | Raised when |
|---|---|
BatchNotClosable | The batch is not proven or rolled, or orders are still in it. |
Solver and stake instructions
register_solver
Creates the operator's Solver account with its commission and marks it active.
Sent by: The operator.
Arguments
commission_bpsu16- The part of the solver's share of clearing fees the operator keeps, in basis points. At most 10,000.
| Account | Writable | Signer | What it is |
|---|---|---|---|
operator | yes | yes | The solver's operator. |
config | The Config account. | ||
solver | yes | The Solver account. | |
system_program | The System program. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits SolverRegistered.
| Error | Raised when |
|---|---|
InvalidConfig | commission_bps is above 10,000. |
stake
Moves amount of a bond mint from the staker to the solver's vault and issues shares: amount for the first stake in that mint, and amount * pool shares / pool amount, rounded down, after that. The deposit's lamport value at the stake pool's rate is added to the stake's reward weight.
Sent by: The staker.
Arguments
bond_mint_idxu8- The index of the bond mint in
Config.bond_mints. amountu64- Atoms of the bond mint to stake. Above 0.
| Account | Writable | Signer | What it is |
|---|---|---|---|
owner | yes | yes | The owner. Signs. |
config | The Config account. | ||
solver | yes | The Solver account. | |
stake | yes | The Stake account. | |
bond_mint | The bond mint. | ||
solver_vault | yes | The solver's vault for the bond mint. Created by the first stake in that mint. | |
owner_ata | yes | The owner's associated token account for the mint. | |
stake_pool | The bond mint's SPL Stake Pool account, read for its rate. Any account for wSOL. | ||
token_program | The mint's token program. | ||
system_program | The System program. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits Staked.
| Error | Raised when |
|---|---|
ZeroLiquidity | amount is 0, or it is too small to issue one share. |
UnsupportedBondMint | The mint or its token program is not the one at that index of the bond mint list, or the entry is inactive. |
Unauthorized | The stake account at that address belongs to another owner. |
InvalidStakePool | The stake pool account is not the bond mint's, is not an SPL Stake Pool, or holds no stake. |
MathOverflow | An amount does not fit its integer type. |
request_unstake
Moves shares into cooldown. They stop counting as the solver's free bond at once and can be withdrawn after the cooldown. Requesting again adds to the shares in cooldown and restarts the cooldown for all of them.
Sent by: The staker.
Arguments
sharesu64- Shares to move into cooldown. Above 0 and at most the stake's.
| Account | Writable | Signer | What it is |
|---|---|---|---|
owner | yes | The owner. Signs. | |
config | The Config account. | ||
solver | yes | The Solver account. | |
stake | yes | The Stake account. | |
stake_pool | The bond mint's SPL Stake Pool account, read for its rate. Any account for wSOL. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits UnstakeRequested.
| Error | Raised when |
|---|---|
ZeroLiquidity | shares is 0. |
InsufficientStake | shares is more than the stake holds outside cooldown. |
Unauthorized | The signer does not own the account, or an associated token account passed is not the owner's. |
InvalidStakePool | The stake pool account is not the bond mint's, is not an SPL Stake Pool, or holds no stake. |
MathOverflow | An amount does not fit its integer type. |
withdraw_stake
After the cooldown, pays out the shares in cooldown at the pool's current rate, shares * pool amount / pool shares, rounded down, and reduces the stake's reward weight in proportion.
Sent by: The staker.
| Account | Writable | Signer | What it is |
|---|---|---|---|
owner | yes | The owner. Signs. | |
config | The Config account. | ||
solver | yes | The Solver account. | |
stake | yes | The Stake account. | |
bond_mint | The bond mint. | ||
solver_vault | yes | The solver's vault for the bond mint. Created by the first stake in that mint. | |
owner_ata | yes | The owner's associated token account for the mint. | |
token_program | The mint's token program. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits StakeWithdrawn.
| Error | Raised when |
|---|---|
CooldownActive | The current slot is before the unlock slot. |
UnsupportedBondMint | The mint or its token program is not the one at that index of the bond mint list, or the entry is inactive. |
NothingToClaim | No shares are in cooldown. |
Unauthorized | The signer does not own the account, or an associated token account passed is not the owner's. |
MathOverflow | An amount does not fit its integer type. |
claim_rewards
Pays what is owed in one token from that token's vault to the claimer's associated token account: a stake's pending rewards, or the operator's commission.
Sent by: A staker, or the operator when is_operator_commission is true.
Arguments
token_indexu16- The token to be paid in. Rewards are held per token; one call pays one token.
is_operator_commissionbooltruefor the operator claiming commission,falsefor a staker claiming rewards.
| Account | Writable | Signer | What it is |
|---|---|---|---|
owner | yes | The owner. Signs. | |
config | The Config account. | ||
solver | yes | The Solver account. | |
stake | yes | The Stake account. | |
token | The Token account. | ||
mint | The token's mint. | ||
token_vault | yes | The token's vault. | |
owner_ata | yes | The owner's associated token account for the mint. | |
token_program | The mint's token program. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
For an operator's claim, stake may be any account.
Emits RewardsClaimed.
| Error | Raised when |
|---|---|
NothingToClaim | Nothing is owed in that token. |
Unauthorized | The signer is not the stake's owner or the solver's operator, the stake is not behind that solver, or the token account is not the signer's associated token account. |
InvalidIndex | token_index is 32 or more. |
Administration instructions
init
Creates the Config account and batch 1, which opens at once.
Sent by: Once, by the key that becomes the admin.
Arguments
paramsInitParams- See the type below. See InitParams.
| Account | Writable | Signer | What it is |
|---|---|---|---|
admin | yes | yes | The admin. |
config | yes | The Config account. | |
first_batch | yes | Batch 1, created here. | |
system_program | The System program. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits ConfigInitialized.
| Error | Raised when |
|---|---|
InvalidConfig | A window or the cooldown is 0, a rate is out of range, there are more than 4 bond mints, or the verifying key is longer than 512 bytes. |
MathOverflow | An amount does not fit its integer type. |
set_config
Changes any of the settings.
Sent by: The admin.
Arguments
paramsSetConfigParams- See the type below. See SetConfigParams.
| Account | Writable | Signer | What it is |
|---|---|---|---|
admin | yes | The admin. | |
config | yes | The Config account. | |
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits ConfigUpdated.
| Error | Raised when |
|---|---|
Unauthorized | The signer is not the admin. |
InvalidConfig | A value given is outside the range init accepts. |
list_token
Lists a token: creates its Token account and its vault, and sets its starting price. Tokens are indexed in listing order, 32 at most.
Sent by: The admin.
Arguments
last_priceu128- The token's starting price as Q64.64, in lamports per atom. For token 0 it must be 2^64.
| Account | Writable | Signer | What it is |
|---|---|---|---|
admin | yes | yes | The admin. |
config | yes | The Config account. | |
mint | The token's mint. | ||
token | yes | The Token account. | |
vault | yes | The token's vault, created here. | |
token_program | The mint's token program. | ||
system_program | The System program. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits TokenListed.
| Error | Raised when |
|---|---|
Unauthorized | The signer is not the admin. |
CapacityExceeded | 32 tokens are already listed. |
InvalidConfig | The price is 0, or token 0 is given a price other than 2^64. |
create_pair
Creates a pair between two listed tokens, with its liquidity fee and tick spacing. The pair starts at the price the two tokens' last proven prices give. One pair per two tokens, 64 at most.
Sent by: The admin.
Arguments
fee_bpsu16- The pair's liquidity fee. Below 10,000.
tick_spacingu16- The pair's tick spacing. Above 0.
| Account | Writable | Signer | What it is |
|---|---|---|---|
admin | yes | yes | The admin. |
config | yes | The Config account. | |
token_x | yes | The Token account of the pair's first token. | |
token_y | yes | The Token account of the pair's second token. | |
pair | yes | The Pair account. | |
system_program | The System program. | ||
event_authority | The program's event authority, "__event_authority". | ||
program | The una program itself. |
Emits PairCreated.
| Error | Raised when |
|---|---|
PriceOutOfBand | The two tokens' prices give a pair price the program cannot represent. |
InvalidTickRange | The starting price is outside the tick range. |
Unauthorized | The signer is not the admin. |
CapacityExceeded | 64 pairs already exist. |
InvalidConfig | The first token's index is not below the second's, the fee is 10,000 or more, the tick spacing is 0, or the two tokens already have a pair. |
Argument types
InitParams
The argument of init.
InitParams
fee_recipientpubkey- The wallet whose token accounts receive the protocol share of the clearing fee.
dev_attesterpubkey- A key read only by a localnet build of the program.
batch_window_slotsu64- The batch window, in slots.
clearing_timeout_slotsu64- How many slots after sealing a batch may be rolled if no solver has cleared it.
proof_window_slotsu64- The proof window, in slots, counted from the slot of
clear_batch. unstake_cooldown_slotsu64- The unstake cooldown, in slots.
band_bpsu16- The price band, in basis points of the last proven price. Below 10,000.
clearing_fee_bpsu16- The clearing fee, in basis points of each filled order's output. Below 10,000.
protocol_fee_share_bpsu16- The share of the clearing fee paid to the fee recipient, in basis points. At most 10,000.
bond_mintsVec<BondMintInput>- The bond mints, 4 at most. See BondMintInput.
sp1_vkey_hash[u8; 32]- The SP1 verification key hash of the guest program: the first public input of every proof.
groth16_vkbytes- SP1's Groth16 verifying key, 512 bytes at most.
SetConfigParams
The argument of set_config. Every field is optional; a field left out keeps its value.
SetConfigParams
fee_recipientOption<pubkey>- The wallet whose token accounts receive the protocol share of the clearing fee.
dev_attesterOption<pubkey>- A key read only by a localnet build of the program.
batch_window_slotsOption<u64>- The batch window, in slots.
clearing_timeout_slotsOption<u64>- How many slots after sealing a batch may be rolled if no solver has cleared it.
proof_window_slotsOption<u64>- The proof window, in slots, counted from the slot of
clear_batch. unstake_cooldown_slotsOption<u64>- The unstake cooldown, in slots.
band_bpsOption<u16>- The price band, in basis points of the last proven price. Below 10,000.
clearing_fee_bpsOption<u16>- The clearing fee, in basis points of each filled order's output. Below 10,000.
protocol_fee_share_bpsOption<u16>- The share of the clearing fee paid to the fee recipient, in basis points. At most 10,000.
bond_mintsOption<Vec<BondMintInput>>- A new bond mint list. It replaces the whole list. See BondMintInput.
sp1_vkey_hashOption<[u8; 32]>- The SP1 verification key hash of the guest program: the first public input of every proof.
groth16_vkOption<bytes>- A new Groth16 verifying key.
BondMintInput
One bond mint in InitParams or SetConfigParams.
BondMintInput
mintpubkey- The token's mint.
stake_poolpubkey- The SPL Stake Pool that issues the mint. The default address for wSOL.
token_programpubkey- The token program that owns the mint: SPL Token or Token-2022.
decimalsu8- The mint's decimals.
ClearBatchParams
The argument of clear_batch: the clearing a solver posts.
ClearBatchParams
state_hash[u8; 32]- The hash of the state the clearing was solved against.
tokensVec<u16>- The indexes of the batch tokens, strictly ascending, 16 at most. Every token the batch's orders touch is in it.
pricesVec<u128>- One price per token, in the same order, as Q64.64.
feesVec<u64>- The clearing fee collected per token, in the same order.
fillsVec<ClearFillArg>- The fill fractions, ascending by sell then buy, 16 at most. See ClearFillArg.
n_pairsu8- How many pair accounts follow the token accounts.
ClearFillArg
One fill fraction in ClearBatchParams.
ClearFillArg
sellu16- The index of the token the direction sells.
buyu16- The index of the token the direction buys.
phiu64- The fill fraction, out of
FILL_ONE, 2^63.
Errors
Anchor reports a program error by number and name. These are the program's own; the numbers start at 6000.
| Number | Name | Message | Raised by |
|---|---|---|---|
| 6000 | BatchAlreadySealed | This batch has already sealed. | place_order, settle_order, seal_batch |
| 6001 | BatchNotSealed | This batch is not sealed yet. | clear_batch, roll_batch |
| 6002 | BatchNotCleared | This batch has not cleared yet. | prove_batch, slash_batch |
| 6003 | BatchAlreadyCleared | Another solver already cleared this batch. | clear_batch, roll_batch |
| 6004 | BatchAlreadyProven | This batch is already proven. | clear_batch, prove_batch, roll_batch, slash_batch |
| 6005 | BatchAlreadySlashed | This batch is already slashed. | clear_batch, prove_batch, roll_batch, slash_batch |
| 6006 | ProofWindowOpen | The proof window has not ended yet. | slash_batch |
| 6007 | ProofWindowExpired | The proof window has already ended. | prove_batch |
| 6008 | InvalidProof | The Groth16 proof did not verify against the batch public values. | prove_batch |
| 6009 | StateHashMismatch | Pool liquidity changed since the clearing was solved. | clear_batch |
| 6010 | PriceOutOfBand | A posted token price is outside the allowed price band. | clear_batch, create_pair |
| 6011 | InsufficientBond | The solver does not have enough free bond to back this batch. | clear_batch |
| 6012 | OrderNotCancellable | The order cannot be cancelled after its batch seals. | cancel_order |
| 6013 | OrderNotSettleable | The order is not ready to settle. | settle_order |
| 6014 | OrderExpired | The order expiry batch must be in the future. | place_order |
| 6015 | SameTokenOrder | Sell and buy tokens must be different. | place_order |
| 6016 | InvalidTickRange | The tick range is invalid or misaligned with tick spacing. | add_liquidity, remove_liquidity, create_pair |
| 6017 | ZeroLiquidity | Liquidity amount must be greater than zero. | place_order, add_liquidity, remove_liquidity, stake, request_unstake |
| 6018 | SlippageExceeded | Token amounts fell below the requested minimum. | add_liquidity, remove_liquidity |
| 6019 | CooldownActive | The unstake cooldown has not finished yet. | withdraw_stake |
| 6020 | InsufficientStake | Unstake amount exceeds available stake. | request_unstake |
| 6021 | UnsupportedBondMint | This token is not on the configured bond mint list. | stake, withdraw_stake |
| 6022 | NothingToClaim | There is nothing claimable for this account. | collect_fees, claim_cover, withdraw_stake, claim_rewards |
| 6023 | Unauthorized | The signer is not authorized for this account. | cancel_order, settle_order, add_liquidity, remove_liquidity, collect_fees, settle_position, clear_batch, prove_batch, claim_cover, stake, request_unstake, withdraw_stake, claim_rewards, set_config, list_token, create_pair |
| 6024 | BatchWindowNotElapsed | Batch window has not elapsed yet. | seal_batch |
| 6025 | ClearingTimeoutNotElapsed | Clearing timeout has not elapsed yet. | roll_batch |
| 6026 | OutOfOrderBatch | Sealed batches must be cleared or rolled in order. | clear_batch, roll_batch |
| 6027 | InvalidBatchAccounts | Batch token or pair account set is incomplete or unsorted. | remove_liquidity, clear_batch, prove_batch, slash_batch, claim_cover |
| 6028 | CapacityExceeded | Too many tokens or ticks for account capacity. | place_order, settle_order, add_liquidity, clear_batch, list_token, create_pair |
| 6029 | InvalidConfig | Invalid configuration value. | place_order, clear_batch, register_solver, init, set_config, list_token, create_pair |
| 6030 | InvalidStakePool | Invalid SPL Stake Pool account. | clear_batch, slash_batch, stake, request_unstake |
| 6031 | InvalidFeeRecipientAta | Invalid fee recipient associated token account. | prove_batch |
| 6032 | MathOverflow | Arithmetic overflow or underflow. | place_order, settle_order, add_liquidity, remove_liquidity, seal_batch, clear_batch, prove_batch, roll_batch, slash_batch, claim_cover, stake, request_unstake, withdraw_stake, init |
| 6033 | InvalidIndex | Invalid token or pair index. | settle_order, clear_batch, claim_cover, claim_rewards |
| 6034 | OrderNotOpen | Order is not open. | cancel_order |
| 6035 | CoverAlreadyClaimed | Cover has already been claimed for this participant. | claim_cover |
| 6036 | NoCoverWeight | Participant has no claimable weight in this slashed batch. | claim_cover |
| 6037 | BatchNotSlashed | This batch has not been slashed. | claim_cover |
| 6038 | PairInFlight | This pair is in a cleared batch that is not yet proven or slashed. | remove_liquidity |
| 6039 | BatchEmpty | This batch has no orders to seal. | seal_batch |
| 6040 | BatchNotClosable | This batch still holds orders or is not proven or rolled. | close_batch |
| 6041 | OrderTooSmall | The order is below the smallest size a batch takes (0.0001 SOL of value). | place_order |
Events
Each event is the data of an inner instruction to the program, after an 8-byte tag and the event's 8-byte discriminator.
BatchCleared
A solver cleared a batch and its bond locked. Emitted by clear_batch.
BatchCleared
batch_idu64- The batch's number. Batches count from 1.
solverpubkey- The solver account.
state_hash[u8; 32]- The hash of the state the clearing was solved against.
result_hash[u8; 32]- The hash of the posted prices, fees and fill fractions.
value_movedu64- The value the program measured the clearing to move, in lamports.
bond_lockedu64- The bond locked behind the batch, in lamports. Equal to
value_moved. proof_deadline_slotu64- The last slot
prove_batchis accepted in.
BatchProven
A batch's proof verified and its bond was released. Emitted by prove_batch.
BatchProven
batch_idu64- The batch's number. Batches count from 1.
solverpubkey- The solver account.
proven_slotu64- The slot the proof verified in.
bond_releasedu64- The bond released, in lamports.
dev_attestedbool- Always
falseon mainnet.
BatchRolled
A sealed batch was rolled. Emitted by roll_batch.
BatchRolled
batch_idu64- The batch's number. Batches count from 1.
rolled_at_slotu64- The slot it was rolled in.
BatchSealed
A batch sealed and the next one opened. Emitted by seal_batch.
BatchSealed
batch_idu64- The batch's number. Batches count from 1.
next_batch_idu64- The batch that opened.
seal_slotu64- While open, the slot the window ends at. Once sealed, the slot it was sealed in.
input_hash[u8; 32]- The running hash of the batch's input.
BatchSlashed
A batch was slashed and its bond moved to the cover. Emitted by slash_batch.
BatchSlashed
batch_idu64- The batch's number. Batches count from 1.
solverpubkey- The solver account.
coverpubkey- The cover account.
bond_slashedu64- The bond moved to the cover, in lamports.
ConfigInitialized
The settings as init set them. Emitted by init.
ConfigInitialized
adminpubkey- The key that may send
set_config,list_tokenandcreate_pair. fee_recipientpubkey- The wallet whose token accounts receive the protocol share of the clearing fee.
batch_window_slotsu64- The batch window, in slots.
clearing_timeout_slotsu64- How many slots after sealing a batch may be rolled if no solver has cleared it.
proof_window_slotsu64- The proof window, in slots, counted from the slot of
clear_batch. unstake_cooldown_slotsu64- The unstake cooldown, in slots.
band_bpsu16- The price band, in basis points of the last proven price. Below 10,000.
clearing_fee_bpsu16- The clearing fee, in basis points of each filled order's output. Below 10,000.
protocol_fee_share_bpsu16- The share of the clearing fee paid to the fee recipient, in basis points. At most 10,000.
ConfigUpdated
The settings after set_config. Emitted by set_config.
ConfigUpdated
adminpubkey- The key that may send
set_config,list_tokenandcreate_pair. fee_recipientpubkey- The wallet whose token accounts receive the protocol share of the clearing fee.
batch_window_slotsu64- The batch window, in slots.
clearing_timeout_slotsu64- How many slots after sealing a batch may be rolled if no solver has cleared it.
proof_window_slotsu64- The proof window, in slots, counted from the slot of
clear_batch. unstake_cooldown_slotsu64- The unstake cooldown, in slots.
band_bpsu16- The price band, in basis points of the last proven price. Below 10,000.
clearing_fee_bpsu16- The clearing fee, in basis points of each filled order's output. Below 10,000.
protocol_fee_share_bpsu16- The share of the clearing fee paid to the fee recipient, in basis points. At most 10,000.
CoverClaimed
A participant claimed its share of a cover. Emitted by claim_cover.
CoverClaimed
batch_idu64- The batch's number. Batches count from 1.
coverpubkey- The cover account.
claimantpubkey- The wallet paid.
participantpubkey- The order or position the claim was made for.
weightu64- The claim's weight, in lamports.
total_paid_lamportsu64- The atoms paid, summed across bond mints.
FeesCollected
A position's owner collected its earnings. Emitted by collect_fees.
FeesCollected
positionpubkey- The position account.
ownerpubkey- The wallet that owns it.
pair_indexu16- The pair's index.
amount_xu64- Atoms of the first token paid out.
amount_yu64- Atoms of the second token paid out.
LiquidityAdded
Liquidity was added to a position. Emitted by add_liquidity.
LiquidityAdded
positionpubkey- The position account.
ownerpubkey- The wallet that owns it.
pair_indexu16- The pair's index.
tick_loweri32- The lower tick of the range.
tick_upperi32- The upper tick of the range.
liquidity_deltau128- The liquidity added or removed.
amount_xu64- Atoms of the first token paid in.
amount_yu64- Atoms of the second token paid in.
LiquidityRemoved
Liquidity was removed from a position. Emitted by remove_liquidity.
LiquidityRemoved
positionpubkey- The position account.
ownerpubkey- The wallet that owns it.
pair_indexu16- The pair's index.
liquidity_deltau128- The liquidity added or removed.
amount_xu64- Atoms of the first token returned.
amount_yu64- Atoms of the second token returned.
OrderCancelled
An order was cancelled and its sell amount returned. Emitted by cancel_order.
OrderCancelled
orderpubkey- The order account.
ownerpubkey- The wallet that owns it.
batch_idu64- The batch's number. Batches count from 1.
amountu64- Atoms of the sell token returned.
OrderPlaced
An order joined the open batch. Emitted by place_order.
OrderPlaced
orderpubkey- The order account.
ownerpubkey- The wallet that owns it.
batch_idu64- The batch's number. Batches count from 1.
expiry_batch_idu64- The last batch the order may clear in.
sell_tokenu16- The index of the token sold.
buy_tokenu16- The index of the token bought.
amountu64- Atoms of the sell token.
limitu128- The limit as Q64.64: least atoms of the buy token per atom of the sell token.
OrderSettled
An order was settled against its batch. Emitted by settle_order.
OrderSettled
orderpubkey- The order account.
ownerpubkey- The wallet that owns it.
batch_idu64- The batch the order was settled against.
filledu64- Atoms of the sell token filled.
receivedu64- Atoms of the buy token paid to the owner.
feeu64- The clearing fee, in atoms of the buy token.
remainderu64- Atoms of the sell token not filled.
rolled_to_batch_idu64- The batch the remainder moved into, or 0 if it was returned or there was none.
PairCreated
A pair was created. Emitted by create_pair.
PairCreated
pair_indexu16- The pair's index.
pairpubkey- The pair account.
token_xu16- The index of the pair's first token, the lower index.
token_yu16- The index of the pair's second token.
fee_bpsu16- The pair's liquidity fee, in basis points. Below 10,000.
tick_spacingu16- Ticks of a range on this pair are multiples of this.
sqrt_priceu128- The square root of the pair's price as Q64.64. The price is atoms of the second token per atom of the first.
ticki32- The tick of the starting price.
PositionSettled
A position's earnings were paid out by settle_position. Emitted by settle_position.
PositionSettled
positionpubkey- The position account.
ownerpubkey- The wallet that owns it.
pair_indexu16- The pair's index.
amount_xu64- Atoms of the first token paid out.
amount_yu64- Atoms of the second token paid out.
RewardsClaimed
Rewards or commission were paid in one token. Emitted by claim_rewards.
RewardsClaimed
solverpubkey- The solver account.
ownerpubkey- The wallet paid.
token_indexu16- The token's index.
amountu64- Atoms of the token paid.
is_operator_commissionbool- Whether it was the operator's commission.
SolverRegistered
A solver registered. Emitted by register_solver.
SolverRegistered
solverpubkey- The solver account.
operatorpubkey- The wallet that runs the solver.
commission_bpsu16- The part of the solver's share of clearing fees the operator keeps, in basis points. At most 10,000.
StakeWithdrawn
Shares in cooldown were paid out. Emitted by withdraw_stake.
StakeWithdrawn
stakepubkey- The stake account.
solverpubkey- The solver account.
ownerpubkey- The wallet that owns it.
bond_mint_idxu8- The index of the bond mint in
Config.bond_mints. sharesu64- Shares withdrawn.
amountu64- Atoms of the bond mint paid out.
Staked
A stake was made or added to. Emitted by stake.
Staked
stakepubkey- The stake account.
solverpubkey- The solver account.
ownerpubkey- The wallet that owns it.
bond_mint_idxu8- The index of the bond mint in
Config.bond_mints. amountu64- Atoms of the bond mint staked.
sharesu64- Shares issued.
lamport_valueu64- The deposit valued in lamports at the stake pool's rate.
TokenListed
A token was listed. Emitted by list_token.
TokenListed
indexu16- The token's index.
mintpubkey- The token's mint.
vaultpubkey- The token's vault.
token_programpubkey- The token program that owns the mint: SPL Token or Token-2022.
decimalsu8- The mint's decimals.
last_priceu128- The token's last proven price as Q64.64, in lamports per atom.
UnstakeRequested
Shares moved into cooldown. Emitted by request_unstake.
UnstakeRequested
stakepubkey- The stake account.
solverpubkey- The solver account.
ownerpubkey- The wallet that owns it.
sharesu64- Shares moved into cooldown.
unlock_slotu64- The slot the cooldown ends at.