UniswapX — Dutch auction based routing protocol

UniswapX — Dutch auction based routing protocol

Heard about UniswapX and have no idea what it is ? We’ll get a brief understanding of how everything works in UniswapX. To understand UniswapX we must first understand what Dutch auction is.

Dutch auction

Dutch auction is the type of auction in which a seller starts with a very high price, incrementally lowering the price until buyer places a bid. In the above example seller starts off with 100,000$ for a tulip,then lowers the price until the buyer offers to buy the tulip for 20,000$, then the auction is closed. UniswapX also uses similar mechanism for its routing protocol.

As i stated in the title above UniswapX is a dutch auction based routing protocol. But what is routing exactly ? Routing refers to the process of finding the optimal path to exchange one token for another through a series of interconnected liquidity pools.For example, if you want to exchange Token A for Token D, but there is no direct liquidity pool for this pair, the routing algorithm will look for alternative paths. It might go through Token A → Token B → Token C → Token D, using intermediate liquidity pools to complete the trade step by step.

Now, we get into working component of UniswapX routing protocol.

Routing architecture (Non technical)

Routing architecture (Technical)

There are 5 main components involved :

  1. Swapper

  2. Fillers

  3. Permit2

  4. Reactor

  5. Executor

Initially, the swapper will approve Permit2 contract for token spending. Permit2 is a token approval contract that can safely share and manage token approvals across different smart contracts. As more projects integrate with Permit2, token approvals can be standardized across all applications.

Permit2 workflow

Lets take Vitalik as a swapper. Now assume the Vitalik wants to sell 1ETH for USDC. Vitalik will request the potential buyers also known as fillers. Let’s assume the fillers to be BOB, Alice and Daniel. Bob offers to buy for 1000 USDC, Alice for 999 USDC, Daniel for 998 USDC. Vitalik can also use Uniswap v3 to swap 1 ETH for 997 USDC.

Say, Vitalik accepts BOB’s qoute. Then, Vitalik will sign an order. This order includes an input token,an output token, a maximum value (set by Bob’s quote of 1,000 USDC) and minimum value of 997 USDC (set by the Uniswap smart order router API) and permit2 signature for token spending.

Fillers sends the order to the reactor contract, while doing so fillers will pay for the gas on behalf of the Vitalik. The gas fees will be factored into the cost by the fillers. Therefore, Vitalik will not need to pay any gas for the swap, Vitalik will only have to pay gas for the permit2 approval. This is the reason why UniswapX provides gas a free experience not a free gas experience.

Reactor are set of contracts that are responsible for validating whether the conditions of the orders are met or not, pulls input tokens from the swapper(Vitalik) and sends them to executor contracts for execution. It also verifies whether the order was successfully fulfilled or not. Executor are filler contracts that receives Vitalik’s token and fills the order by routing through a variety of on-chain liquidity venues like Uniswap Protocol, Sushiswap and so on which would benefit the filler. After successful swap Vitalik would recieve the ouput tokens from the Executor and the process would be verified by the reactors.

In summary, the Vitalik approves for token approval(Permit2) -> Vitalik signs an order with permit2 signature → Bob(Filler) routes the order with help of reactors and executor. So UniswapX outsources the routing complexity to a network of fillers. Seems not too complex right ?

Yeah, but where does the dutch auction come into play in the process? For that, let’s assume that Bob decided not to go forward and rescind the order. Vitalik does not have to resubmit another order with new signatures. His orders will be updated after each block with a new lower price. In this case 1 ETH for 999 USDC. After another block the order would be updated as 1ETH for 998 USDC, Seeing this Daniel realizes that he can fill the order and fills the order for 998 USDC. So, Vitalik gets 998 USDC for 1 ETH which is 1 extra USDC, as compared to 997 USDC he would have gotten from normal Uniswap trade. In this way, the pricing becomes more efficient for the users.

In addition to that this routing model will also prevent bot from frontrunning and sandwiching your trades.

MEV protection

Usually sandwich attack happens when a MEV bot sees your buy transaction in a memepool and bribes the miner to place his transaction before yours. Your transaction goes through with higher buy price, then the bot will sell at the higher price, essentially profiting from the trade. How profitable is this ? Well you could as this guy :

Jared from subway

In case of UniswapX, the fillers will use private relay to send the routing transaction so that no MEV bot sees your trade going by. Therfore, MEV protection.

Cross chain routing :

Cross Chain Swap

The workflow for cross chain routing :

1 . Offchain Order: Swappers sign an offchain order that includes the regular trade parameters, like tokens and amounts, along with additional details:

— Settlement Oracle: An oracle that confirms events on the destination chain (e.g., a bridge between different chains).

— Fill Deadline: The time limit for executing the order on the destination chain

. — Filler Bond: The amount and asset that the filler (order executor) must deposit on the original chain.

— Proof Deadline: The deadline for the filler to provide proof of execution on the original chain.

2. Order Execution: The swapper’s order is shared with a network of fillers who compete to execute it. Fillers submit the order, along with the swapper’s funds and a filler bond, to the reactor contract on the original chain.

3. Filling the Order: The filler transfers the swapper’s desired assets to the destination chain. The assets are sent to the destination chain’s reactor contract, which then forwards them to the swapper’s address. The destination chain’s reactor contract confirms the order fulfillment and relays the information back to the original chain’s reactor contract through the settlement oracle.

4. Asset Release: Once the fulfillment is confirmed, the swapper’s assets and the filler’s bond are released to the filler on the original chain. If the filler fails to execute the order before the proof deadline, the swapper receives both their input assets and the filler’s bond from the original chain’s reactor contract.

For more details follow the whitepaper: https://uniswap.org/whitepaper-uniswapx.pdf