CRYPTO

Swap Tokens

Quote first, inspect pricing risk fields, then execute swap with explicit mainnet parameters.

Human Flow

Quote preview, swap execution, and on-chain evidence.

state: idle

Swap Inputs

Swap button unlocks only after a fresh quote and requires `network: "mainnet"`.

Quote Preview

No quote yet. Run quote to inspect output amount, provider, and price impact.

Swap Result

Execute swap after quote to see tx evidence and local history echo.

Agent Flow

SDK quote/swap calls with copy-ready snippets, examples, and failure guidance.

Quote

SDK method
CALLmoney.quote
- Quote is read-only and does not execute a transaction.
- Keep quote parameters unchanged before swap execution.
# SDK method (no HTTP endpoint)
# Use JavaScript snippet instead.
Example success response
{
  "fromToken": "ETH",
  "toToken": "USDC",
  "fromAmount": "0.5",
  "toAmount": "1234.56",
  "rate": "1 ETH = 2469.12 USDC",
  "priceImpact": "0.42",
  "provider": "paraswap",
  "chain": "ethereum",
  "network": "mainnet"
}
Example failure responses
Failure
{
  "code": "UNSUPPORTED_OPERATION",
  "message": "Swap/quote requires mainnet. Testnet DEXes have no liquidity."
}
Recovery: Set `network: "mainnet"` explicitly.
Failure
{
  "code": "UNSUPPORTED_OPERATION",
  "message": "No swap provider available for chain \"fast\"."
}
Recovery: Use a supported swap chain/provider pair.

Swap

SDK method
CALLmoney.swap
- Swap executes on-chain and returns tx hash + explorer URL.
- UI requires a fresh quote with matching params before execution.
# SDK method (no HTTP endpoint)
# Use JavaScript snippet instead.
Example success response
{
  "txHash": "0x...",
  "explorerUrl": "https://...",
  "fromToken": "ETH",
  "toToken": "USDC",
  "fromAmount": "0.5",
  "toAmount": "1234.56",
  "provider": "paraswap",
  "chain": "ethereum",
  "network": "mainnet"
}
Example failure responses
Failure
{
  "code": "CHAIN_NOT_CONFIGURED",
  "message": "Chain \"ethereum\" is not configured for mainnet."
}
Recovery: Run setup first: await money.setup({ chain: "ethereum", network: "mainnet" })
Failure
{
  "code": "UNSUPPORTED_OPERATION",
  "message": "Swap requires mainnet. Testnet DEXes have no liquidity."
}
Recovery: Switch to mainnet and re-run quote before swap.