Skip to main content
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.

Workflow

  1. Build the swap limits
  2. Optionally call quote() to preview pricing and routing
  3. Pass the same limits to execute()
  4. Check data.status in the response

Get Quote

Get pricing and routing information for a swap.
Request Parameters:
  • 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”)
  • priceImpact (string, optional): Maximum acceptable price impact % as a string (default: “2”)
  • engines (string[], optional): Restrict routing to specific engines - route providers ("relay", "lifi", "across", "kyberswap", "paraswap", "jupiter") and/or action adapters ("weth", "pusd", "erc4626", "hypercore-deposit")
Response:
  • success (boolean): Whether the quote was retrieved
  • data (object): Quote data (on success)
    • engine (string): Routing engine used (e.g., "relay", "lifi", "across", "kyberswap", "paraswap", "jupiter", "weth", "pusd", "erc4626")
    • engines (string[], optional): Original routing engine filter when one was requested
    • assetSend (object): Source asset details
      • network (string): Network identifier
      • address (string): Onchain token contract address (or the chain’s native-asset sentinel)
      • token (string): Token identifier
      • name (string): Token name
      • symbol (string): Token symbol
      • decimals (number): Token decimals
      • amount (string): Amount in smallest units
      • amountFormatted (string): Human-readable amount
      • amountUsd (string, optional): Approximate value in USD
    • assetReceive (object): Destination asset details (same shape as assetSend, plus an optional minimumAmount - the slippage floor in smallest units)
    • estimatedCost (object): Estimated route and asset-flow value loss
      • usd (string): Signed estimated cost in USD; positive means the operation costs the user value, while negative means favorable execution
      • percentage (string): The same signed estimated cost as a percentage
      • The estimate is starting USD minus ending USD. It includes costs already reflected in the received asset value and excludes separately paid network fees.
    • The former priceImpact response object is removed; read estimatedCost instead
    • fees (array): Separately paid network fee line items; these are not included in estimatedCost
      • name (string): Fee label
      • amount (string, optional): Fee amount in the token’s smallest units
      • amountFormatted (string, optional): Human-readable fee amount
      • amountUsd (string, optional): Approximate USD value of the fee
    • steps (array): Transaction steps to execute
    • quoteFreshness (object, optional): Quote expiry metadata
      • issuedAtMs (number): Quote issue time in milliseconds
      • ttlMs (number): Quote time-to-live in milliseconds
      • resolvedSlippage (string): Slippage value applied to this quote
      • minimumOutputAtIssue (string): Minimum output amount captured at quote time
    • slippage (string, optional): Slippage applied to the quote and preserved for execution re-quoting
    • maxPriceImpact (string, optional): Caller-supplied price-impact approval limit preserved for execution re-quoting
  • error (string | null): Error message if quote failed
Example:

Execute

Execute a swap from caller-owned limits. The engine gets a fresh executable quote under these limits; it does not execute a prior preview quote.
Parameters:
  • request: The quote request fields listed above, or an array of independent requests
  • expiresAt (string | null): ISO 8601 timestamp. Use null for no time-based expiry.
Response:
  • success (boolean): Whether execution started
  • data.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)
Example:

Bulk Execution

Execute multiple swaps sequentially by passing an array of limit requests:

Routing Engines

Circuit queries all compatible routing engines and selects the quote with the highest net output amount. Selection is a pure quote competition - there is no static engine preference.

Notes

  • Validate the preview’s estimated cost and expected output before execution.
  • Execution uses the source amount, endpoints, token addresses, slippage, engine filter, and request-side priceImpact cap as approval limits. It does not pin the preview’s receive amount.
  • The engine rejects its own stale executable quotes before broadcast.
  • Amounts are in smallest units (wei for ETH, lamports for SOL, etc.).
  • Omit fromToken/toToken for native tokens (ETH, SOL).
  • Execution status is final for same-chain swaps. For cross-chain bridges, the data.status field 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

Python: from Parameter

from is a reserved keyword in Python. Use the string key "from" in dicts (recommended), or from_ if using the Pydantic model directly.
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_: