# Routing Response

`POST /routing/scan/stream` streams route objects as NDJSON (newline-delimited JSON). Each line is a JSON object with either a `simulation` field (success) or an `error` field (failure). The `simulation` object contains the fields below.

`POST /routing/scan` returns all routes as a single JSON array. Each item has the same fields. Use `/routing/scan/stream` for better responsiveness — routes arrive as they are evaluated, rather than waiting for all providers to finish.

| Field                      | Type   | Description                                                      |
| -------------------------- | ------ | ---------------------------------------------------------------- |
| `query`                    | object | Echo of request parameters (`params`, `slippage`)                |
| `route`                    | array  | Ordered list of route steps (pass entire object to `/tx/create`) |
| `amountIn`                 | string | Input amount in smallest token units                             |
| `amountOut`                | string | Expected output amount in smallest token units                   |
| `amountOutWithoutSlippage` | string | Output amount without slippage applied                           |
| `tokenInPrice`             | number | USD price of the input token                                     |
| `tokenOutPrice`            | number | USD price of the output token                                    |
| `priceImpact`              | number | Price impact as a percentage                                     |
| `sourceFee`                | object | Fee charged on the source chain                                  |
| `deliveryFee`              | object | Fee for cross-chain delivery                                     |
| `slippage`                 | number | Slippage tolerance as provided in the request                    |
| `expectedFinalitySeconds`  | number | Estimated time to finality in seconds                            |
| `deadline`                 | number | Expiration timestamp in milliseconds                             |
| `signature`                | string | Encrypted signature (pass to `/tx/create` as-is)                 |
| `txs`                      | array  | Per-chain gas estimates                                          |

**Fee objects (`sourceFee`, `deliveryFee`)**

| Field    | Type   | Description                             |
| -------- | ------ | --------------------------------------- |
| `token`  | string | Token address the fee is denominated in |
| `amount` | string | Fee amount in smallest token units      |
| `usd`    | number | Fee value in USD                        |

**Gas estimate objects (`txs` array items)**

| Field            | Type   | Description                          |
| ---------------- | ------ | ------------------------------------ |
| `chainId`        | number | Chain where gas will be consumed     |
| `gasConsumption` | number | Estimated gas units                  |
| `gasFeeUsd`      | number | Gas cost in USD                      |
| `gasFeeNative`   | string | Gas cost in the chain's native token |

**Route step objects (`route` array items)**

Each step describes one leg of the swap:

| Field              | Type   | Description                                    |
| ------------------ | ------ | ---------------------------------------------- |
| `chainId`          | number | Chain where this step executes                 |
| `type`             | string | Step type (e.g. `"bridgeIn"`)                  |
| `params.tokenIn`   | object | Input token (`address`, `symbol`, `decimals`)  |
| `params.tokenOut`  | object | Output token (`address`, `symbol`, `decimals`) |
| `params.amountIn`  | string | Input amount for this step                     |
| `params.amountOut` | string | Output amount for this step                    |

> When calling `/tx/create`, pass the route object as the `routing` field. For `/routing/scan/stream`, this is the `simulation` object from each NDJSON line. For `/routing/scan`, this is an item from the response array. Do not modify or cherry-pick fields from it.

***
