---
title: "Create DEX Swap Transaction"
method: POST
path: "/defi/v1/dex/swap"
tags: ["dex"]
---

# Create DEX Swap Transaction

`POST /defi/v1/dex/swap`

Enables users to perform token swaps on a DEX by supplying source tokens, desired output tokens, and other trade parameters. This endpoint calculates the optimal path (or uses a given path) across liquidity pools, then returns key details such as the route taken, final amounts, and any additional transaction data needed to finalize the swap on-chain. It is particularly useful for DeFi integrations that require seamless conversions between multiple ERC20 tokens within a single request.

> 💡 
**Compute Unit Value:** `55` (Fixed)

## Request body

- DexSwapRequest — The request body for a /defi/v1/dex/swap
  - `dexId` '1000' | '1001' | '1900' | '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](https://docs.blockdaemon.com/docs/defi-api-supported-protocols#supported-dexs-protocols).
  - `path` string[], required — Array of token addresses to swap, in order of the swap.
  - `amountIn` string, required — Amount of token to be swapped.
  - `amountOutMin` string — Minimum amount accepted as the result of the swap.
  - `to` string, required — Address of the recipient of the token.
  - `deadline` string, required — Deadline for the transaction to be executed (UNIX Timestamp).
  - `from` string, required — Address of the sender of the token.
  - `gas` string — Maximum gas to be approved for the transaction.
  - `gasPriority` string — Specifies the priority level for gas fees (e.g., 'low', 'medium', or 'high'), which influences the transaction speed and cost.
  - `slippage` string — Percentage of total swap value allowed for slippage. Default is 1 (0 <= slippage <= 100).
  - `enableFee` boolean — 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.
  - `batcherContract` string — 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.
  - `poolFees` string — Different pool based on the fees. By default, it will take the pool with maximum amountOut.

## Response `200`

Successful response

- object
  - `status` number — Numeric status code indicating success or failure of the API call
  - `msg` string — Human-readable message describing the API result or error
  - `data` union
    - object
      - `chainId` string, required — Blockchain network identifier (EVM chain ID, Solana chain name, etc.)
      - `from` string — Sender's wallet address
      - `to` string — Recipient's wallet address
      - `gas` string — Gas limit for the transaction
      - `value` string — Amount being transferred or involved in a transaction
      - `data` union — Main payload object or array returned by the API
        - string
        - string[]
      - `gasPrice` string — Price per gas unit for the transaction
      - `estimationCheck` union — Flag or value indicating transaction fee/estimate status
        - string
        - boolean
      - `referenceId` string, required — Unique ID for tracking a specific transaction or operation
      - `message` string — Message string related to an operation
    - object
      - `createFeeTxn` object, required
        - `chainId` string, required — Blockchain network identifier (EVM chain ID, Solana chain name, etc.)
        - `from` string, required — Sender's wallet address
        - `to` string, required — Recipient's wallet address
        - `value` string, required — Amount being transferred or involved in a transaction
        - `gasPrice` string — Price per gas unit for the transaction
        - `gas` string, required — Gas limit for the transaction
      - `swapTxn` object, required
        - `chainId` string, required — Blockchain network identifier (EVM chain ID, Solana chain name, etc.)
        - `from` string — Sender's wallet address
        - `to` string — Recipient's wallet address
        - `gas` string — Gas limit for the transaction
        - `value` string — Amount being transferred or involved in a transaction
        - `data` union — Main payload object or array returned by the API
          - string
          - string[]
        - `gasPrice` string — Price per gas unit for the transaction
        - `estimationCheck` union — Flag or value indicating transaction fee/estimate status
          - string
          - boolean
        - `referenceId` string, required — Unique ID for tracking a specific transaction or operation
        - `message` string — Message string related to an operation
    - object
      - `from` string, required
      - `chainId` string, required
      - `referenceId` string, required
      - `methodUsed` 'EIP-5792' | 'EIP-7702', required
      - `calls` object[], required
        - `to` string, required
        - `value` string, required
        - `data` string, required

---

[API](https://skmtc.dev/blockdaemon/apis/staking-api.md) · [All operations](https://skmtc.dev/blockdaemon/apis/staking-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/blockdaemon/staking-api/revisions/f94e296a08a3/schema)
