Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.o1.exchange/llms.txt

Use this file to discover all available pages before exploring further.

The routePlan object is returned on every successful /quote and /execute call. It’s the canonical description of what the swap will do, broken down by route and leg. You don’t need to construct a RoutePlan yourself. The API generates it; this page is for callers who want to display its contents in detail or audit a swap before signing.

Top-level shape

{
  "chainId": 8453,
  "tokenIn": "0x...",
  "tokenOut": "0x...",
  "amountIn": "1000000000",
  "expectedAmountOut": "484446072048780734",
  "minAmountOut": "479601611328292926",
  "slippageBps": 100,
  "feeBps": 30,
  "blockNumber": 44266656,
  "gasEstimate": { "gasUnits": 300000, "gasCostWei": "..." },
  "feeBreakdown": {
    "protocolFeeAmount": "...",
    "integratorFeeAmount": "..."
  },
  "routes": [ /* SplitRoute[] */ ],
  "metadata": { /* RouteMetadata */ },
  "nativeIn": false,
  "nativeOut": false
}
FieldTypeDescription
chainIdintegerEVM chain ID. 8453 for Base.
tokenInaddressEcho of the request tokenIn.
tokenOutaddressEcho of the request tokenOut.
amountInstringEcho of the request amountIn, in wei.
expectedAmountOutstringThe output amount the optimizer believes you’ll receive, in wei.
minAmountOutstringThe on-chain enforced minimum after slippage.
slippageBpsintegerSlippage tolerance in bps. Same value as the request.
feeBpsintegerTotal fee in bps (protocol + optional integrator).
blockNumberintegerBlock at which the routing engine snapshotted pool state.
gasEstimateobjectEstimated gas usage. See gasEstimate.
feeBreakdownobjectFee split between protocol and integrator. See feeBreakdown.
routesarrayOne or more SplitRoute objects. See Routes.
metadataobjectOptimizer telemetry. See metadata.
nativeInbooleantrue when the request used the native sentinel for tokenIn. The submit handler must set useNativeIn: true accordingly.
nativeOutbooleantrue when the request used the native sentinel for tokenOut. Mirrors of nativeIn.

gasEstimate

{ "gasUnits": 300000, "gasCostWei": "12000000000000000" }
FieldTypeDescription
gasUnitsintegerEstimated gas units the swap will consume.
gasCostWeistring(Optional) Estimated gas cost in wei at the snapshotted base fee. Display only; the transaction is priced by the user’s wallet, not this number.

feeBreakdown

{
  "protocolFeeAmount": "1457804507741243911",
  "integratorFeeAmount": "0"
}
FieldTypeDescription
protocolFeeAmountstringProtocol fee taken out of expectedAmountOut, in tokenOut base units.
integratorFeeAmountstringIntegrator fee (when you set feeBps on the request), in tokenOut base units.

Routes

routes[] is an array of SplitRoute. Each route is one path through the venue graph. When the optimizer splits a trade, you’ll see multiple entries with the input divided across them.
{
  "amountIn": "600000000",
  "legs": [ /* RouteLeg[] */ ]
}
FieldTypeDescription
amountInstringPortion of the total amountIn allocated to this route.
legsarray1 to 3 hops. Each leg swaps one pair on a specific venue.

RouteLeg

{
  "dex": "UNIV3",
  "tokenIn": "0x...",
  "tokenOut": "0x...",
  "amountIn": "600000000",
  "minOut": "0",
  "poolId": "0xd0b5...f224",
  "data": { "kind": "v3_direct", "pool": "0xd0b5...f224" }
}
FieldTypeDescription
dexDexIdWhich venue the adapter dispatches to. See Supported DEXes.
tokenInaddressInput token for this leg.
tokenOutaddressOutput token for this leg.
amountInstringInput amount to this leg, in wei.
minOutstringMinimum output for this leg in isolation. May be 0 because the global minAmountOut is the binding check.
poolIdstringA human-friendly identifier for the pool, when applicable.
dataobjectTagged union with kind discriminator. Shape varies per venue. See below.

data shapes (by kind)

The data object is a tagged union keyed by kind. The router’s adapter for each venue knows how to consume the corresponding shape.
kindCarriesUsed for
v2_directpool, feeBpsSingle Uni V2 / Aerodrome V2-like / PancakeSwap V2 pool
v3_directpoolSingle Uni V3 pool
pancake_v3_directpoolSingle PancakeSwap V3 pool
algebra_directpoolAlgebra family pool (Hydrex, QuickSwap V4)
hydrexdeadlineHydrex multi-hop
univ4commands, inputs, deadlineUniswap V4 universal-router payload
curvepool, i, jCurve TwoCrypto-NG (or compatible)
prop_ammrouter, protocolProprietary AMMs (PropSwap, Tessera, Elfomofi, LunarBase, Feltir)
dodo_v2pool, baseTokenDODO V2
woofirouterWooFi
univ2path, deadlineMulti-hop V2 fallback
univ3path, deadlineMulti-hop V3 path-encoded fallback
aerodrome_v2routes, deadlineAerodrome multi-hop with stable/volatile flags
These details exist mainly for debugging and auditing. Application code rarely needs to inspect them.

metadata

Optimizer telemetry. Useful for displaying a “tried N paths, picked M” indicator in dev tools or analytics.
{
  "candidatePaths": 16,
  "selectedPaths": 1,
  "connectorsConsidered": [
    "0xcbb7...3bf",
    "0x9401...631"
  ],
  "candidates": [ /* RouteCandidateMetadata[] */ ]
}
FieldTypeDescription
candidatePathsintegerNumber of token paths the optimizer considered.
selectedPathsintegerHow many of those are in the final plan.
connectorsConsideredarray of addressIntermediate tokens the optimizer hopped through.
candidatesarray(Optional) Per-candidate scoring detail. Useful for debugging “why did it pick that route?”
In production UIs, the only fields most apps need from routePlan are expectedAmountOut, minAmountOut, feeBps, gasEstimate.gasUnits, and the list of dex names from routes[].legs[]. Treat the rest as advanced.