> ## Documentation Index
> Fetch the complete documentation index at: https://docs.houdiniswap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# POST DEX Exchange

> Initiate a DEX cryptocurrency swap

# POST DEX Exchange

## Endpoint

```
POST /dexExchange
```

Initiates a DEX swap. Returns transaction metadata including the on-chain transaction data to submit.

## Request Body

```json theme={null}
{
  "amount": 0.2,
  "tokenIdTo": "6689b73ec90e45f3b3e51558",
  "tokenIdFrom": "6689b73ec90e45f3b3e51553",
  "addressTo": "H1DiPSsBVBpDG57q5ZnxhZpRrsPQBvZfrbFQth6wyGyw",
  "addressFrom": "0x45CF73349a4895fabA18c0f51f06D79f0794898D",
  "swap": "sw",
  "quoteId": "66fa79723eccf00d849b48ed",
  "route": {
    "duration": 1,
    "gas": "5387746374601800",
    "quote": {
      "integration": "debridge",
      "type": "swap",
      "bridgeFee": "29257969",
      "bridgeFeeInNativeToken": "1000000000000000",
      "amount": "657693444",
      "decimals": 9,
      "amountUSD": "94.905",
      "bridgeFeeUSD": "4.221",
      "bridgeFeeInNativeTokenUSD": "2.434",
      "fees": [
        {
          "type": "bridge",
          "amount": "29257969",
          "amountUSD": "4.221",
          "chainSlug": "solana",
          "tokenSymbol": "SOL",
          "tokenAddress": "11111111111111111111111111111111",
          "decimals": 9,
          "deductedFromSourceToken": true
        },
        {
          "type": "bridge",
          "amount": "1000000000000000",
          "amountUSD": "2.434",
          "chainSlug": "ethereum",
          "tokenSymbol": "ETH",
          "tokenAddress": "0x0000000000000000000000000000000000000000",
          "decimals": 18,
          "deductedFromSourceToken": false
        },
        {
          "type": "gas",
          "amount": "5387746374601800",
          "amountUSD": "13.118",
          "chainSlug": "ethereum",
          "tokenSymbol": "ETH",
          "tokenAddress": "0x0000000000000000000000000000000000000000",
          "decimals": 18,
          "deductedFromSourceToken": false
        },
        {
          "type": "partner",
          "amount": "200000",
          "amountUSD": "0.200",
          "chainSlug": "ethereum",
          "tokenSymbol": "USDT",
          "tokenAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
          "decimals": 6,
          "deductedFromSourceToken": true
        }
      ]
    },
    "route": [
      {
        "bridge": "debridge",
        "bridgeTokenAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "steps": ["allowance", "approve", "send"],
        "name": "USDC",
        "part": 100
      }
    ],
    "distribution": { "debridge": 1 },
    "gasUSD": "13.118",
    "useXmr": false,
    "deviceInfo": "MacOS",
    "isMobile": false
  }
}
```

## Request Fields

| Field         | Type   | Description                                                        |
| ------------- | ------ | ------------------------------------------------------------------ |
| `amount`      | number | Amount to exchange (e.g., `0.2`)                                   |
| `tokenIdTo`   | string | ID of the output token                                             |
| `tokenIdFrom` | string | ID of the input token                                              |
| `addressTo`   | string | Destination wallet address                                         |
| `addressFrom` | string | Sender's wallet address                                            |
| `swap`        | string | Swap method identifier (e.g., `sw`)                                |
| `quoteId`     | string | Quote ID from `dexQuote` response                                  |
| `route`       | object | Full route object from `dexQuote` raw response. See RouteDTO below |

### RouteDTO Fields

| Field          | Type    | Description                                     |
| -------------- | ------- | ----------------------------------------------- |
| `duration`     | number  | Estimated duration of the swap in minutes       |
| `gas`          | string  | Gas fee for the swap transaction                |
| `quote`        | object  | Quote data for the swap. See QuoteDataDTO below |
| `route`        | array   | Array of bridge route objects                   |
| `distribution` | object  | Distribution of the swap across bridges         |
| `gasUSD`       | string  | Gas fee in USD                                  |
| `useXmr`       | boolean | Whether XMR is used for anonymous routing       |
| `deviceInfo`   | string  | Device information (example: `MacOS`)           |
| `isMobile`     | boolean | Whether the client is a mobile device           |

