swap
Build an unsigned swap transaction. Routes to user for signing.
Tier: Free
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sellToken | string | Yes | Token to sell — symbol (e.g. “USDC”) or contract address |
buyToken | string | Yes | Token to buy — symbol or contract address |
sellAmount | string | Yes | Amount to sell in human-readable units (e.g. “100” for 100 USDC) |
chainId | number | No | Chain ID (default: 1) |
slippage | number | No | Slippage tolerance in % (default: 1) |
The sender’s wallet address is resolved automatically from the Y0_API_KEY session — no need to pass it explicitly.
Example
"Swap 100 USDC to ETH on Ethereum"Signing Flow
- MCP server calls signing service
/api/build/swap - Signing service fetches route from 0x (fallback: 1inch)
- Unsigned tx is queued with status
pending - User gets WebSocket notification
- User reviews and signs on their device
- Returns pending transaction ID
Notes
- Non-custodial: y0 never touches the signed transaction
- Uses 0x as primary router, 1inch as fallback
- Transaction expires after 5 minutes if not signed