Research Platform by Qdit Research
This document explains the mechanics of Maximal Extractable Value (MEV), the fair batch auction solution, and the cryptographic zero‑knowledge proof system that guarantees correctness.
In a traditional continuous order book, transactions are processed sequentially in the order they arrive. However, miners or validators (or bots paying high gas fees) can reorder, insert, or censor transactions to extract profit at the expense of ordinary users. This is known as Maximal Extractable Value (MEV).
Example: A user submits a large buy order. A front‑running bot sees this transaction in the mempool, quickly submits its own buy order at a slightly higher gas price, buys the asset first, and then sells back to the user at a higher price — pocketing the difference.
The continuous order book suffers from ordering dependence: the sequence of transactions determines who gets what price. This creates an unfair advantage for sophisticated actors.
A batch auction collects all orders submitted within a fixed time window and matches them simultaneously using a uniform clearing price. The goal is to find a single price that maximises the total traded volume without favouring any particular order based on arrival time.
Let B be the set of buy orders, each with a limit price pb and quantity qb. Let S be the set of sell orders with price ps and quantity qs.
For any candidate clearing price P:
The filled volume at price P is min(Σ bid_qty, Σ ask_qty).
The algorithm iterates over all distinct limit prices in the batch and selects the price that yields the maximum filled volume. This price is the uniform clearing price.
Because all orders are treated as arriving at the same time, there is no “first” order to exploit. Front‑running bots gain no advantage: their orders are matched at the same uniform price as everyone else’s. The profit that would have been extracted by bots in a continuous book is completely eliminated.
We want to prove to any third party that the batch auction was executed correctly — i.e., the published clearing price and filled volume are indeed the result of the above algorithm applied to the submitted orders — without revealing the actual orders (which are private).
We encode the clearing algorithm as an arithmetic circuit using the Circom language. The circuit takes as private inputs the array of orders (price and quantity for each) and as public inputs the clearing price and filled volume. It computes the cumulative buy and sell quantities and asserts that the minimum matches the output volume.
The circuit uses circomlib’s LessThan template to perform the minimum comparison without revealing which side was smaller.
We use the Groth16 proving scheme, which consists of:
Our simulation generates random orders (bids and asks) with prices uniformly distributed between 90 and 110, and quantities from 1 to 5. MEV bots are introduced by selecting random positions in the order sequence and inserting front‑running orders with a 1‑unit price advantage. The continuous book simulation counts the profit captured by these bots. The batch auction simulation uses the same orders and bots but applies the uniform clearing algorithm — showing zero bot profit.
The 3D Surface Sweep varies the number of orders (100‑500) and bots (5‑30) and computes average MEV profit over multiple runs, giving a complete picture of vulnerability.
The full project is open‑source and available at:
https://github.com/BorelSigmaInc/MEV_FairOrdering_ZK
You can fork the repository, run your own simulations, and integrate the fair batch auction into any trading system.
Last updated: June 2026