# Errors

### Error format

Errors return a JSON object with an `error` field.

```json
{
  "error": "Missing required parameters: tokenIn, tokenOut, amount"
}
```

### HTTP status codes

#### `400` invalid parameters

This means the request is malformed.

Common causes:

* missing required fields
* invalid address format
* non-integer `amount`

Fixes:

* pass every required parameter
* use checksum-safe or valid hex addresses
* send raw token amounts as integer strings

#### `404` no route found

This means Dirol could not find executable liquidity for the pair and amount.

Fixes:

* try a smaller amount
* verify both token addresses
* remove aggressive `excludeSources` filters

#### `502` upstream or calldata failure

This means quoting or calldata generation failed upstream.

Fixes:

* retry the request
* refresh token metadata
* request a fresh `/swap` before execution

#### `504` timeout

This means the quote request took too long.

Fixes:

* retry with the same parameters
* reduce request frequency bursts
* try again without exclusions

### Common mistakes

#### Using human-readable amounts

`amount` must use raw units.

Example:

* `1 WMON` = `1000000000000000000`
* `1 USDC` = `1000000`

#### Calling `/quote` and expecting calldata

`/quote` only returns routing data.

Use `/swap` when you need `tx.to`, `tx.data`, and `tx.value`.

#### Forgetting `recipient` on `/swap`

`recipient` is required on `/swap`.

Use a valid Monad address.

#### Forgetting token approval

ERC-20 input tokens must be approved before sending the swap transaction.

Approve the aggregator address from `tx.to`.

#### Handling native `MON` like an ERC-20

For native `MON`, request the route with `WMON` as `tokenIn`.

Then send the transaction with `value = amountIn`.

### Debug checklist

* confirm the chain is **Monad Mainnet** with ID `143`
* confirm `tokenIn`, `tokenOut`, and `recipient` are valid addresses
* confirm `amount` matches the token `decimals`
* confirm approvals are in place for ERC-20 swaps
* confirm excluded sources still leave a valid route


---

# Agent Instructions: 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:

```
GET https://dirolprotocols-organization.gitbook.io/dirol/api/errors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
