Skip to main content
POST
/
swap
Create swap calldata
curl --request POST \
  --url https://trade-api.gateway.uniswap.org/v1/swap \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '{
  "quote": {
    "input": {
      "token": "<string>",
      "amount": "<string>"
    },
    "output": {
      "token": "<string>",
      "amount": "<string>",
      "recipient": "<string>"
    },
    "swapper": "<string>",
    "chainId": 1,
    "slippage": 123,
    "tradeType": "EXACT_INPUT",
    "gasFee": "<string>",
    "gasFeeUSD": "<string>",
    "gasFeeQuote": "<string>",
    "route": [
      [
        {
          "type": "v2-pool",
          "address": "<string>",
          "tokenIn": {
            "address": "<string>",
            "chainId": 1,
            "symbol": "ETH",
            "decimals": "<string>",
            "buyFeeBps": "<string>",
            "sellFeeBps": "<string>"
          },
          "tokenOut": {
            "address": "<string>",
            "chainId": 1,
            "symbol": "ETH",
            "decimals": "<string>",
            "buyFeeBps": "<string>",
            "sellFeeBps": "<string>"
          },
          "reserve0": {
            "token": {
              "address": "<string>",
              "chainId": 1,
              "symbol": "ETH",
              "decimals": "<string>",
              "buyFeeBps": "<string>",
              "sellFeeBps": "<string>"
            },
            "quotient": "<string>"
          },
          "reserve1": {
            "token": {
              "address": "<string>",
              "chainId": 1,
              "symbol": "ETH",
              "decimals": "<string>",
              "buyFeeBps": "<string>",
              "sellFeeBps": "<string>"
            },
            "quotient": "<string>"
          },
          "amountIn": "<string>",
          "amountOut": "<string>"
        }
      ]
    ],
    "portionBips": 123,
    "portionAmount": "<string>",
    "portionRecipient": "<string>",
    "routeString": "<string>",
    "quoteId": "<string>",
    "gasUseEstimate": "<string>",
    "blockNumber": "<string>",
    "gasPrice": "<string>",
    "maxFeePerGas": "<string>",
    "maxPriorityFeePerGas": "<string>",
    "txFailureReasons": [
      "SIMULATION_ERROR"
    ],
    "priceImpact": 123,
    "aggregatedOutputs": [
      {
        "token": "<string>",
        "amount": "<string>",
        "recipient": "<string>",
        "bps": 123,
        "minAmount": "<string>"
      }
    ]
  },
  "signature": "<string>",
  "includeGasInfo": false,
  "refreshGasPrice": false,
  "simulateTransaction": false,
  "permitData": {
    "domain": {},
    "values": {},
    "types": {}
  },
  "safetyMode": "SAFE",
  "deadline": 123,
  "urgency": "urgent"
}'
{
  "requestId": "<string>",
  "swap": {
    "to": "<string>",
    "from": "<string>",
    "data": "<string>",
    "value": "<string>",
    "gasLimit": "<string>",
    "chainId": 1,
    "maxFeePerGas": "<string>",
    "maxPriorityFeePerGas": "<string>",
    "gasPrice": "<string>"
  },
  "gasFee": "<string>"
}

Authorizations

x-api-key
string
header
required

Headers

x-universal-router-version
enum<string>
default:1.2

The version of the Universal Router to use for the swap journey. MUST be consistent throughout the API calls.

Available options:
2.0

Body

application/json

The parameters signature and permitData should only be included if permitData was returned from /quote.

quote
object
required
  • Classic Quote
  • Wrap/Unwrap Quote
  • Bridge Quote
signature
string

The signed permit.

includeGasInfo
boolean
default:false
deprecated

Use refreshGasPrice instead.

refreshGasPrice
boolean
default:false

If true, the gas price will be re-fetched from the network.

simulateTransaction
boolean
default:false

If true, the transaction will be simulated. If the simulation results on an onchain error, endpoint will return an error.

permitData
object

the permit2 message object for the customer to sign to permit spending by the permit2 contract.

safetyMode
enum<string>

Swap safety mode will automatically sweep the transaction for the native token and return it to the sender wallet address. This is to prevent accidental loss of funds in the event that the token amount is set in the transaction value instead of as part of the calldata.

Available options:
SAFE
deadline
number

The unix timestamp at which the order will be reverted if not filled.

urgency
enum<string>
default:urgent

The urgency impacts the estimated gas price of the transaction. The higher the urgency, the higher the gas price, and the faster the transaction is likely to be selected from the mempool. The default value is urgent.

Available options:
normal,
fast,
urgent

Response

Create swap successful.

requestId
string
required

A unique ID for the request.

swap
object
required
gasFee
string

The total estimated gas cost of this transaction (eg. gasLimit multiplied by maxFeePerGas) in the base unit of the chain.

I