> For the complete documentation index, see [llms.txt](https://flowrouter.gitbook.io/flowrouter-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://flowrouter.gitbook.io/flowrouter-docs/how-it-works/routing.md).

# Routing and execution

How a token pair becomes a quoted route and an account-bound transaction.

FlowRouter separates route discovery and quoting from transaction construction and wallet submission.

```mermaid
flowchart LR
    A[Token pair and amount] --> B[Route and quote]
    B --> C[Account and allowance checks]
    C --> D[Transaction build and simulation]
    D --> E[Wallet confirmation]
    E --> F[Onchain execution and receipt]
```

## Route selection

The routing service evaluates available liquidity for the requested pair and amount. A route can use direct liquidity, intermediate tokens, or allocations across multiple venues. The selected route carries quoted token amounts and gas information.

The result is specific to the request and observed chain state. Route availability and relative prices can change. FlowRouter does not reserve liquidity when it displays a preview.

## Ordered execution

The current API represents a route as an **ordered execution graph**. Each flow describes a token movement associated with an execution operation. The ordering matters, especially when later operations consume tokens produced by earlier ones.

The route preview may simplify that graph to make it readable. Integrators must use the transaction returned by the build service, rather than compiling calldata from visual branches or percentage labels.

## Requested input and executable input

Amounts use the token's smallest units. A quote distinguishes:

```
requestedInput = executableInput + sourceResidue
```

`requestedInput` is the amount the user requested. `executableInput` is the amount committed to the executable route. `sourceResidue` is the difference and is not part of that transaction's input amount.

For example, a request for 1,000 base units might yield an executable input of 998 and residue of 2. Preserve all three fields; do not silently rewrite the quoted amount or route.

## Binding the transaction

An active quote is bound to the account, network, tokens, requested input, slippage, and intent identifier. The build service checks that the saved quote and the requested transaction still agree.

It also checks chain state and simulates the call. A valid result has a submission deadline. Changing trade parameters or submitting after that deadline requires a fresh quote and build.

The wallet signs and submits the transaction. The gateway does not need the user's private key to return a quote, prepare a transaction, or check its receipt.
