Skip to main content
POST
/
quote
Get a quote
curl --request POST \
  --url https://trade-api.gateway.uniswap.org/v1/quote \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '{
  "type": "EXACT_INPUT",
  "amount": "<string>",
  "tokenInChainId": 1,
  "tokenOutChainId": 1,
  "tokenIn": "<string>",
  "tokenOut": "<string>",
  "generatePermitAsTransaction": false,
  "swapper": "<string>",
  "slippageTolerance": 123,
  "autoSlippage": "undefined",
  "routingPreference": "BEST_PRICE",
  "protocols": [
    "V2"
  ],
  "hooksOptions": "V4_HOOKS_INCLUSIVE",
  "spreadOptimization": "EXECUTION",
  "urgency": "urgent",
  "permitAmount": "FULL"
}'
{
  "requestId": "<string>",
  "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>"
      }
    ]
  },
  "routing": "CLASSIC",
  "permitTransaction": {
    "to": "<string>",
    "from": "<string>",
    "data": "<string>",
    "value": "<string>",
    "gasLimit": "<string>",
    "chainId": 1,
    "maxFeePerGas": "<string>",
    "maxPriorityFeePerGas": "<string>",
    "gasPrice": "<string>"
  },
  "permitData": {
    "domain": {},
    "values": {},
    "types": {}
  },
  "permitGasFee": "<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
type
enum<string>
required

The handling of the amount field. EXACT_INPUT means the requester will send the specified amount of input tokens and get a quote with a variable quantity of output tokens. EXACT_OUTPUT means the requester will receive the specified amount of output tokens and get a quote with a variable quantity of input tokens.

Available options:
EXACT_INPUT,
EXACT_OUTPUT
amount
string
required

The quantity of tokens denominated in the token's base units. (For example, for an ERC20 token one token is 1x10^18 base units. For one USDC token one token is 1x10^6 base units.) This value must be greater than 0.

tokenInChainId
enum<number>
required

The unique ID of the blockchain. For a list of supported chains see the FAQ.

Available options:
1,
10,
56,
130,
137,
324,
480,
1868,
8453,
10143,
42161,
42220,
43114,
81457,
7777777,
1301,
84532,
11155111
tokenOutChainId
enum<number>
required

The unique ID of the blockchain. For a list of supported chains see the FAQ.

Available options:
1,
10,
56,
130,
137,
324,
480,
1868,
8453,
10143,
42161,
42220,
43114,
81457,
7777777,
1301,
84532,
11155111
tokenIn
string
required

The token which will be sent, specified by its token address. For a list of supported tokens, see the FAQ.

tokenOut
string
required

The token which will be received, specified by its token address. For a list of supported tokens, see the FAQ.

swapper
string
required

The wallet address which will be used to send the token.

generatePermitAsTransaction
boolean
default:false

Indicates whether you want toreceive a permit2 transaction to sign and submit onchain, or a permit message to sign. When set to true, the quote response returns the Permit2 as a calldata which the user signs and broadcasts. When set to false (the default), the quote response returns the Permit2 as a message which the user signs but does not need to broadcast. When using a 7702-delegated wallet, set this field to true. Except for this scenario, it is recommended that this field is set to false. Note that a Permit2 calldata (e.g. true), will provide indefinite permission for Permit2 to spend a token, in contrast to a Permit2 message (e.g. false) which is only valid for 30 days. Further, a Permit2 calldata (e.g. true) requires the user to pay gas to submit the transaction, whereas the Permit2 message (e.g. false ) does not require the user to submit a transaction and requires no gas.

slippageTolerance
number

The slippage tollerace as a percentage up to a maximum of two decimal places. For Uniswap Protocols (v2, v3, v4), the slippage tolerance is the maximum amount the price can change between the time the transaction is submitted and the time it is executed. The slippage tolerance is a percentage of the total value of the swap.

