UniswapX Protocol White Paper

Abstract

The UniswapX protocol is a non-custodial trading protocol based on Dutch auctions implemented on the Ethereum Virtual Machine.

UniswapX combines on-chain and off-chain liquidity to internalize MEV (Miner Extractable Value) into the protocol, providing users with gasless swaps and scalability to support cross-chain transactions.

1 Introduction

We present the design of a decentralized trading protocol based on Dutch-style auctions, which uses off-chain signed orders for on-chain execution and settlement.

The UniswapX protocol has several advantages:

  • UniswapX outsources routing and batching to a group of permissionless fillers. These fillers can route orders to a combination of on-chain and off-chain liquidity, ensuring the best execution for the swapper’s orders.

  • UniswapX trades use Permit2 executable off-chain tokens, allowing swappers to implicitly include transaction fees as part of the swap, eliminating the requirement to hold a balance of the native on-chain tokens.

  • Unlike swaps on the Uniswap protocol, swappers do not have to pay fees for failed transactions, and batch settlements and/or swaps filled directly from filler inventory are more cost-effective.

  • Unlike AMMs, UniswapX internalizes MEV [9] by returning any surplus generated by the order to the swapper in the form of improved prices, reducing value loss. Additionally, UniswapX orders are less susceptible to front-running.

  • UniswapX can be extended to support cross-chain transactions, allowing swappers to seamlessly trade assets on the source chain for assets needed on the target chain.

The following sections will provide a detailed explanation of these changes and the architecture that facilitates these changes.

2 Signed Orders

When swappers make trades using the Uniswap protocol (v1, v2, v3, and v4 [3-6]), they create and sign transactions. These transactions specify an input token, an output token, a specific execution path, and a minimum output amount. The swapper then submits the transaction to a memory pool, either public or private, which is received and included in a block by a block builder.

UniswapX leverages Permit2 [19], a token authorization contract that introduces signature-based authorization and transfer for any ERC20 token. Additionally, UniswapX uses the Reactor contract for on-chain settlement. The Reactor contract is responsible for checking if the transaction execution meets the user’s expected parameters and revoking transactions that do not meet the parameters. Swappers must first authorize the Permit2 contract. Then, instead of creating and submitting transactions themselves, swappers using the UniswapX protocol specify the following in the order before the transaction:

(1) Input token (i.e. token being paid)

(2) Output token (i.e. token being acquired)

(3) Input (output) amount

(4) Initial output (input) amount

(5) Minimum output (input) amount

(6) Decay function

(7) Exchange deadline

(8) Authorize the UniswapX reactor contract to use the token

These orders are received by the MEV searcher, market makers, and/or other on-chain agents (referred to as fillers) together, and sent to the Reactor contract. By submitting the orders of the exchangers on-chain, the fillers pay the gas fees on behalf of them. These fees will be reflected in the executed price to recover the gas costs.

The Reactor contract will call the Executor contract of the fillers to specify the order filling logic. Once the asset source is determined, the Executor contract will send the assets to the exchangers, and the Executor contract will extract funds from the exchanger’s address. Finally, the Reactor will check if the order conditions are met.

UniswapX does not specify how the fillers fill the orders of the exchangers: liquidity can come from on-chain liquidity pools such as Uniswap or other DEXs, off-chain liquidity, or other UniswapX orders. Multiple orders can be bundled into the same transaction, or other operations can be atomically executed on-chain.

3 Dutch Auction

In order to provide the best execution price to the exchangers, UniswapX uses a type of order called Dutch Auction, which is very similar to Dutch auction. The decaying feature of the Dutch auction creates a competitive market among the fillers to quickly find the best price for the exchangers, while retaining a small profit margin for themselves.

Regular limit orders are always executed at their limit price, while Dutch auctions are different. Their execution price depends on the time they are included in the block. The initial price of the order is a more favorable price for the exchangers than the current estimated market price – for example, if the current market price is 1 ETH = 1000 USDC, the initial price of a sell ETH order may be 1 ETH = 1050 USDC. The price of the order gradually decreases over time until it reaches the worst price the exchanger is willing to accept (e.g. 1 ETH = 995 USDC).

