CoW Swap seeks to solve the MEV problem in decentralized trading

Using batch auctions in CoW Swap, users sign “trade intent” in an off-chain message that sets a limit price

article-image

Alena Demidyuk/Shutterstock modified by Blockworks

share

A coincidence of wants, Felix Leupold explains, is “an economic phenomenon where one party would like to purchase an asset that another party wants to sell, and the other party wants to buy another asset that the first party wants to sell.”

Enter the creation of the CoW protocol, built on the notion of two parties with opposite interests. 

The advantage is that the trading parties can forgo the complications of trading into another medium of exchange, like money, and instead trade directly.

Leupold, the technical lead at CoW Swap, explains the trading mechanism’s advantages on the 0xResearch podcast (Spotify/Apple), allowing for more efficient trading and, according to Leupold, mitigating the problem of MEV.

Due to the “Cambrian explosion” of a vast variety of tokens in the DeFi space, market liquidity is highly fragmented, Leupold says. To create liquidity between the wide variety of token pairs, market makers need to “step in and provide liquidity,” he says. 

If instead, a “holistic approach” can look at the “entire preference expression of the world” once per block, Leupold says, “you can re-aggregate that fragmented liquidity space and find those coincidences of wants.”

Importantly, such an arrangement cuts down on MEV — or maximum extractable value — attacks, where traders incur losses by being “sandwiched” or front-run by opportunistic bots. “Traditionally, if you want to trade token A for token B on Ethereum, you go directly to an [automated market maker] interface or a DEX aggregator,” he says. 

“The algorithm will find you the best on-chain route for your trade,” he says, and “give you back a transaction that you, with your MetaMask account, will submit to the blockchain to execute that trade.”

The problem takes place because of an “asynchronous aspect,” Leupold says, as time passes between receiving the “optimal route from whatever API you’re using” and the transaction being sent to the public mempool to be mined.

“During that time,” he explains, “prices can change,” and MEV actors can extract profit at the expense of traders. 

Batch auctions

Using batch auctions in CoW Swap, the user instead signs “trade intent” in an off-chain message that sets a limit, Leupold explains. “I want to sell token A for token B, and here’s my limit price. But I don’t care exactly how it is executed.”

The user then hands off the intent to “solvers,” Leupold says, a “decentralized network of matching engines.” They compete to find the best execution path at the time that the order is being made valid, he says.

As opposed to individual trades, orders are aggregated into batches, Leupold says. “All the trades that are placed into the API, within a 30-second window roughly, are placed into the same batch.” The solvers that find the optimal trade solution then receive the right to execute the batch.

“All these risks, these complexities of managing your own transaction,” Leupold says, “are now taken care of by a professional entity.” 

Podcast host Dan Smith observes that the solution sounds a lot like MEV-Boost, where builders work to solve transactions for proposers, but Leupold says the process is exactly the opposite in effect.

“If there are two people trading the same asset in the same batch,” he explains, “then the protocol enforces that there is only one price per token per batch.”

The two trades would be cleared “at exactly the same price,” Leupold says. “There’s no concept of first come, first serve or some kind of ordering, fair ordering. There’s just uniform price clearing, one price per token per batch.” This method removes “all kinds of MEV,” according to Leupold.

On CoW Swap, he says, “if there’s two people trading the same asset, you actually need to have a uniform price clearing, so [there’s] no difference between buy and ask.”

Unsophisticated users who don’t know how to “boost” their way to priority over others in the public mempool can be protected by the CoW Swap mechanism, Leupold says, and “not have to worry about all these games that are being played in the Dark Forest.”


Start your day with top crypto insights from David Canellis and Katherine Ross. Subscribe to the Empire newsletter.

Tags

Upcoming Events

Salt Lake City, UT

WED - FRI, OCTOBER 9 - 11, 2024

Pack your bags, anon — we’re heading west! Join us in the beautiful Salt Lake City for the third installment of Permissionless. Come for the alpha, stay for the fresh air. Permissionless III promises unforgettable panels, killer networking opportunities, and mountains […]

recent research

Research report HL cover.jpg

Research

It's increasingly apparent that orderbooks represent the most efficient model for perpetual trading, with the primary obstacle being that the most popular blockchains are ill-suited for hosting a fully onchain orderbook. Hyperliquid is a perpetual trading protocol built on its own L1 that aims to replicate the user experience of centralized exchanges while offering a fully onchain orderbook.

article-image

They both may be in prison for an overlapping 120 days, but the similarities stop there

article-image

The tokenization of real-world assets is set to continue as a “defining trend” for institutional crypto in 2024, Anchorage Digital CEO says

article-image

Upcoming macroeconomic clarity, or a lack thereof, is likely to be a key contributor to bitcoin’s next price movement

article-image

Runes protocol will bring versatility to Bitcoin, but some are worried about the increased fees

article-image

The sentencing closes the book on the DOJ’s settlement with Binance and its former CEO

article-image

Roger Ver was arrested in Spain on Tuesday, the DOJ said