UniswapX Protocol White Paper

This article is machine translated
Show original

Summary

The UniswapX protocol is a Dutch auction-based non-custodial exchange protocol implemented for the Ethereum Virtual Machine.

UniswapX aggregates on-chain and off-chain liquidity, internalizes MEV into the protocol in the form of continuously optimizing prices, provides users with gas-free exchange, and is scalable to support cross-chain transactions.

1 Introduction

We introduce the design of a Dutch auction-based decentralized exchange protocol that uses off-chain signed orders to be executed and settled on-chain.

The UniswapX protocol has several advantages:

  • UniswapX outsources routing and batch processing to a set of permissionless Fillers. These order fillers can route orders to a combination of on-chain and off-chain liquidity, ensuring that converters’ orders are always optimally executed.

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

  • Compared to swaps on the Uniswap protocol, swappers don't pay fees for failed trades, and swaps that are settled in batches and/or filled directly from a filler's inventory are cheaper.

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

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

The following sections provide an in-depth explanation of these changes and the architecture that facilitates them.

2 signed orders

When redeemers transact through 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. Converters then submit transactions to a mempool (whether public or private), which are then received and included in blocks by block builders.

UniswapX leverages Permit2 [19], a token authorization contract that introduces signature-based authorization and transfer for any ERC20 token. In addition, UniswapX also uses the Reactor contract for on-chain settlement. The Reactor contract is responsible for checking whether the execution of the transaction meets the parameters expected by the user, and canceling the transaction that does not meet the parameters. Converters must first authorize the Permit2 contract. Then, the exchangers who trade through the UniswapX protocol do not need to create and submit transactions themselves, but specify in front of the transaction order:

(1) Input tokens (i.e. payment tokens)

(2) One output token (i.e. get token)

(3) Input (output) volume

(4) A starting output (input) amount

(5) Minimum output (input) volume

(6) A decay function

(7) Exchange period

(8) Authorize the UniswapX reactor contract to use tokens on its behalf

These orders are collectively received by MEV searchers, market makers, and/or other on-chain agents (collectively referred to as fillers) and send them to the Reactor contract. By submitting the exchanger's order on-chain, the order filler pays the gas fee on their behalf. These fees will be reflected in the execution price in order to recover the Gas cost.

The Reactor contract will call the Executor contract (executor) of the form-filler to specify the form-filling logic. Once the asset source is determined, the Executor contract will send the asset to the changer, and the Executor contract will withdraw funds from the changer's address. Finally, Reactor checks that the order conditions are met.

UniswapX does not specify how the order filler fills the order of the exchanger: 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, and other operations can be performed atomically on-chain.

3 dutch orders

In order to offer best execution prices to converters, UniswapX uses an order type that we call a Dutch order, which is very similar to a Dutch auction. The decaying nature of the Dutch order creates a competitive market among order-fillers to find the best price for the changer as quickly as possible, while preserving some razor-thin profit margins for themselves.

Unlike a normal limit order, which is always executed at its limit price, a Dutch order is executed at a price determined by when it was included in a block. The starting price of the order is a price that is more favorable to the changer than the current estimated market price - for example, if the current market price is 1 ETH = 1000 USDC, the starting price of a sell ETH order might be 1 ETH = 1050 USDC. The price of this order will gradually decrease over time until it reaches the worst price the convertor is willing to accept (for example, 1 ETH = 995 USDC).

Once it is profitable, the form filler has an incentive to fill the form as soon as possible. If they wait too long, they risk giving up the order to other fillers who are willing to accept a lower profit.

4 Cross-chain orders

The UniswapX protocol can be extended to support cross-chain transactions, that is, the exchanger exchanges the assets held on the source chain for the required assets on the target chain.

Cross-chain UniswapX has the following advantages:

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

  • Exchange and bridge are merged into a single operation, and the exchanger does not need to directly connect with the bridge, maintain Gas tokens on either chain, or wait for settlement delays.

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

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

  • Passive bridging risks are minimized. Converters do not take any bridging risk when exchanging native assets, whereas fillers only take bridging risk when rebalancing assets between chains via bridging.

4.1 Simplified cross-chain order

First, we will explain a simplified version of the UniswapX protocol cross-chain, before extending it to a more efficient optimistic version.

In order to initiate a cross-chain order, a convertor needs to sign an off-chain order, which includes the same parameters as a single-chain order, plus the following additional parameters:

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

(2) Order filling deadline - the time when the order must be executed on the target chain

(3) Filler's margin amount and filler's margin asset - the margin that the filler must deposit on the source chain

(4) Proof cut-off time - the order filler must prove on the source chain that he has completed the order before this time

Parameters such as the deposit amount of the form-filler, the deadline for filling the form, and the deadline for proof are beyond the scope of this article.

Like the single-chain implementation of the UniswapX protocol, the order from the changer will be propagated to the form-filler network, and the form-filler submits the order to the reactor contract of the source chain, the fund of the changer and the deposit of the form-filler to compete for the execution of the order.

