Swap
Quote a swap, build it, sign it and track it, the same way on every chain and venue.
A swap takes four calls. Only signing and sending differ between EVM chains and Solana.
1. Quote
curl -X POST "$AQUA0_API/api/swap/quote" \
-H "X-API-Key: $AQUA0_API_KEY" -H "Content-Type: application/json" \
-d '{
"chainId": 8453,
"tokenIn": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"tokenOut": "0x4200000000000000000000000000000000000006",
"amountIn": "1000000",
"slippageBps": 50
}'amountIn is in the token's smallest unit, as a string. slippageBps defaults to 50, which is 0.5%. To fix the amount
bought instead, send "tradeType": "exactOut" and amountOut.
Pick a route from routes, usually best. Show the trader its amountOut, minAmountOut and, when impactTier is
warn, its price impact. Add maxPriceImpactBps to refuse a route above that impact. It defaults to 500.
2. Build
Send the same fields, the chosen route exactly as the quote returned it, the minAmountOut you showed and the
trader's wallet as recipient.
curl -X POST "$AQUA0_API/api/swap/prepare" \
-H "X-API-Key: $AQUA0_API_KEY" -H "Content-Type: application/json" \
-d '{
"chainId": 8453,
"tokenIn": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"tokenOut": "0x4200000000000000000000000000000000000006",
"amountIn": "1000000",
"slippageBps": 50,
"route": { "venue": "v4", "poolId": "0x..." },
"minAmountOut": "396888850224313",
"recipient": "0x<wallet>"
}'A 1inch Aqua route reads { "venue": "aqua", "strategyId": "0x..." }. With exactOut, send maxAmountIn in place of
minAmountOut.
curl -X POST "$AQUA0_API/api/swap/prepare" \
-H "X-API-Key: $AQUA0_API_KEY" -H "Content-Type: application/json" \
-d '{
"chainId": 1151111081099710,
"tokenIn": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"tokenOut": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
"amountIn": "1000000",
"slippageBps": 50,
"route": { "venue": "orca", "poolId": "<pool>", "strategyId": "<strategy>" },
"minAmountOut": "994701",
"recipient": "<wallet>"
}'recipient is the trader's base58 wallet. It signs the transaction, pays the network fee and receives tokenOut.
It quotes the route again. If the swap would now pay less than minAmountOut, it answers 409 with the code
PRICE_MOVED and the fresh figures. Quote again. Building takes a key of your own, not the shared "Try it" key.
3. Sign and send
Send each call in approvals that the wallet still needs, then transaction, from the wallet that pays tokenIn.
When the build has a deadline, the swap must land before it.
Sign transaction.data in the trader's wallet without changing it, then send it before transaction.expiresAt. The
wallet pays the network fee.
curl -X POST "$AQUA0_API/api/solana/swaps/transactions/<requestId>/submit" \
-H "X-API-Key: $AQUA0_API_KEY" -H "Content-Type: application/json" \
-d '{ "signedTransaction": "<base64>" }'4. Track
Poll GET /api/swap/status/{chainId}/{txHash} with the transaction hash, or the signature on Solana, until it reads
SETTLED or FAILED. See Track a swap.
To send a Uniswap V4 swap through your own router, sign it with authorize instead of step 2.