Use swap to move tokens between chains or swap between assets on the same chain. This is the primary way most agents rebalance portfolios, enter/exit positions, or convert between tokens.Documentation Index
Fetch the complete documentation index at: https://docs.circuit.org/llms.txt
Use this file to discover all available pages before exploring further.
Workflow
- Get a quote with
quote() - Execute the swap with
execute() - Check
data.statusin the response
Get Quote
Get pricing and routing information for a swap.from(object): Source wallet{ network, address }to(object): Destination wallet{ network, address }amount(string): Amount in smallest unit (wei, lamports, etc.)fromToken(string | null, optional): Source token address (omit for native tokens)toToken(string | null, optional): Destination token address (omit for native tokens)slippage(string, optional): Slippage tolerance % as string (default: “0.5”)engines(string[], optional): Restrict routing to specific engines ("uniswap","lifi","relay")
success(boolean): Whether the quote was retrieveddata(object): Quote data (on success)engine(string): Routing engine used (e.g.,"uniswap","lifi","relay")engines(string[], optional): Original routing engine filter when one was requestedassetSend(object): Source asset detailsnetwork(string): Network identifiertoken(string | null): Token address (nullfor native)name(string): Token namesymbol(string): Token symboldecimals(number): Token decimalsamount(string): Amount in smallest unitsamountFormatted(string): Human-readable amountamountUsd(string): Total value in USD
assetReceive(object): Destination asset details (same shape asassetSend)priceImpact(object): Price impact infopercentage(string): Price impact as a percentageusd(string, optional): Price impact in USD
fees(array): Fee breakdownname(string): Fee labelamount(string, optional): Fee amount in smallest unitsamountFormatted(string, optional): Human-readable feeamountUsd(string, optional): Fee value in USD
steps(array): Transaction steps to executequoteFreshness(object, optional): Quote expiry metadataissuedAtMs(number): Quote issue time in millisecondsttlMs(number): Quote time-to-live in millisecondsresolvedSlippage(string): Slippage value applied to this quoteminimumOutputAtIssue(string): Minimum output amount captured at quote timesignature(string, optional): Server signature used to reject tampered freshness metadata
error(string | null): Error message if quote failed
Execute Quote
Execute a swap using a quote.quoteData: Complete quote object fromquote(), or array of quotes for bulk executionexpiresAt(string | null, optional): ISO 8601 timestamp. In manual mode, the suggestion is discarded if not approved by this time. If omitted, no time-based expiry is set (all suggestions are auto-cleared at the start of eachruncycle regardless).
success(boolean): Whether execution starteddata.status(string): Execution status (“success”, “failure”, “refund”, “delayed”)data.in.txs(string[]): Input transaction hashes (on success)data.out.txs(string[]): Output transaction hashes (on success)error(string | null): Error message (on failure)
Bulk Execution
Execute multiple swaps in parallel by passing an array of quotes:Routing Engines
Circuit queries multiple routing engines and selects the best route automatically. Same-chain EVM swaps prefer Uniswap when it can return an executable route, then fall back to LiFi.| Engine | Supported Networks |
|---|---|
uniswap | Same-chain swaps on supported EVM chains |
relay | EVM chains, Solana, Hyperliquid |
lifi | EVM chains, Solana |
Notes
- Always validate quotes before executing. Check price impact and slippage.
- Execute quotes promptly. Expired quotes are rejected with
QUOTE_STALE; request a fresh quote and retry. - Circuit filters quotes with price impact exceeding 100%. Agents should validate returned quotes based on their own parameters.
- Amounts are in smallest units (wei for ETH, lamports for SOL, etc.).
- Omit
fromToken/toTokenfor native tokens (ETH, SOL). - Execution status is final for same-chain swaps. For cross-chain bridges, the
data.statusfield in the execute response indicates the final status:"success","failure","refund", or"delayed".
Manual Mode
In manual mode,execute() returns a suggestion instead of executing. The response will have data.suggested = true and data.suggestionId.
See Also
- Positions — Check balances before and after swaps
- SDK Quick Reference — Network identifiers and native token addresses
- Error Handling — Swap-specific error codes
- Yield Agent Example — Full working agent using swap
Python: from Parameter
from is a reserved keyword in Python. When passing a dict to quote(), use the string key "from" — it works because dict keys are strings. If using the Pydantic model directly, the field is from_: