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).
| Code | Name | Message | Raised by |
|---|---|---|---|
| 6000 | NotAdmin | Only the admin may do this. | update_config |
| 6001 | NotSequencer | Only the sequencer may do this. | post_batch, withdraw |
| 6002 | ZeroAmount | Amount must be above zero. | deposit, withdraw |
| 6003 | InvalidEscapeSlots | Escape slots must be above zero. | initialize |
| 6004 | BatchOutOfOrder | Batch number must be exactly the last batch number plus one. | post_batch |
| 6005 | EntryCountMismatch | Batch entries and trader accounts differ in count. | post_batch |
| 6006 | InvalidTraderAccount | A batch account is not a writable trader account of this program. | post_batch |
| 6007 | TraderAlreadyInBatch | A trader appears twice in one batch. | post_batch |
| 6008 | CreditExceedsDeposits | Credited deposits exceed the trader's cumulative deposits. | post_batch |
| 6009 | CreditExceedsWithdrawals | Credited withdrawals exceed the trader's cumulative withdrawals. | post_batch |
| 6010 | FeesDecreased | Reported protocol fees must not decrease. | post_batch |
| 6011 | InsufficientEquity | Amount exceeds the trader's available equity. | withdraw |
| 6012 | EscapeNotOpen | The escape window is not open yet. | escape_withdraw |
| 6013 | NothingToSweep | No unswept protocol fees. | sweep_fees |
| 6014 | MathOverflow | Arithmetic 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
| Field | Type | Description |
|---|---|---|
batch_number | u64 | The batch number. |
slot | u64 | The slot it landed in. |
state_hash | [u8; 32] | The engine's state hash. |
fees_total | u64 | Cumulative protocol fees reported. |
traders | u32 | How many trader accounts it carried. |
DepositMade, from deposit, discriminator d2c982b7f4cb9bc7
| Field | Type | Description |
|---|---|---|
owner | pubkey | The trader wallet. |
amount | u64 | USDC base units deposited. |
deposited | u64 | Cumulative deposited after this deposit. |
Escaped, from escape_withdraw, discriminator f0e4073ed8796c52
| Field | Type | Description |
|---|---|---|
owner | pubkey | The trader wallet. |
amount | u64 | USDC base units paid. |
FeesSwept, from sweep_fees, discriminator 60da73884aaacaac
| Field | Type | Description |
|---|---|---|
recipient | pubkey | The fee recipient. |
amount | u64 | USDC base units paid. |
fees_swept | u64 | Cumulative swept after this sweep. |
SessionRegistered, from register_session, discriminator 60a04aaad9d67337
| Field | Type | Description |
|---|---|---|
owner | pubkey | The trader wallet. |
session_key | pubkey | Pubkey::default() revokes. |
expiry | i64 | Unix seconds; 0 on a revocation. |
Withdrawn, from withdraw, discriminator 1459dfc6c27cdb0d
| Field | Type | Description |
|---|---|---|
owner | pubkey | The trader wallet. |
amount | u64 | USDC base units paid. |
withdrawn | u64 | Cumulative withdrawn after this withdrawal. |