Overview
Swap mode provides a flexible interface for cross-chain token exchanges. Users control both input and output, with the widget handling optimal routing across bridges and DEXs. Trade types:EXACT_INPUT and EXACT_OUTPUT.
Quick start
Props
Required
Source (optional)
Destination (optional)
Payment method (optional)
paymentMethod controls the source funding method. Omit to default to the connected wallet.
Route options (optional)
Lifecycle callbacks
Examples
Basic swap — user picks everything
Pre-configured cross-chain swap
Lock destination, let user pick source
Cross-chain swap with a fixed output amount
Custom bridge provider
Headless implementation
For custom UI, use theuseQuote hook directly:
Trade Types
EXACT_INPUT
User specifies exact input amount; output amount varies:EXACT_OUTPUT
User specifies exact output amount; input amount varies:Quote Types
Quote Refresh Strategy
Quotes can become stale. Implement refresh logic:Event Handling
Widget Events
useQuote Transaction Status
Error Handling
Use Cases
- Cross-chain Token Exchange: Swap any token to any other token across chains
- Portfolio Rebalancing: Shift holdings between chains and tokens
- Yield Optimization: Move assets to chains with better yields
- Gas Token Acquisition: Get native tokens for new chains
- Arbitrage: Take advantage of price differences across chains
Technical Notes
- Quotes automatically factor in gas costs and fees
- Multiple liquidity sources are queried for optimal routing
- Supports both same-chain and cross-chain swaps
- Native token wrapping/unwrapping is handled automatically
- Slippage protection is built-in
See Also
- Swap use cases — portfolio rebalancing, stablecoin conversion
- Hooks reference —
useQuotedetails - Quote providers — CCTP, Relay, SushiSwap, and more