HomeKnowledge BaseUnderstanding Batch Auctions

Understanding Batch Auctions

7 min read

Batch auctions are a powerful trading mechanism for settling orders on decentralized exchanges. Recently, batch auctions have attracted attention in the DeFi space thanks to a host of benefits including better prices and built-in MEV protection.

In this article, we’ll take a look at how batch auctions work, why they’re important, and how CoW Protocol, one of the leading innovators in the DeFi space, is leveraging batch auctions as a decentralized exchange aggregator.

What is a batch auction?

1-understanding-batch-auctions.webp

A batch auction is a trading mechanism that groups orders together into “batches” and “auctions” them off to execution parties who compete against each other to find the most optimal order settlement path.

Grouping trades together allows batch auctions to enforce certain execution rules that prevent MEV attacks. The competition between execution parties makes batch auctions a type of “order flow auction,” meaning they are designed to find optimal prices for user trades.

In order to find the best prices for the orders in a given batch, the execution parties (commonly known as “solvers”) aggregate liquidity from as many sources as possible — AMMs, private off-chain liquidity, and even by routing swaps peer-to-peer between the orders in a batch.

To really understand how batch auctions work under the hood, however, we must first consider how trading takes place on decentralized exchanges (DEX’s).

How decentralized exchanges work

Due to the volatility of crypto markets, traders have to set a “slippage tolerance” every time they make a trade on a decentralized exchange. The slippage tolerance specifies the price deviation that traders are willing to accept for the assets in their order. Slippage is necessary because it accounts for changes in price between the time traders place an order and the time the order gets executed.

Decentralized exchanges rely on automated market makers (AMMs) to provide liquidity for trades. AMMs settle trades sequentially, meaning that every order gets executed individually as it comes in. While AMMs ensure a smooth and continuous flow of transactions, their design leaves room for MEV as malicious parties can force trades to execute at a maximum slippage tolerance, giving traders worse prices than they would normally get.

This is where batch auctions come in.

How batch auctions mitigate the MEV problem

At its core, MEV relies on reordering transactions from the way they were submitted to a new, more profitable order. Malicious traders, known as “searchers,” monitor the Ethereum mempool — a holding area where transactions accumulate before they are included in a block and confirmed on-chain — and bribe block builders to strategically place transactions to their advantage.

Orders in a batch are executed as a single transaction, rather than sequential transactions, giving solvers tools they can leverage to keep trades safe from MEV.

Uniform Clearing Prices: MEV relies on reordering transactions such that sequential orders clear for slightly different prices. Searchers pocket the differences between these prices as arbitrage. With batch auctions, multiple orders trading the same token pair (such as ETH-DAI) within a single batch clear for the same price. This makes transaction reordering useless, bypassing the risk of MEV.

Coincidence of Wants (CoWs): If traders in a batch are trading opposite assets, they may be matched peer-to-peer in a “Coincidence of Wants” trade. For example, if one user is selling ETH for DAI and another is selling DAI for ETH, the two traders can simply swap assets. This provides better prices and bypasses MEV, as orders don’t have to tap on-chain liquidity.

Enforcing the Ethereum Best Bid Offer (EBBO): Thanks to the competition for execution, batch auctions guarantee that the settlement solution is at least as good as the on-chain price a user could get directly by going directly to an AMM.

CoW Protocol’s batch auction process explained

CoW Protocol, an innovative DEX aggregator, leverages batch auctions to provide optimal trading prices and protect traders from MEV.

2-understanding-batch-auctions.webp

Trades on CoW Protocol begin as signed “intent to trade” messages that get sent to an orderbook. From here, the protocol groups these intents into batches and invokes solvers for the actual order execution. Solvers search all available on-chain liquidity, and even tap off-chain liquidity, to find the most efficient execution route for the batch.

Once the protocol gathers orders in a batch, it runs an “auction” to pick the winning solver that gets to settle the batch on-chain. The winner is picked based on which solver can offer the most price surplus for the orders in the batch (surplus is defined as the positive difference in price between the quoted price and the actual execution price.) Finally, the winning solver executes the orders in the batch on-chain on behalf of the users.

Thanks to frequent batch auctions, CoW Protocol guarantees a uniform clearing price for all assets, allows trades to be matched peer-to-peer in Coincidences of Wants (CoWs), and also provides several other unique benefits including:

  • Gas optimizations thanks to reduced overhead when executing multiple orders in a single transaction
  • No deposits or withdrawals into an exchange contract, meaning that all balances are credited directly to user accounts atomically in a single Ethereum transaction
  • Fair, decentralized settlement in which an open competition for order matching replaces a central operator or a constant function market maker

An example batch auction on CoW Protocol

To demonstrate the power of batch auctions, let’s take a look at an example involving a typical batch on CoW Protocol.

3-understanding-batch-auctions.webp

For this example, we’ll take a look at a batch from January 2024. In this settlement, a solver executed five different trades as a single batch, forming several CoWs and leveraging on-chain liquidity to fill the orders the rest of the way.

The batch began with traders trading DAI for ETH in the first two orders and the reverse — ETH for DAI — in the third order.

4-understanding-batch-auctions.webp

This inverse-swap allowed for a Coincidence of Wants. The third order was for ~500 ETH, while the first two orders were only for ~216 ETH, so the solver was able to fill the first two orders entirely using the third order’s liquidity. In return, the third order received ~216 ETH’s worth of DAI and the solver went to an on-chain AMM (0x in this case) to source liquidity for the remaining DAI it needed to fill.

5-understanding-batch-auctions.webp

The last two orders in the batch traded USDC for ETH. The solver executed both of these orders on-chain, but they still received a better price than quoted because they executed in a single batched transaction, saving on gas fees and protocol fees.

6-understanding-batch-auctions.webp

In the end, not only did batch auctions protect these orders from MEV, they also allowed the solver responsible for executing the batch to provide each order with price surplus.

A few percentage points may not seem like much, but the surplus amounts to almost $20,000 across all orders in this batch. This is money that would have been left on the table in a traditional AMM.

7-understanding-batch-auctions.webp

Batch auctions: The future of fair trading

Batch auctions are gaining notoriety as a mechanism for ensuring optimal price discovery and protecting orders from MEV.

While CoW Protocol has built an innovative frequent batch auction mechanism for DeFi trades, there are still improvements that can further protect users. In particular, CoW Protocol is looking forward to experimenting with batch time lengths that are equivalent to block time lengths. This would ensure that each CoW Protocol batch executes 1:1 with each Ethereum block, providing uniform clearing prices on the block level, rather than just the batch level, further mitigating MEV.

To experience the power of batch auctions for yourself, give CoW Swap a try for your next trade on Ethereum or Gnosis chain.

Happy batching!