Skip to main content

High Level Message Flow

Uniswap supports one primary swapping workflow with a variety of optionality. By default, the API uses a secure three-step Permit2 swapping workflow. For compatibility with legacy two-step routing workflows, the API supports a Proxy Approval workflow. The diagram below is an illustration of the workflow between the API and customer wallet to complete a swap.
  1. Check if the customer has given the necessary approval to the Permit2 (or Proxy) contract to spend the token they intend to swap through a /check_approval request. a. If the approval is not yet in place, a fully-formed transaction is returned to the customer to sign.
  2. Request a quote for their desired swap using a /quote request. a. Quotes are requested whether the customer is seeking to perform a token for token swap, a cross-chain bridge, or a token wrap/unwrap. b. The quote optionally specifies the desired execution paths (Uniswap protocols or UniswapX) through the protocols array. c. The quote returns the most efficient route to achieve the swap, including a fully-formed Permit2 message for signature (if necessary).
  3. Depending upon the swap routing, the customer makes either a gasless /order or gasful /swap request a. /order requests are submitted when the swap will be filled by a UniswapX RFQ market maker. In this case the order is “gasless” because the market maker will write the transaction to chain to fill the swap. b. /swap requests are submitted when the swap will be filled by a “classic” v2, v3, or v4 Uniswap protocol pool, or in the event that the swap is a bridge or a token wrap/unwrap. This is a “gasful” transaction because the swapping wallet will write the transaction to the chain to fill the swap.

Detailed Message Flow

  • Every arrow represents a message exchanged between the two indicated parties.
  • Bolded values are API calls or specific fields or values within an API request or response.
  • The most important details of the request or response are called out with helper text, but complete details of every request and response field can be found within the Token Trading endpoints found further on in this documentation.
  • Note that customers must take different actions depending on the result of their /quote request. The /quote request may result in a proposed swap against Uniswap or other public protocols, causing the following API request from the customer to be a /swap. Alternatively, the /quote request may result in a proposed swap with a private liquidity filler, causing the following API request from the customer to be an /order.