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

ThingHow the program holds it
A priceu128, Q64.64, lamports per atom of the token. The integer stands for itself divided by 2^64.
A limitu128, Q64.64, atoms of the buy token per atom of the sell token.
A fill fractionu64 out of FILL_ONE, 2^63.
A rateu16, basis points.
TimeSlots.
A tokenIts index, a u16 given in listing order. wSOL is 0.
BondLamports. 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.

AccountSeedsWhat it is
Config"config"The one configuration account. It is also the authority of every vault.
Batch"batch", batch id as u64 LEOne per batch. Batch 1 is created by init, each next one by seal_batch.
Token"token", token index as u16 LEOne per listed token.
Token vault"token_vault", token index as u16 LEThe token account that holds a listed token: sell amounts, liquidity and fees not yet claimed.
Pair"pair", pair index as u16 LEOne per pair.
Order"order", owner, nonce as u64 LEOne 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 LEOne per owner, pair and range.
Solver"solver", operatorOne per operator.
Stake"stake", solver, owner, bond mint index as u8One per staker, solver and bond mint.
Solver vault"solver_vault", solver, bond mint index as u8The token account that holds a solver's stake in one bond mint.
Cover"cover", batch id as u64 LEOne per slashed batch.
Cover vault"cover_vault", batch id as u64 LE, bond mint index as u8The token account that holds a slashed batch's cover in one bond mint.

Limits

LimitValue
Listed tokens32
Pairs64
Tokens in one batch16
Fill fractions in one batch16
Initialized ticks on one pair64
Bond mints4
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_token and create_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_vk are 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_mints are 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_count entries 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_batch landed in.
proof_deadline_slotu64
The last slot prove_batch is accepted in.
proven_slotu64
The slot prove_batch landed 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_count entries 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_count entries are in use.
pairs[u16; 16]
The indexes of the batch pairs. The first pair_count entries 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_order pays 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_batch that created it, or the admin for batch 1. close_batch returns 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_share when 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 u64 the 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.
AccountWritableSignerWhat it is
owneryesyesThe owner. Signs.
configThe Config account.
open_batchyesThe open batch.
sell_tokenThe Token account of the token sold.
buy_tokenThe Token account of the token bought.
orderyesThe Order account.
sell_mintThe mint of the token sold.
owner_sell_atayesThe owner's associated token account for the token sold.
sell_vaultyesThe vault of the token sold.
sell_token_programThe token program of the token sold.
system_programThe System program.
event_authorityThe program's event authority, "__event_authority".
programThe 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.

ErrorRaised when
BatchAlreadySealedNeither the batch passed nor any Batch account after the listed ones is open.
OrderExpiredexpiry_batch_id is before the open batch.
SameTokenOrderThe sell token and the buy token are the same.
ZeroLiquidityamount is 0.
CapacityExceededThe batch already holds 16 tokens and the order would add another.
InvalidConfiglimit is 0.
MathOverflowAn amount does not fit its integer type.
OrderTooSmallThe 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.

AccountWritableSignerWhat it is
owneryesThe owner. Signs.
configThe Config account.
orderyesThe Order account.
batchyesThe batch.
sell_tokenThe Token account of the token sold.
sell_mintThe mint of the token sold.
sell_vaultyesThe vault of the token sold.
owner_sell_atayesThe owner's associated token account for the token sold.
sell_token_programThe token program of the token sold.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits OrderCancelled.

ErrorRaised when
OrderNotCancellableThe order's batch has sealed.
UnauthorizedThe signer is not the order's owner, or the token account is not the owner's associated token account.
OrderNotOpenThe 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.

AccountWritableSignerWhat it is
configThe Config account.
orderyesThe Order account.
order_batchyesThe batch the order is in.
open_batchyesThe open batch.
sell_tokenThe Token account of the token sold.
buy_tokenThe Token account of the token bought.
sell_mintThe mint of the token sold.
buy_mintThe mint of the token bought.
sell_vaultyesThe vault of the token sold.
buy_vaultyesThe vault of the token bought.
owner_sell_atayesThe owner's associated token account for the token sold.
owner_buy_atayesThe owner's associated token account for the token bought.
sell_token_programThe token program of the token sold.
buy_token_programThe token program of the token bought.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits OrderSettled.

