Skip to main content
These are the AMM program errors an integrator can hit on the swap path of the Lend AMM. Codes are the Anchor custom-error numbers (the program’s error enum starts at 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

CodeNameWhenFix
6024DexNotEnoughAmountOutswap_in output would be < amount_out_min.Re-quote and/or widen slippage.
6051DexExceedsAmountInMaxswap_out input would be > amount_in_max.Re-quote and/or widen slippage.
These are the expected failures when the market moves between quote and execution. No funds move. Re-quote with a fresh snapshot and retry.

Size and dust limits

CodeNameWhenFix
6052DexSwapInLimitingAmountsAdjusted input > 50% of combined input-side imaginary reserves.Split into smaller swaps.
6053DexSwapOutLimitingAmountsAdjusted output > 50% of combined output-side imaginary reserves.Split into smaller swaps.
6060DexLimitingAmountsSwapAndNonPerfectInput/output below the dust floor (~1e6 in 9-dec terms, 1e2 native).Increase the amount.
6048DexOracleUpdateHugeSwapDiffThe swap would move the pool price more than the oracle’s 5%-per-swap bound.Split into smaller swaps.

Reserves and utilization

CodeNameWhenFix
6022DexTokenReservesTooLowA post-swap real reserve would fall below the minimum-liquidity floor.Smaller swap / other direction.
6057DexDebtReservesTooLowDebt-pool reserves insufficient for the routed leg.Smaller swap.
6058DexInvalidCollateralReservesCollateral reserves in an invalid state for the trade.Smaller swap / re-quote.
6059DexInvalidDebtReservesDebt reserves in an invalid state for the trade.Smaller swap / re-quote.
6025DexUtilizationCapReachedPost-swap Liquidity Layer utilization exceeds the token’s max_utilization.Wait for utilization to ease / smaller swap.
6023DexNoSwapRouteNeither side can service the requested direction.Check the pool has the needed side enabled.

Pool state

CodeNameWhenFix
6050DexSwapAndArbitragePausedSwaps and arbitrage are paused on this pool.None, pool is paused by admin.
6017DexAlreadyEnteredRe-entrancy lock held (e.g. two swaps on one pool in one instruction).Don’t re-enter the same pool.
6021DexPoolNotInitializedPool not set up / no side enabled.Use a live dex_id.
6019DexSmartColNotEnabledCollateral (supply) side not enabled.Use a pool with the side enabled.
6020DexSmartDebtNotEnabledDebt (borrow) side not enabled.Use a pool with the side enabled.

Center price (external-oracle pools)

CodeNameWhenFix
6067DexMissingExternalCenterPricePool needs an external center price but no oracle accounts were passed.Pass [center_price_address, ...sources] as remaining accounts.
6068DexInvalidExternalCenterPriceremaining_accounts[0] is not the pool’s center_price_address.Pass the correct oracle first.
6056DexCenterPriceOutOfRangeResolved center price outside the pool’s configured clamps.Transient: retry. Persistent: pool misconfigured.

Accounts (CPI integrators)

CodeNameWhenFix
6077DexValidateInvalidLiquidityPositionA required supply/borrow position account was None or wrong.Pass all four positions (see CPI).
6078DexValidateMissingLiquidityPositionA liquidity position required for an enabled leg is missing.Include the leg’s position.
6066DexInvalidTokenAccountA token account’s mint/authority/program doesn’t match.Fix ATA owner / mint / token program.
6079DexInvalidRecipientPositionWithdrawOutput routed to a recipient but its token account is missing/invalid.Provide a valid recipient_token_*_account.

Simulation sentinel (not a real failure)

CodeNameWhen
6081DexSwapInResultRecipient is ADDRESS_DEAD; swap_in reverts with the result in the log.
6082DexSwapOutResultRecipient is ADDRESS_DEAD; swap_out reverts with the result in the log.
These are intentional: the off-chain quote-by-simulation path (see TypeScript: exact on-chain quoting via simulation). A real swap must never use the ADDRESS_DEAD recipient.

Reading the code from a failed transaction

  • TypeScript: Anchor throws an AnchorError; read err.error.errorCode.number (e.g. 6024) and err.error.errorMessage. Raw logs contain Program ... 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 a match and 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.