Once it becomes profitable, the fillers have an incentive to fill the orders as soon as possible. If the waiting time is too long, they may hand over the order to other fillers who are willing to accept lower profits.

4 Cross-Chain Orders

The UniswapX protocol can be extended to support cross-chain transactions, where the exchangers exchange the assets they hold on the source chain for the assets they need on the target chain.

Cross-chain UniswapX has the following advantages:

  • As long as there is an information bridge between two chains, UniswapX can provide fast exchanges between any two chains.

  • The exchange and bridging are combined into a single operation, and the exchangers do not need to directly connect with the bridge, maintain gas tokens on either chain, or wait for settlement delays.

  • UniswapX can provide near-instant withdrawals from L2 to its parent L1.

  • The exchangers can specify whether to receive native assets or standard assets on the target chain, instead of bridged assets. For example, ETH on the mainnet can be directly exchanged for AVAX on Avalanche.

  • Passive bridging risks are minimized. The exchangers do not bear any bridging risks when exchanging native assets, while the fillers only bear bridging risks when rebalancing assets between chains through bridging.

4.1 Simplified Cross-chain Orders

First, we will explain the simplified version of the UniswapX protocol for cross-chain orders, and then expand it to a more efficient optimistic version.

To initiate a cross-chain order, the swapper needs to sign an off-chain order, which includes the same parameters as a single-chain order, as well as the following additional parameters:

(1) A settlement oracle – a one-way oracle that can prove events happening on a target chain. This can be an official bridge between Rollup and its parent chain, a light client bridge, or a third-party bridge.

(2) Fill order deadline – the time by which the order must be executed on the target chain.

(3) Swapper’s deposit amount and swapper’s deposit asset – the deposit the swapper must make on the source chain.

(4) Proof deadline – the swapper must prove the completion of the order on the source chain before this time.

The parameters of the swapper’s deposit amount, fill order deadline, and proof deadline are beyond the scope of this article.

Similar to the single-chain implementation of the UniswapX protocol, the swapper’s order will propagate to the network of fillers, and fillers will compete to execute the order by submitting the order, the swapper’s funds, and the filler’s deposit to the reactor contract on the source chain.

Fillers execute the order by transferring the required assets from the swapper on the target chain. They first send the assets to the reactor contract, which then forwards the assets to the swapper’s address. The reactor contract on the target chain records the completion of the order before the specified deadline and conveys the message back to the reactor contract on the source chain through the settlement oracle, confirming the completion of the swapper’s order.

Then, the swapper’s assets, along with the deposit, are released to the filler on the source chain. If the filler fails to execute the order before the proof deadline, the swapper will receive the assets paid by the filler and the filler’s deposit from the reactor contract on the source chain.

Single-chain swap

Simplified cross-chain swap in UniswapX

4.2 Optimistic Cross-chain Orders

The use of certain settlement oracles may be too slow or expensive. For example, for fillers, executing a swap from one Rollup chain to another Rollup chain may be too expensive and take more than seven days, requiring at least one transaction on L1 before they can have custody of the swapper’s input tokens and their initial deposit.

The optimistic cross-chain protocol can mitigate these settlement latency issues, effectively building a fast and cost-effective bridge on top of any slow bridge.

The optimistic protocol includes the same parameters as the simplified protocol, as well as the following additional parameters:

(1) Challenge deposit amount and challenge deposit asset – the deposit the challenger must pay on the source chain.

(2) Challenge deadline – the deadline by which a challenger can challenge a fill order. This deadline must be before the proof deadline.

In the simplified version of the protocol, the way for the form filler to execute the order is as follows: request the order from the exchanger and submit the form filler’s margin to the source chain Reactor contract, and then transfer the assets to the exchanger’s address on the target chain through the reactor contract on the target chain. The reactor contract will record that the order has been executed before the deadline.

In the most optimistic scenario, the form filler completes the exchanger’s order on the target chain before the order deadline, and no one raises any questions about the order transaction before the questioning period ends. The form filler receives the exchanger’s funds and the form filler’s margin on the source chain.