ErrorRaised when
BatchAlreadySealedThe open batch passed is no longer open. Send again with the current one.
OrderNotSettleableThe order is already settled or cancelled, or its batch is still open or sealed.
UnauthorizedA token account passed is not the owner's associated token account.
CapacityExceededThe open batch already holds 16 tokens and the remainder would add another.
MathOverflowAn amount does not fit its integer type.
InvalidIndexThe 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.
AccountWritableSignerWhat it is
owneryesyesThe owner. Signs.
configThe Config account.
pairyesThe Pair account.
positionyesThe Position account.
token_xThe Token account of the pair's first token.
token_yThe Token account of the pair's second token.
mint_xThe mint of the first token.
mint_yThe mint of the second token.
owner_ata_xyesThe owner's associated token account for the first token.
owner_ata_yyesThe owner's associated token account for the second token.
vault_xyesThe vault of the first token.
vault_yyesThe vault of the second token.
token_program_xThe token program of the first token.
token_program_yThe token program of the second token.
system_programThe System program.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits LiquidityAdded.

ErrorRaised when
InvalidTickRangeThe 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.
ZeroLiquidityliquidity_delta is 0.
SlippageExceededThe liquidity takes more than max_amount_x or max_amount_y.
UnauthorizedThe position at that address belongs to another owner.
CapacityExceededThe pair already has 64 initialized ticks and the range needs a new one.
MathOverflowAn 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.
AccountWritableSignerWhat it is
owneryesThe owner. Signs.
configThe Config account.
pairyesThe Pair account.
positionyesThe Position account.
token_xThe Token account of the pair's first token.
token_yThe Token account of the pair's second token.
mint_xThe mint of the first token.
mint_yThe mint of the second token.
owner_ata_xyesThe owner's associated token account for the first token.
owner_ata_yyesThe owner's associated token account for the second token.
vault_xyesThe vault of the first token.
vault_yyesThe vault of the second token.
token_program_xThe token program of the first token.
token_program_yThe token program of the second token.
event_authorityThe program's event authority, "__event_authority".
programThe 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.

ErrorRaised when
InvalidTickRangeA tick is outside the tick range the program supports.
ZeroLiquidityliquidity_delta is 0 or more than the position holds.
SlippageExceededThe liquidity returns less than min_amount_x or min_amount_y.
UnauthorizedThe signer does not own the account, or an associated token account passed is not the owner's.
InvalidBatchAccountsThe accounts after the listed ones are missing, out of order or not the expected addresses.
MathOverflowAn amount does not fit its integer type.
PairInFlightThe 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.

AccountWritableSignerWhat it is
owneryesThe owner. Signs.
configThe Config account.
pairThe Pair account.
positionyesThe Position account.
token_xThe Token account of the pair's first token.
token_yThe Token account of the pair's second token.
mint_xThe mint of the first token.
mint_yThe mint of the second token.
owner_ata_xyesThe owner's associated token account for the first token.
owner_ata_yyesThe owner's associated token account for the second token.
vault_xyesThe vault of the first token.
vault_yyesThe vault of the second token.
token_program_xThe token program of the first token.
token_program_yThe token program of the second token.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits FeesCollected.

ErrorRaised when
NothingToClaimThe position is owed nothing in either token.
UnauthorizedThe 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.

AccountWritableSignerWhat it is
configThe Config account.
pairThe Pair account.
positionyesThe Position account.
token_xThe Token account of the pair's first token.
token_yThe Token account of the pair's second token.
mint_xThe mint of the first token.
mint_yThe mint of the second token.
owner_ata_xyesThe owner's associated token account for the first token.
owner_ata_yyesThe owner's associated token account for the second token.
vault_xyesThe vault of the first token.
vault_yyesThe vault of the second token.
token_program_xThe token program of the first token.
token_program_yThe token program of the second token.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits PositionSettled.

ErrorRaised when
UnauthorizedThe 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.

AccountWritableSignerWhat it is
payeryesyesWhoever sends the instruction. Pays the rent of the account it creates.
configyesThe Config account.
open_batchyesThe open batch.
next_batchyesThe next batch, created here.
system_programThe System program.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits BatchSealed.

ErrorRaised when
BatchAlreadySealedThe batch is not open.
BatchWindowNotElapsedThe current slot is before the batch's seal slot.
MathOverflowAn amount does not fit its integer type.
BatchEmptyThe 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.
AccountWritableSignerWhat it is
operatoryesThe solver's operator.
configyesThe Config account.
batchyesThe batch.
solveryesThe Solver account.
event_authorityThe program's event authority, "__event_authority".
programThe 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.

