# Errors

> Intear DEX engine errors: the panic messages of failed calls, what causes each one, and how to fix it.

This page is part of the Intear DEX docs. Intear DEX is the `dex.intear.near` contract. https://docs.intear.tech/intear-dex/llms-full.txt has all of its pages in one file, and https://docs.intear.tech/llms.txt lists every page of the Intear docs.

When a call fails, the engine panics and nothing in the call changes: no balances, no storage. Deposits with `*_transfer_call` are refunded by the token contract. The message is in the receipt's failure, after `Smart contract panicked: `. Many messages come after a source location and a line break, like `panicked at src/lib.rs:491:18:`, and some have details after them, so match the messages below as substrings.

`<asset>` is an [asset ID](https://docs.intear.tech/intear-dex/reference/types.md#assetid), `<owner>` is `Account(<account id>)` or `Dex(<dex id>)`.

## Any method

| Message | Cause |
| --- | --- |
| `Contract is paused` | The contract is [paused](https://docs.intear.tech/intear-dex/reference/methods.md#pause). Try again later |
| `Requires attached deposit of exactly 1 yoctoNEAR` | The method needs exactly 1 yoctoNEAR attached |
| `Deposit of at least one yoctoNEAR is required.` | `execute_operations` was called without a deposit |
| `Failed to deserialize input from JSON. Error: <error>` | Malformed arguments, for example an asset ID without its `nep141:` prefix (`Invalid asset id: ...`), a DEX ID without `/` (`Invalid dex id: ...`), or a missing required argument |

## Balances

| Message | Cause |
| --- | --- |
| `Asset <asset> is not registered for <owner>` | The owner would receive an asset that isn't [registered](https://docs.intear.tech/intear-dex/guides/inner-balances.md#register-assets) for them |
| `Failed to deposit assets to contract tracked balance: asset not registered` | Nobody ever registered this asset. Register it for yourself |
| `Insufficient balance for account <account> and asset <asset>: <balance> < <amount>` | Not enough in your inner balance |
| `Insufficient balance of <asset> for <owner>: <balance> < <amount>` | Not enough in your inner balance for the `attached_assets` of a DEX call |
| `User balance not found for account <account> and asset <asset>` | An asset in the `attached_assets` of a DEX call isn't registered for you |
| `Failed to withdraw assets from user balance: user <account> balance for asset <asset> was not found` | The asset isn't registered for you, so you have none of it |
| `Not enough balance for withdraw <asset>: <balance> < Some(U128(<at_least>))`, `Not enough balance for withdrawal of <asset>: <balance> < U128(<at_least>)` | A `Full` withdrawal with a balance lower than `at_least`. The second one is a `Withdraw` in a deposit message |
| `Invalid input array lengths` | A multi token contract called `mt_on_transfer` with arrays of different lengths |
| `account_id and dex_id are mutually exclusive` | `registered_assets_of` needs exactly one of them |
| `No assets to register` | `register_assets` or a `RegisterAssets` operation with an empty `asset_ids` |

## Swaps

| Message | Cause |
| --- | --- |
| `Output amount is less than constraint` | An `ExactIn` swap would give less than `constraint`. The price moved: get a new quote |
| `Input amount is greater than constraint` | An `ExactOut` swap would cost more than `constraint`, [referral fees](https://docs.intear.tech/intear-dex/guides/referral-fees.md) included |
| `At most 5 referrers are allowed` | More than 5 accounts in [`referral_fees`](https://docs.intear.tech/intear-dex/guides/referral-fees.md) |
| `Referral fees must add up to at most 50000` | The `referral_fees` add up to more than 5% |
| `Insufficient balance for dex <dex id> and asset <asset>: <balance> < <amount>` | The DEX doesn't hold enough `asset_out` |
| `Amount in does not match`, `Amount out does not match` | The DEX returned a different exact amount than requested. A bug in the DEX |
| `Dex code not found` | No DEX with this ID |
| `At least one swap option is required` | A [`SwapAdvanced`](https://docs.intear.tech/intear-dex/guides/operations.md#best-of-several-dexs) with an empty `options` |
| `All swap options failed` | Every option of a `SwapAdvanced` failed, or, with `FallbackQueue`, didn't meet the `constraint`. The receipt logs why each was skipped |

## DEX calls

| Message | Cause |
| --- | --- |
| `Failed to call function '<method>': [<dex id>] Dex panicked: <message>` | The DEX refused the swap or call. It comes after `Running wasm failed: `. `<method>` is `swap` for swaps. `<message>` comes from the DEX, which can also panic without one. A message raised with a Rust `panic!`, like Plach's `Invalid message`, starts with `panicked at <file>:<line>:<col>:` and a line break. One raised with `env::panic_str`, like Plach's `No routes`, has no prefix |
| `Failed to get function '<method>'` | The DEX has no such method. It comes after `Running wasm failed: ` |
| `Failed to instantiate module: <error>` | The DEX imports a host function the engine doesn't have, like `attached_deposit` or `log_utf8`. It comes after `Running wasm failed: ` |
| `Method name 'swap' is reserved for the swap operation` | `dex_call` and `dex_view` can't call `swap`. Use `swap_simple` |
| `Cannot modify data in view-only mode` | The DEX tried to change its storage in `dex_view`. It comes after `Running wasm failed: Failed to call function '<method>': ` |

## Operations

| Message | Cause |
| --- | --- |
| `Failed to parse operations` | `msg` of a deposit isn't a valid [`DepositMessage`](https://docs.intear.tech/intear-dex/reference/types.md#depositmessage) |
| `Operation only available in execute_actions` | `RegisterAssets` or `DeployDexCode` in a deposit message |
| `Sandboxed assets must be empty after execution. Did you forget to withdraw <amount> <asset>?` | Operations in a deposit didn't use up everything. Add a `Withdraw` or `TransferAsset` for the rest |
| `Asset in not found in anonymous assets`, `Asset to withdraw not found in anonymous assets`, `Asset to transfer not found in anonymous assets` | An operation in a deposit uses an asset that wasn't deposited and isn't the output of an earlier swap |
| `Not enough balance in anonymous assets`, `Not enough input balance in anonymous assets` | An operation in a deposit uses more than what's left. The second one is a swap whose input is more than what's left, for example an `ExactOut` swap that needs more than was deposited |
| `No rescue address provided and user doesn't have a registered balance for this asset` | A `Withdraw` in a deposit needs the sender or `rescue_address` to have the asset registered. See [Withdrawing from a deposit](https://docs.intear.tech/intear-dex/guides/operations.md#withdrawing-from-a-deposit) |
| `Asset <asset> was not attached, while specified that it was attached`, `Not enough balance for attached deposit of <asset>` | A `DexCall` in a deposit attaches an asset that wasn't deposited, or more than what's left |
| `Near balance not found in anonymous assets`, `Not enough near balance in anonymous assets` | A `StorageDeposit` in a deposit uses NEAR that wasn't deposited, or more than what's left |
| `Amount is required for the first swap operation` | `OutputOfLastIn` without a swap before it |
| `Amount can only be omitted if the last swap asset out matches the current asset in` | `OutputOfLastIn` after a swap to a different asset |
| `PreviousSwapOutput can only be used after a swap, in the same operation batch` | `PreviousSwapOutput` without a swap before it |
| `PreviousSwapOutput can only be used if the last swap asset out matches the withdraw asset` | `PreviousSwapOutput` after a swap to a different asset |
| `Only the previous owner can execute operations on behalf of the previous owner` | An NFT or multi token sent with an approval, with a non-empty `msg` |
| `Operations can only follow a transfer of one token` | An `mt_batch_transfer_call` of several tokens with a non-empty `msg` |
| `r#for is required for StorageDeposit operation` | `StorageDeposit` without `for` |

## Storage

| Message | Cause |
| --- | --- |
| `Storage used (<used>) exceeds total (<total>)` | Not enough [storage balance](https://docs.intear.tech/intear-dex/guides/storage.md): yours for a registration, the DEX's for `deploy_dex_code` or for a swap or call that stores more data. Deposit more |
| `Deposit amount <amount> is less than the minimum bound 0.005 NEAR` | Storage deposits must be at least 0.005 NEAR |
| `Storage used not found` | `storage_withdraw` from an account without a storage balance |
| `Amount exceeds storage used` | `storage_withdraw` of more than `available` |
| `Only the deployer can withdraw dex storage` | `dex_storage_withdraw` by someone other than the DEX's deployer |
| `not implemented: Storage unregistration is not supported` | `storage_unregister` isn't supported |

Amounts in storage errors are in NEAR, rounded up, like `0.006 NEAR`.

## Admin

| Message | Cause |
| --- | --- |
| `Only the trusted code deployer can deploy dex code` | `deploy_dex_code` by another account |
| `Only the trusted code deployer can transfer this permission` | `set_trusted_code_deployer` by another account |
| `Only authorized accounts can pause the contract` | `pause` or `unpause` by another account |
| `Invalid dex code: <error>` | `deploy_dex_code` with code that isn't valid WebAssembly |
| `Contract must be paused to rescue assets` | `rescue` while the contract isn't paused |
| `Nothing to rescue` | `rescue` with nothing untracked, or an `amount` of 0 |
