dex

Aggregate DEX Swap

Aggregates swap quotes from all DEXs supporting a specified token pair. It allows users to customize their query to prioritize either the best output or the lowest gas costs. The response provides detailed transaction data including DEX identifiers, output amounts, swap routing parameters (such as call data), gas estimates, and a reference, enabling traders to compare and select the most efficient swap route for their needs.

💡 Compute Unit Value: 115 (Fixed)

post/defi/v1/dex/swaps

Request

  • Base URL
    https://svc.blockdaemon.com
  • URL
    https://svc.blockdaemon.com/defi/v1/dex/swaps
  • Auth
    API key in header X-API-Key

Request body

chainId'1' | '43114' | '56' | '137' | '42161' | '10' | '8453' | '324' | '5000' | '900' | '1400' | '1200' | '101' | '1700' | '1500' | '1100' | '1600' | '8217'

The unique ID to direct queries or transactions to the correct blockchain. Find more here.

pathstring[] required

Ordered array of token contract addresses defining the swap route. Provide [tokenInAddress, tokenOutAddress] for a direct swap. Example (WETH→USDC on Ethereum): ['0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'].

amountInstring required

Amount of the input token to provide, specified in the token's smallest denomination (base units). Do not send human-readable decimal values. Examples: to swap 1 WETH (18 decimals), use "1000000000000000000"; to swap 1 USDC (6 decimals), use "1000000".

chainSymbolstring

The abbreviated chain name for queries or transactions.

fromstring required

Blockchain address of the token sender. For EVM chains, use a checksummed hex address (e.g., 0xABCDEF...). This address must hold sufficient balance of the input token and will sign the transaction.

gasstring

Maximum number of gas units to allocate for the transaction, as an integer string (e.g., '200000'). If omitted, gas is estimated automatically. Note: this is gas units, not wei or gwei.

tostring required

Blockchain address of the token recipient. For EVM chains, use a checksummed hex address (e.g., 0xABCDEF...). Output tokens are delivered to this address after the swap.

poolFeesstring

Fee tier of the target liquidity pool in basis points (1 bp = 0.01%). Common values for Uniswap V3-style AMMs: 100 (0.01%), 500 (0.05%), 3000 (0.3%), 10000 (1%). If omitted, the pool yielding the highest output amount is selected automatically.

excludedDexesstring

Comma-separated list of DEX protocol IDs (dexId values) to exclude from routing. Find available IDs via the /support endpoint.

bestNetPriceboolean

If true, sorts prepared transactions by net value (amountsOut minus gas) in descending order. If multiple sort parameters are true, bestNetPrice takes precedence.

bestQuoteboolean

If true, sorts prepared transactions by amountsOut in descending order. If multiple sort parameters are true, bestNetPrice takes precedence.

lowestGasboolean

If true, sorts prepared transactions by gas cost in ascending order. If multiple sort parameters are true, bestNetPrice takes precedence.

gasPrioritystring

Specifies the priority level for gas fees (e.g., 'low', 'medium', or 'high'), which influences the transaction speed and cost.

amountOutMinstring

Minimum acceptable output amount in the token's smallest denomination (base units). Provides slippage protection — the transaction reverts if the output falls below this value. Set to "0" to disable slippage protection. Examples: to require at least 0.99 USDC (6 decimals), use "990000"; to require at least 0.99 WETH (18 decimals), use "990000000000000000".

slippagestring

Maximum acceptable slippage as a percentage of the swap value. Valid range: 0 to 100 (e.g., 1 = up to 1% slippage). Defaults to 1. The transaction reverts if the output deviates more than this percentage from the quoted price.

enableFeeboolean

Flag to include a basis points fee transaction alongside the main transaction when set to true.

batchOption'EIP-5792' | 'EIP-7702'

Transaction batching standard to use. Supported values: 'EIP-5792' (wallet-level batching via wallet_sendCalls) or 'EIP-7702' (EOA code delegation via batcherContract). Requires batcherContract when using EIP-7702.

batcherContractstring

The EOA address of the batcher that will be used to execute the transaction when using EIP-7702 batching. If not provided, the default batcher contract for the chain will be used.

simulateboolean

When true, dry-runs the transaction batch via eth_simulateV1 and returns a simulate field with status and error on each transaction.

Example request

{
  "chainId": "1",
  "path": [
    "0x514910771AF9Ca656af840dff83E8264EcF986CA",
    "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
  ],
  "amountIn": "1000000000000000000",
  "chainSymbol": "ETH",
  "from": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
  "gas": "100000",
  "to": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
  "poolFees": "3000",
  "excludedDexes": "1700",
  "bestNetPrice": false,
  "bestQuote": false,
  "lowestGas": false,
  "gasPriority": "low",
  "amountOutMin": "0",
  "slippage": "10",
  "enableFee": false,
  "batchOption": "EIP-5792",
  "batcherContract": "0x9c933f9d2efd76ce25b0d3dde84d3f94e78a50ca",
  "simulate": false
}

Response

Successful response

statusnumber

Numeric status code indicating success or failure of the API call

msgstring

Human-readable message describing the API result or error

Example response