When submitting a quote, note that slippage tolerance works differently in UniswapX swaps where it does not set a limit on the Spread in an order. See here for more information.

Note that if the trade type is EXACT_INPUT, then the slippage is in terms of the output token. If the trade type is EXACT_OUTPUT, then the slippage is in terms of the input token.

When submitting a request, slippageTolerance may not be set when autoSlippage is defined. One of slippageTolerance or autoSlippage must be defined.

autoSlippage
enum<string>
default:undefined

The auto slippage strategy to employ. Presently there is a single slippage strategy, "DEFAULT", which uses a combination of the estimated gas cost and swap size to calcualte a slippage. Note that the DEFAULT slippage strategy is bounded between (and including) 0.5% and 5.5%.

If the trade type is EXACT_INPUT, then the slippage is in terms of the output token. If the trade type is EXACT_OUTPUT, then the slippage is in terms of the input token.

When submitting a request, autoSlippage may not be set when slippageTolerance is defined. One of slippageTolerance or autoSlippage must be defined.

Available options:
DEFAULT
routingPreference
enum<string>
default:BEST_PRICE

The routingPreference specifies the preferred strategy to determine the quote. If the routingPreference is BEST_PRICE, then the quote will propose a route through the specified whitelisted protocols (or all, if none are specified) that provides the best price. When the routingPreference is FASTEST, the quote will propose the first route which is found to complete the swap. Note that the values CLASSIC, BEST_PRICE_V2, UNISWAPX_V2, V3_ONLY, and V2_ONLY are deprecated and will be removed in a future release. See the Token Trading Workflow page for more information.

Available options:
BEST_PRICE,
FASTEST,
CLASSIC,
BEST_PRICE_V2,
UNISWAPX_V2,
V3_ONLY,
V2_ONLY
protocols
enum<string>[]

The protocols to use for the swap/order. If the protocols field is defined, then you can only set the routingPreference to BEST_PRICE.

hooksOptions
enum<string>

The hook options to use for V4 pool quotes. V4_HOOKS_INCLUSIVE will get quotes for V4 pools with or without hooks. V4_HOOKS_ONLY will only get quotes for V4 pools with hooks. V4_NO_HOOKS will only get quotes for V4 pools without hooks. Defaults to V4_HOOKS_INCLUSIVE if V4 is included in protocols and hookOptions is not set. This field is ignored if V4 is not passed in protocols.

Available options:
V4_HOOKS_INCLUSIVE,
V4_HOOKS_ONLY,
V4_NO_HOOKS
spreadOptimization
enum<string>
default:EXECUTION

For UniswapX swaps, when set to EXECUTION, quotes optimize for looser spreads at higher fill rates. When set to PRICE, quotes optimize for tighter spreads at lower fill rates. This field is not applicable to Uniswap Protocols (v2, v3, v4), bridging, or wrapping/unwrapping and will be ignored if set.

Available options:
EXECUTION,
PRICE
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
permitAmount
enum<string>
default:FULL

For Uniswap Protocols (v2, v3, v4) swaps, specify the input token spend allowance (e.g. quantity) to be set in the permit. FULL can be used to specify an unlimited token quantity, and may prevent the wallet from needing to sign another permit for the same token in the future. EXACT can be used to specify the exact input token quantity for this request. Defaults to FULL.

Available options:
FULL,
EXACT

Response

Quote request successful.

requestId
string
required

A unique ID for the request.

quote
object
required
  • Classic Quote
  • Wrap/Unwrap Quote
  • UniswapX V2 Quote
  • UniswapX V3 Quote
  • Bridge Quote
  • UniswapX Priority Quote
routing
enum<string>
required

The routing for the proposed transaction.

Available options:
CLASSIC,
DUTCH_V2,
DUTCH_V3,
BRIDGE,
LIMIT_ORDER,
PRIORITY,
WRAP,
UNWRAP
permitData
object | null
required

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

permitTransaction
object
permitGasFee
string

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

I