> For the complete documentation index, see [llms.txt](https://docs.infraredtrading.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.infraredtrading.com/api-reference/api-guides/quote.md).

# Quote

POST /v1/quote computes optimal routing for a swap and returns estimated outputs, costs, and routing details.

`POST /v1/quote` computes optimal routing for a token swap and returns a quote with estimated outputs, costs, and routing details. This is the first step in the swap flow -- use the returned `quote_id` with the [Build endpoint](/api-reference/api-guides/build.md) to assemble an executable transaction.

Authentication is optional on this endpoint: anonymous requests are served with IP-based rate limits, while a valid API key applies your subscription tier's limits and quota. An invalid key is ignored rather than rejected, so quote requests never return 401.

New to the API? Start with [Getting Started](/getting-started.md) for authentication setup and a minimal example.

## Single Swap Example

Swap 1 WETH for DAI on Ethereum mainnet (chain ID 1). Infrared also supports Base L2 (chain ID 8453).

```bash
curl -X POST "https://api.infraredtrading.com/v1/quote" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "inputs": [
      {
        "chain_id": 1,
        "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
        "amount": "1000000000000000000"
      }
    ],
    "outputs": [
      {
        "chain_id": 1,
        "address": "0x6B175474E89094C44Da98b954EedeBC836211103",
        "ratio_bps": 10000
      }
    ],
    "taker": "0x742d35Cc6634C0532925a3b844Bc9e7595f8b3c4"
  }'
```

## Multi-Output Split Example

Swap 1 WETH into 50% DAI and 50% USDC:

```bash
curl -X POST "https://api.infraredtrading.com/v1/quote" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "inputs": [
      {
        "chain_id": 1,
        "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
        "amount": "1000000000000000000"
      }
    ],
    "outputs": [
      {
        "chain_id": 1,
        "address": "0x6B175474E89094C44Da98b954EedeBC836211103",
        "ratio_bps": 5000
      },
      {
        "chain_id": 1,
        "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
        "ratio_bps": 5000
      }
    ],
    "taker": "0x742d35Cc6634C0532925a3b844Bc9e7595f8b3c4",
    "slippage_tolerance_bps": 50
  }'
```

The `ratio_bps` values across all outputs must sum to 10000 (100%).

## Request Fields

### Required Fields

| Field     | Type                                 | Description                                                                              |
| --------- | ------------------------------------ | ---------------------------------------------------------------------------------------- |
| `inputs`  | array of [InputToken](#inputtoken)   | Tokens to swap from. 1-6 entries.                                                        |
| `outputs` | array of [OutputToken](#outputtoken) | Desired output tokens with ratio allocation. 1-6 entries. Ratios must sum to 10000.      |
| `taker`   | string                               | EVM address holding input tokens with allowances set. Pattern: `0x` + 40 hex characters. |

### Optional Fields

| Field                    | Type             | Default         | Description                                                                                                                                                               |
| ------------------------ | ---------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `recipient`              | string           | Same as `taker` | Address to receive output tokens. Defaults to `taker` if not specified.                                                                                                   |
| `slippage_tolerance_bps` | integer          | 100             | Maximum acceptable slippage in basis points. 100 = 1%. Range: 0-5000.                                                                                                     |
| `max_hops`               | integer          | 4               | Maximum number of intermediate swaps allowed in the route. Range: 1-10.                                                                                                   |
| `exclude_protocols`      | array of strings | `[]`            | Protocol identifiers to exclude from routing, in `name/product` form (e.g., `["uniswap/v2", "sushiswap"]`).                                                               |
| `include_protocols`      | array of strings | `[]`            | Allowlist of protocol identifiers. When non-empty, only pools matching an entry are considered. Must not overlap with `exclude_protocols` (rejected with 400 if it does). |
| `exclude_pools`          | array of strings | `[]`            | Pool addresses to exclude from routing.                                                                                                                                   |
| `simulate`               | boolean          | `true`          | Run full causal simulation. Disabling returns faster but less accurate quotes.                                                                                            |
| `gas_priority`           | string           | `"fast"`        | Gas price tier: `"slow"`, `"standard"`, `"fast"`, or `"urgent"`. Affects EIP-1559 gas parameters.                                                                         |
| `include_usd_pricing`    | boolean          | `false`         | Include USD cost estimates (`gas_cost_usd`, `max_slippage_usd`, `total_cost_usd`) in the response.                                                                        |
| `check_allowances`       | boolean          | `false`         | Check on-chain allowances and only return approvals for tokens with insufficient allowance.                                                                               |
| `include_permit2`        | boolean          | `false`         | Include Permit2 EIP-712 typed data for signature-based approval flow.                                                                                                     |
| `partner_fee`            | object           | --              | Per-quote partner (affiliate) fee policy. See [partner\_fee](#partner_fee).                                                                                               |

### InputToken

| Field      | Type    | Required | Description                                                                                                                                                                                                                    |
| ---------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `chain_id` | integer | Yes      | Blockchain network ID (1 for Ethereum mainnet, 8453 for Base L2).                                                                                                                                                              |
| `address`  | string  | Yes      | Token contract address. For the native currency use the zero address `0x0000...0000` or the sentinel `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` (both are normalized to the sentinel; responses always return the sentinel). |
| `amount`   | string  | Yes      | Amount in atomic units (wei) as a decimal string. Must be non-zero.                                                                                                                                                            |

### OutputToken

| Field       | Type    | Required | Description                                                                                |
| ----------- | ------- | -------- | ------------------------------------------------------------------------------------------ |
| `chain_id`  | integer | Yes      | Blockchain network ID. Must match input chain.                                             |
| `address`   | string  | Yes      | Token contract address.                                                                    |
| `ratio_bps` | integer | Yes      | Desired proportion of this output in basis points (1-10000). All ratios must sum to 10000. |

### partner\_fee

Optional affiliate fee policy, charged on top of the platform protocol fee. Omitting the object is equivalent to all-zero/false. The partner fee is the integrator's own margin; the platform protocol fee and positive-slippage routing are derived server-side from the caller's subscription tier, not from this object.

| Field                   | Type    | Default | Description                                                                                                                                                       |
| ----------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `partner_fee_bps`       | integer | 0       | Partner fee in basis points. Capped at the Router's `MAX_PARTNER_FEE_BPS` -- exceeding the cap fails with 422 and `details.engine_code: PARTNER_FEE_EXCEEDS_CAP`. |
| `partner_recipient`     | string  | --      | Address credited with the partner fee on-chain. Required when `partner_fee_bps > 0` (else 422 with `details.engine_code: PARTNER_FEE_MISSING_RECIPIENT`).         |
| `partner_fee_on_output` | boolean | `false` | Charge the fee on the output token instead of the input token.                                                                                                    |

## Response Fields

A successful response returns HTTP 200 with the following structure:

```json
{
  "data": {
    "quote_id": "...",
    "inputs": [ ... ],
    "outputs": [ ... ],
    "taker": "...",
    "estimated_outputs": [ ... ],
    "costs": { ... },
    "path": { ... },
    "protocols_used": [ ... ],
    "approvals": [ ... ],
    "permit2": { ... },
    "total_price_impact_bps": -15,
    "fee_config": { ... }
  }
}
```

### Core Fields

| Field                    | Type          | Description                                                                                                                                                                                                                                            |
| ------------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `quote_id`               | string (UUID) | Unique identifier for this quote. Pass to `POST /v1/build` to assemble a transaction. A quote is buildable for 2 minutes after creation and only by the principal that requested it -- see [Build](/api-reference/api-guides/build.md#quote-lifetime). |
| `inputs`                 | array         | Echoed input tokens with checksummed addresses.                                                                                                                                                                                                        |
| `outputs`                | array         | Echoed output tokens with checksummed addresses.                                                                                                                                                                                                       |
| `taker`                  | string        | Checksummed taker address.                                                                                                                                                                                                                             |
| `total_price_impact_bps` | integer       | Aggregate price impact across all hops in basis points. Negative values indicate favorable pricing.                                                                                                                                                    |

### estimated\_outputs

Array of estimated output amounts, one per output token:

| Field              | Type    | Description                                                                                                                                                                                                                                                                                     |
| ------------------ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `token`            | string  | EIP-55 checksummed token address.                                                                                                                                                                                                                                                               |
| `chain_id`         | integer | Network ID.                                                                                                                                                                                                                                                                                     |
| `expected_amount`  | string  | Estimated output before slippage (atomic units). Already net of every fee in `fee_config` -- the protocol fee is skimmed from the input before routing and any partner fee is deducted on its configured side. This is the estimate of what the recipient receives; do not subtract fees again. |
| `minimum_amount`   | string  | Guaranteed minimum after applying `slippage_tolerance_bps` (atomic units), also net of all fees. Enforced on-chain -- execution reverts below this floor.                                                                                                                                       |
| `price_impact_bps` | integer | Price impact for this specific output token in basis points. Negative values indicate favorable pricing.                                                                                                                                                                                        |

### costs

Gas cost breakdown with EIP-1559 parameters:

| Field                      | Type           | Description                                                                                        |
| -------------------------- | -------------- | -------------------------------------------------------------------------------------------------- |
| `gas_cost_wei`             | string         | Estimated gas cost in wei.                                                                         |
| `gas_cost_usd`             | number or null | Gas cost in USD. Only present when `include_usd_pricing=true`.                                     |
| `max_slippage_usd`         | number or null | Maximum potential slippage loss in USD. Only present when `include_usd_pricing=true`.              |
| `total_cost_usd`           | number or null | Sum of gas and fee costs in USD (excludes slippage). Only present when `include_usd_pricing=true`. |
| `total_gas_units`          | integer        | Estimated gas units for execution.                                                                 |
| `base_fee_wei`             | integer        | EIP-1559 base fee in wei at quote time.                                                            |
| `max_priority_fee_per_gas` | integer        | EIP-1559 max priority fee (tip) in wei.                                                            |
| `max_fee_per_gas`          | integer        | EIP-1559 max total fee per gas in wei.                                                             |
| `gas_priority`             | string         | Gas priority tier used for this quote.                                                             |

### path

The execution route with token metadata and step-by-step details:

| Field         | Type   | Description                                                                                                                                  |
| ------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `path.tokens` | object | Map of token addresses to metadata (`name`, `symbol`, `decimals`, `token_type`). `token_type` is one of: `erc20`, `lp`, `native`, `wrapped`. |
| `path.steps`  | array  | Ordered list of execution steps.                                                                                                             |

Each step in `path.steps`:

| Field                | Type             | Description                                                                                                                                            |
| -------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `type`               | string           | Operation type: `swap`, `decompose`, `compose`, `wrap`, or `unwrap`.                                                                                   |
| `protocol`           | string           | Protocol handling this step (e.g., `uniswap_v3`).                                                                                                      |
| `pool`               | string           | Pool identity: a 20-byte EIP-55 address for per-contract protocols (uniswap/v2, uniswap/v3, etc.) or the full 32-byte keccak256 PoolId for uniswap/v4. |
| `tokens_in`          | array of strings | Input token addresses for this step.                                                                                                                   |
| `tokens_out`         | array of strings | Output token addresses for this step.                                                                                                                  |
| `amounts_in`         | array of strings | Input amounts in atomic units. `"0"` if dynamic.                                                                                                       |
| `amounts_out`        | array of strings | Output amounts in atomic units. `"0"` if dynamic.                                                                                                      |
| `gas_estimate`       | string           | Estimated gas units for this step.                                                                                                                     |
| `share_of_input_bps` | integer          | Percentage of total input flowing through this step (0-10000).                                                                                         |

### protocols\_used

Array of protocol identifiers involved in the route (e.g., `["uniswap_v3", "curve"]`).

### approvals

Array of ERC-20 approval requirements. Each entry:

| Field     | Type   | Description                                      |
| --------- | ------ | ------------------------------------------------ |
| `token`   | string | Token contract address requiring approval.       |
| `amount`  | string | Amount to approve in atomic units.               |
| `spender` | string | Address to approve as spender (Router contract). |

Empty if the taker already has sufficient allowances (when `check_allowances=true`) or if inputs are native tokens only.

### permit2

Only present when `include_permit2=true`. Contains EIP-712 typed data for Permit2 signature-based approval:

| Field    | Type   | Description                                                                                                                     |
| -------- | ------ | ------------------------------------------------------------------------------------------------------------------------------- |
| `hash`   | string | Keccak256 hash of the typed data.                                                                                               |
| `eip712` | object | Complete EIP-712 typed data structure with `types`, `domain`, `primaryType`, and `message`. Ready for `wallet.signTypedData()`. |

Sign the `eip712` object with the taker's wallet and pass the resulting signature to the [Build endpoint](/api-reference/api-guides/build.md) as `permit2_signature`.

### fee\_config

The validated fee policy attached to this quote -- the form the Router actually receives. Omitted entirely when every field is zero-value. These fields are informational: `estimated_outputs` already reflects every fee in this object, so do not apply them again when computing expected proceeds.

`protocol_fee_bps` and positive-slippage routing are resolved server-side from the requesting principal's tier and signed by Infrared at build time; the Router rejects any call whose fee, positive-slippage or quote parameters differ from the signed values, so they cannot be edited after build. The partner fee is bound the same way but is whatever this request specified: a taker who obtains their own API key can quote the same route without it, so do not expose partner keys client-side. The route program itself is visible in the transaction calldata.

| Field                            | Type    | Description                                                                                                                                                                                       |
| -------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `protocol_fee_bps`               | integer | Platform protocol fee in basis points, resolved from your subscription tier (and per-account overrides), and signed into the built transaction. Not caller-supplied and not editable after build. |
| `partner_fee_bps`                | integer | Partner fee in basis points applied for this quote.                                                                                                                                               |
| `partner_recipient`              | string  | Checksummed address credited with the partner fee. Zero address when no partner fee applies.                                                                                                      |
| `partner_fee_on_output`          | boolean | Whether the partner fee is charged on the output token.                                                                                                                                           |
| `pass_positive_slippage_to_user` | boolean | Whether positive slippage is returned to the user.                                                                                                                                                |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.infraredtrading.com/api-reference/api-guides/quote.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
