> For the complete documentation index, see [llms.txt](https://docs.lighter.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lighter.xyz/developers/reference/data-structures-constants-and-errors.md).

# Data Structures, Constants and Errors

## Data and Event Structures

{% code collapsedlinecount="10" %}

```go
type Order struct {
	OrderIndex                  int64  `json:"i"`
	ClientOrderIndex            int64  `json:"u"`
	OwnerAccountId              int64  `json:"a"`
	InitialBaseAmount           int64  `json:"is"`
	Price                       uint32 `json:"p"`
	RemainingBaseAmount         int64  `json:"rs"`
	IsAsk                       uint8  `json:"ia"`
	Type                        uint8  `json:"ot"`
	TimeInForce                 uint8  `json:"f"`
	ReduceOnly                  uint8  `json:"ro"`
	TriggerPrice                uint32 `json:"tp"`
	Expiry                      int64  `json:"e"`
	Status                      uint8  `json:"st"`
	TriggerStatus               uint8  `json:"ts"`
	ToTriggerOrderIndex0        int64  `json:"t0"`
	ToTriggerOrderIndex1        int64  `json:"t1"`
	ToCancelOrderIndex0         int64  `json:"c0"`
	IntegratorFeeCollectorIndex int64  `json:"ifci"`
	IntegratorTakerFee          uint32 `json:"itf"`
	IntegratorMakerFee          uint32 `json:"imf"`
}

type OrderExecution struct {
	MarketId   int64  `json:"m"`
	Trade      *Trade `json:"t"`
	MakerOrder *Order `json:"mo"`
	TakerOrder *Order `json:"to"`
	AppError   string `json:"ae"`
}

type CancelOrder struct {
	AccountId        int64  `json:"a"`
	OrderIndex       int64  `json:"i"`
	ClientOrderIndex int64  `json:"u"`
	AppError         string `json:"ae"`
}

type ModifyOrder struct {
	MarketId int64  `json:"m"`
	OldOrder *Order `json:"oo"`
	NewOrder *Order `json:"no"`
	AppError string `json:"ae"`
}

type Trade struct {
	Price    uint32 `json:"p"`
	Size     int64  `json:"s"`
	TakerFee int32  `json:"tf"`
	MakerFee int32  `json:"mf"`
}

// Order Status
const (
	InProgressOrder                  = iota // In register
	PendingOrder                            // Pending to be triggered
	ActiveLimitOrder                        // Active limit order
	FilledOrder                             // 3
	CanceledOrder                           // 4
	CanceledOrder_PostOnly                  // 5
	CanceledOrder_ReduceOnly                // 6
	CanceledOrder_PositionNotAllowed        // 7
	CanceledOrder_MarginNotAllowed          // 8
	CanceledOrder_TooMuchSlippage           // 9
	CanceledOrder_NotEnoughLiquidity        // 10
	CanceledOrder_SelfTrade                 // 11
	CanceledOrder_Expired                   // 12
	CanceledOrder_OCO                       // 13
	CanceledOrder_Child                     // 14
	CanceledOrder_Liquidation               // 15
	CanceledOrder_InvalidBalance            // 16
)
```

{% endcode %}

## Constants

{% code collapsedlinecount="10" %}

```go
TxTypeL2ChangePubKey     = 8
TxTypeL2CreateSubAccount = 9
TxTypeL2CreatePublicPool = 10
TxTypeL2UpdatePublicPool = 11
TxTypeL2Transfer         = 12
TxTypeL2Withdraw         = 13
TxTypeL2CreateOrder      = 14
TxTypeL2CancelOrder      = 15
TxTypeL2CancelAllOrders  = 16
TxTypeL2ModifyOrder      = 17
TxTypeL2MintShares       = 18
TxTypeL2BurnShares       = 19
TxTypeL2UpdateLeverage   = 20
TxTypeL2CreateGroupedOrders = 28
TxTypeL2UpdateMargin        = 29
TxTypeL1BurnShares          = 30
TxTypeL2ApproveIntegrator = 45
TxTypeL2UpdateAccountConfig = 41
TxTypeL2UpdateAccountAssetConfig = 42
TxTypeL2StakeAssets = 35
TxTypeL2UnstakeAssets = 36
```

{% endcode %}

See all constants here: <https://github.com/elliottech/lighter-go/blob/main/types/txtypes/constants.go>

### Binary options values

These values are returned in REST and WebSocket market data; the field name determines which value to use.

| Field                           | Binary options value                                                       |
| ------------------------------- | -------------------------------------------------------------------------- |
| Market definition `market_type` | `binary_options`                                                           |
| Trade `market_kind`             | `bo`                                                                       |
| Order/trade query `market_type` | `bo`                                                                       |
| Trade `type`                    | `market-settlement` for settlement records; `trade` for regular fills      |
| Market `status`                 | `inactive`, `active`, `waiting-for-settlement`, `in-settlement`, `settled` |
| Market `outcome`                | `0`: none/refund; `1`: No/Down; `2`: Yes/Up                                |
| Market `settlement_type`        | `0`: discrete; `1`: continuous                                             |

See [Binary options lifecycle](https://docs.lighter.xyz/developers/binary-options/discover-markets.md#market-lifecycle) and [Settlement records](https://docs.lighter.xyz/developers/binary-options/positions-and-settlement.md#settlement).

## Transaction Status Mapping

{% code collapsedlinecount="10" %}

```go
0: Failed
1: Pending
2: Executed
3: Pending - Final State
```

{% endcode %}

## Error Codes

### Binary options errors

| Code    | Meaning                                   | What to check                                                                    |
| ------- | ----------------------------------------- | -------------------------------------------------------------------------------- |
| `21618` | Invalid order type for market             | Use limit or market orders, with `reduceOnly = 0` and `triggerPrice = 0`         |
| `21631` | Market is outside its trading window      | Create and modify requests must be between `start_timestamp` and `end_timestamp` |
| `21632` | Order price must be below the full payout | Require `price < settlement_cap`; Up/Down order prices are `1`–`99` ticks        |
| `21638` | Order book is frozen                      | Create and modify requests are rejected while `is_frozen = true`                 |
| `21752` | Pools cannot trade binary options         | Public pool and insurance fund accounts are not supported                        |

See [Binary options order rules](https://docs.lighter.xyz/developers/binary-options/trading-and-fees.md#order-rules) for collateral and minimum-notional checks.

### RFQ errors

| Code  | Message                                               | Notes                                                      |
| ----- | ----------------------------------------------------- | ---------------------------------------------------------- |
| 64001 | rfq not found                                         |                                                            |
| 64002 | invalid market\_index                                 | Unknown or inactive market                                 |
| 64003 | base\_amount must be a valid positive integer         |                                                            |
| 64004 | insufficient balance for rfq request                  | Non-positive perp collateral or spot funding-asset balance |
| 64005 | account is not whitelisted for rfq                    | `respond` only                                             |
| 64006 | rfq is already closed                                 |                                                            |
| 64007 | invalid rfq status transition                         |                                                            |
| 64008 | account is not the owner of this rfq                  | `update` only                                              |
| 64010 | rfq is being processed, please try again              | Another request on the same RFQ is in progress. Retry.     |
| 64011 | quote\_amount must be a valid positive integer        |                                                            |
| 64012 | either base\_amount or quote\_amount must be provided |                                                            |
| 64013 | too many active rfqs already exist for this market    | 3 open per account per market                              |

### Full error list

{% hint style="info" %}
The updated messages for codes `21133`, `21134`, `21149`, `21150`, `21152`, `21520`, `21751`, `23100`, and `62006` are confirmed on Lighter mainnet. On Robinhood Chain, match errors by numeric code; the message wording may differ.
{% endhint %}

{% code collapsedlinecount="10" %}

```go
// General
AppErrInvalidParam                                           = NewBusinessError(20001, "invalid param ")
AppErrInactiveOrderBook                                      = NewBusinessError(20008, "order book does not exist or is delisted")
AppErrInvalidCursor                                          = NewBusinessError(20009, "invalid cursor")
AppErrInvalidExpireTime                                      = NewBusinessError(20011, "invalid expired time")
AppErrTooLongInput                                           = NewBusinessError(20012, "input is too long")
AppErrInvalidAuth                                            = NewBusinessError(20013, "invalid auth")

// Account
AppErrAccountNotFound                                        = NewBusinessError(21100, "account not found")
AppErrAccountNonceNotFound                                   = NewBusinessError(21101, "account nonce not found")
AppErrInvalidAccountIndex                                    = NewBusinessError(21102, "invalid account index")
AppErrInvalidAccountL1Address                                = NewBusinessError(21103, "invalid account l1 address")
AppErrInvalidNonce                                           = NewBusinessError(21104, "invalid nonce")
AppErrNonIncreasingNonce                                     = NewBusinessError(21105, "batch transaction nonce is not increasing")
AppErrAccountInvalidToAccount                                = NewBusinessError(21106, "invalid ToAccount")
AppErrInvalidAccount                                         = NewBusinessError(21107, "invalid account")
AppErrInvalidPublicKey                                       = NewBusinessError(21108, "invalid PublicKey,please run changePubKey")
AppErrApiKeyNotFound                                         = NewBusinessError(21109, "api key not found")
AppErrInvalidApiKeyIndex                                     = NewBusinessError(21110, "invalid api key index")
AppErrPreLiquidation                                         = NewBusinessError(21111, "account is in pre-liquidation and the transaction doesn't increase the account health")
AppErrAccountIsInLiquidation                                 = NewBusinessError(21112, "account is in liquidation")
AppErrInvalidInitialMarginFraction                           = NewBusinessError(21113, "invalid initial margin fraction")
AppErrFaultyLiquidation                                      = NewBusinessError(21114, "account value is over maintenance margin, can't activate liquidation")
AppErrWithdrawalAmountTooLow                                 = NewBusinessError(21116, "withdrawal amount is too small")
AppErrWithdrawalAmountTooHigh                                = NewBusinessError(21117, "withdrawal amount is too high")
AppErrTransferAmountTooLow                                   = NewBusinessError(21118, "transfer amount is too small")
AppErrTransferAmountTooHigh                                  = NewBusinessError(21119, "transfer amount is too high")
AppErrInvalidSignature                                       = NewBusinessError(21120, "invalid signature")
AppErrBatchTxMultipleOwner                                   = NewBusinessError(21121, "all transactions in the batch must have use same account and apikey")
AppErrDeadMansSwitchShouldBeTriggered                        = NewBusinessError(21122, "dead man's switch should be triggered")
AppErrInvalidAccountType                                     = NewBusinessError(21123, "invalid account type")
AppErrInvalidRouteType                                       = NewBusinessError(21124, "invalid route type")
AppErrWitnessNotFound                                        = NewBusinessError(21125, "witness not found")
AppErrAccountHasZeroCollateral                               = NewBusinessError(21126, "Account with zero collateral can't change PublicKey")
AppErrWithdrawalFromPublicPool                               = NewBusinessError(21127, "withdrawal from public pool is not allowed")
AppErrInvalidMasterAccountIndex                              = NewBusinessError(21128, "invalid master account index")
AppErrTooManySubAccounts                                     = NewBusinessError(21129, "too many sub accounts")
AppErrTooManyPublicPools                                     = NewBusinessError(21130, "too many public pools")
AppErrInvalidL1Address                                       = NewBusinessError(21131, "invalid l1 address")
AppErrMarginModeChangeOnActivePosition                       = NewBusinessError(21132, "margin mode change on a market with position or open order is not allowed")
AppErrInvalidRiskChange                                      = NewBusinessError(21133, "leverage change rejected: account risk or collateral requirements are not met")
AppErrInvalidFee                                             = NewBusinessError(21134, "invalid transfer fee: use the fee from the transfer fee endpoint")
AppErrAssetAlreadyExist                                      = NewBusinessError(21135, "asset already exist for given index")
AppErrPublicKeyUpdateSdk                                     = NewBusinessError(21136, "invalid PublicKey, update the sdk to the latest version")
AppErrRestrictedWithdrawal                                   = NewBusinessError(21137, "Withdrawals are restricted for this asset")
AppErrMaxPendingUnlocksExceeded                              = NewBusinessError(21138, "maximum pending unlocks per account exceeded")
AppErrNoPendingUnlocks                                       = NewBusinessError(21139, "no pending unlocks for the account")
AppErrPendingUnlockStillWaiting                              = NewBusinessError(21140, "pending unlock is still in waiting period")
AppErrPendingUnlockInvalidAsset                              = NewBusinessError(21141, "only LIT asset can be used for pending unlock")
AppErrAccountTradingModeAlreadyInUse                         = NewBusinessError(21142, "new account trading mode is same as current account trading mode")
AppErrAccountHasLockedBalance                                = NewBusinessError(21143, "account has open orders in corresponding spot markets, cannot change margin mode")
AppErrAccountReachedMaxApprovedIntegrators                   = NewBusinessError(21145, "account reached maximum approved integrators")
AppErrSystemAccountCannotBeIntegrator                        = NewBusinessError(21146, "system account cannot be an integrator except a subaccount of the treasury account")
AppErrInvalidApprovalExpiry                                  = NewBusinessError(21147, "invalid approval expiry, it should be in the future and within maximum allowed expiry")
AppErrIntegratorIsNotApproved                                = NewBusinessError(21149, "integrator not approved by this account or approval expired; send ApproveIntegrator first")
AppErrGivenIntegratorFeeExceedsApprovedLimit                 = NewBusinessError(21150, "integrator fee exceeds the maximum this account approved for this integrator")
AppErrInvalidIntegratorAccountType                           = NewBusinessError(21151, "invalid integrator account type")
AppErrIntegratorFeeExceedsSystemLimit                        = NewBusinessError(21152, "approved integrator fee exceeds the platform maximum")
AppErrIntegratorAccountIndexRequiredForNonZeroFees           = NewBusinessError(21153, "integrator account index is required for non-zero fees")
AppErrIntegratorAccountIndexInvalidRange                     = NewBusinessError(21154, "IntegratorAccountIndex is in invalid range")
AppErrIntegratorFeeInvalidRange                              = NewBusinessError(21155, "Integrator fees are in invalid range")
AppErrAccountAssetMarginModeAlreadyInUse                     = NewBusinessError(21156, "new account asset margin mode is same as current account asset margin mode")
AppErrMarginModeDisabledForSimpleAccount                     = NewBusinessError(21157, "margin mode change is not allowed for simple accounts")
AppErrCannotExitUnifiedModeWithMarginAssets                  = NewBusinessError(21158, "cannot exit unified mode with margin assets, please disable margin for all assets first")
AppErrSelfTradeSpecificationNotAllowedWithNonZeroFees        = NewBusinessError(21159, "self-trade specifications are not allowed when there are non-zero fees")
AppErrReduceModeNotAllowedWithMasterAccountIndexEqualityMode = NewBusinessError(21160, "Reduce mode is not allowed with master account index equality mode")
AppErrSelfTradeBehaviorModeInvalidRange                      = NewBusinessError(21161, "self-trade behavior mode is in invalid range")
AppErrSelfTradeEqualityModeInvalidRange                      = NewBusinessError(21162, "self-trade equality mode is in invalid range")
AppErrMarginModeNotAllowedOnMarket                           = NewBusinessError(21163, "margin mode is not compatible with this market's required margin mode")

// Public pools
AppErrInvalidPublicPoolIndex                                 = NewBusinessError(21200, "invalid public pool index")
AppErrInvalidOperatorFee                                     = NewBusinessError(21201, "invalid operator fee")
AppErrInvalidPublicPoolStatus                                = NewBusinessError(21202, "invalid public pool status")
AppErrPublicPoolIsFrozen                                     = NewBusinessError(21203, "public pool is frozen, only burning is allowed")
AppErrPoolInitialTotalSharesInvalid                          = NewBusinessError(21204, "invalid pool initial usdc amount")
AppErrInvalidMinOperatorShareRate                            = NewBusinessError(21205, "invalid min operator share rate")
AppErrTooManyInvestedPublicPools                             = NewBusinessError(21206, "too many invested public pools")
AppErrInsufficientAvailableShares                            = NewBusinessError(21207, "insufficient available shares")
AppErrOwnerDropsBelowMinimumOwnership                        = NewBusinessError(21208, "owner drops below minimum ownership")
AppErrInvalidMintShareAmount                                 = NewBusinessError(21209, "invalid mint share amount")
AppErrInvalidBurnShareAmount                                 = NewBusinessError(21210, "invalid burn share amount")
AppErrShareUSDCAmountTooHigh                                 = NewBusinessError(21211, "burnt share usdc amount is too high")
AppErrEntryUSDCAmountTooHigh                                 = NewBusinessError(21212, "entry usdc amount is too high")
AppErrInvalidUpdatePublicPoolStatus                          = NewBusinessError(21213, "invalid update public pool status")
AppErrInvalidPoolPositionToTransfer                          = NewBusinessError(21214, "invalid pool position to transfer")
AppErrInvalidMasterAccount                                   = NewBusinessError(21215, "only master account can update public pool")
AppErrPoolInLiquidation                                      = NewBusinessError(21216, "public pool is in liquidation")
AppErrPoolReachedMaximumInvestedPools                        = NewBusinessError(21217, "public pool reached maximum invested pools")
AppErrPoolCreationDisabled                                   = NewBusinessError(21218, "pool creation is disabled")
AppErrMaxLLPPercentageExceeded                               = NewBusinessError(21219, "max llp percentage exceeded")
AppErrPublicPoolHasOpenPositions                             = NewBusinessError(21220, "public pool has open positions")
AppErrPublicPoolHasActiveOrders                              = NewBusinessError(21221, "public pool has active orders")
AppErrPoolHasNoShares                                        = NewBusinessError(21222, "public pool has no shares")
AppErrMaxLLPAmountExceeded                                   = NewBusinessError(21223, "max llp amount exceeded")
AppErrStakingPoolIsFrozen                                    = NewBusinessError(21224, "staking pool is frozen, only burning is allowed")
AppErrInvalidStakingPoolIndex                                = NewBusinessError(21225, "invalid staking pool index")
AppErrEntryStakedAmountTooHigh                               = NewBusinessError(21226, "entry staked amount is too high")
AppErrShareLITAmountTooHigh                                  = NewBusinessError(21227, "burnt share lit amount is too high")
AppErrInsufficientAvailableStakingShares                     = NewBusinessError(21228, "insufficient available staking shares")
AppErrInvalidUnstakeAmount                                   = NewBusinessError(21229, "invalid unstake amount")
AppErrStakingPoolAlreadyInitialized                          = NewBusinessError(21230, "staking pool is already initialized")
AppErrMintShareAmountExceedsStakedLIT                        = NewBusinessError(21231, "mint share amount exceeds staked LIT value")
AppErrInvalidStakeAssetAmount                                = NewBusinessError(21232, "invalid stake asset amount")
AppErrInvalidUnstakeAssetAmount                              = NewBusinessError(21233, "invalid unstake asset amount")
AppErrLiquidityPoolCooldownPeriodNotPassed                   = NewBusinessError(21234, "liquidity pool cooldown period has not passed yet")
AppErrStakingPoolDoesNotExist                                = NewBusinessError(21236, "staking pool does not exist")

// 213xx
AppErrInvalidAssetAmount                                     = NewBusinessError(21300, "invalid asset amount")
AppErrNotEnoughCollateral                                    = NewBusinessError(21301, "not enough collateral")
AppErrInvalidReceiverAssetAmount                             = NewBusinessError(21302, "invalid receiver asset amount")
AppErrInvalidFeeAccountAssetAmount                           = NewBusinessError(21303, "invalid fee account asset amount")
AppErrNotEnoughAssetBalance                                  = NewBusinessError(21304, "not enough asset balance")
AppErrNotEnoughAssetBalanceForFee                            = NewBusinessError(21305, "not enough asset balance for fee")
AppErrAssetBalanceExceedsLimit                               = NewBusinessError(21307, "asset balance exceeds limit")
AppErrAssetMarginBalanceExceedsLimit                         = NewBusinessError(21308, "asset margin balance exceeds limit")
AppErrCollateralExceedsLimit                                 = NewBusinessError(21309, "collateral exceeds limit")

// 214xx
AppErrBlockNotFound                                          = NewBusinessError(21400, "block not found")
AppErrInvalidBlockHeight                                     = NewBusinessError(21401, "invalid block height")

// Transactions
AppErrTxNotFound                                             = NewBusinessError(21500, "transaction not found")
AppErrInvalidTxInfo                                          = NewBusinessError(21501, "invalid tx info")
AppErrMarshalTxFailed                                        = NewBusinessError(21502, "marshal tx failed")
AppErrMarshalEventsFailed                                    = NewBusinessError(21503, "marshal event failed")
AppErrFailToL1Signature                                      = NewBusinessError(21504, "fail to l1 signature")
AppErrUnsupportedTxType                                      = NewBusinessError(21505, "unsupported tx type")
AppErrTooManyTxs                                             = NewBusinessError(21506, "too many pending txs. Please try again later")
AppErrAccountBelowMaintenanceMargin                          = NewBusinessError(21507, "account is below maintenance margin, can't execute transaction")
AppErrAccountBelowInitialMargin                              = NewBusinessError(21508, "account is below initial margin, can't execute transaction")
AppErrInvalidTxTypeForAccount                                = NewBusinessError(21511, "invalid tx type for account")
AppErrInvalidL1RequestId                                     = NewBusinessError(21512, "invalid l1 request id")
AppErrTxInfoTxTypeLengthMismatch                             = NewBusinessError(21513, "TxInfos and TxTypes should have the same length")
AppErrMaxBatchTx                                             = NewBusinessError(21514, "maximum 50 transactions allowed per batch")
AppErrCannotCreateTxOnAsset                                  = NewBusinessError(21515, "transaction is not allowed")
AppErrTreasuryOutgoingTransferNotAllowed                     = NewBusinessError(21516, "outgoing transfers from treasury account are not allowed")
AppErrInvalidAttributes                                      = NewBusinessError(21518, "invalid transaction attributes")
AppErrTreasurySubAccountOutgoingTransferNotAllowed           = NewBusinessError(21519, "outgoing transfers from a treasury sub account are not allowed")
AppErrIntegratorCannotChargeFreeTier                         = NewBusinessError(21520, "integrator fees cannot be charged to Standard accounts; upgrade or set integrator fees to zero")
AppErrOnlySpotTradingAllowed                                 = NewBusinessError(21521, "only spot trading is available on this instance")

// Orders
AppErrInactiveCancel                                         = NewBusinessError(21600, "given order is not an active limit order")
AppErrOrderBookFull                                          = NewBusinessError(21601, "order book is full")
AppErrInvalidMarketIndex                                     = NewBusinessError(21602, "invalid market index")
AppErrInvalidMinAmountsForMarket                             = NewBusinessError(21603, "invalid min amounts for market")
AppErrInvalidMarketStatus                                    = NewBusinessError(21605, "invalid market status")
AppErrMarketAlreadyExist                                     = NewBusinessError(21606, "market already exist for given index")
AppErrInvalidMarketFees                                      = NewBusinessError(21607, "invalid market fees")
AppErrInvalidQuoteMultiplier                                 = NewBusinessError(21608, "invalid quote multiplier")
AppErrInvalidInterestRate                                    = NewBusinessError(21611, "invalid interest rate")
AppErrInvalidOpenInterest                                    = NewBusinessError(21612, "invalid open interest")
AppErrInvalidMarginMode                                      = NewBusinessError(21613, "invalid margin mode")
AppErrNoPositionFound                                        = NewBusinessError(21614, "no position found")
AppErrInvalidUpdateMarginDirection                           = NewBusinessError(21615, "invalid update margin direction")
AppErrAssetNotExist                                          = NewBusinessError(21616, "asset does not exists for given index")
AppErrInvalidCreateMarketParameters                          = NewBusinessError(21617, "invalid create market parameters")
AppErrInvalidOrderTypeForMarket                              = NewBusinessError(21618, "invalid order type for market")
AppErrInvalidMarketType                                      = NewBusinessError(21619, "invalid market type")
AppErrInvalidFundingClamp                                    = NewBusinessError(21620, "invalid funding clamp")
AppErrInvalidPerpsMarketIndex                                = NewBusinessError(21621, "invalid perps market index")
AppErrInvalidOrderQuoteLimit                                 = NewBusinessError(21622, "invalid order quote limit")
AppErrInvalidOpenInterestLimit                               = NewBusinessError(21623, "invalid open interest limit")
AppErrInvalidMinBaseAmount                                   = NewBusinessError(21624, "invalid min base amount")
AppErrInvalidMinQuoteAmount                                  = NewBusinessError(21625, "invalid min quote amount")
AppErrInvalidMarginFraction                                  = NewBusinessError(21626, "invalid margin fraction")
AppErrMarketNotInTradingWindow                               = NewBusinessError(21631, "market is outside its trading window")
AppErrPriceExceedsPayout                                     = NewBusinessError(21632, "order price must be below the full payout")
AppErrOrderBookFrozen                                        = NewBusinessError(21638, "order book is frozen")

// Trading and risk
AppErrInvalidOrderIndex                                      = NewBusinessError(21700, "invalid order index")
AppErrInvalidBaseAmount                                      = NewBusinessError(21701, "invalid base amount")
AppErrInvalidPrice                                           = NewBusinessError(21702, "invalid price")
AppErrInvalidIsAsk                                           = NewBusinessError(21703, "invalid isAsk")
AppErrInvalidOrderType                                       = NewBusinessError(21704, "invalid OrderType")
AppErrInvalidOrderTimeInForce                                = NewBusinessError(21705, "invalid OrderTimeInForce")
AppErrInvalidOrderAmount                                     = NewBusinessError(21706, "invalid order base or quote amount")
AppErrInvalidOrderOwner                                      = NewBusinessError(21707, "account is not owner of the order")
AppErrEmptyOrder                                             = NewBusinessError(21708, "order is empty")
AppErrInactiveOrder                                          = NewBusinessError(21709, "order is inactive")
AppErrUnsupportedOrderType                                   = NewBusinessError(21710, "unsupported order type")
AppErrInvalidOrderExpiry                                     = NewBusinessError(21711, "invalid expiry")
AppErrAccountHasAQueuedCancelAllOrdersRequest                = NewBusinessError(21712, "account has a queued cancel all orders request")
AppErrInvalidCancelAllTimeInForce                            = NewBusinessError(21713, "invalid cancel all time in force")
AppErrInvalidCancelAllTime                                   = NewBusinessError(21714, "invalid cancel all time")
AppErrInctiveOrder                                           = NewBusinessError(21715, "given order is not an active order")
AppErrOrderNotExpired                                        = NewBusinessError(21716, "order is not expired")
AppErrMaxOrdersPerAccount                                    = NewBusinessError(21717, "maximum active limit order count reached")
AppErrMaxOrdersPerAccountPerMarket                           = NewBusinessError(21718, "maximum active limit order count per market reached")
AppErrMaxPendingOrdersPerAccount                             = NewBusinessError(21719, "maximum pending order count reached")
AppErrMaxPendingOrdersPerAccountPerMarket                    = NewBusinessError(21720, "maximum pending order count per market reached")
AppErrMaxTWAPOrdersInExchange                                = NewBusinessError(21721, "maximum twap order count reached")
AppErrMaxConditionalOrdersInExchange                         = NewBusinessError(21722, "maximum conditional order count reached")
AppErrInvalidAccountHealth                                   = NewBusinessError(21723, "invalid account health")
AppErrInvalidLiquidationSize                                 = NewBusinessError(21724, "invalid liquidation size")
AppErrInvalidLiquidationPrice                                = NewBusinessError(21725, "invalid liquidation price")
AppErrInsuranceFundCannotBePartiallyLiquidated               = NewBusinessError(21726, "insurance fund cannot be partially liquidated")
AppErrInvalidClientOrderIndex                                = NewBusinessError(21727, "invalid client order index")
AppErrClientOrderIndexExists                                 = NewBusinessError(21728, "client order index already exists")
AppErrInvalidOrderTriggerPrice                               = NewBusinessError(21729, "invalid order trigger price")
AppErrFatFingerPrice                                         = NewBusinessError(21733, "order price flagged as an accidental price")
AppErrPriceTooFarFromMarkPrice                               = NewBusinessError(21734, "limit order price is too far from the mark price")
AppErrPriceTooFarFromTrigger                                 = NewBusinessError(21735, "SL/TP order price is too far from the trigger price")
AppErrInvalidOrderTriggerStatus                              = NewBusinessError(21736, "invalid order trigger status")
AppErrInvalidOrderStatus                                     = NewBusinessError(21737, "invalid order status")
AppErrInvalidReduceOnlyDirection                             = NewBusinessError(21738, "invalid reduce only direction")
AppErrNotEnoughOrderMargin                                   = NewBusinessError(21739, "not enough margin to create the order")
AppErrInvalidReduceOnlyMode                                  = NewBusinessError(21740, "invalid reduce only mode")
AppErrInvalidGroupingType                                    = NewBusinessError(21741, "invalid grouping type")
AppErrInvalidOrderGroupSize                                  = NewBusinessError(21742, "invalid order group size")
AppErrInvalidOrderInfo                                       = NewBusinessError(21743, "invalid order info")
AppErrInvalidAccountTypeForSpotMarket                        = NewBusinessError(21744, "pools are not allowed to trade in spot markets")
AppErrInvalidMarketTypeForL1Order                            = NewBusinessError(21745, "only perps markets are allowed for L1 orders")
AppErrPublicPoolNotAllowedInIsolatedOnlyMarket               = NewBusinessError(21747, "public pools are not allowed to trade in isolated only markets")
AppErrMarginModeConflictsWithMarket                          = NewBusinessError(21748, "user's margin mode conflicts with this market's required margin mode")
AppErrInvalidOrderOrderVersion                               = NewBusinessError(21751, "order_version must be greater than the order's current version")
AppErrInvalidAccountTypeForBinaryOptionsMarket               = NewBusinessError(21752, "pools are not allowed to trade in binary options markets")
AppErrPriceTooFarFromIndexPrice                              = NewBusinessError(21753, "order price is too far from the index price")

// 218xx
AppErrInvalidAssetIndex                                      = NewBusinessError(21801, "invalid asset index")
AppErrInvalidAssetMarginMode                                 = NewBusinessError(21802, "invalid asset margin mode")
AppErrAssetAlreadyExists                                     = NewBusinessError(21803, "asset already exists for given index")
AppErrAssetDoesNotExists                                     = NewBusinessError(21804, "asset does not exist for given index")
AppErrOnlyUSDCTransferSupported                              = NewBusinessError(21805, "only usdc transfer supported")
AppErrInvalidExtensionMultiplier                             = NewBusinessError(21806, "invalid extension multiplier")
AppErrInvalidMinTransferAmount                               = NewBusinessError(21807, "invalid min transfer amount")
AppErrInvalidMinWithdrawalAmount                             = NewBusinessError(21808, "invalid min withdrawal amount")
AppErrAssetNotFound                                          = NewBusinessError(21809, "asset not found")
AppErrAssetSupplyCapExceeded                                 = NewBusinessError(21813, "asset supply cap exceeded")

// 219xx
AppErrDeleverageAgainstItself                                = NewBusinessError(21901, "deleverage against itself")
AppErrDeleverageDoesNotMatchLiquidationStatus                = NewBusinessError(21902, "deleverage does not match liquidation status")
AppErrDeleverageWithOpenOrders                               = NewBusinessError(21903, "deleverage with open orders")
AppErrInvalidDeleverageSize                                  = NewBusinessError(21904, "invalid deleverage size")
AppErrInvalidDeleveragePrice                                 = NewBusinessError(21905, "invalid deleverage price")
AppErrInvalidDeleverageSide                                  = NewBusinessError(21906, "invalid deleverage side")

// 224xx
AppErrInvalidTimestamps                                      = NewBusinessError(22400, "invalid timestamps: end_timestamp must be greater than start_timestamp")
AppErrInvalidTimestamp                                       = NewBusinessError(22401, "invalid timestamp: timestamp must be greater than 0 and less than year 2286")
AppErrInvalidResolution                                      = NewBusinessError(22402, "invalid resolution: resolution unsupported")
AppErrTimeRangeExceedsLimit                                  = NewBusinessError(22403, "time range exceeds maximum allowed range for the specified resolution")

// 225xx
AppErrExportInvalidTimestampRange                            = NewBusinessError(22501, "start_timestamp must be before end_timestamp")
AppErrExportTimestampRequired                                = NewBusinessError(22503, "both start_timestamp and end_timestamp must be provided")
AppErrExportNoDataFound                                      = NewBusinessError(22504, "no export data found for the given parameters")
AppErrExportQueueFull                                        = NewBusinessError(22505, "export queue is full, please try again later")
AppErrExportInvalidType                                      = NewBusinessError(22506, "invalid export type")
AppErrExportTimestampRangeTooLarge                           = NewBusinessError(22507, "export time range exceeds the maximum allowed limit")
AppErrExportHistoricalDisabled                               = NewBusinessError(22509, "historical data export is not enabled")
AppErrExportPaymentRequired                                  = NewBusinessError(22510, "historical data export requires a one-time payment")

// 230xx
AppErrTooManyRequest                                         = NewBusinessError(23000, "Too Many Requests!")
AppErrTooManySubscriptions                                   = NewBusinessError(23001, "Too Many Subscriptions!")
AppErrTooManyDifferentAccounts                               = NewBusinessError(23002, "Too Many Different Accounts!")
AppErrTooManyConnections                                     = NewBusinessError(23003, "Too Many Connections!")
AppErrTooManyL2Withdrawals                                   = NewBusinessError(23004, "Too Many L2 Withdrawal Requests!")
AppErrTooManyFastWithdrawals                                 = NewBusinessError(23005, "Too Many Fast Withdrawal Requests!")
AppErrTooManyGaslessDeposits                                 = NewBusinessError(23006, "Too Many Gasless Deposit Requests!")

// API keys
AppErrPermissionForbidden                                    = NewBusinessError(23100, "this action is not permitted for this account")

// 294xx
AppErrNotFound                                               = NewBusinessError(29404, "not found")

// 295xx
AppErrInternal                                               = NewBusinessError(29500, "internal server error")

// WebSocket
AppErrWebsocketInvalidJson                                   = NewBusinessError(30000, "Invalid Json")
AppErrWebsocketInvalidType                                   = NewBusinessError(30001, "Invalid Type")
AppErrWebsocketNotSubscribed                                 = NewBusinessError(30002, "Not Subscribed to ")
AppErrWebsocketAlreadySubscribed                             = NewBusinessError(30003, "Already Subscribed to ")
AppErrWebsocketFetchFailed                                   = NewBusinessError(30004, "Failed to fetch ")
AppErrWebsocketInvalidChannel                                = NewBusinessError(30005, "Invalid Channel")
AppErrWebsocketNotSupported                                  = NewBusinessError(30006, "Operation isn't supported ")
AppErrWebsocketInvalidData                                   = NewBusinessError(30007, "Invalid Data")
AppErrWebsocketInvalidAccountType                            = NewBusinessError(30008, "Invalid account type")
AppErrWebsocketRateLimit                                     = NewBusinessError(30009, "Too Many Websocket Messages!")
AppErrWebsocketTooManyInflight                               = NewBusinessError(30010, "Too Many Inflight Messages!")
AppErrWebsocketFailedToConnect                               = NewBusinessError(30011, "Failed to connect")
AppErrWebsocketFailedToSubscribe                             = NewBusinessError(30012, "Failed to subscribe")
AppErrWebsocketMessageTooLarge                               = NewBusinessError(30013, "Message too large to send, unsubscribed from channel")

// Validation
AppErrReferralAlreadyExists                                  = NewBusinessError(41001, "Referral code already exists")
AppErrReferralExpired                                        = NewBusinessError(41002, "Referral code is expired")
AppErrReferralAlreadyUsed                                    = NewBusinessError(41003, "Referral code already used")
AppErrReferralUserHasAccess                                  = NewBusinessError(41004, "User can already access")
AppErrReferralUserCantInvite                                 = NewBusinessError(41005, "User can't invite")
AppErrReferralInvalid                                        = NewBusinessError(41006, "Invalid referral code")
AppErrReferralRequired                                       = NewBusinessError(41007, "Referral code is required")
AppErrReferralKickbackUpdate                                 = NewBusinessError(41008, "Kickback can only be updated once per week")
AppErrReferralCodeAlreadyUpdated                             = NewBusinessError(41009, "Referral code has already been updated once, cannot update again")
AppErrReferralCodeInvalid                                    = NewBusinessError(41010, "Referral code must be 4-14 characters and contain only uppercase letters (A-Z) and numbers (0-9)")
AppErrReferralOnlyMainAccount                                = NewBusinessError(41011, "only main account index is valid, please use the main account")
AppErrReferralCannotUseOwnCode                               = NewBusinessError(41012, "cannot use your own referral code")
AppErrReferralVolumeTooHigh                                  = NewBusinessError(41013, "referral codes can only be used by accounts with less than $10,000 of traded volume")

// Guild
AppErrGuildCreationNotAllowed                               = NewBusinessError(42001, "account is not whitelisted to create a guild")
AppErrGuildAlreadyLeader                                    = NewBusinessError(42002, "account already leads a guild")
AppErrGuildAlreadyMember                                    = NewBusinessError(42003, "account is already a member of a guild")
AppErrGuildNameInvalid                                      = NewBusinessError(42004, "guild name must be 3-32 characters of letters, numbers, spaces or basic punctuation")
AppErrGuildNameTaken                                        = NewBusinessError(42005, "guild name is already taken")
AppErrGuildDescriptionTooLong                               = NewBusinessError(42006, "guild description must be at most 500 characters")
AppErrGuildNotMember                                        = NewBusinessError(42008, "account is not a member of a guild")
AppErrGuildNotLeader                                        = NewBusinessError(42009, "only the guild leader can do this")
AppErrGuildRenameCooldown                                   = NewBusinessError(42010, "guild can only be renamed once every 30 days")
AppErrGuildNotEmpty                                         = NewBusinessError(42011, "guild still has other members")
AppErrGuildNotAdmin                                         = NewBusinessError(42012, "only the guild leader or an admin can do this")
AppErrGuildJoinRequestsOff                                  = NewBusinessError(42013, "guild does not accept join requests")
AppErrGuildJoinRequestExists                                = NewBusinessError(42014, "a pending join request for this guild already exists")
AppErrGuildJoinRequestMissing                               = NewBusinessError(42015, "join request not found or no longer pending")
AppErrGuildInviteMissing                                    = NewBusinessError(42016, "invite code not found, no longer pending, or not issued to this address")
AppErrGuildInviteExpired                                    = NewBusinessError(42017, "invite code has expired")
AppErrGuildInviteExists                                     = NewBusinessError(42018, "a pending invite for this address already exists")
AppErrGuildTooManyInvites                                   = NewBusinessError(42019, "at most 10 invite codes can be created at once")
AppErrGuildInvalidAddress                                   = NewBusinessError(42020, "invalid l1 address")
AppErrGuildLeaderCannotLeave                                = NewBusinessError(42021, "guild leader must transfer leadership before leaving")
AppErrGuildTargetNotMember                                  = NewBusinessError(42022, "address is not a member of your guild")
AppErrGuildRoleNotAllowed                                   = NewBusinessError(42023, "not allowed to change or remove this member")
AppErrGuildFull                                             = NewBusinessError(42024, "guild has reached its member limit")
AppErrGuildMaxMembersTooLow                                 = NewBusinessError(42025, "max_members cannot be lower than the current member count")
AppErrGuildDuelNotFound                                     = NewBusinessError(42026, "guild duel not found")
AppErrGuildDuelAlreadyActive                                = NewBusinessError(42027, "guild already has a duel in progress")
AppErrGuildDuelTargetBusy                                   = NewBusinessError(42028, "the other guild already has a duel in progress")
AppErrGuildDuelSelf                                         = NewBusinessError(42029, "a guild cannot challenge itself")
AppErrGuildDuelNotYourTurn                                  = NewBusinessError(42030, "the other guild must respond to the pending offer")
AppErrGuildDuelOfferStale                                   = NewBusinessError(42031, "offer is no longer pending or its start time is no longer reachable")
AppErrGuildDuelInvalidTerms                                 = NewBusinessError(42032, "invalid metric, stake, start time, duration or min members")
AppErrGuildDuelBadStatus                                    = NewBusinessError(42033, "action not allowed in the duel's current status")
AppErrGuildDuelInvalidStake                                 = NewBusinessError(42034, "transfer must be an executed USDC transfer of the exact stake from the leader to the escrow account")
AppErrGuildDuelMemoMismatch                                 = NewBusinessError(42035, "transfer memo does not match this duel")
AppErrGuildDuelStakeExists                                  = NewBusinessError(42036, "transfer is already recorded as a stake of this duel")
AppErrGuildDuelStakeTxNotFound                              = NewBusinessError(42037, "stake transfer not found or not executed yet")
AppErrGuildDuelDisabled                                     = NewBusinessError(42038, "guild duels are currently disabled")
AppErrGuildDuelInProgress                                   = NewBusinessError(42039, "roster members cannot leave or be removed while the guild is in a committed duel")
AppErrGuildDuelRefundQueued                                 = NewBusinessError(42040, "transfer reached escrow but cannot be used as the stake; its refund has been queued")
AppErrGuildDuelRosterTooSmall                               = NewBusinessError(42041, "roster is below the minimum size")
AppErrGuildDuelChallengePending                             = NewBusinessError(42042, "a challenge to this guild is already pending")
AppErrGuildDuelTooManyOutgoing                              = NewBusinessError(42043, "guild has too many open challenges")
AppErrGuildBusy                                             = NewBusinessError(42044, "guild or duel is busy, re-try later")

// 520xx
AppErrBlacklistBlocksAction                                  = NewBusinessError(52001, "Unauthorized use of the API, contact our team if you think you got this in error.")
AppErrEncouragePremium                                       = NewBusinessError(52002, "You've reached the limit of Standard trading and can now only close or reduce positions. Upgrade to Premium to keep trading normally. Standard accounts stay free forever for casual use.")

// 610xx
AppErrAPITokenExpiryBeforeMinAllowed                         = NewBusinessError(61001, "api token expiry is before minimum allowed expiry of 5 minutes")
AppErrAPITokenExpiryAfterMaxAllowed                          = NewBusinessError(61002, "api token expiry is after maximum allowed expiry of 10 years")
AppErrAPITokenMaxTokensExceeded                              = NewBusinessError(61003, "maximum number of 10 api tokens for the account exceeded")
AppErrAPITokenCustomScopesNotSupported                       = NewBusinessError(61004, "custom scopes for api tokens are not supported yet")
AppErrAPITokenNotFound                                       = NewBusinessError(61005, "api token not found or does not belong to this account")
AppErrAPITokenAlreadyRevoked                                 = NewBusinessError(61006, "api token has already been revoked")
AppErrAPITokenNameEmpty                                      = NewBusinessError(61007, "api token name cannot be empty")
AppErrAPITokenNameTooLong                                    = NewBusinessError(61008, "api token name cannot exceed 50 characters")
AppErrAPITokenNameInvalidChars                               = NewBusinessError(61009, "api token name can only contain letters, numbers, spaces, hyphens, underscores, and periods")

// Service
AppErrTierChangeInProgress                                   = NewBusinessError(62001, "tier change already in progress")
AppErrTierChangeInvalidTier                                  = NewBusinessError(62002, "invalid tier")
AppErrTierChangeSameTier                                     = NewBusinessError(62003, "account already part of requested tier")
AppErrTierChangeTooManyRequest                               = NewBusinessError(62006, "downgrades require a 24-hour cooldown after the last tier change; try again later")
AppErrMakerOnlyKeyNonMakerTx                                 = NewBusinessError(62007, "maker-only api key can only send 0ms delay transactions")
AppErrMakerOnlyChangeTooFrequent                             = NewBusinessError(62008, "maker-only api key indexes can only be changed once per hour")
AppErrMakerOnlyKeyRequiresPremium                            = NewBusinessError(62009, "maker-only api key can only be used with premium accounts")
AppErrTierChangeTooManySubAccounts                           = NewBusinessError(62010, "account has more sub-accounts than the requested tier allows")

// 640xx
AppErrRFQNotFound                                            = NewBusinessError(64001, "rfq not found")
AppErrRFQInvalidMarketIndex                                  = NewBusinessError(64002, "invalid market_index")
AppErrRFQInvalidBaseAmount                                   = NewBusinessError(64003, "base_amount must be a valid positive integer")
AppErrRFQInsufficientBalance                                 = NewBusinessError(64004, "insufficient balance for rfq request")
AppErrRFQNotWhitelisted                                      = NewBusinessError(64005, "account is not whitelisted for rfq")
AppErrRFQAlreadyClosed                                       = NewBusinessError(64006, "rfq is already closed")
AppErrRFQInvalidStatusTransition                             = NewBusinessError(64007, "invalid rfq status transition")
AppErrRFQNotOwner                                            = NewBusinessError(64008, "account is not the owner of this rfq")
AppErrRFQLocked                                              = NewBusinessError(64010, "rfq is being processed, please try again")
AppErrRFQInvalidQuoteAmount                                  = NewBusinessError(64011, "quote_amount must be a valid positive integer")
AppErrRFQMissingAmount                                       = NewBusinessError(64012, "either base_amount or quote_amount must be provided")
AppErrRFQActiveExists                                        = NewBusinessError(64013, "too many active rfqs already exist for this market")

// Volume quota purchase
AppErrBuyVolumeQuotaDisabled                                 = NewBusinessError(69001, "buying volume quota is not enabled")
AppErrBuyVolumeQuotaInvalidAmount                            = NewBusinessError(69002, "quota must be a positive integer")
AppErrBuyVolumeQuotaPayment                                  = NewBusinessError(69003, "transfer amount does not match quota * price")
AppErrBuyVolumeQuotaDestination                              = NewBusinessError(69004, "destination is not a known L1 address")
AppErrBuyVolumeQuotaOverCap                                  = NewBusinessError(69005, "purchase would exceed the maximum volume quota")
AppErrBuyVolumeQuotaNotEnforced                              = NewBusinessError(69006, "volume quota does not apply to this account tier")
AppErrBuyVolumeQuotaBelowMinimum                             = NewBusinessError(69007, "purchase is below the minimum USDC transfer amount")
AppErrBuyVolumeQuotaPaymentFailed                            = NewBusinessError(69008, "payment transfer failed; nothing was charged or credited")
AppErrBuyVolumeQuotaPaymentPending                           = NewBusinessError(69009, "payment transfer is not executed yet; retry with tx_hash once it is")
AppErrBuyVolumeQuotaAlreadyCredited                          = NewBusinessError(69010, "payment transfer was already credited")
AppErrBuyVolumeQuotaUnknownPurchase                          = NewBusinessError(69011, "no volume quota purchase recorded for tx_hash")
```

{% endcode %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.lighter.xyz/developers/reference/data-structures-constants-and-errors.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