In order to keep the form filler honest, anyone can challenge the form filler using the Reactor contract on the source chain after the order deadline and before the challenge deadline. If the form filler is challenged, the form filler must provide proof using a settlement oracle before the proof deadline. If the form filler can prove that they completed the order before the proof deadline, they will receive the challenger’s margin. If the form filler fails to provide valid proof, the form filler’s margin will be split between the challenger and the exchanger, and the exchanger’s funds will be returned to them on the source chain.

UniswapX Optimistic Cross-chain Exchange without Challenges
UniswapX Optimistic Cross-chain Exchange with Unsuccessful Challenge

5 Order Parameterization Scheme

The UniswapX protocol does not enforce a specific decay function. Similarly, the protocol does not specify a method for setting the initial Dutch auction order price, but it includes optional features to enable different mechanisms.

One method for parameterizing the initial price of a Dutch auction order is to select the form filler through an off-chain quoting system (RFQ: Request For Quote) vote. In order to incentivize this network of form fillers to provide the best possible prices, UniswapX allows an order to specify a form filler who has exclusive rights to fill the order for a brief period of time, after which the Dutch auction begins and any form filler can execute the order.

The RFQ system may benefit from a complementary compensation or penalty system to restrict abuse of the exclusive rights provided to the form fillers and ensure that the user experience of the exchangers is not harmed. Like order parameterization design, any such system is beyond the scope of the core protocol and this document[2].

6 Fees

The Uniswap governance can charge a maximum fee of 0.05% per UniswapX exchange, the same as the maximum fee for Uniswap v2. Governance must specify fees per trading pair and fees must be integer values in basis points. Governance must also activate fees per chain.

Interfaces and wallets may choose to charge additional unlimited fees for swaps submitted through their platforms.

7 Preliminary Work

The UniswapX protocol draws inspiration from many past and present protocols. This is not an exhaustive list.

7.1 Signed Orders

Many protocols have realized the use of actual transactions by having exchangers sign orders, including 0x [20] and Wyvern [21]. Some protocols, including CoW Swap [8] and dYdX [13], support batch signing of off-chain orders. Seaport [17] specifically supports off-chain signed orders with decay functions.

7.2 Dutch Auction

Dutch auctions have been widely used in DeFi, including NFT sales in Seaport, liquidation in MakerDAO [14] and Euler Protocol [11], and transactions in protocols like DutchX [15]. Stephane Gosselin also proposed using Dutch auctions as a method to determine transaction fees in EIP 2593 [10].

Recently, 1inch explored the combination of signed orders and Dutch auctions in its Fusion protocol [1].

7.3 Aggregators

Projects such as 1inch, 0x API, and LianGuairaswap [18] provide exchangers with smart order routing across various on-chain liquidity pools. Some of these projects also allow off-chain market makers to provide order improvements through an RFQ system.

7.4 Cross-Chain Dutch Auction

Summa [12] was the first to propose the idea of cross-chain transactions based on Dutch auctions using one-way message-passing oracles.

7.5 Optimistic Bridge

Optics [7], Nomad [16], and Across [2] all adopt anti-fraud settlement designs and provide trustless and fast token bridges.

8 Conclusion

UniswapX is a non-custodial and permissionless trading protocol that creates a competitive routing market among fillers using Dutch auctions and combines on-chain and off-chain liquidity. By structuring orders as Permit2 executable off-chain signatures, the protocol provides exchangers with a gas-free trading experience. UniswapX can also be extended to support cross-chain exchanges, allowing exchangers to bridge assets from L2 to their parent chain L1 almost instantly.

References

[1]

Blockchain in Translation Project: https://github.com/lbc-team/Pioneer

[2]

Tiny Bear: https://learnblockchain.cn/people/15

[3]

learnblockchain.cn/article…: https://learnblockchain.cn/article/6200

Like what you're reading? Subscribe to our top stories.

We will continue to update Gambling Chain; if you have any questions or suggestions, please contact us!

Follow us on Twitter, Facebook, YouTube, and TikTok.

Share:

Was this article helpful?

93 out of 132 found this helpful

Gambling Chain Logo
Industry
Digital Asset Investment
Location
Real world, Metaverse and Network.
Goals
Build Daos that bring Decentralized finance to more and more persons Who love Web3.
Type
Website and other Media Daos

Products used

GC Wallet

Send targeted currencies to the right people at the right time.