ErrorRaised when
BatchNotSealedThe batch is not sealed.
BatchAlreadyClearedThe batch has already been cleared.
BatchAlreadyProvenThe batch is already proven.
BatchAlreadySlashedThe batch is already slashed.
StateHashMismatchThe 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.
PriceOutOfBandA price is 0 or outside its token's band.
InsufficientBondThe solver's free bond is less than the value the clearing moves.
UnauthorizedThe solver is not active.
OutOfOrderBatchAn older sealed batch has not been cleared or rolled yet.
InvalidBatchAccountsThe 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.
CapacityExceededMore than 16 tokens or 16 fill fractions were posted.
InvalidConfigA fill fraction is above FILL_ONE, or the fill fractions are not ascending.
InvalidStakePoolThe stake pool account is not the bond mint's, is not an SPL Stake Pool, or holds no stake.
MathOverflowAn amount does not fit its integer type.
InvalidIndexA 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.
AccountWritableSignerWhat it is
proveryesWhoever sends the proof. Any key.
configThe Config account.
batchyesThe batch.
solveryesThe Solver account.
event_authorityThe program's event authority, "__event_authority".
programThe 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.

ErrorRaised when
BatchNotClearedThe batch is not in the cleared status.
BatchAlreadyProvenThe batch is already proven.
BatchAlreadySlashedThe batch is already slashed.
ProofWindowExpiredThe current slot is past the batch's proof deadline.
InvalidProofThe proof is not 260 bytes, was made for another verifying key, or does not verify against the batch's public values.
UnauthorizedRaised only by a localnet build of the program.
InvalidBatchAccountsThe accounts after the listed ones are missing, out of order or not the expected addresses.
InvalidFeeRecipientAtaA fee account is missing or is not the token's mint, vault, token program or the fee recipient's associated token account.
MathOverflowAn 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.

AccountWritableSignerWhat it is
configyesThe Config account.
batchyesThe batch.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits BatchRolled.

ErrorRaised when
BatchNotSealedThe batch is not sealed.
BatchAlreadyClearedThe batch has already been cleared.
BatchAlreadyProvenThe batch is already proven.
BatchAlreadySlashedThe batch is already slashed.
ClearingTimeoutNotElapsedFewer than clearing_timeout_slots slots have passed since the batch sealed.
OutOfOrderBatchAn older sealed batch has not been cleared or rolled yet.
MathOverflowAn 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.

AccountWritableSignerWhat it is
payeryesyesWhoever sends the instruction. Pays the rent of the account it creates.
configThe Config account.
batchyesThe batch.
solveryesThe Solver account.
coveryesThe Cover account.
system_programThe System program.
event_authorityThe program's event authority, "__event_authority".
programThe 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.

ErrorRaised when
BatchNotClearedThe batch is not in the cleared status.
BatchAlreadyProvenThe batch is already proven.
BatchAlreadySlashedThe batch is already slashed.
ProofWindowOpenThe current slot is not past the batch's proof deadline.
InvalidBatchAccountsThe accounts after the listed ones are missing, out of order or not the expected addresses.
InvalidStakePoolThe stake pool account is not the bond mint's, is not an SPL Stake Pool, or holds no stake.
MathOverflowAn 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.

AccountWritableSignerWhat it is
claimantyesThe owner of the order or position.
configThe Config account.
batchThe batch.
coveryesThe Cover account.
participantyesThe Order or Position the claim is for.
ref_accountFor an order, the Token account of its sell token. For a position, its Pair account.
event_authorityThe program's event authority, "__event_authority".
programThe 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.

ErrorRaised when
NothingToClaimThe share rounds to 0 in every bond mint.
UnauthorizedThe 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.
InvalidBatchAccountsThe accounts after the listed ones are missing, out of order or not the expected addresses.
MathOverflowAn amount does not fit its integer type.
InvalidIndexA token or pair index does not match the account passed.
CoverAlreadyClaimedThe order or position has already claimed from this batch.
NoCoverWeightThe 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.
BatchNotSlashedThe 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.

AccountWritableSignerWhat it is
configThe Config account.
batchyesThe batch.
payeryesThe account that paid the batch's rent. It receives the rent back.
ErrorRaised when
BatchNotClosableThe 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.
AccountWritableSignerWhat it is
operatoryesyesThe solver's operator.
configThe Config account.
solveryesThe Solver account.
system_programThe System program.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits SolverRegistered.

ErrorRaised when
InvalidConfigcommission_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.
AccountWritableSignerWhat it is
owneryesyesThe owner. Signs.
configThe Config account.
solveryesThe Solver account.
stakeyesThe Stake account.
bond_mintThe bond mint.
solver_vaultyesThe solver's vault for the bond mint. Created by the first stake in that mint.
owner_atayesThe owner's associated token account for the mint.
stake_poolThe bond mint's SPL Stake Pool account, read for its rate. Any account for wSOL.
token_programThe mint's token program.
system_programThe System program.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits Staked.

ErrorRaised when
ZeroLiquidityamount is 0, or it is too small to issue one share.
UnsupportedBondMintThe mint or its token program is not the one at that index of the bond mint list, or the entry is inactive.
UnauthorizedThe stake account at that address belongs to another owner.
InvalidStakePoolThe stake pool account is not the bond mint's, is not an SPL Stake Pool, or holds no stake.
MathOverflowAn 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.
AccountWritableSignerWhat it is
owneryesThe owner. Signs.
configThe Config account.
solveryesThe Solver account.
stakeyesThe Stake account.
stake_poolThe bond mint's SPL Stake Pool account, read for its rate. Any account for wSOL.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits UnstakeRequested.

ErrorRaised when
ZeroLiquidityshares is 0.
InsufficientStakeshares is more than the stake holds outside cooldown.
UnauthorizedThe signer does not own the account, or an associated token account passed is not the owner's.
InvalidStakePoolThe stake pool account is not the bond mint's, is not an SPL Stake Pool, or holds no stake.
MathOverflowAn 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.

AccountWritableSignerWhat it is
owneryesThe owner. Signs.
configThe Config account.
solveryesThe Solver account.
stakeyesThe Stake account.
bond_mintThe bond mint.
solver_vaultyesThe solver's vault for the bond mint. Created by the first stake in that mint.
owner_atayesThe owner's associated token account for the mint.
token_programThe mint's token program.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits StakeWithdrawn.

ErrorRaised when
CooldownActiveThe current slot is before the unlock slot.
UnsupportedBondMintThe mint or its token program is not the one at that index of the bond mint list, or the entry is inactive.
NothingToClaimNo shares are in cooldown.
UnauthorizedThe signer does not own the account, or an associated token account passed is not the owner's.
MathOverflowAn 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_commissionbool
true for the operator claiming commission, false for a staker claiming rewards.
AccountWritableSignerWhat it is
owneryesThe owner. Signs.
configThe Config account.
solveryesThe Solver account.
stakeyesThe Stake account.
tokenThe Token account.
mintThe token's mint.
token_vaultyesThe token's vault.
owner_atayesThe owner's associated token account for the mint.
token_programThe mint's token program.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

For an operator's claim, stake may be any account.

Emits RewardsClaimed.

ErrorRaised when
NothingToClaimNothing is owed in that token.
UnauthorizedThe 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.
InvalidIndextoken_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.
AccountWritableSignerWhat it is
adminyesyesThe admin.
configyesThe Config account.
first_batchyesBatch 1, created here.
system_programThe System program.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits ConfigInitialized.

ErrorRaised when
InvalidConfigA 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.
MathOverflowAn 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.
AccountWritableSignerWhat it is
adminyesThe admin.
configyesThe Config account.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits ConfigUpdated.

ErrorRaised when
UnauthorizedThe signer is not the admin.
InvalidConfigA 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.
AccountWritableSignerWhat it is
adminyesyesThe admin.
configyesThe Config account.
mintThe token's mint.
tokenyesThe Token account.
vaultyesThe token's vault, created here.
token_programThe mint's token program.
system_programThe System program.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits TokenListed.

ErrorRaised when
UnauthorizedThe signer is not the admin.
CapacityExceeded32 tokens are already listed.
InvalidConfigThe 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.
AccountWritableSignerWhat it is
adminyesyesThe admin.
configyesThe Config account.
token_xyesThe Token account of the pair's first token.
token_yyesThe Token account of the pair's second token.
pairyesThe Pair account.
system_programThe System program.
event_authorityThe program's event authority, "__event_authority".
programThe una program itself.

Emits PairCreated.

ErrorRaised when
PriceOutOfBandThe two tokens' prices give a pair price the program cannot represent.
InvalidTickRangeThe starting price is outside the tick range.
UnauthorizedThe signer is not the admin.
CapacityExceeded64 pairs already exist.
InvalidConfigThe 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.

NumberNameMessageRaised by
6000BatchAlreadySealedThis batch has already sealed.place_order, settle_order, seal_batch
6001BatchNotSealedThis batch is not sealed yet.clear_batch, roll_batch
6002BatchNotClearedThis batch has not cleared yet.prove_batch, slash_batch
6003BatchAlreadyClearedAnother solver already cleared this batch.clear_batch, roll_batch
6004BatchAlreadyProvenThis batch is already proven.clear_batch, prove_batch, roll_batch, slash_batch
6005BatchAlreadySlashedThis batch is already slashed.clear_batch, prove_batch, roll_batch, slash_batch
6006ProofWindowOpenThe proof window has not ended yet.slash_batch
6007ProofWindowExpiredThe proof window has already ended.prove_batch
6008InvalidProofThe Groth16 proof did not verify against the batch public values.prove_batch
6009StateHashMismatchPool liquidity changed since the clearing was solved.clear_batch
6010PriceOutOfBandA posted token price is outside the allowed price band.clear_batch, create_pair
6011InsufficientBondThe solver does not have enough free bond to back this batch.clear_batch
6012OrderNotCancellableThe order cannot be cancelled after its batch seals.cancel_order
6013OrderNotSettleableThe order is not ready to settle.settle_order
6014OrderExpiredThe order expiry batch must be in the future.place_order
6015SameTokenOrderSell and buy tokens must be different.place_order
6016InvalidTickRangeThe tick range is invalid or misaligned with tick spacing.add_liquidity, remove_liquidity, create_pair
6017ZeroLiquidityLiquidity amount must be greater than zero.place_order, add_liquidity, remove_liquidity, stake, request_unstake
6018SlippageExceededToken amounts fell below the requested minimum.add_liquidity, remove_liquidity
6019CooldownActiveThe unstake cooldown has not finished yet.withdraw_stake
6020InsufficientStakeUnstake amount exceeds available stake.request_unstake
6021UnsupportedBondMintThis token is not on the configured bond mint list.stake, withdraw_stake
6022NothingToClaimThere is nothing claimable for this account.collect_fees, claim_cover, withdraw_stake, claim_rewards
6023UnauthorizedThe 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
6024BatchWindowNotElapsedBatch window has not elapsed yet.seal_batch
6025ClearingTimeoutNotElapsedClearing timeout has not elapsed yet.roll_batch
6026OutOfOrderBatchSealed batches must be cleared or rolled in order.clear_batch, roll_batch
6027InvalidBatchAccountsBatch token or pair account set is incomplete or unsorted.remove_liquidity, clear_batch, prove_batch, slash_batch, claim_cover
6028CapacityExceededToo many tokens or ticks for account capacity.place_order, settle_order, add_liquidity, clear_batch, list_token, create_pair
6029InvalidConfigInvalid configuration value.place_order, clear_batch, register_solver, init, set_config, list_token, create_pair
6030InvalidStakePoolInvalid SPL Stake Pool account.clear_batch, slash_batch, stake, request_unstake
6031InvalidFeeRecipientAtaInvalid fee recipient associated token account.prove_batch
6032MathOverflowArithmetic 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
6033InvalidIndexInvalid token or pair index.settle_order, clear_batch, claim_cover, claim_rewards
6034OrderNotOpenOrder is not open.cancel_order
6035CoverAlreadyClaimedCover has already been claimed for this participant.claim_cover
6036NoCoverWeightParticipant has no claimable weight in this slashed batch.claim_cover
6037BatchNotSlashedThis batch has not been slashed.claim_cover
6038PairInFlightThis pair is in a cleared batch that is not yet proven or slashed.remove_liquidity
6039BatchEmptyThis batch has no orders to seal.seal_batch
6040BatchNotClosableThis batch still holds orders or is not proven or rolled.close_batch
6041OrderTooSmallThe 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_batch is 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 false on 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_token and create_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_token and create_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.