6000); the name is the ErrorCodes variant. The on-chain message string is the SCREAMING_SNAKE form of the name (e.g. DEX_NOT_ENOUGH_AMOUNT_OUT).
Slippage
| Code | Name | When | Fix |
|---|---|---|---|
6024 | DexNotEnoughAmountOut | swap_in output would be < amount_out_min. | Re-quote and/or widen slippage. |
6051 | DexExceedsAmountInMax | swap_out input would be > amount_in_max. | Re-quote and/or widen slippage. |
Size and dust limits
| Code | Name | When | Fix |
|---|---|---|---|
6052 | DexSwapInLimitingAmounts | Adjusted input > 50% of combined input-side imaginary reserves. | Split into smaller swaps. |
6053 | DexSwapOutLimitingAmounts | Adjusted output > 50% of combined output-side imaginary reserves. | Split into smaller swaps. |
6060 | DexLimitingAmountsSwapAndNonPerfect | Input/output below the dust floor (~1e6 in 9-dec terms, 1e2 native). | Increase the amount. |
6048 | DexOracleUpdateHugeSwapDiff | The swap would move the pool price more than the oracle’s 5%-per-swap bound. | Split into smaller swaps. |
Reserves and utilization
| Code | Name | When | Fix |
|---|---|---|---|
6022 | DexTokenReservesTooLow | A post-swap real reserve would fall below the minimum-liquidity floor. | Smaller swap / other direction. |
6057 | DexDebtReservesTooLow | Debt-pool reserves insufficient for the routed leg. | Smaller swap. |
6058 | DexInvalidCollateralReserves | Collateral reserves in an invalid state for the trade. | Smaller swap / re-quote. |
6059 | DexInvalidDebtReserves | Debt reserves in an invalid state for the trade. | Smaller swap / re-quote. |
6025 | DexUtilizationCapReached | Post-swap Liquidity Layer utilization exceeds the token’s max_utilization. | Wait for utilization to ease / smaller swap. |
6023 | DexNoSwapRoute | Neither side can service the requested direction. | Check the pool has the needed side enabled. |
Pool state
| Code | Name | When | Fix |
|---|---|---|---|
6050 | DexSwapAndArbitragePaused | Swaps and arbitrage are paused on this pool. | None, pool is paused by admin. |
6017 | DexAlreadyEntered | Re-entrancy lock held (e.g. two swaps on one pool in one instruction). | Don’t re-enter the same pool. |
6021 | DexPoolNotInitialized | Pool not set up / no side enabled. | Use a live dex_id. |
6019 | DexSmartColNotEnabled | Collateral (supply) side not enabled. | Use a pool with the side enabled. |
6020 | DexSmartDebtNotEnabled | Debt (borrow) side not enabled. | Use a pool with the side enabled. |
Center price (external-oracle pools)
| Code | Name | When | Fix |
|---|---|---|---|
6067 | DexMissingExternalCenterPrice | Pool needs an external center price but no oracle accounts were passed. | Pass [center_price_address, ...sources] as remaining accounts. |
6068 | DexInvalidExternalCenterPrice | remaining_accounts[0] is not the pool’s center_price_address. | Pass the correct oracle first. |
6056 | DexCenterPriceOutOfRange | Resolved center price outside the pool’s configured clamps. | Transient: retry. Persistent: pool misconfigured. |
Accounts (CPI integrators)
| Code | Name | When | Fix |
|---|---|---|---|
6077 | DexValidateInvalidLiquidityPosition | A required supply/borrow position account was None or wrong. | Pass all four positions (see CPI). |
6078 | DexValidateMissingLiquidityPosition | A liquidity position required for an enabled leg is missing. | Include the leg’s position. |
6066 | DexInvalidTokenAccount | A token account’s mint/authority/program doesn’t match. | Fix ATA owner / mint / token program. |
6079 | DexInvalidRecipientPositionWithdraw | Output routed to a recipient but its token account is missing/invalid. | Provide a valid recipient_token_*_account. |
Simulation sentinel (not a real failure)
| Code | Name | When |
|---|---|---|
6081 | DexSwapInResult | Recipient is ADDRESS_DEAD; swap_in reverts with the result in the log. |
6082 | DexSwapOutResult | Recipient is ADDRESS_DEAD; swap_out reverts with the result in the log. |
ADDRESS_DEAD recipient.
Reading the code from a failed transaction
- TypeScript: Anchor throws an
AnchorError; readerr.error.errorCode.number(e.g.6024) anderr.error.errorMessage. Raw logs containProgram ... failed: custom program error: 0x1798, which is the code in hex:0x1798=6040,6024=0x1788. - CPI: the inner error propagates to your program. Wrap the
dex::cpi::*call in amatchand map the failure to your own error if you want a cleaner message; otherwise let it bubble up and the transaction fails with the error code above.
