Quotes are price snapshots at a specific block. Pool reserves, tick state, and competing trades can move the market between the moment you quote and the moment your transaction lands. The aggregator handles this with a short server-side cache TTL and explicit expiry semantics.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 contract
TTL is ~10 seconds
Each
/quote response includes expiresAt (Unix milliseconds). The default TTL is 10 seconds. After that, the cache entry is gone./submit returns 404 on expired quotes
Once
expiresAt has passed, POST /submit with that quoteId returns { "error": "quote not found or expired" }. Re-quote and retry.Recommended UI pattern
Fetch a fresh quote when the swap modal opens
On modal open, call
/quote and store the result. Display the price.Re-quote on a 5 to 8 second interval
While the modal is open, re-fetch the quote periodically. Compare
expectedAmountOut against the previous value to decide whether to flash an “updated” indicator.Stop polling on user action
When the user clicks “Swap” (or your equivalent), pause polling so the price doesn’t change between their decision and the wallet prompt.
Submit using the latest quoteId
Always submit using the
quoteId from the most recent successful /quote. Don’t reuse an older one.Reference implementation
Why not use /execute for this?
/execute always returns a fresh quote, so it sidesteps the 404 problem. But:
- You lose the ability to display the quoted price before the user signs.
- Every
/executecall burns rate-limit budget and re-runs the routing engine, so it’s more expensive than alternating/quoteand/submit.
/execute for one-click flows where preview doesn’t matter. Use the two-step pattern with the freshness loop above for any UI that shows a price.
Slippage as a freshness backstop
Even with aggressive re-quoting, your submitted transaction may land 1-2 blocks after/quote ran. Use slippageBps as the safety margin:
| Pair type | Recommended slippageBps |
|---|---|
| Stablecoin to stablecoin (USDC → USDT) | 10 to 30 (0.1% to 0.3%) |
| Blue-chip to blue-chip (WETH → cbBTC) | 30 to 100 (0.3% to 1%) |
| Blue-chip to mid-cap | 100 to 300 (1% to 3%) |
| Long tail / memecoins | 300 to 1000 (3% to 10%) |
minAmountOut is set on the router, so the swap reverts cleanly if real output falls below the slippage threshold — your transaction never lands in a worse-than-expected state.
