Skip to main content
A complete same-chain swap end to end: quote a route, build, sign, and confirm (EVM approves the token first). Pick a chain below; the tabs stay in sync across Setup, Steps, End-to-end, and API usage.

Setup

A same-chain swap on Arbitrum: 100 USDC → WETH.

Steps

1

Quote

Ask for the best route. The response is keyed by pair: read recommendedSource, then pull that route out of quoteRates.
Provider allow/deny lists, filter, and quote-timing knobs are optional. See advanced quote fields.
2

Approve

Give the router an allowance for the source token. AutoPermit picks EIP-2612 or Permit2 automatically, so most tokens need no on-chain approval at all.
Permit2 vs EIP-2612 vs plain approvals, and gasless permit signing, are in Check allowance and Approval mechanisms.
3

Build & send

trade() builds the transaction from the request, then signs and sends it in one call.
trade() builds and sends in one call. Call buildTradeTxn first only to preview the transaction or reuse it via txnData. Full field list, gasless variant, and the TRY_ANOTHER_ROUTE retry are in Execute trade.
4

Status

Confirm settlement. chainId is a number, and the terminal states are uppercase.
Same-chain swaps settle in one block. For the full response shape and multi-tx polling, see Track trade status.

End-to-end

API usage

The same flow over REST. Non-EVM chains build a chain-specific transaction you sign locally, then submit via Broadcast.
Sign and broadcast the transaction from the build response with your own signer. Full reference: Quote, Build Tx, Status.

What can go wrong

  • No route returned, the pair is thin or unsupported. Try a different amount or token, or widen slippage.
  • Approval fails, make sure the wallet holds gas (ETH on Arbitrum).
  • TRY_ANOTHER_ROUTE on the trade response, retry with pair.bestReturnSource. See Execute trade.
See Error codes for the full catalog.
Last modified on September 21, 2026