Fillers execute orders by transferring the assets required by the changer on the target chain. They first send the assets to the reactor contract, and the reactor contract forwards the assets to the exchanger's address. The reactor contract on the target chain will record that the order has been completed before the specified deadline, and pass the message back to the reactor contract on the source chain through the settlement oracle to confirm that the order of the exchanger has been completed.

Then, the convertor's assets are released to the form-filler on the source chain along with the security deposit. If the order filler does not execute the order before the proof deadline, the changer will receive the assets it paid and the order filler's deposit from the reactor contract on the source chain.

Single Chain Exchange

UniswapX simplified cross-chain swap

4.2 Optimistic cross-chain orders

Some settlement oracles may be too slow or expensive to use. For example, performing a swap from one Rollup chain to another could be too expensive for a filler, take more than seven days, and require at least one transaction on L1 before they are allowed to take custody of a converter's input tokens and their initial deposit.

An optimistic cross-chain protocol can alleviate these settlement delay issues, effectively building a fast and cheap bridge on top of any slow bridge.

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

(1) Challenge Deposit Amount and Challenge Deposit Assets--the deposit amount that the challenger must pay on the source chain.

(2) Challenge Deadline - The deadline for the challenger to challenge the form. This period must be before the certification deadline.

In the simplified version of the agreement, the order filler executes the order by requesting the order from the exchanger, submitting the filler’s deposit to the Reactor contract on the source chain, and then transferring the assets to the address of the exchanger on the target chain through the reactor contract on the target chain. The reactor contract will record that the order has been filled before the deadline.

In the most optimistic case, the filler completes the order of the convertor on the target chain before the deadline for filling the order, and no one questions the order transaction before the end of the challenge period, and the filler receives the money from the changer and its fill-in deposit on the source chain.

In order to keep the fillers honest, anyone can use the Reactor contract on the source chain to challenge the fillers after the fill deadline and before the challenge deadline. If the form filler is challenged, the form filler must provide proof using the settlement oracle before the proof deadline. If the filler can prove that they completed the order by the proof deadline, then they will receive the challenger's bond. If the form filler fails to provide a valid proof, the form filler's deposit will be split equally between the challenger and the changer, and the changer's funds will be returned to them on the source chain.

UniswapX optimistic cross-chain exchange, no challenges
UniswapX Optimistic Cross-chain Unsuccessful Challenge

5 Order Parameterization Scheme

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

One way to parameterize the starting price of Dutch-style orders is to vote for the order fillers through the off-chain RFQ (Request For Quote) system. To incentivize this network of fillers to offer the best possible prices, UniswapX allows orders to specify a filler who has the exclusive right to fill orders for a short period of time, after which the Dutch auction begins and any filler can execute the order.

RFQ systems may benefit from an accompanying system of compensation or penalties to limit abuse of the freedom of choice afforded to fillers and ensure that the user experience for redeemers is not compromised. As with order parametric design, any such system is outside the scope of the core protocol and this paper [2].

6 fees

Uniswap governance can charge a fee of up to 0.05% per UniswapX swap, the same maximum fee as Uniswap v2. Governance must specify a fee per trading pair, and the fee must be an integer value in pips. Governance must also activate fees on-chain.

Interfaces and wallets can choose to charge additional uncapped fees for swaps submitted through their platforms.

7 Preliminary work

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

7.1 Signature order

A number of protocols have recognized 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 off-chain orders. Seaport [17] specifically supports off-chain signed orders with a decay function.

7.2 Dutch auction

Dutch auctions have numerous applications in DeFi, including NFT sales in Seaport, liquidations in MakerDAO [14] and Euler Protocol [11], and transactions in protocols such as DutchX [15]. Stephane Gosselin also proposed in EIP 2593 the use of a Dutch auction as a method for determining transaction fees [10].

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

7.3 Aggregators

Projects [18] including 1inch, 0x API, and Paraswap provide changers with smart order routing capabilities across various on-chain liquidity pools. Some of these projects also allow off-chain market makers to offer order improvement through the RFQ system.

7.4 Cross-chain Dutch auction

Summa [12] pioneered the idea of ​​Dutch auction-based cross-chain transactions via one-way message passing oracles.

7.5 Optimistic Bridge

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

8 Conclusion

UniswapX is a custody-free and permissionless exchange protocol that uses a Dutch auction to create a competitive routing market among order fillers and leverages a combination of on-chain and off-chain liquidity. By structuring orders into Permit2 executable off-chain signatures, the protocol provides a gas-free transaction experience for redeemers. UniswapX can also be extended to support cross-chain swaps, allowing redeemers to bridge assets from L2 to their parent chain L1 in near-instantaneity.

References

[1]

Pioneer 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

Source
Disclaimer: The content above is only the author's opinion which does not represent any position of Followin, and is not intended as, and shall not be understood or construed as, investment advice from Followin.
Like
Add to Favorites
Comments