> For the complete documentation index, see [llms.txt](https://docs.kanalabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kanalabs.io/perpetual-futures/kana-perps/api-docs/perps-contract-error-codes.md).

# Perps Contract Error Codes

## KanaPerps Error Codes

#### perpetual\_core.move

| Error Messag                                                 | Error Code | Description                                                                         |
| ------------------------------------------------------------ | ---------- | ----------------------------------------------------------------------------------- |
| E\_NOT\_KANA                                                 | 1001       | Indicates that the caller is not Kana                                               |
| E\_PAUSED                                                    | 1002       | System or functionality is paused                                                   |
| E\_MARKET\_NOT\_FOUND                                        | 1003       | Market ID is not available in the perpetual market registry                         |
| E\_LEVERAGE\_MISMATCH\_CLOSE\_POSITION                       | 1004       | Leverage given while closing position does not match the current leverage           |
| E\_LEVERAGE\_MISMATCH\_INCREASE\_POSITION                    | 1005       | Leverage given while increasing position does not match the current leverage        |
| E\_INVALID\_LEVERAGE                                         | 1006       | Leverage is either greater than the maximum allowed for the market or zero          |
| E\_INSUFFICIENT\_LIQUIDITY\_IN\_ORDERBOOK                    | 1007       | Not enough liquidity in orderbook to fill the order                                 |
| E\_INSUFFICIENT\_BALANCE\_TO\_EXIT\_POSITION                 | 1008       | Not enough balance available to exit the position                                   |
| E\_INSUFFICIENT\_BALANCE\_IN\_TRADING\_ACCOUNT\_TO\_WITHDRAW | 1009       | User doesn't have enough balance in trading account to withdraw                     |
| E\_INSUFFICIENT\_FUND\_IN\_USER\_DEPOSITS                    | 1010       | User doesn't have enough funds in UserDeposits to withdraw                          |
| E\_TRADE\_SIZE\_EXCEEDS\_EXISTING\_FILLED                    | 1011       | Given order size is greater than the existing filled position size                  |
| E\_LOSS\_GREATER\_THAN\_COLLATERAL                           | 1012       | Loss is greater than available collateral                                           |
| E\_INVALID\_MAINTENANCE\_MARGIN                              | 1013       | Given maintenance margin is greater than the divisor                                |
| E\_INVALID\_INITIAL\_MARGIN                                  | 1014       | Given max leverage allows the initial margin to be less than the maintenance margin |
| E\_INSUFFICIENT\_FUND\_IN\_COLLATERAL\_STORE                 | 1015       | Not enough funds available in the collateral store to withdraw                      |
| E\_INSUFFICIENT\_FUND\_IN\_INSURANCE\_FUND                   | 1016       | Not enough funds available in the insurance fund to withdraw                        |
| E\_SIZE\_TOO\_LARGE                                          | 1017       | Order size exceeds the maximum allowed lots for the market                          |
| E\_INSUFFICIENT\_BASE\_IN\_MARKET\_ACCOUNT                   | 1018       | Not enough base asset in market account to withdraw                                 |
| E\_INSUFFICIENT\_QUOTE\_IN\_MARKET\_ACCOUNT                  | 1019       | Not enough quote asset in market account to withdraw                                |
| E\_LIMIT\_ORDER\_FOUND\_CANNOT\_RESET                        | 1020       | Long Limit orders found in the position registry cannot be reset                    |
| E\_LIQUIDATION\_PRICE\_NOT\_REACHED                          | 1021       | Liquidation price not reached to liquidate the position                             |
| E\_LIQUIDATION\_SIZE\_ZERO                                   | 1022       | Liquidation size is zero                                                            |
| E\_ZERO\_FILLED\_SIZE\_FOR\_TPSL\_EXECUTION                  | 1023       | Zero filled size for take profit/stop loss orders                                   |
| E\_TAKE\_PROFIT\_ORDER\_NOT\_FILLED                          | 1024       | Take profit order not filled completely                                             |
| E\_STOP\_LOSS\_ORDER\_NOT\_FILLED                            | 1025       | Stop loss order not filled completely                                               |
| E\_NO\_BIDS\_IN\_ORDERBOOK                                   | 1026       | No bids present in the orderbook                                                    |
| E\_NO\_ASKS\_IN\_ORDERBOOK                                   | 1027       | No asks present in the orderbook                                                    |
| E\_TAKE\_PROFIT\_PRICE\_NOT\_REACHED                         | 1028       | Take profit price is not reached for the position                                   |
| E\_STOP\_LOSS\_PRICE\_NOT\_REACHED                           | 1029       | Stop loss price is not reached for the position                                     |
| E\_TAKE\_PROFIT\_NOT\_SET                                    | 1030       | Take profit price is not set                                                        |
| E\_STOP\_LOSS\_NOT\_SET                                      | 1031       | Stop loss price is not set                                                          |
| E\_CANCEL\_VECTOR\_LEN\_MISMATCH                             | 1032       | Cancel order ID vector length not equal to sides vector length                      |
| E\_VECTOR\_LENGTH\_MISMATCH\_IN\_MULTIPLE\_ORDER\_PLACING    | 1033       | Input vector lengths for placing multiple orders are not equal                      |
| E\_NOT\_MARKET\_CREATOR                                      | 1034       | Caller is not the market creator                                                    |
| E\_UNSUPPORTED\_RESTRICTION\_TYPE                            | 1035       | Unsupported restriction type                                                        |
| E\_INSUFFICIENT\_QUOTE\_IN\_MARKET\_ACCOUNT\_TO\_COLLAPSE    | 1036       | Insufficient quote asset in the market account to collapse                          |
| E\_INSUFFICIENT\_BASE\_IN\_MARKET\_ACCOUNT\_TO\_COLLAPSE     | 1037       | Insufficient base asset in the market account to collapse                           |
| E\_NO\_FILLED\_OPEN\_POSITION\_ON\_ONE\_SIDE                 | 1038       | Attempted collapse with no active position on one side                              |
| E\_ZERO\_FILLED\_SIZE\_FOR\_UPDATE\_TPSL                     | 1039       | Zero filled size for updating take profit/stop loss                                 |
| E\_NO\_OPEN\_POSITION                                        | 1040       | No open position available                                                          |
| E\_MARGIN\_ADDITION\_EXCEEDS\_POSITION\_VALUE                | 1041       | Attempting to add margin would exceed the total position value                      |
| E\_LESS\_THAN\_MIN\_MARGIN\_ADDITION                         | 1042       | Amount less than the minimum margin addition amount                                 |
| E\_TRADE\_PROFILE\_DOESNT\_EXISTS                            | 1043       | Trade profile doesn't exist                                                         |
| E\_DEPRECATED                                                | 1044       | Function is deprecated                                                              |

#### utils.move

| Error Code                                              | Error Message | Description                                                                |
| ------------------------------------------------------- | ------------- | -------------------------------------------------------------------------- |
| E\_VALUE\_TOO\_LARGE\_U64                               | 4001          | Value is greater than the maximum possible u64                             |
| E\_ZERO\_TRADE\_ID                                      | 4002          | Generated Trade ID is zero                                                 |
| E\_INVALID\_MARKET\_ID\_ZERO                            | 4003          | Given market ID is zero                                                    |
| E\_INVALID\_TRADE\_COUNTER\_ZERO                        | 4004          | Given trade counter is zero                                                |
| E\_INVALID\_TAKE\_PROFIT\_PRICE\_LONG                   | 4005          | Given take profit price is less than the entry price for long position     |
| E\_INVALID\_STOP\_LOSS\_PRICE\_LONG                     | 4006          | Given stop loss price is greater than the entry price for long position    |
| E\_INVALID\_TAKE\_PROFIT\_PRICE\_SHORT                  | 4007          | Given take profit price is greater than the entry price for short position |
| E\_INVALID\_STOP\_LOSS\_PRICE\_SHORT                    | 4008          | Given stop loss price is less than the entry price for short position      |
| E\_STOP\_LOSS\_LESS\_THAN\_LIQUIDATION\_PRICE\_LONG     | 4009          | Stop loss price is less than the liquidation price for long position       |
| E\_STOP\_LOSS\_GREATER\_THAN\_LIQUIDATION\_PRICE\_SHORT | 4010          | Stop loss price is greater than the liquidation price for short position   |
| E\_INSUFFICIENT\_LIQUIDITY\_IN\_ORDERBOOK               | 4011          | Not enough liquidity in orderbook to fill                                  |
| E\_DIVISION\_BY\_ZERO                                   | 4012          | Denominator is zero                                                        |
| E\_INVALID\_PROFILE\_ID                                 | 4013          | Invalid Profile ID                                                         |

#### price\_oracle.move

| Error Code                        | Error Message | Description                                         |
| --------------------------------- | ------------- | --------------------------------------------------- |
| E\_NOT\_KANA                      | 2001          | Caller is not Kana                                  |
| E\_MARKET\_ID\_EXISTS             | 2002          | Market ID already exists                            |
| E\_INVALID\_PRICE\_FEED           | 2003          | Price feed does not exist                           |
| E\_INVALID\_PYTH\_PRICE\_EXPONENT | 2004          | Pyth price exponent is less than the quote exponent |

#### delegate\_proxy.move

| Error Code                        | Error Message | Description                 |
| --------------------------------- | ------------- | --------------------------- |
| E\_ALREADY\_DELEGATED             | 5001          | Already Delegated           |
| E\_NOT\_DELEGATED                 | 5002          | Not Delegated               |
| E\_NOT\_DELEGATED\_PROXY\_ADDRESS | 5003          | Not Delegated proxy address |
| E\_DELEGATION\_EXPIRED            | 5004          | Delegation expired          |
