Detailed Guides
Swap Message Sample
A Complete Message Sequence for a Swap
The following is a complete swap flow demonstrating a swap from WBTC to ETH on Mainnet. Routing is restricted to UniswapX V2, V2, V3, and V4 routes. Both wallet spend approval and permit signature are required and demonstrated; note that the interacting wallet broadcasts the approval
object from the Check Approval Response and the swap
object from the Swap Response to the chain after receiving each.
Check Approval Request
--url https://trade-api.gateway.uniswap.org/v1/check_approval \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-api-key: ****' \
--data '
{
"chainId": 1,
"urgency": "urgent",
"includeGasInfo": true,
"walletAddress": "0xC9bebBA9f481b12cE6f3EA54c4B182c9636ec421",
"token": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"amount": "2516"
}
'
Check Approval Response
{
"requestId": "e63f1e1e-b9e9-411a-bcc8-ff18ce4e77cf",
"approval": {
"to": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"value": "0x00",
"from": "0xC9bebBA9f481b12cE6f3EA54c4B182c9636ec421",
"data": "0x095ea7b3000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"maxFeePerGas": "4656513686",
"maxPriorityFeePerGas": "2000000000",
"gasLimit": "56344",
"chainId": 1
},
"cancel": null,
"gasFee": "262366607123984",
}
Quote Request
--url https://trade-api.gateway.uniswap.org/v1/quote \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-api-key: ****' \
--header 'x-universal-router-version: 2.0' \
--data '
{
"type": "EXACT_INPUT",
"tokenInChainId": 1,
"tokenOutChainId": 1,
"generatePermitAsTransaction": false,
"autoSlippage": "DEFAULT",
"routingPreference": "BEST_PRICE",
"spreadOptimization": "EXECUTION",
"urgency": "normal",
"permitAmount": "FULL",
"amount": "2516",
"tokenIn": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"tokenOut": "0x0000000000000000000000000000000000000000",
"swapper": "0xC9bebBA9f481b12cE6f3EA54c4B182c9636ec421",
"protocols": ["UNISWAPX_V2","V4","V3","V2"]
}
'
Quote Response
{
"requestId": "34784ef4-065a-4fa2-b77c-521f785fc068",
"routing": "CLASSIC",
"quote": {
"chainId": 1,
"input": {
"amount": "2516",
"token": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599"
},
"output": {
"amount": "996320746321162",
"token": "0x0000000000000000000000000000000000000000",
"recipient": "0xC9bebBA9f481b12cE6f3EA54c4B182c9636ec421"
},
"swapper": "0xC9bebBA9f481b12cE6f3EA54c4B182c9636ec421",
"route": [
[
{
"type": "v4-pool",
"address": "0x599326d9cd5e1ea0893305c87d5ec3199e7f05e94d72159f35dea381479a615e",
"tokenIn": {
"chainId": 1,
"decimals": "8",
"address": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"symbol": "WBTC"
},
"tokenOut": {
"chainId": 1,
"decimals": "18",
"address": "0x0000000000000000000000000000000000000000",
"symbol": "ETH"
},
"fee": "500",
"tickSpacing": "10",
"hooks": "0x0000000000000000000000000000000000000000",
"liquidity": "82781860385007263",
"sqrtRatioX96": "125814565506407615477027",
"tickCurrent": "-267075",
"amountIn": "2516",
"amountOut": "993829944455359"
}
]
],
"slippage": 5.5,
"tradeType": "EXACT_INPUT",
"quoteId": "62e83902-9455-405d-8c62-cdf8ee9e2042",
"gasFeeUSD": "1.27511942409885062",
"gasFeeQuote": "489108586810000",
"gasUseEstimate": "180350",
"priceImpact": 0.14,
"txFailureReasons": [],
"maxPriorityFeePerGas": "2000000000",
"maxFeePerGas": "4656513686",
"gasFee": "489108586810000",
"routeString": "[V4] 100.00% = WBTC -- 0.05% [0x599326d9cd5e1ea0893305c87d5ec3199e7f05e94d72159f35dea381479a615e]ETH",
"blockNumber": "22483653",
"aggregatedOutputs": [
{
"amount": "993829944455360",
"token": "0x0000000000000000000000000000000000000000",
"recipient": "0xC9bebBA9f481b12cE6f3EA54c4B182c9636ec421",
"bps": 9975,
"minAmount": "993829944455360"
},
{
"amount": "2490801865802",
"token": "0x0000000000000000000000000000000000000000",
"recipient": "0x000000fee13a103A10D593b9AE06b3e05F2E7E1c",
"bps": 25,
"minAmount": "2490801865802"
}
],
"portionAmount": "2490801865802",
"portionBips": 25,
"portionRecipient": "0x000000fee13a103A10D593b9AE06b3e05F2E7E1c"
},
"permitData": {
"domain": {
"name": "Permit2",
"chainId": 1,
"verifyingContract": "0x000000000022D473030F116dDEE9F6B43aC78BA3"
},
"types": {
"PermitSingle": [
{
"name": "details",
"type": "PermitDetails"
},
{
"name": "spender",
"type": "address"
},
{
"name": "sigDeadline",
"type": "uint256"
}
],
"PermitDetails": [
{
"name": "token",
"type": "address"
},
{
"name": "amount",
"type": "uint160"
},
{
"name": "expiration",
"type": "uint48"
},
{
"name": "nonce",
"type": "uint48"
}
]
},
"values": {
"details": {
"token": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"amount": "1461501637330902918203684832716283019655932542975",
"expiration": "1749845047",
"nonce": "1"
},
"spender": "0x66a9893cc07d91d95644aedd05d03f95e1dba8af",
"sigDeadline": "1747254847"
}
},
"permitTransaction": null
}
Swap Request
--url https://trade-api.gateway.uniswap.org/v1/swap \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-api-key: ****' \
--header 'x-universal-router-version: 2.0' \
--data '
{
"quote":
{
"chainId": 1,
"input":
{
"amount": "2516",
"token": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599"
},
"output":
{
"amount": "996320746321162",
"token": "0x0000000000000000000000000000000000000000",
"recipient": "0xC9bebBA9f481b12cE6f3EA54c4B182c9636ec421"
},
"swapper": "0xC9bebBA9f481b12cE6f3EA54c4B182c9636ec421",
"route":
[
[
{
"type": "v4-pool",
"address": "0x599326d9cd5e1ea0893305c87d5ec3199e7f05e94d72159f35dea381479a615e",
"tokenIn":
{
"chainId": 1,
"decimals": "8",
"address": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"symbol": "WBTC"
},
"tokenOut":
{
"chainId": 1,
"decimals": "18",
"address": "0x0000000000000000000000000000000000000000",
"symbol": "ETH"
},
"fee": "500",
"tickSpacing": "10",
"hooks": "0x0000000000000000000000000000000000000000",
"liquidity": "82781860385007263",
"sqrtRatioX96": "125814565506407615477027",
"tickCurrent": "-267075",
"amountIn": "2516",
"amountOut": "993829944455359"
}
]
],
"slippage": 5.5,
"tradeType": "EXACT_INPUT",
"quoteId": "62e83902-9455-405d-8c62-cdf8ee9e2042",
"gasFeeUSD": "1.27511942409885062",
"gasFeeQuote": "489108586810000",
"gasUseEstimate": "180350",
"priceImpact": 0.14,
"txFailureReasons":
[],
"maxPriorityFeePerGas": "2000000000",
"maxFeePerGas": "4656513686",
"gasFee": "489108586810000",
"routeString": "[V4] 100.00% = WBTC -- 0.05% [0x599326d9cd5e1ea0893305c87d5ec3199e7f05e94d72159f35dea381479a615e]ETH",
"blockNumber": "22483653",
"aggregatedOutputs":
[
{
"amount": "993829944455360",
"token": "0x0000000000000000000000000000000000000000",
"recipient": "0xC9bebBA9f481b12cE6f3EA54c4B182c9636ec421",
"bps": 9975,
"minAmount": "993829944455360"
},
{
"amount": "2490801865802",
"token": "0x0000000000000000000000000000000000000000",
"recipient": "0x000000fee13a103A10D593b9AE06b3e05F2E7E1c",
"bps": 25,
"minAmount": "2490801865802"
}
],
"portionAmount": "2490801865802",
"portionBips": 25,
"portionRecipient": "0x000000fee13a103A10D593b9AE06b3e05F2E7E1c"
},
"permitData":
{
"domain":
{
"name": "Permit2",
"chainId": 1,
"verifyingContract": "0x000000000022D473030F116dDEE9F6B43aC78BA3"
},
"types":
{
"PermitSingle":
[
{
"name": "details",
"type": "PermitDetails"
},
{
"name": "spender",
"type": "address"
},
{
"name": "sigDeadline",
"type": "uint256"
}
],
"PermitDetails":
[
{
"name": "token",
"type": "address"
},
{
"name": "amount",
"type": "uint160"
},
{
"name": "expiration",
"type": "uint48"
},
{
"name": "nonce",
"type": "uint48"
}
]
},
"values":
{
"details":
{
"token": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"amount": "1461501637330902918203684832716283019655932542975",
"expiration": "1749845047",
"nonce": "1"
},
"spender": "0x66a9893cc07d91d95644aedd05d03f95e1dba8af",
"sigDeadline": "1747254847"
}
},
"signature": "0xb22e7f47d85108d964f1f90cbca724111f11e0247584821f3da9d653626da48678b977a3c78036d528a6a2dd4261bd47ba32335bc0a523fe75f640389ac9ed031b",
"simulateTransaction": true,
"refreshGasPrice": true,
"safetyMode":"SAFE",
"urgency": "normal"
}
Swap Response
{
"requestId": "dfc1bd88-c741-4cdb-b118-0dddb690bfef",
"swap": {
"data": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006824fe4700000000000000000000000000000000000000000000000000000000000000040a1006040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000005e0000000000000000000000000000000000000000000000000000000000000066000000000000000000000000000000000000000000000000000000000000001600000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000ffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000684c8437000000000000000000000000000000000000000000000000000000000000000100000000000000000000000066a9893cc07d91d95644aedd05d03f95e1dba8af000000000000000000000000000000000000000000000000000000006824fe3f00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000041b22e7f47d85108d964f1f90cbca724111f11e0247584821f3da9d653626da48678b977a3c78036d528a6a2dd4261bd47ba32335bc0a523fe75f640389ac9ed031b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003070b0e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000009d4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c59900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c000000000000000000000000000000000000000000000000000000000000001900000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c9bebba9f481b12ce6f3ea54c4b182c9636ec421000000000000000000000000000000000000000000000000000358c2de2fa8be0c",
"value": "0x00",
"to": "0x66a9893cc07d91d95644aedd05d03f95e1dba8af",
"from": "0xC9bebBA9f481b12cE6f3EA54c4B182c9636ec421",
"maxFeePerGas": "4794697230",
"maxPriorityFeePerGas": "2000000000",
"gasLimit": "179302",
"chainId": 1
},
"gasFee": "859698802733460",
}
Assistant
Responses are generated using AI and may contain mistakes.