{
  "status": 200,
  "msg": "success",
  "data": [
    {
      "dexName": "UniswapV2",
      "amountsOut": "3696603530",
      "chainId": "1",
      "from": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
      "to": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
      "value": "1000000",
      "gas": "800000",
      "data": "0x7ff36ab500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000dae2f6eddda6fb4fb60cc02633de27e2b431b40200000000000000000000000000000000000000000000000000000193817718420000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f",
      "estimationCheck": "Returned error: insufficient funds for gas * price + value: address 0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402 have 17695120464000 want 136837418655888595",
      "referenceId": "01dac9c06f08417e826b42e28a403d50"
    },
    {
      "dexName": "SushiswapV2",
      "amountsOut": "3693198033",
      "chainId": "1",
      "from": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
      "to": "0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F",
      "value": "1000000",
      "gas": "800000",
      "data": "0x7ff36ab500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000dae2f6eddda6fb4fb60cc02633de27e2b431b40200000000000000000000000000000000000000000000000000000193817718420000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f",
      "estimationCheck": "Returned error: insufficient funds for gas * price + value: address 0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402 have 17695120464000 want 136837418655888595",
      "referenceId": "01dac9c06f08417e826b42e28a403d50"
    },
    {
      "dexName": "UniswapV3",
      "amountsOut": "3696374718",
      "chainId": "1",
      "from": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
      "to": "0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45",
      "value": "1000000",
      "gas": "800000",
      "data": "0xac9650d8000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000e404e45aaf000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000dae2f6eddda6fb4fb60cc02633de27e2b431b40200000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000412210e8a00000000000000000000000000000000000000000000000000000000",
      "estimationCheck": "Returned error: insufficient funds for gas * price + value: address 0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402 have 17695120464000 want 136837418655888595",
      "referenceId": "01dac9c06f08417e826b42e28a403d50"
    },
    {
      "dexName": "0x",
      "amountsOut": "3695949530",
      "chainId": "1",
      "from": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
      "to": "0x70bf6634ee8cb27d04478f184b9b8bb13e5f4710",
      "value": "1000000",
      "gas": "800000",
      "data": "0x1fff991f000000000000000000000000dae2f6eddda6fb4fb60cc02633de27e2b431b4020000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000da29e44400000000000000000000000000000000000000000000000000000000000000a049f45b98764cc9c837ea3898a1a07800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000000000010438c9c147000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000002710000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000024d0e30db00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a4d92aadfb00000000000000000000000070bf6634ee8cb27d04478f184b9b8bb13e5f47100000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000dcb2edbfd08400449e9d945c57f1a4d289fba1d97785d27b93b45020f6886192880ae61300000000000000000000000000000000000000000000000000000000674c263b000000000000000000000000b02f39e382c90160eb816de5e0e428ac771d77b50000000000000000000000000000000000000000000000000000000000000120000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000f424000000000000000000000000000000000000000000000000000000000000000411b64c63d6976390e6613f9da98022a6e01a9d4f499060dacefb87225e98132c1c6778cd65649acc761390e0d6a32870eef601a9fcf751b7e65b4af84ea90c3f7270000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012438c9c1470000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000ad01c20d5886137e056775af56915de824c8fce500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "estimationCheck": "Returned error: insufficient funds for gas * price + value: address 0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402 have 17695120464000 want 136837418655888595",
      "referenceId": "01dac9c06f08417e826b42e28a403d50"
    },
    {
      "dexName": "Kyberswap",
      "amountsOut": "3696603530",
      "chainId": "1",
      "from": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
      "to": "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
      "value": "1000000",
      "gas": "800000",
      "data": "0xe21fd0e90000000000000000000000000000000000000000000000000000000000000020000000000000000000000000f081470f5c6fbccf48cc4e5b82dd926409dcdd67000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000480000000000000000000000000000000000000000000000000000000000000068000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000dae2f6eddda6fb4fb60cc02633de27e2b431b40200000000000000000000000000000000000000000000000000000000674c2aaa0000000000000000000000000000000000000000000000000000000000000360000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000040989238340000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000aaaaaaaaa24eeeb8d57d431224f73832bc34f68800000000000000000000000000000000000000000000000000000000000f424000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007fc66500c84a76ad7e9c93437bfc5ac33e2ddae900000000000000000000000000000000000000000000000000000000000001a4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400e00deaa0000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000800000000000000000000000007a7d6209d5950bb3b5b3a7724eeb48df8e8a1a630000000000000000000000007fc66500c84a76ad7e9c93437bfc5ac33e2ddae90000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000017ca44e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000003a8e0000000000000000000000037d82cb19000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000dae2f6eddda6fb4fb60cc02633de27e2b431b40200000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002137b22536f75726365223a22657870616e64222c22416d6f756e74496e555344223a22302e30303030303030303337303935333233323336383531222c22416d6f756e744f7574555344223a2230222c22526566657272616c223a22222c22466c616773223a302c22416d6f756e744f7574223a2230222c2254696d657374616d70223a313733333034333730362c22496e74656772697479496e666f223a7b224b65794944223a2231222c225369676e6174757265223a2243756e47794b4155314c357567746a53554563565a68674d38505a41534b634d444b5732346a367635337a425a585852497570492b4d7432685165704e7574704e4965716a532f6e716d4a384c2b697979373278497556563671582f71354550534b79324a7a716f4630765a444d3551484664473332302b5571784b4c5132734e79686e62756f4d685a76715a4c7932546e6f315474584238325771456739417a57516b33463875434d57776c716b717a75463869366a4a6a34666d62427455354c6a5533694d592f7077527a477a68523738736368414e59697569544a316d64753177413158373676334839427a52726c4e4131666747316a67474459314b596857785576386e376e3437632f6e6d3064532b5042466773394338336675377956765368696f5445574e52694b6a64613039334e577846305741436d396246784b7062564f377145304e55335968306432366372773d3d227d7d00000000000000000000000000",
      "estimationCheck": "Returned error: insufficient funds for gas * price + value: address 0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402 have 17695120464000 want 136837418655888595",
      "referenceId": "01dac9c06f08417e826b42e28a403d50"
    }
  ]
}

Changes

No recorded changes to this operation across all 1 revision of this API.