Written by Arjun Chand, LI.FI
Introduction
Since Uniswap launched in 2018, it has executed over 300 million trades and processed more than $1.5 trillion in total trading volume.
Over the years, Uniswap has become the hub for decentralized trading in crypto. V1 was an innovation in-and-of-itself and led to automated market making (AMM) as the backbone of DeFi. V2 and V3 were released in the following years, with V2 offering new features and optimizations to the AMM design space and V3 enabling liquidity providers (LPs) to play around with price ranges and fee tiers. In 2023, there have been two more releases from Uniswap Labs:
- In June 2023, Uniswap Labs released draft code for v4 introducing the concept of hooks, which enables anyone to create liquidity pools on Uniswap with customized features (like dynamic fees, onchain limit orders, etc.).
- In July 2023, Uniswap Labs introduced UniswapX as an opt-in beta. UniswapX is an auction based protocol for finding the best price for user’s trade across AMMs and other onchain and offchain liquidity sources.
Uniswap v4 and UniswapX have many features and design elements that may potentially change the trading landscape in crypto.
Since v4 has yet to go live, we will specifically look into why Uniswap decided to launch UniswapX, how UniswapX works (w/ a special detours on intents and Dutch auctions), and analyze what UniswapX might mean for the future of trading assets in crypto.
Let’s dive in!
The Origins of UniswapX
Liquidity in DeFi is currently spread across a variety of on and off-chain venues:
- decentralized exchanges (DEXs)
- different versions of DEXs (Uniswap v1-v4)
- centralized exchanges (Binance, Coinbase)
- cross-chain liquidity networks (Across, Stargate, Thorchain, cBridge)
- locked in native bridges of chains (Polygon PoS Bridge, Arbitrum Native Bridge)
- stablecoin pools (Curve, MakerDAO)
- DeFi applications (Yearn, Aave)
Additionally, these liquidity pools are spread across chains, rollups, and rollApp ecosystems.
UnswapX attempts to overcome the challenge of inefficient routing across fragmented liquidity pools in DeFi. To do so, UniswapX trades liquidity pools popularized by AMMs for a network of third-party entities called ‘Fillers’ (combination of MEV searchers, market makers, and other onchain agents) that compete with other Fillers in a Dutch auction to fill swaps at the best price.
According to Paradigm’s Dan Robinson (who also moonlights as a researcher for UniswapX), a system like UniswapX is important for the future of DeFi.
UniswapX theoretically finds a sustainable balance in the profitability dynamic between users and liquidity providers (LPs) and does not benefit one more than the other –especially at the cost of the other. Put simply, UniswapX focuses on price improvement for users by offering them the best execution for their trades and finds ways to reduce the value lost to factors like MEV, which often leave LPs in an unprofitable position.
As a system, UniswapX strives for the following:
- Ensuring that users get the best price for their trades by reducing the value lost to MEV strategies (like sandwich attacks), poor execution (that leads to slippage), or opportunity cost (in terms of other liquidity sources that could offer a better price).
- Reducing the value loss experienced by passive LPs due to arbitrage and MEV in the form of impermanent loss, front-running, sandwich attacks, among others, by providing a platform for active capital management.
- Gas efficiency to reduce the gas costs that are being paid by both users and LPs.
UniswapX attempts to achieve these objectives predominantly by 1) moving towards a system where users express their trades as intents instead of transactions and 2) ensuring that users get the best price for trades through a Dutch auction run via UniswapX Fillers.
So, as promised, let’s detour and explore what UniswapX is doing with intents and a Dutch auction design in more detail.
Intents Over Transactions — Understanding UniswapX’s Design Principle
UniswapX adopts an intent based approach instead of using predetermined transaction paths for executing trades. Here’s how it works:
On the user’s end, the trading process appears largely the same. The user interacts with the same Uniswap frontend as they would for their regular trade. However, under the hood, the process to execute the trades is different.
Instead of users approving quotes for an exchange transaction, they sign a specific message with the details of their trade (similar to a limit order) which are relayed to UniswapX’s Filler network which effectively formulates it into a transaction, and ensures its addition to the blockchain.
For example, a user might say they want to trade 1,000 DAI for .5487 ETH. In the old days, on Uniswap’s frontend, a signature would require that a transaction is executed through a DAI/ETH liquidity pool. With UniswapX, however, the user’s signature on the front-end is passed to a group of Fillers with the prerogative to find the best price from a variety of sources (CEXs, Uniswap pools, DEX aggregators, etc.).
Dutch Auctions — How UniswapX Optimizes for Best Price
The Dutch auction design adopted by UniswapX is just as important to understand as intents. The nature of the auction ensures that users get the best price for their trades. Here’s how:
- Dutch auctions have a dynamic model for price discovery. The auction starts with a high asking price for an asset, and the price keeps going lower until one of the bidders (Fillers) accepts to fulfil the trade.
- The decaying price leads to a competitive auction among Fillers and they are incentivized to fill the order as soon as possible to win the auction.
- The price continues to decay until an agreed upon floor price is reached.
The key assumption in Dutch auction’s game theory mechanics is that any Filler will be incentivized to fulfil the trade order as soon as it becomes profitable, compelling them to act quickly and execute it. In return, the users get the best price for their trade order in the fastest possible time.
With those two detours done, let’s get back on track to analyzing UniswapX’s design and transaction lifecycle when the protocol is out of the beta phase.
UniswapX Architecture Design
UniswapX’s architecture borrows, combines, and incorporates several design concepts that previously gave protocols a competitive edge, including:
- Limit orders popularized by 0x,
- Transaction batching, coincidence of wants (CoW), ring trades executed by Solvers (Fillers in UniswapX) unique by CoW Protocol,
- Dutch auctions and gasless trades by 1inch Fusion, and
- Optimistic cross-chain trades similar to Across, Connext, and DLN.
UniswapX’s design enables it to offer the following benefits:
- Users get the best price — Dutch auction based trading is time bound and allows decentralized price discovery. Fillers are incentivised to compete against each other and give users the best possible price for their trade as soon as possible in order to win the auction.
- Access to a wider variety of liquidity — Fillers can route orders through any onchain and offchain liquidity (or a combination of them) in order to give users the best price for their trade.
- Protects users from MEV and returns surplus — Since orders are executed by Fillers, users are protected against negative forms of MEV like sandwich attacks and are less vulnerable to frontrunning. Moreover, any positive slippage is given back to the swappers in the form of price improvement.
- Gas free swapping — Users can pay transaction fees in the token being swapped and thus are not required to hold native assets. Moreover, users never pay gas costs for failed trades.
- Cross-chain trading — Users can swap native assets between chains in the future through UniswapX.
Before diving into the lifecycle of an intent on UniswapX, let’s familiarise ourselves with the key roles and components of UniswapX’s architecture:
- Swappers — users initiating trades on UniswapX.
- Fillers — entities competing to fill orders at the best price.
- Quoters — permissioned set of Fillers (in the beta period) that participate in order parameterizing process and are given execution priority to fulfil trades they submit winning quotes for.
- Reactor contract — checks that the execution of a trade matches the users’ expected parameters (trades that don’t are reverted).
- Executor contract — handles order filling and is responsible for sending funds to the swapper and receiving funds from the swapper’s address.
Now, before we dive into transaction flows, there are a few qualifiers that must be mentioned, as UniswapX is still in a beta phase. Because of this, there are certain limitations and design variations in how UniswapX actually works compared to what the whitepaper says or the long-term roadmap plans:
- UniswapX is only available on Ethereum (Uniswap front-end supports 8 chains).
- The type of orders it can offer users better price execution compared to Uniswap v3 or v3 liquidity pools or compared to other DEXs and orderflow auction based protocols like CoWSwap and 1inch Fusion is limited.
- The current implementation uses a permissioned RFQ system. Here, ‘Quoters’ approved by Uniswap Labs provide users an exchange rate for their order. They are only able to do so if they offer a better rate than v3 or v2 liquidity pools. The Quoters are given execution priority for a set period of time in which they can fulfil the order. If the Quoter isn’t able to execute the order, a Dutch auction begins where any Filler can execute the order. Thus, one key limitation in the beta phase of UniswapX is that the game theory benefits aren’t fully realized as a Dutch auction where users can set parameters like the maximum/minimum output amount, decaying function, etc., isn’t conducted.
UniswapX Intent to Transaction Lifecycle
There are three different types of intents UniswapX can facilitate: same-chain swaps, cross-chain swaps, and fast cross-chain swaps:
- Same-chain swaps — users trade one token for another, both on the same blockchain. The interaction between users and Fillers is instant, i.e., when the user intent is fulfilled, the filler gets the users’ assets at the same time.
- Cross-Chain swaps — users trade a token on one blockchain for a token on a different blockchain. Settlement oracles such as messaging bridges are used to confirm the correct execution of the trade. The interaction between the users and Fillers is slow, i.e., they need to wait for the protocol to verify that the user received the desired tokens using the settlement oracle.
- Fast cross-chain swaps — similar to cross-chain swaps but instead of waiting for every trade to be confirmed by the settlement oracle. These trades are optimistically assumed to be correct unless someone challenges them in which case, the settlement oracle is used to verify the correctness of the trade. The interaction between the user and Fillers is instant in cases when no entity challenges the trade and slow when trades are challenged and there is a need to wait for the protocol to verify that the user received the desired tokens using the settlement oracle.
Lifecycle of a Swap Intent
A same-chain swap on UniswapX is a three step process:
- Intent Signature
Swappers express their intent by specifying the details of a trade and signing an order.
For example, let’s say the user wants to sell 1 ETH for USDC @ current price of ETH = 1000 USDC.
In this case, the Swapper signs an order with the following details:
(a) An input token — ETH
(b) An output token — USDC
© An input (output) amount — 1 ETH
(e) A starting output (input) amount — 1050 USDC per ETH
(f) A minimum output (input) amount — 995 USDC per ETH
(g) A decay function — This could be linear decay (constant and uniform) over a specified time.
(h) A claim deadline — This could be a specific date and time by which the auction must be completed.
(i) Authorization for the UniswapX reactor contract to spend tokens on their behalf — Signs order
Note: In the beta phase of UniswapX, the user doesn’t have the flexibility to set all of the different parameters mentioned above. The user only enters the input token and amount while the Quoters determine the minimum output amount and have exclusive execution rights for a given period of time.
Dutch Auction
Once the user signs the order, a Dutch auction is kicked off to decide which Filler gets to fulfil the order. Here, Fillers compete with each other to fill this order at the best price in the least amount of time as there is a risk of losing the order (as explained above).
The auction starts at 1050 USDC per ETH, decays over time until it becomes profitable for a Filler or hits 995 USDC per ETH.
Let’s assume that a Filler wins the auction by filling the order at 1005 USDC per ETH.
Execution and Verification
2) The winning Filler submits the orders to the reactor contract (and pays gas fees).
3a) Reactor contract calls the Filler’s Executor Contract — specifying the fill logic.
3b) Executor contract pulls the input tokens from the swapper’s address.
3c) Executor contract sends the output tokens to the swapper.
4) Reactor contract checks that the trade matches the expected parameters.
Lifecycle of a Cross-Chain Swap Intent
For a cross-chain swap, a swapper needs to sign an order that includes the following parameters in addition to the same chain swap intent:
- Settlement oracle — an entity that can attest that an event occurred on some destination chain (can be canonical bridges, light client bridges, third party bridges).
- Fill deadline — the time within which the trade must be completed.
- Filler bond amount and bond asset — the bond that the filler must deposit on the origin chain
- A proof deadline — the time before which the filler must prove they have completed the trade on the origin chain.
Here’s how a cross-chain swap intent is fulfilled by UniswapX:
1. Intent Signature — Similar to same chain swaps, a swapper must input order details and sign them.
2a. A Dutch auction is conducted and the winning Filler claims the order and deposits the Filler bond.
2b. Reactor contract pulls the swapper’s input tokens — user’s input tokens are now locked in the reactor contract.
Execution and Same-Chain Verification
3a. Filler sends the desired assets to the Reactor contract on the destination chain.
3b. The reactor contract transfers the funds deposited by the Filler to the Swapper’s address on the destination chain.
The Reactor contract on the destination chain records that the order was filled before the deadline.
Cross-Chain Verification
A message is relayed through the settlement oracle (messaging bridge) to the Reactor contract on the origin chain confirming that the order has been filled successfully.
3c. The Reactor contract on the origin chain sends the a) swapper’s assets and b) Filler bond to the Filler.
In case the order isn’t fulfilled within the deadline, the swapper gets their funds back on the origin chain and the Filler’s bond from the Reactor contract as compensation for the failed order.
Lifecycle of a Fast Cross-Chain Swap Intent
Typically, the canonical bridges of the rollups are used as the settlement oracle. However, these bridges are slow and expensive to use. For example, if a Filler is filling orders across Optimism and Arbitrum and uses a canonical bridge for confirmation of the order fulfilment, it will take the native bridge seven days and high gas fees.
To overcome these challenges, a fast cross-chain iteration of UniswapX is required. Here, UniswapX adopts an optimistic verification model, similar to what platforms like Across, Connext, and Hop launched with over the last few years. In this type of optimistic verification system, trades are assumed to be executed correctly unless challenged by a watcher.
For a fast cross-chain swap, a swapper needs to sign an order that includes the following parameters in addition to the cross-chain same chain swap intent:
- Challenge bond amount and challenge bond asset — the amount that a challenger must post as a bond on the origin chain (Challengers are similar to watchers in a bridge who can prove fraud on the origin chain).
- Challenge deadline — the deadline before which a challenger can challenge a fill. This must be before the proof deadline.
Here’s how a fast cross-chain swap intent that is optimistically verified is fulfilled by UniswapX:
1. Intent Signature — The swapper inputs the order details and signs it.
Dutch Auction
2a. A Dutch auction is conducted and the winning Filler claims the order and deposits the Filler bond.
2b. Reactor contract pulls the swapper’s input tokens — user’s input tokens are now locked in the reactor contract.
Execution and Same-Chain Verification
3a. Filler sends the desired assets to the Reactor contract on the destination chain.
3b. The reactor contract transfers the funds deposited by the Filler to the Swapper’s address on the destination chain.
The Reactor contract on the destination chain records that the order was filled before the deadline.
4. Challenge Period — A challenge period begins. During this time, anyone can challenge the Filler before the challenge deadline expires.
5. Cross-Chain Verification and Possible Penalty
In the optimistic case, no one challenges the fill and the Filler receives a) the swapper’s funds and b) Filler bond on the origin chain.
However, if anyone challenges the Filler using the reactor contract on the origin chain, the Filler has to provide a proof before the Proof deadline using the settlement oracle (aka the messaging bridge).
If the Filler proves they filled the order correctly, they get the Challenger’s bond.
If the Filler fails to prove the order, the Filler’s bond is split between the Challenger and the Swapper + the Swapper gets their funds back on the origin chain.
Trust Assumptions, Trade-Offs & Potential Impact on Trading in DeFi
UniswapX is currently in beta and is gradually being rolled out to the public. As such, this article did not have a section explaining “Details of UniswapX’s Filler Network” because no such details exist yet. However, this is where the main concern over the viability of UniswapX as a long-term solution is housed.
Based on the whitepaper, UniswapX’s Filler network is promised to become more permissionless, fostering a competitive, decentralized marketplace of Fillers who compete for price discovery to secure the best price for user orders. However, in its existing iteration in the beta period, UniswapX operates under certain trust assumptions that can influence the efficiency of trading activities across the DeFi ecosystem. Here’s a few trust assumptions that LI.FI is closely monitoring:
Permissioned Quoters & Fillers could Collude to Extract Value or Censor Users
In the current beta phase, Quoters are responsible for parameterizing user orders. If their quote is the most competitive in the RFQ (Request for Quote) process, they also become Fillers. However, at present, only those approved by Uniswap Labs can provide quotes, making the order flow auction a permissioned process. This means only authorized entities can participate in UniswapX’s auctions to fulfil user orders.
In the future, Uniswap Labs intends to allow any entity in the DeFi ecosystem to act as a Filler without needing permission. This change would mean honest Fillers could potentially outcompete and surpass malicious Quoters by offering better prices, mitigating risks like Quoter collusion. The approach to ensuring honest behavior from Fillers can be analogized to the way validators operate in bridges and/or blockchains. It will be interesting to observe how UniswapX designs the system to disincentivize Fillers from colluding. Some ideas commonly seen across DeFi include penalty systems, such as slashing.
That being said, in the current filler network setup, “rent extraction” might occur if entities controlling the permissioned order flow auctions (OFAs) collude to use their control to extract value from the users or simply refuse to fulfil (censor) certain intents. For example, a centralized set of fillers might decide to omit routing through liquidity pools that have been touched by OFAC sanctioned wallets — even if the price for swapping through that pool is cheapest.This problem would be less prevalent in a permissionless system, as a profit-maximizing Filler would pursue the most advantageous trades without such restrictions.
It’s important to note that the described scenario of rent extraction is improbable because of two reasons:
- During the beta phase, Uniswap Labs will work closely with reputable organizations who will act as Quoters (and thus Fillers), reducing the likelihood of collusion and malicious activities.
- If there is even one honest Filler consistently offering users the best price, it can significantly reduce the risk of rent extraction.
As for censorship, it remains to be seen. Uniswap Labs has previously blocked access to certain tokens and currently screens OFAC sanctioned wallet addresses (along with addresses that TRM flags) from the Uniswap.org frontend. What requirements Uniswap Labs will have for Quoters and Fillers regarding screening or token access is not clear at the moment, but it is something we are keeping a close eye on.
Quoters and Fillers Could Misuse Order Flow Information Asymmetry
On UniswapX, when users set up their trades, they share details about it, just like on any exchange. Quoters then offer them a price. The Quoter with the best price gets a brief window where they have exclusive rights to decide if they want to fulfil the trade. If they can’t, Fillers step in through an auction. This brief window is often referred to as the ‘last look’ advantage, where where winning Quoters could misuse their right to fulfil trades. This last look could give them insights into market demand — which they could then use to adjust trading strategies (especially when the order flow information is available to a permissioned set of Fillers and is not public information).
A Filler, for instance, could use the order information to trade ahead or against the user in a marketplace outside UniswapX, thereby potentially generating profits at the expense of users and other honest Fillers in the UniswapX platform.
Additionally, Fillers might also be able to better predict market movements based on the information revealed during the auction process, thus gaining a competitive advantage. For example, they could raise their asking price for the asset in other venues, or purchase the asset in a different market with the anticipation that demand, and hence price, will continue to rise.
This scenario could lead to an unfair trading environment across the DeFi ecosystem, especially given the large volume flows that are generated on the Uniswap front-end.
Moreover, if Fillers on UniswapX begin to filter trades, selecting only the non-toxic, profitable flows for execution, it could impact the profitability of passive LPs, particularly in major pools like ETH/USDC, as they are only left with the toxic flow (i.e., order flow that’s likely to lead to losses as it’s been generated by users who are exploiting market inefficiencies).
It will be interesting to see the rules that UniswapX will establish governing trades and how they tackle the issue of information asymmetry. One way that could be interesting is to have Fillers stake and lock UNI tokens in order to access order flow (similar to 1inch Fusion). In this way, UNI token holders might see benefits in price action and social + economic slashing mechanisms could be put into place to dissuade Fillers for maliciously using order flow.
In the future, with the transition to a permissionless role for Quoters and Fillers, many of the aforementioned concerns will likely be mitigated. UniswapX’s order flow will then be open to competition from various Fillers within the DeFi ecosystem, resulting in a more robust price discovery process that can secure the best prices for user orders.
Potential Inefficiencies in UniswapX’s Design for Fillers
UniswapX’s design to fulfil cross-chain intents involves a process where Fillers instantly provide users with desired tokens on the destination chain and subsequently receive user’s tokens on the origin chain. While this method offers users fast and cheap cross-chain swaps, it might not be as capital efficient for Fillers. This inefficiency arises from a few key points:
- When a cross-chain trade is challenged, its accurate execution is verified using a settlement oracle. If a trade is from Arbitrum to Ethereum, for instance, the Filler might need to wait up to 7 days for user funds on Ethereum if the verification process is taking place via a rollup bridge. Alternatively, if a third-party messaging bridge like LayerZero or Axelar is used for quicker verification, the Filler’s funds’ security is then reliant on that bridge’s security, which could vary significantly depending on the bridge.
It’s important to note that Uniswap has typically relied on canonical bridges between rollups and Ethereum due to their stronger security guarantees. For instance, for multi-chain governance. However, due to their limited connectivity, Uniswap has, in the past, turned to third-party bridges for messaging between chains. We can expect UniswapX to follow a similar trend in bridge usage.
- As Fillers receive the user’s funds on the origin chain, they have to bear the costs of rebalancing their inventory on different chains. This rebalancing could be both a resource intensive and time consuming activity for Fillers as in order to fulfil orders on different chains, they will end up with funds on all of them and will actively have to rebalance depending on the flow of cross-chain swaps on a hourly/daily/weekly basis. This cost is lesser for large-scale Fillers who can efficiently rebalance through centralized exchanges (CEXs) and over-the-counter (OTC) desks. This situation can give an edge to Fillers with bigger inventories, possibly restricting the variety of Fillers participating in UniswapX’s orderflow auction.
These challenges are not unique to UniswapX and have been faced by liquidity bridges in the past (and present). To overcome such challenges, platforms like Connext and Across have adopted different models:
- Across Fillers (aka Relayers) can get repaid with the user’s funds on any chain (for a small fee)
- Connext allows Fillers (aka Routers) to be repaid on the destination chain itself.
However, each of these models comes with its own set of limitations. Newer solutions, such as the xERC20 token standard or LayerZero’s OFT (which facilitates token transfers across chains without liquidity pools and with zero slippage), can be explored to enable Fillers to be reimbursed on any desired chain without much hassle.