> ## Documentation Index
> Fetch the complete documentation index at: https://docs.route.fun/llms.txt
> Use this file to discover all available pages before exploring further.

# Build and execute

> From one quote request to a confirmed swap: approvals, slippage, deadlines and reverts.

**1. Check the allowance (ERC-20 input only)**

The sending wallet must allow `swap.spender` from the response to spend at least `amountIn`. Read it from each response; do not hardcode it.

**2. Quote with a transaction**

[`GET /quote`](https://docs.route.fun/api-reference/quote) with `recipient`, after any approval so the quote is fresh.

**3. Show the terms**

`swap.netOut` is the expected output after fees, `swap.minOut` the minimum received.

**4. Sign and send `tx`**

Send `to`, `data` and `value` exactly as returned, on `tx.chainId`. Or let Route send it: [submit and track](https://docs.route.fun/execution/submit-and-track.md).

**5. Wait for the receipt**

Success emits `Settled` from the Route contract. A revert moves no tokens.

## Payer, recipient, native token

* The wallet that **sends** `tx` pays the input. Route's contract pulls only from the sender.
* `recipient` receives the output: the sender or any address except the zero address.
* The native token is `0x0000000000000000000000000000000000000000`. Native input needs no approval and `tx.value` equals `amountIn`. Native output arrives as the native token.
* Legs in `swaps` show the wrapped native token (WETH `0x0bd7d308f8e1639fab988df18a8011f41eacad73` on Robinhood Chain). That is expected.

## Approvals

Approve the exact `amountIn`, or more if your product supports standing approvals. Route's contract uses only the order's amount
and clears approvals it grants to pools.

> [!WARNING]
>
> `tx.to` is always a Route contract, and `swap.spender` is that contract (or Permit2 with `permit2=1`). If either differs from
> [the published addresses](https://docs.route.fun/contracts.md), do not sign.

### Permit2 instead of an approval (Robinhood Chain)

With a partner key, add `permit2=1` (ERC-20 input, with `recipient`). `swap.spender` is then the
[Permit2 contract](https://docs.route.fun/contracts.md): the wallet approves it once per token, then signs a Permit2 transfer for each swap. The response
carries `permit2.typedData` to sign, and `permit2.signatureOffset` and `permit2.signatureLength` (65): write the 65 signature bytes
into `tx.data` at that byte offset (counted after `0x`), then send.

## Slippage, minimum and deadline

| Parameter | Default | Range | Effect |
| - | - | - | - |
| `slippageBps` | `50` (0.5%) | `0` to `500` | Tolerance below the quoted output. Sets `swap.minOut`. |
| `minOut` | not set | up to the quoted output | Your own minimum after fees, raw units. Overrides `slippageBps`. |
| `deadline` | now + 600 s | now to now + 3600 s | Unix seconds. The swap reverts after it. |

The quote is exact at `block`. A swap sent later may get less than `swap.netOut`, never less than `swap.minOut`.

Quotes have no ID or server-side expiry. Request a new one right before the user signs, and again if they wait more than a few
seconds, or keep one fresh with a [live stream](https://docs.route.fun/execution/streaming.md).

## Reverts

Nothing is transferred on a revert.

| Error | Meaning | Fix |
| - | - | - |
| `Slippage(net, minOut)` | Price moved past the minimum | New quote |
| `Expired()` | Sent after `deadline` | New quote |
| ERC-20 transfer failure | Allowance or balance too low | Approve or top up, then quote again |
| `BadOrder()` | `value` does not match the order, or the input token takes a transfer fee | Send `tx.value` exactly. Fee-on-transfer and rebasing input tokens are not supported. |

## Gas

`gas` is the router's estimate for the swaps. `swap.executorGas` is what the transaction used through Route's contract at the
quote block. Prefer `eth_estimateGas` from the sending wallet, or `executorGas` plus a margin.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.