Build any-token swap (Polygon, Base, Ethereum): approve + swap, simulated
blazar_build_any_swapOne call to swap ANY non-BZB token pair on Polygon (default), Base or Ethereum (chain param) through the best of KyberSwap and LI.FI (Velora fallback; same-chain only, no bridges): token-safety check (refuses blocked tokens; unverified ones need allowUnverified=true), router allowlist, exact approve, slippage (max 300 bps) and deadline guards, USD-loss cap, recipient/value calldata checks, and an eth_call simulation of the swap before returning. Returns ordered UNSIGNED txs[] plus batch (EIP-5792). BZB/BBY pairs are refused with USE_BLAZAR_ROUTE: use blazar_build_swap (fee router, earns trading rewards). Not eligible for trading rewards.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"tokenIn": "<tokenIn>",
"tokenOut": "<tokenOut>",
"amount": "<amount>",
"from": "<from>"
},
"name": "blazar_build_any_swap"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from | Yes | Address that will sign and send the txs. Required: used for allowance checks, simulation and nonce. | |
| chain | No | Chain: "polygon" (default, chain 137), "base" (8453) or "ethereum" (1). BZB / BlazarSwap tools are Polygon only. | |
| amount | Yes | Amount of tokenIn in HUMAN units, not wei: "1.5" = 1.5 POL, "250" = 250 BZB. Set amountIsBaseUnits=true to pass wei/base units instead. | |
| tokenIn | Yes | Token to sell: a symbol (USDC, WETH, AAVE, LINK...; resolved only via the chain's curated list or an exact unique KyberSwap-verified match) or any 0x token address on the chosen chain. Native coin: "POL" on Polygon, "ETH" on Base / Ethereum. | |
| provider | No | auto (default): KyberSwap and LI.FI compared, best output wins; Velora as fallback. Same-chain swaps only. | |
| tokenOut | Yes | Token to buy: a symbol (USDC, WETH, AAVE, LINK...; resolved only via the chain's curated list or an exact unique KyberSwap-verified match) or any 0x token address on the chosen chain. Native coin: "POL" on Polygon, "ETH" on Base / Ethereum. | |
| recipient | No | Who receives the output. Defaults to `from`. | |
| slippageBps | No | Max slippage in bps (50 = 0.5%). Default 50, max 300. | |
| allowUnverified | No | Allow tokens whose safety verdict is caution (unverified, taxed, proxy). Blocked tokens are always refused. Default false. | |
| deadlineSeconds | No | Seconds until the swap expires. Default 150. | |
| amountIsBaseUnits | No | If true, amount is in base units (wei for 18-decimal tokens; 6 decimals for USDC). Default false. | |
| maxPriceImpactBps | No | Refuse when the output is worth more than this many bps less than the input in USD. Default 500 (5%). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| txs | Yes | Sign and send in order. | |
| from | No | ||
| next | No | ||
| batch | No | EIP-5792 wallet_sendCalls request with the same calls (smart wallets). | |
| quote | No | ||
| action | Yes | ||
| guards | No | ||
| safety | No | ||
| chainId | No | 137 Polygon, 8453 Base, 1 Ethereum. BlazarForce builds are always 137. | |
| details | No | ||
| signing | No | ||
| summary | Yes | ||
| warnings | Yes | ||
| routeGuide | No | ||
| simulation | Yes |