v1

latestOpenAPI 3.1.02026-07-24223580832.9 KB
dex

Create DEX Swap Transaction with Approval

Generates both token approval and swap transactions in a single call with configurable slippage protection.

💡 Compute Unit Value: 85 (Fixed)

post/defi/v1/dex/swap-with-approval

Request body

dexId'1000' | '1001' | '1300' | '1301' | '1305' | '1306' | '1307' | '1308' | '1309' | '1310' | '1100' | '1101' | '1200' | '1201' | '2900' | '2901' | '2800' | '2808' | '2809' | '1500' | '1400' | '1402' | '2300' | '2100' | '2101' | '2500' | '2501' | '2700' | '2600' | '2400' | '2401' | '1600' | '1602' | '1604' | '1605' | '1607' | '1608' | '1700' | '1701' | '1702' | '1703' | '1704' | '1706' | '1707' | '2200' | '2201' | '2202' | '2203' | '2204' | '2205' | '2206' | '3000' | '3001' | '3100' | '3300' | '3301' | '3500' | '3501' | '3400' | '3401' | '3600' | '3800' | '3700'

The unique ID to specify the decentralized exchange (DEX) within a particular blockchain. Find more here.

pathstring[] required

Array of token addresses to swap, in order of the swap.

amountInstring required

Amount of token to be swapped.

amountOutMinstring

Minimum amount accepted as the result of the swap.

tostring required

Address of the recipient of the token.

deadlinestring required

Deadline for the transaction to be executed (UNIX Timestamp).

fromstring required

Address of the sender of the token.

gasstring

Maximum gas to be approved for the transaction.

gasPrioritystring

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

slippagestring

Percentage of total swap value allowed for slippage. Default is 1 (0 <= slippage <= 100).

enableFeeboolean

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

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

The batch option to be used for the transaction.

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.

poolFeesstring

Different pool based on the fees. By default, it will take the pool with maximum amountOut.

Example request

{
  "dexId": "1000",
  "path": [
    "0x514910771AF9Ca656af840dff83E8264EcF986CA",
    "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
  ],
  "amountIn": "10000",
  "amountOutMin": "0",
  "to": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
  "deadline": "1707313948",
  "from": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
  "gas": "100000",
  "gasPriority": "low",
  "slippage": "10",
  "enableFee": false,
  "batchOption": "EIP-5792",
  "batcherContract": "0x9c933f9d2efd76ce25b0d3dde84d3f94e78a50ca",
  "poolFees": "3000"
}

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": [
    {
      "chainId": "1",
      "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
      "to": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
      "value": "0",
      "gas": "173376",
      "data": "0x095ea7b30000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d00000000000000000000000000000000000000000000000000038d7ea4c68000",
      "nonce": 0,
      "referenceId": "497ef8cb1f224ab3ac8ee68211237298"
    },
    {
      "chainId": "1",
      "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
      "to": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
      "value": "0",
      "gas": "173376",
      "data": "0x38ed173900000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000063056e00436da25bcf48a40dfbbdcc708935100600000000000000000000000000000000000000000000000000000000634d00ee0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f",
      "nonce": 1,
      "referenceId": "497ef8cb1f224ab3ac8ee68211237298"
    }
  ]
}