### QuoteDataDTO Fields

| Field                       | Type   | Description                                               |
| --------------------------- | ------ | --------------------------------------------------------- |
| `integration`               | string | Integration name (example: `debridge`)                    |
| `type`                      | string | Type of exchange (example: `swap`)                        |
| `bridgeFee`                 | string | Fee for bridge transactions (example: `29257969`)         |
| `bridgeFeeInNativeToken`    | string | Bridge fee in native tokens (example: `1000000000000000`) |
| `amount`                    | string | Amount involved in the exchange (example: `657693444`)    |
| `decimals`                  | number | Number of decimals for precision (example: `9`)           |
| `amountUSD`                 | string | Amount converted to USD (example: `94.905`)               |
| `bridgeFeeUSD`              | string | Bridge fee in USD (example: `4.221`)                      |
| `bridgeFeeInNativeTokenUSD` | string | Bridge fee in native token converted to USD               |
| `fees`                      | array  | Array of fee objects (bridge, gas, partner fees)          |

## Example Response

```json theme={null}
{
  "houdiniId": "h9NpKm75gRnX7GWaFATwYn",
  "created": "2024-10-08T12:22:25.843Z",
  "senderAddress": "0xe90cAc99ccab34A669fFC2eE4e9c0E5067dE29ac",
  "receiverAddress": "H1DiPSsBVBpDG57q5ZnxhZpRrsPQBvZfrbFQth6wyGyw",
  "anonymous": false,
  "expires": "2024-10-08T12:52:25.843Z",
  "status": 0,
  "inAmount": 50,
  "inSymbol": "6689b73ec90e45f3b3e51592",
  "outAmount": 0.266471241,
  "outSymbol": "6689b73ec90e45f3b3e51558",
  "senderTag": "",
  "receiverTag": "",
  "notified": false,
  "eta": 1,
  "inAmountUsd": 38.422,
  "inCreated": "2024-10-08T12:22:25.843Z",
  "quote": {
    "amountIn": 50,
    "amountOut": 0.266471241
  },
  "metadata": {
    "from": "0xe90cAc99ccab34A669fFC2eE4e9c0E5067dE29ac",
    "to": "0xD0c0bA0b6F151729f4BacB40b8Bb8047360b1ad6",
    "data": "0x601e0bbe...",
    "value": "0x11c37937e08000",
    "txId": "0x2c0d17c9ecde56ec1604582abfe102c331c235be9da45aa266519080d3e9d10d",
    "gas": "0x0699bc"
  },
  "isDex": true
}
```

## Response Fields

| Field             | Type    | Description                            |
| ----------------- | ------- | -------------------------------------- |
| `houdiniId`       | string  | Unique transaction identifier          |
| `created`         | string  | Timestamp when transaction was created |
| `senderAddress`   | string  | Sender's wallet address                |
| `receiverAddress` | string  | Recipient's wallet address             |
| `anonymous`       | boolean | Whether transaction is anonymous       |
| `expires`         | string  | Expiration timestamp                   |
| `status`          | number  | Status code                            |
| `inAmount`        | number  | Input amount                           |
| `inSymbol`        | string  | Input token ID                         |
| `outAmount`       | number  | Output amount                          |
| `outSymbol`       | string  | Output token ID                        |
| `eta`             | number  | Estimated time in minutes              |
| `inAmountUsd`     | number  | Input amount in USD                    |
| `inCreated`       | string  | Timestamp when input was created       |
| `quote`           | object  | Quoted exchange details                |
| `metadata`        | object  | On-chain transaction data to submit    |
| `isDex`           | boolean | `true` for DEX transactions            |

### metadata Object

| Field   | Type   | Description              |
| ------- | ------ | ------------------------ |
| `from`  | string | Sender address           |
| `to`    | string | Contract address to call |
| `data`  | string | Encoded calldata (hex)   |
| `value` | string | ETH value to send (hex)  |
| `txId`  | string | Transaction ID           |
| `gas`   | string | Gas limit (hex)          |
