Swidge (swaps + bridges)

Cross-chain token swaps and bridges using Circuit's swap engine. The engine automatically selects the best route across multiple liquidity sources.

Workflow

  1. Get a quote with quote()

  2. Execute the swap with execute()

  3. Check execution status

Get Quote

Get pricing and routing information for a swap.

async quote(request: SwidgeQuoteRequest): Promise<SwidgeQuoteResponse>

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")

  • engines (string[], optional): Constrain which engines to query. If omitted, all available engines are queried and the best route is selected.

Response:

  • success (boolean): Whether the quote was retrieved

  • data (object): Quote data with asset details, fees, and steps

  • error (string | null): Error message if quote failed

Example:

Execute Quote

Execute a swap using a quote.

Parameters:

  • quoteData: Complete quote object from quote(), or array of quotes for bulk execution

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 in parallel by passing an array of quotes:

Notes

  • Always validate quotes before executing. Check price impact and slippage.

  • 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/toToken for native tokens (ETH, SOL).

  • Execution status is final. The API waits for completion and never returns "pending" or "waiting".

Last updated