Trade
Errors and events

Program

Errors and events

Program error codes and the events it emits.

Errors

A failed instruction returns custom error code 6000 or above. In the API, a refused transaction carries the program's address and the error's name and number in error.programError (Errors).

CodeNameMessageRaised by
6000NotAdminOnly the admin may do this.update_config
6001NotSequencerOnly the sequencer may do this.post_batch, withdraw
6002ZeroAmountAmount must be above zero.deposit, withdraw
6003InvalidEscapeSlotsEscape slots must be above zero.initialize
6004BatchOutOfOrderBatch number must be exactly the last batch number plus one.post_batch
6005EntryCountMismatchBatch entries and trader accounts differ in count.post_batch
6006InvalidTraderAccountA batch account is not a writable trader account of this program.post_batch
6007TraderAlreadyInBatchA trader appears twice in one batch.post_batch
6008CreditExceedsDepositsCredited deposits exceed the trader's cumulative deposits.post_batch
6009CreditExceedsWithdrawalsCredited withdrawals exceed the trader's cumulative withdrawals.post_batch
6010FeesDecreasedReported protocol fees must not decrease.post_batch
6011InsufficientEquityAmount exceeds the trader's available equity.withdraw
6012EscapeNotOpenThe escape window is not open yet.escape_withdraw
6013NothingToSweepNo unswept protocol fees.sweep_fees
6014MathOverflowArithmetic overflow.deposit, post_batch, withdraw, escape_withdraw, sweep_fees

Events

Events are emitted by CPI to the program's event authority. Decode them from the transaction's inner instructions: each carries the 8-byte event tag e445a52e51cb9a1d, then the event's discriminator, then its fields.

BatchPosted, from post_batch, discriminator 9a50039a8f83e3ef
FieldTypeDescription
batch_numberu64The batch number.
slotu64The slot it landed in.
state_hash[u8; 32]The engine's state hash.
fees_totalu64Cumulative protocol fees reported.
tradersu32How many trader accounts it carried.
DepositMade, from deposit, discriminator d2c982b7f4cb9bc7
FieldTypeDescription
ownerpubkeyThe trader wallet.
amountu64USDC base units deposited.
depositedu64Cumulative deposited after this deposit.
Escaped, from escape_withdraw, discriminator f0e4073ed8796c52
FieldTypeDescription
ownerpubkeyThe trader wallet.
amountu64USDC base units paid.
FeesSwept, from sweep_fees, discriminator 60da73884aaacaac
FieldTypeDescription
recipientpubkeyThe fee recipient.
amountu64USDC base units paid.
fees_sweptu64Cumulative swept after this sweep.
SessionRegistered, from register_session, discriminator 60a04aaad9d67337
FieldTypeDescription
ownerpubkeyThe trader wallet.
session_keypubkeyPubkey::default() revokes.
expiryi64Unix seconds; 0 on a revocation.
Withdrawn, from withdraw, discriminator 1459dfc6c27cdb0d
FieldTypeDescription
ownerpubkeyThe trader wallet.
amountu64USDC base units paid.
withdrawnu64Cumulative withdrawn after this withdrawal.