> For the complete documentation index, see [llms.txt](https://docs.flash.trade/flash-trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/errors/onchain-error-codes.md).

# On-chain error codes

When a built transaction fails on-chain, your RPC returns the program log with one of the codes below (mainnet program `FLASH6Lo6h3iasJKWDs2F8TkW2UKf3s15C8PMGuVfgBn`). The full list is derived from the program IDL.

## Trading (most common)

| Code | Name                         | Solution                                                                               |
| ---- | ---------------------------- | -------------------------------------------------------------------------------------- |
| 6020 | MaxPriceSlippage             | Price moved beyond tolerance. Widen `slippagePercentage` or rebuild with a fresh quote |
| 6021 | MaxLeverage                  | Post-modification leverage exceeds the market max. Reduce size or add collateral       |
| 6022 | MaxInitLeverage              | New-position leverage exceeds the initial-leverage cap                                 |
| 6023 | MinLeverage                  | Leverage below the minimum. Increase size or reduce collateral                         |
| 6064 | MinInitLeverage              | Initial leverage below the minimum                                                     |
| 6024 | CustodyAmountLimit           | Pool capacity reached. Try smaller or wait                                             |
| 6025 | PositionAmountLimit          | Single position exceeds the max size. Split it                                         |
| 6031 | InstructionNotAllowed        | Trading paused (maintenance / circuit breaker). Wait and retry                         |
| 6032 | MaxUtilization               | Pool utilization at capacity. Try smaller or wait                                      |
| 6033 | CloseOnlyMode                | Market in close-only mode. Only close/decrease allowed                                 |
| 6034 | MinCollateral                | Below minimum collateral. Increase it (leave a buffer for TP/SL)                       |
| 6087 | InsufficientCollateral       | Not enough collateral for the requested position                                       |
| 6088 | MaxPositionSize              | Position size exceeds the allowed maximum                                              |
| 6089 | MaxExposure                  | Market exposure cap exceeded. Reduce size or wait                                      |
| 6065 | InsufficientPositionSize     | Resulting size too small (e.g. over-large partial close)                               |
| 6110 | InsufficientCustodyLiquidity | Not enough free liquidity in the custody. Smaller size or wait                         |
| 6040 | CloseRatio                   | Invalid close amount relative to current size                                          |

## Orders (limit / TP / SL)

| Code | Name                   | Solution                                                            |
| ---- | ---------------------- | ------------------------------------------------------------------- |
| 6049 | InvalidStopLossPrice   | SL price invalid for the direction (e.g. SL above entry for a long) |
| 6050 | InvalidTakeProfitPrice | TP price invalid for the direction                                  |
| 6051 | ExposureLimitExceeded  | Market exposure cap hit. Reduce size or wait                        |
| 6052 | MaxStopLossOrders      | Max SL orders per market reached. Cancel one first                  |
| 6053 | MaxTakeProfitOrders    | Max TP orders per market reached. Cancel one first                  |
| 6054 | MaxOpenOrder           | Max open limit orders per market reached. Cancel one first          |
| 6055 | InvalidOrder           | Order doesn't exist at the specified index                          |
| 6057 | InvalidLimitPrice      | Limit price invalid for the direction                               |
| 6083 | MaxOrdersReached       | Order limit exhausted for this market + side                        |
| 6084 | InvalidOrderIndex      | `orderId` out of range (0–4)                                        |
| 6085 | OrderNotFound          | No order at the given `orderId`                                     |
| 6086 | LimitPriceNotMet       | Limit price condition not met (keeper context)                      |
| 6090 | InvalidTriggerPrice    | Trigger price invalid for the order type/direction                  |
| 6092 | TriggerPriceNotMet     | Trigger condition not met (keeper context)                          |

## Oracle

| Code      | Name                         | Solution                                                            |
| --------- | ---------------------------- | ------------------------------------------------------------------- |
| 6005      | StaleOraclePrice             | Oracle price too old. Retry after a few slots; check market session |
| 6002      | UnsupportedOracle            | Internal: custody oracle misconfigured                              |
| 6003      | InvalidOracleAccount         | Wrong oracle account. Ensure the pool config is current             |
| 6004      | InvalidOracleState           | Oracle feed offline/corrupted. Wait and retry                       |
| 6006      | InvalidOraclePrice           | Oracle returned 0 or invalid confidence. Wait and retry             |
| 6093      | InvalidPrice                 | Computed/derived price invalid                                      |
| 6094      | OracleDivergenceTooHigh      | Oracle price divergence exceeds the maximum                         |
| 6095      | OracleConfidenceTooWide      | Oracle confidence interval exceeds the maximum                      |
| 6096      | StaleBackupOraclePrice       | Backup oracle price too stale                                       |
| 6097      | InvalidBackupOracleSignature | Invalid backup oracle Ed25519 signature                             |
| 6035–6038 | PermissionlessOracle\*       | Keeper/oracle authority or signature errors                         |

## Pyth Lazer

| Code | Name                  | Notes                                  |
| ---- | --------------------- | -------------------------------------- |
| 6098 | InvalidLazerMessage   | Lazer message format error             |
| 6099 | InvalidLazerPayload   | Lazer payload parsing failure          |
| 6100 | InvalidLazerChannel   | Wrong Lazer channel for this custody   |
| 6101 | InvalidLazerTimestamp | Lazer message too old or in the future |

## Deposit / withdrawal / balance

| Code | Name                         | Solution                                                                    |
| ---- | ---------------------------- | --------------------------------------------------------------------------- |
| 6078 | InsufficientBalance          | Insufficient balance for the operation                                      |
| 6079 | InsufficientAvailableBalance | Insufficient *available* balance (deposits minus obligations)               |
| 6075 | NoDepositsToClaim            | No deposits available to claim                                              |
| 6076 | PendingDepositNotClaimed     | Pending deposit hasn't been claimed yet                                     |
| 6077 | NoWithdrawalPending          | No pending withdrawal to settle (nothing for `withdrawal-settle` to resume) |
| 6048 | MaxDepostsReached            | Token vault deposit limit hit                                               |
| 6058 | MinReserve                   | Custody minimum-reserve threshold                                           |
| 6059 | MaxWithdrawTokenRequest      | Max pending withdraw requests reached                                       |
| 6108 | UserDepositDisabled          | User deposits currently disabled                                            |
| 6109 | UserWithdrawDisabled         | User withdrawals currently disabled                                         |

## Access, authority & delegation

| Code | Name                     | Solution                                                          |
| ---- | ------------------------ | ----------------------------------------------------------------- |
| 6102 | Unauthorized             | Signer is not the owner or an authorized delegate                 |
| 6056 | InvalidAuthority         | Wrong authority for the instruction                               |
| 6045 | InvalidOwner             | Token account owner mismatch. Ensure the ATA is derived correctly |
| 6046 | InvalidAccess            | Pool requires NFT/referral access                                 |
| 6111 | InvalidValidatorKey      | Delegation key is invalid                                         |
| 6105 | TradeInitDisabled        | Opening/increasing positions currently disabled                   |
| 6106 | TradeMaintDisabled       | Position maintenance (modify) currently disabled                  |
| 6107 | TradeLiquidationDisabled | Liquidations currently disabled                                   |

## State validation

| Code      | Name                       | Solution                                                          |
| --------- | -------------------------- | ----------------------------------------------------------------- |
| 6009      | InvalidPoolState           | Pool account corrupted/uninitialized. Verify the pool address     |
| 6010      | InvalidCustodyState        | Custody account issue. Re-fetch the pool config                   |
| 6011      | InvalidMarketState         | Market account issue. Verify the market exists for this pool/side |
| 6012      | InvalidCollateralCustody   | Wrong collateral token for this market                            |
| 6013      | InvalidPositionState       | Position doesn't exist or is already closed                       |
| 6018      | InvalidBasketState         | Basket corrupted, not initialized, or not delegated               |
| 6071      | InvalidPoolAccount         | Pool account failed PDA validation                                |
| 6072      | InvalidCustodyAccount      | Custody account failed PDA validation                             |
| 6069      | InvalidCustodyTokenAccount | Custody token account mismatch                                    |
| 6070      | InvalidTokenMint           | Token mint mismatch for the operation                             |
| 6074      | InvalidAccountData         | Account data failed to deserialize/validate                       |
| 6007–6017 | Invalid\*Config / \*State  | Environment, platform, perpetuals, pool, custody config issues    |

## Token / pool / market support

| Code | Name               | Solution                                             |
| ---- | ------------------ | ---------------------------------------------------- |
| 6027 | UnsupportedToken   | Token mint not recognized by the pool                |
| 6028 | UnsupportedCustody | Custody not found in the pool                        |
| 6029 | UnsupportedPool    | Pool address invalid                                 |
| 6030 | UnsupportedMarket  | Market doesn't exist for this target/collateral/side |

## Arithmetic & misc

| Code | Name                       | Notes                                            |
| ---- | -------------------------- | ------------------------------------------------ |
| 6001 | MathOverflow               | Arithmetic overflow. Rare — extreme sizes/prices |
| 6039 | ExponentMismatch           | Internal price-calc error (operand exponents)    |
| 6019 | InsufficientAmountReturned | Output below minimum                             |
| 6066 | InsufficientLockedAmount   | Not enough locked amount for the operation       |
| 6073 | InvalidAmount              | Amount is zero or otherwise invalid              |
| 6063 | InvalidInput               | Generic invalid input parameter                  |
| 6091 | InvalidArgument            | Generic invalid argument                         |
| 6000 | CustomError                | Generic catch-all                                |

For step-by-step fixes to the most common integration failures, see [Recovery patterns](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/errors/recovery-patterns.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/errors/onchain-error-codes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
