> For the complete documentation index, see [llms.txt](https://docs.peach.ag/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.peach.ag/documentation/bsc/aggregator/editor/quotes-and-routing.md). Agents can also search and read this documentation through its [MCP server](https://docs.peach.ag/~gitbook/mcp).

# Quotes and Routing

Read prepared quotes and paths, choose providers and retain legacy quote compatibility.

The swap methods return quoted amounts with the prepared trade. Use this page to display those amounts, inspect paths and choose routing providers.

### Prepared quotes and routing

Set `providers`, `depth` and `splitCount` at the top level of the swap request; depth and split defaults are 3 and 20. See [Quickstart](https://docs.peach.ag/documentation/bsc/aggregator/quickstart) for preparation and [Fees](https://docs.peach.ag/documentation/bsc/aggregator/editor/fees-slippage-and-settlement) for custom-fee settings.

| Allowance result           | Meaning                                                |
| -------------------------- | ------------------------------------------------------ |
| `prepared.amountIn`        | Input amount; compare with the requested order         |
| `prepared.expectAmountOut` | Expected net recipient output after fees               |
| `prepared.amountOut`       | Gross output before custom fees                        |
| `prepared.tx.amountOutMin` | Validated signed minimum received                      |
| `prepared.raw.paths`       | Display-only paths; service strings and string amounts |

Each path has `provider`, `adapter`, `token_in`, `token_out`, `direction`, `fee_rate`, `amount_in` and `amount_out`. `pool` and `extra_data` are optional. A server-whitelisted `api.apiKey` reveals pool addresses on Allowance; an absent or invalid key does not prevent transaction construction. Do not reconstruct transaction data from display paths.

Use output-token decimals with `formatUnits()` and preserve integers as `bigint` or decimal strings. Reuse the confirmed result at submission; another swap preparation requests a new route and requires new confirmation.

### Available providers

`getAvailableProviders()` returns names from the selected service. Pass these strings unchanged. Omitting providers, or passing an empty list, lets the service select enabled providers. Availability does not guarantee liquidity for a particular pair or amount.

### Refresh behavior

Ignore responses for superseded orders and disable confirmation while the current request is pending or failed. Follow [Transaction Safety](https://docs.peach.ag/documentation/bsc/aggregator/editor/validation-approvals-and-expiry#when-to-prepare-again) for refreshing and reconfirming plans.

### Legacy quote reference

> **Planned deprecation:** `find_routes`, used by `getQuote()` and `ApiClient.findRoutes()`, remains available for compatibility and is planned for future deprecation. No removal date is announced. New integrations should use `swapAllowance()`, `swapPermit2()` and `swapPermit2Build()`. Follow [Migration Guide](https://docs.peach.ag/documentation/bsc/aggregator/editor/migration-guide).

The following reference preserves the old display-only contract. It is not a prerequisite for the recommended swap flow. `getQuote()` returns no transaction. The local `RouteDiscovery` estimator is no longer exported.

### Quote parameters

| Input                                 | Purpose                                                                                                      |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `from`, `target`                      | ERC20 addresses or `NATIVE_TOKEN_ADDRESS`                                                                    |
| `amountIn`                            | Positive exact input amount as `bigint` in input-token base units; validate the user's amount before calling |
| `options.providers`                   | Optional list of provider strings                                                                            |
| `options.depth`, `options.splitCount` | Route search controls; SDK defaults are 3 and 20                                                             |
| `options.customFee`                   | Optional display fee using `feeAccount` and `feeBps`                                                         |
| `options.includeResponseHeaders`      | Defaults to `false`; when `true`, adds available response headers to `quote.responseHeaders`                 |

The service and SDK support exact-input quotes and swaps only. Amounts always use input-token decimals. The SDK sends `by_amount_in=true` internally and exposes no direction setting. Legacy JavaScript calls that pass `byAmountIn: false` are rejected before an HTTP request is sent.

A legacy read-only quote does not require a connected wallet. Its amount field is `amountIn`; swap preparation uses `amount`.

### Quote response

| Field                                     | Display usage                                                                                                          |
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `srcToken`, `dstToken`                    | Returned token addresses; these output fields retain their names and use WBNB for native BNB requests                  |
| `srcNative`, `dstNative`                  | Set to `true` for a native input or output request                                                                     |
| `amountIn`                                | Input estimate                                                                                                         |
| `amountOut`                               | Expected user output after the configured display custom fee                                                           |
| `route.totalAmountOut`                    | Gross output before that fee                                                                                           |
| `route.routes[0].steps`                   | The API's route-path steps, including any branching paths, represented in one SDK route container                      |
| `priceImpact`                             | Route-derived value; not a guaranteed slippage bound                                                                   |
| `gasEstimate`                             | Display estimate; final wallet/RPC estimation can differ                                                               |
| `customFee`                               | Optional receiver, basis points and projected total fee                                                                |
| `routerAddress`, `executionRouterAddress` | Optional contract addresses advertised by the route response; use a validated prepared plan for approval and execution |

Use `formatUnits(value, decimals)` for amounts. Avoid converting large integer amounts through JavaScript `number`.

For old-to-new input and result mappings, see [Migration Guide](https://docs.peach.ag/documentation/bsc/aggregator/editor/migration-guide).


---

# 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.peach.ag/documentation/bsc/aggregator/editor/quotes-and-routing.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.
