Docs · Reference
Program: errors
Every error the mesa program returns, with its code, its message, the instructions that raise it and under what condition, what the caller does about it, and how the code reaches an API client.
The mesa program defines 33 errors, numbered 9000 to 9032. This page lists each with the conditions that raise it, read from the program, and what a caller does next. The instructions are in Program: instructions.
How an error reaches the caller
A MesaError leaves the program as Solana's Custom program error carrying the code as a u32. A failed transaction or simulation reports it as the instruction's index and the number:
InstructionError(2, Custom(9011))and the program's log shows the same number in hex, custom program error: 0x2333 for 9011.
When the transaction went through Mesa's API, the failure comes back in the API's error envelope with the code CHAIN_REFUSED or SIMULATION_FAILED, both with HTTP status 422, and a programError object naming the program that refused:
type ApiErrorBody = {
error: {
code: string // 'CHAIN_REFUSED' or 'SIMULATION_FAILED' for a program error
message: string
retryable: boolean
stage: string
programError?: { programId: string; name: string; number?: number }
}
}programError.name is the error's name as listed here and number its code. programId tells whose error it is, because another program in the same transaction can use the same number for something else. The rest of the envelope is in the HTTP API reference.
The errors
| Code | Hex | Name | Message |
|---|---|---|---|
9000 | 0x2328 | ProofVerificationFailed | proof verification failed |
9001 | 0x2329 | InvalidInstructionData | instruction data is invalid |
9002 | 0x232a | InvalidShieldedPoolProgram | shielded-pool program account is invalid |
9003 | 0x232b | MissingMesaAuthority | mesa authority account is missing from transact accounts |
9004 | 0x232c | HashingFailed | poseidon hashing failed |
9005 | 0x232d | Unauthorized | signer is not authorized |
9006 | 0x232e | ProtocolPaused | protocol is paused |
9007 | 0x232f | MarketPaused | market is paused |
9008 | 0x2330 | InvalidConfig | configuration parameter is invalid |
9009 | 0x2331 | InvalidAccount | account address, owner or discriminator is invalid |
9010 | 0x2332 | AlreadyInitialized | account is already initialized |
9011 | 0x2333 | InvalidBatchTime | clock is before genesis or batch is past place margin |
9012 | 0x2334 | BatchNotClosed | batch has not closed yet |
9013 | 0x2335 | OpenWindowClosed | open window has closed |
9014 | 0x2336 | OpenWindowStillActive | open window is still active |
9015 | 0x2337 | CommitmentMismatch | opened action fields do not match stored commitment |
9016 | 0x2338 | InvalidActionState | action is not in the required state |
9017 | 0x2339 | ActionLimitExceeded | batch target exceeded max_actions_per_market |
9018 | 0x233a | BatchTargetsFull | batch exceeded maximum distinct targets |
9019 | 0x233b | TargetAlreadyCleared | target has already been cleared in this batch |
9020 | 0x233c | TargetNotCleared | target has not been cleared in this batch |
9021 | 0x233d | InvalidActionAccounts | remaining action accounts do not match opened count or strict index order |
9022 | 0x233e | InsufficientVaultLiquidity | vault lacks reserves for the batch trade |
9023 | 0x233f | MathOverflow | arithmetic overflow |
9024 | 0x2340 | InvalidRentPayer | rent payer account does not match action rent payer |
9025 | 0x2341 | InvalidMarketMint | market mints must be distinct and non-zero |
9026 | 0x2342 | InvalidSeedReserves | initial vault reserves must be non-zero |
9027 | 0x2343 | InvalidOracle | oracle account is invalid, unverified or mismatched |
9028 | 0x2344 | StaleOracle | oracle price is stale |
9029 | 0x2345 | UnsupportedCollateral | collateral mint is not accepted by this pool |
9030 | 0x2346 | PositionNotLapsed | position has not lapsed past its deadline yet |
9031 | 0x2347 | MarketNotCleared | market must clear before its spot liquidity vault in the same batch |
9032 | 0x2348 | NothingToSweep | nothing to sweep |
ProofVerificationFailed
Code 9000. Raised by every instruction that verifies a proof: deposit, withdraw, consolidate, place, settle, reclaim, renew, repay, close_position and liquidate. The Groth16 check failed against the public inputs the program computed from its own accounts and the clock, or against the private_tx_hash and the public transfers of the transaction.
The usual cause is a value that changed between proving and execution:
place: the batch number. A proof made for batchndoes not verify once the clock is in batchn + 1.placeof a borrow or perp open,renew,repay,liquidate: the oracle price, the pool's borrow index or the perp market's funding index, and the deadline, which moves at each heartbeat epoch.close_position: the pool's borrow index.settle: amounts that differ from the ones the program computes from the batch record.deposit: a proof made for a wallet other than the signer.
Read the accounts again, build the inputs from what they hold now, prove again and send.
InvalidInstructionData
Code 9001. The data after the tag byte could not be used.
- Any instruction with arguments: they do not decode, the SPP transact data does not parse, or the timelock length prefix runs past the end of the data.
place:kindis not one of1to8or0x87.open: the data is not exactly 173 bytes.settle: a perp open sent with data, or any other kind sent without a proof and transact.renew:kindis neither4nor5.repay:modeis neither0nor1. In mode0,kindis not4orrepaidis zero. In mode1,kindis neither4nor5.close_position:modeis neither0nor1, or mode0withrepaidof zero.liquidate:kindis neither4nor5,amountis zero, or a perp'ssideis neither0nor1.withdraw_seed_shares:sharesis zero.
Compare the bytes with the instruction's field table. Empty data and an unknown tag fail earlier, with Solana's own InvalidInstructionData, which is not this code.
InvalidShieldedPoolProgram
Code 9002. Raised by every note-moving instruction when the SPP accounts appended to it do not hold the Solana Privacy Program where the CPI expects it. Build the trailing accounts with the Privacy Rings client's transact CPI builder, as The SPP accounts describes.
MissingMesaAuthority
Code 9003. Raised by every note-moving instruction when the Mesa authority is not among the SPP accounts, and by settle when it is not among the trailing accounts the event is emitted with. A proofless settle of a perp open still needs the authority as its last account. Add the authority, read-only and not as a signer.
HashingFailed
Code 9004. A Poseidon hash failed: of the Mesa authority's identity, of a mint, of the public inputs of a proof, or in open, of the posted fields. A 32-byte value that has to be a field element and is not below the field's modulus causes it. In open, check recipient_owner_hash and recipient_auth.
Unauthorized
Code 9005. Raised by set_config, create_market, create_pool, create_perp_market and withdraw_seed_shares when the admin signer is not Config.admin, and by emit_event when its signer is not the Mesa authority. These instructions are not for users to call. emit_event can be called only by the program itself.
ProtocolPaused
Code 9006. Raised while Config.paused is set by deposit, and by place of an order, a supply, a borrow, a perp open or a vault deposit. Everything that keeps a position sealed or takes funds out runs while paused: withdraw, consolidate, renew, repay, close_position, liquidate, reclaim, and place of a redeem, a perp close or a vault withdrawal. open, clear, settle and sweep_fees run too, so a batch already placed completes. Read Config.paused and send again once it is clear.
MarketPaused
Code 9007. Raised by place of a perp open while the perp market's paused flag is set. A spot order opened against a paused market is recorded as Invalid by open and is reclaimed. Closing a perp, renewing it and clearing either kind of market run while paused.
InvalidConfig
Code 9008. A parameter is out of range.
init_config,set_config:protocol_share_bpsabove 10,000, a zeromax_actions_per_market,batch_len,open_windowordrand_period, orplace_marginnot belowbatch_len.set_configalso refusespausedabove1.create_market:fee_bpsof 10,000 or more.create_pool: acollateral_countof zero or above 4, akink_bpsof zero or of 10,000 or more,reserve_factor_bpsabove 10,000, a zerocollateral_factor_bps,liq_threshold_bpsbelowcollateral_factor_bpsor above 10,000, orliq_bonus_bpsof 10,000 or more.create_perp_market: a zeromax_leverage,maint_margin_bpsormax_oi, ormaint_margin_bps,liq_bonus_bps,open_fee_bpsorclose_fee_bpsof 10,000 or more.
InvalidAccount
Code 9009. An account is not the one the instruction requires. Every instruction can raise it.
configis not the PDA["config"], is not owned by the program, or does not hold aConfig.- A
batch,action, market, vault, pool or perp market account is not owned by the program, does not start with its account type's discriminator, or does not sit at the PDA of the number or id stored in it. place:batchoractionis not the PDA of the current batch and the batch's currentaction_count.open,settle,reclaim,close_position: the action belongs to another batch than the one passed.open:targetis not the PDA of the target id in the postedcode.clear: fewer than three accounts, or a third account that is not a market, pool, perp market or vault.clear,liquidate:vaultis not the vault the market or perp market names.settle: the market, pool, perp market or vault is not the one the action names, ormesa_programis not the program.sweep_fees,withdraw_seed_shares, the create instructions:authorityis not the Mesa authority, a token account is not the associated token account expected, or a program account is not the System, SPL Token or Associated Token Account program.
Derive every PDA from the seeds in Program: accounts and pass the accounts in the order of the instruction's table. For place, read the Batch account again: another action landing first raises action_count, and the action PDA moves with it. The proof does not depend on the index and is kept.
AlreadyInitialized
Code 9010. Raised by init_config when Config exists, by create_market, create_pool and create_perp_market when the new account already holds lamports, and by place when the action account at the batch's next index already exists.
InvalidBatchTime
Code 9011. The clock does not allow the instruction.
place:nowis beforegenesis_ts, or later than the batch'sclose_ts − place_margin. Build the action for the next batch, prove it again and send it once that batch has started.renew: the deadline the program computes, the end of the next heartbeat epoch, is not later thanold_deadline. The position already carries that deadline. Renew again in the next epoch.placeof a borrow or perp open,renew,repay: the clock is beforegenesis_ts, orConfig.heartbeatis zero.
BatchNotClosed
Code 9012. Raised by open and clear when now is before the batch's close_ts. Wait for the close. GET /v1/clock returns it.
OpenWindowClosed
Code 9013. Raised by open when now is at or past close_ts + open_window. The action stays Sealed, and its owner takes the funds back with reclaim.
OpenWindowStillActive
Code 9014. Raised by clear when some action of the batch is still Sealed and now is before close_ts + open_window, and by reclaim at any time before close_ts + open_window. For clear, open the remaining actions or wait for the window to end. For reclaim, wait for the window to end.
CommitmentMismatch
Code 9015. Raised by open when the posted fields do not hash to the commitment stored at place. Post the fields exactly as the timelock ciphertext holds them, in the layout of the open field table.
InvalidActionState
Code 9016. The action is not in the state the instruction needs.
| Instruction | Needs | Typical cause |
|---|---|---|
open | Sealed | The action was already opened |
settle | Opened, or Refused for the no-op | The action is still Sealed, or was opened as Invalid |
reclaim | Sealed or Invalid, or Refused for a redeem, vault withdraw or perp close | The action was opened as valid, and is settled through settle |
close_position, mode 1 | Refused, or Sealed or Invalid after the open window | The borrow or perp open was accepted |
Read the Action account's state and send the instruction that matches it. An Action account that no longer exists was settled, reclaimed or closed, and fails with InvalidAccount.
ActionLimitExceeded
Code 9017. Raised by open when the action's target already has Config.max_actions_per_market opened actions in this batch. The action stays Sealed, and its owner takes the funds back with reclaim after the open window.
BatchTargetsFull
Code 9018. Raised by open and clear when the instruction would add a ninth target record to a batch. A Batch account holds records for 8 targets, counted across markets, pools, perp markets and vaults. An action it stops at open stays Sealed and is reclaimed after the open window.
TargetAlreadyCleared
Code 9019. Raised by clear when the target is already cleared in this batch, and by open for an action whose target was cleared before the action was opened. A second clear needs nothing more: move on to settle. An action that open refuses for this reason stays Sealed and is reclaimed after the open window.
TargetNotCleared
Code 9020. Raised by settle when the batch has no cleared record for the action's target. Send clear for the target first. Both can go in one transaction, clear before settle.
InvalidActionAccounts
Code 9021. Raised by clear when the action accounts after the fixed accounts are not exactly the target's opened actions: their number differs from the opened count in the batch's record, one is not an action PDA of this batch in state Opened for this target and of a kind the target takes, or their index values are not strictly increasing. List the batch's Action accounts, keep the Opened ones whose code names the target, sort them by index, and pass all of them.
InsufficientVaultLiquidity
Code 9022. A vault or pool cannot cover what the instruction would take from it.
clearof a spot market: a reserve is zero, or the batch's fills and protocol fees would take a whole reserve.clearof a vault: a deposit into a spot vault with an empty reserve or no shares. A withdrawal naming more shares than the vault has in total. A withdrawal the vault's reserves cannot pay is markedRefusedand raises nothing.settleof a vault deposit or withdrawal: the same arithmetic on the recorded reserves fails.sweep_feesof a pool:cashis belowreserves. Send it again when cash has returned to the pool.withdraw_seed_shares:sharesexceeds the admin's seed shares or the total, or a pool's cash cannot pay the amount.
MathOverflow
Code 9023. A checked calculation left its type's range, divided by zero, or produced an index above u64::MAX. Any instruction that computes amounts, prices, shares, interest or funding can raise it. Check the amounts and prices in the action or arguments against the reserves and decimals of the target.
InvalidRentPayer
Code 9024. Raised by settle, reclaim and close_position in mode 1 when the rent_payer account is not the address stored in the Action account. Read rent_payer from the Action account and pass that address, writable.
InvalidMarketMint
Code 9025. Raised by create_market when the base and quote mints are the same account or either is the all-zero address.
InvalidSeedReserves
Code 9026. Raised by create_market when initial_base or initial_quote is zero, or when the starting price or the starting share count they give is zero. Raised by create_pool when initial_cash is zero and by create_perp_market when initial_quote is zero.
InvalidOracle
Code 9027. Raised by place of a borrow or perp open, clear of a perp market, renew, repay, liquidate and create_perp_market when the oracle account is not usable:
- it is not owned by the program in
Config.pyth_receiver; - it is shorter than a
PriceUpdateV2account or does not start with that type's discriminator; - its verification level is not full;
- its feed id is not the one the pool lists for the chosen collateral, or the perp market's
base_oracle; - its price is zero or negative, or scales to zero.
Pass the Pyth price update account of the feed the target names. For a borrow, the feed is collateral_oracles[collateral_index] of the pool.
StaleOracle
Code 9028. Raised by the same instructions as InvalidOracle when the price's publish_time is more than Config.max_oracle_age seconds before the clock, or more than that ahead of it. Post a fresh price update for the feed in the same transaction, ahead of the Mesa instruction, and prove against that price.
UnsupportedCollateral
Code 9029. Raised by place of a borrow, renew, repay and liquidate when collateral_index is not below the pool's collateral_count. Read the pool's collateral_mints and send the index of the position's collateral mint in that list.
PositionNotLapsed
Code 9030. Raised by liquidate when now is at or before old_deadline. A position can be liquidated only after its deadline. Send again once the clock is past it.
MarketNotCleared
Code 9031. Raised by clear of a vault when the vault's market, or perp market for a perps vault, has a record in this batch that is not cleared yet. Clear the market first, then the vault. Both can go in one transaction in that order.
NothingToSweep
Code 9032. Raised by sweep_fees when the pool's reserves is zero, or the vault's protocol fees are zero in every asset it holds. Nothing is owed yet.
Errors from other programs
An instruction can also fail outside this list.
Solana's built-in errors. The program returns IncorrectProgramId when it is invoked under another program id, and InvalidInstructionData for empty data or an unknown tag. A missing account, a missing signature or an account that is not writable where the instruction's table says it must be fails the account checks with one of Solana's built-in errors, and too few SPP accounts fails with NotEnoughAccountKeys. None of these is a Custom code.
The Solana Privacy Program. Every note-moving instruction ends in a CPI to SPP transact, which verifies its own proof and applies the notes. A failure there, such as a note that was already spent or a tree root the proof no longer matches, is returned as SPP's own error and fails the whole transaction, so nothing the mesa program wrote before the CPI stays. It carries SPP's program id in programError.programId, and its number is read against SPP's error list.
The token and system programs. The transfers in sweep_fees, withdraw_seed_shares and the create instructions, and the account creation in place, are CPIs to the SPL Token, Associated Token Account and System programs. A missing token account, a short balance or a payer without enough lamports is returned as that program's error.