A DEX Protocol with Best-in-Class Execution

Conor McMenamin
4 min readApr 4, 2022

--

This article focuses on the FairTraDEX protocol, expanding on this introductory article by describing the realities of the MEV landscape, existing attempts to prevent MEV in decentralised exchange (DEX) protocols, and how FairTraDEX stands alone in its guarantees of best execution.

The MEV problem in DEX protocols is a big one. On Ethereum alone, clients and liquidity providers have been front-run, back-run, and sandwiched for nearly $500m since 2021, according to Flashbots. If we extrapolate this to other blockchains/MEV which has not been recorded on Ethereum (the amount we provide is a conservative lower-bound), MEV is likely a billion dollar industry. DEXs however account for less than 10% of cryptocurrency trades, and this does not include OTC trades which likely dwarfs DEX volume to 5%, or less, of total daily cryptocurrency volumes.

This makes sense. Posting an order for $10,000,000 worth of ETH into the Uniswap V3 USDC/ETH pool (the pool with the most TVL, and least implicit fees to impact), has total fees of 1.25% including impact and slippage, while for $100,000,000 ETH, this fee increases to 4.5%. And this is the fee IF the trade clears. If informed counterparties (CPs) submits an order, the whole ecosystem sees. The time between order revelation and confirmation allows the blockchain-equivalent of high-frequency traders (HFTs) to use this information to trade all available liquidity up to the level indicated by the informed CP effectively preventing the CP from trading, or only trading when the HFTs have decided they don’t want it, a negative-selection nightmare.

Existing Solutions

The best existing solutions to this problem try to aggregate orders. Aggregators definitely improve on the standard AMM design by utilising multiple AMMs, and sometimes even professional MMs who respond to orders in an RFQ-style manner. Aggregator protocol can require CPs to send orders on-chain, like 0x’s Matcha , or sometimes off-chain as in CoWSwap, where aggregators are trusted to only match orders, and not use this information themselves. In a decentralised system like a blockchain, this is too good to be true. If an order is revealed *without* getting filled-or-killed, someone can take advantage of it. As such, clients who want to trade any sort of significant size must go to the centralised institutions. Some OTC-style protocol attempts have been made, such as HashFlow and DexPools, but these are far from practical, with RFQs posted by the CPs wanting to trade, incurring selection biases that are protected against in centralised exchanges.

FairTraDEX definitively solves these problems.

FairTraDEX

FairTraDEX implements a frequent batch auction (FBA). FBAs were constructed, and proven to provide CPs with an exchange protocol in which, assuming orders can be submitted anonymously, MMs respond with prices centered around the fair price, with widths diminishing to 0 in the presence of competing MMs. In other words, FairTraDEX provides a platform to facilitate best execution (without the need for intermediate execution professionals).

Given the presence of trusted execution platforms in centralised exchanges, anonymous submission is practically provided . As such, FBAs have not found much use in the centralised setting. However, the guarantees provided by FBAs eliminate the possibility of the MEV attacks listed throughout this article.

The key functionality which allows FairTraDEX to implement an FBA is anonymous order submission. This is achieved using well-studied zero-knowledge (ZK) set-membership tools. CPs in FairTraDEX must make a once-off, redeemable deposit to the FairTraDEX smart contract, receiving back a token which gives them the right to participate in a FairTraDEX auction which are intended to occur frequently (token-pair auction frequency will reflect the trading volume of that token-pair). This can also be extended to an RFQ functionality.

When an auction begins, during the commit phase, any client owning a deposit is allowed to submit an order commitment to the auction. The order specifies trade size, price, and direction. This order commitment reveals nothing about the order, but is uniquely tied to the order contents. To ensure anonymity, the order is sent through a network of third parties known as relayers. To ensure the order commitment was sent by a CP owning a deposit token, the CP provides a ZK proof uniquely related to the token, which proves to the FairTraDEX auction smart contract that the person who generated the order commitment is also one of the players owning a deposit token.

Once the commit phase ends, CPs then reveal their orders. After the orders are revealed, or a predefined deadline has passed, the FairTraDEX contract matches the orders at a clearing price which maximises the volume traded, as in an FBA.

FairTraDEX and it’s unique guarantees have the potential to attract never-before-seen CPs, and trading volumes, to the decentralised eco-system. I’m very excited to see the next steps for FairTraDEX. Watch this space!

--

--

Conor McMenamin

PhD student in Formal Analysis of Blockchain Technology.