> For the complete documentation index, see [llms.txt](https://docs.aqua.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aqua.network/developers/reference/error-codes.md).

# Error codes

Contract error codes returned by the Aquarius AMM router and pools, and how to handle them.

When a contract call fails, the simulation (or transaction) reports a numeric error code, for example, `Error(Contract, #2006)`. The codes below cover the errors an integrator is most likely to encounter.

## Swap & liquidity guards

The errors you should expect and handle in normal operation:

| Code   | Name                  | When it happens                                                                                                            | How to handle                                           |
| ------ | --------------------- | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| `2006` | `OutMinNotSatisfied`  | Exact-input swap: output fell below your `out_min`. Also raised on deposits (`min_shares`) and withdrawals (`min_amounts`) | Re-quote and retry; consider a wider slippage tolerance |
| `2020` | `InMaxNotSatisfied`   | Exact-output swap: required input exceeds your `max_in`                                                                    | Re-quote and retry                                      |
| `2005` | `InMinNotSatisfied`   | Exact-output swap at pool level: output below minimum                                                                      | Re-quote and retry                                      |
| `2018` | `ZeroAmount`          | Zero passed as a swap/deposit amount                                                                                       | Validate input before calling                           |
| `2019` | `InsufficientBalance` | Account balance can't cover the transfer                                                                                   | Check balances before submitting                        |

For multi-hop swaps (`swap_chained`), the slippage guard is enforced **end-to-end** — intermediate hops are unconstrained; only the final output is checked against `out_min`.

## Routing & setup errors

Usually indicate a bug in the integration rather than market conditions:

| Code   | Name              | When it happens                                   | How to handle                                                                                                                                |
| ------ | ----------------- | ------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `301`  | `PoolNotFound`    | No pool exists for the given tokens + pool hash   | Re-discover pools via `get_pools(tokens)`                                                                                                    |
| `302`  | `BadFee`          | Fee tier not in the allowed set for the pool type | Use 10 / 30 / 100 bps (volatile & concentrated)                                                                                              |
| `307`  | `PathIsEmpty`     | `swap_chained` called with an empty swaps chain   | Always pass the XDR from the Find Path API                                                                                                   |
| `2002` | `TokensNotSorted` | Token vector not sorted by contract address       | Sort the vector as described in [Token ordering](https://docs.aqua.network/developers/reference/router-and-pool-contracts.md#token-ordering) |

## Pool Incentive errors

Raised by the router's `pool_gauge_schedule_reward` (see [Pool Incentives](https://docs.aqua.network/developers/reference/router-and-pool-contracts.md#pool-incentives)):

| Code  | Name                          | When it happens                                                                                     | How to handle                                    |
| ----- | ----------------------------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| `317` | `RewardDurationTooShort`      | `duration` is below `pool_gauge_get_min_duration`                                                   | Schedule at least the minimum duration           |
| `318` | `RewardAmountTooLow`          | `tps × 86400`, valued in AQUA along `swaps_chain_proof`, is below `pool_gauge_get_min_daily_amount` | Raise `tps`                                      |
| `319` | `GaugeRewardsDisabledForPool` | The reward token or a pool token is not enabled for Pool Incentives                                 | Check each token with `pool_gauge_token_enabled` |
| `325` | `RewardAmountTooHigh`         | Concentrated pools: `tps × 86400` exceeds the `u128` range                                          | Lower `tps`                                      |

## Pause states

Aquarius contracts have independent kill switches for emergency response. If operations are paused you'll see: `205 PoolDepositKilled`, `206 PoolSwapKilled`, `207 PoolClaimKilled` (standard pools), or `2139 GaugesClaimKilled` (concentrated pool incentives). These are not integration bugs — check [Discord](https://discord.gg/sgzFscHp4C) for status.

## Concentrated-pool specific

| Code   | Name                    | When it happens                              |
| ------ | ----------------------- | -------------------------------------------- |
| `2121` | `InsufficientLiquidity` | The swap exhausted all liquidity in the pool |

## Provider-fee collector specific

Raised by the [provider-fee collector](https://docs.aqua.network/developers/code-examples/add-fees-to-swap.md) and its factory:

| Code   | Name                    | When it happens                                                                                                                                          | How to handle                                                                                   |
| ------ | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| `2904` | `FeeFractionTooHigh`    | Deployment: `max_swap_fee_fraction` exceeds 20% of `swap_fee_fraction_denominator`. Swap: `fee_fraction` exceeds the collector's `max_swap_fee_fraction` | Deploy with a cap at or below `denominator / 5`; keep each swap's `fee_fraction` within the cap |
| `2905` | `InvalidFeeDenominator` | Deployment: `swap_fee_fraction_denominator` is 0                                                                                                         | Pass a positive denominator, for example 10,000                                                 |

## API-level failures

The backend API signals differently — see [Backend API](https://docs.aqua.network/developers/reference/backend-api.md): no route is HTTP `200` + `success: false`; invalid input is HTTP `400`.

{% hint style="info" %}
**Parsing results:** since Stellar protocol 23, transaction metadata uses **version 4** (`TransactionMetaV4`). Code that reads `meta.v3.soroban_meta` directly will find `None` — use the version-aware pattern shown in the [code examples](https://docs.aqua.network/developers/code-examples.md), or `meta.value().sorobanMeta()` in JavaScript.
{% endhint %}
