back to all posts

CoW Protocol

by Brett Sun


Decentralized token exchanges (DEXes) need no introduction in 2022. Acting as essential infrastructure in decentralized finance (DeFi), DEXes are amongst the most used applications1 in crypto and have played an instrumental role in the proliferation and maturation of token-based projects. Uniswap, the market leader, has become a household name and facilitated more daily exchange volume than Coinbase on several occasions.

While Uniswap could theoretically service the entire market for DEX trading by itself, the genie for on-chain liquidity was let out of the bottle with its initial release. By late 2020, within two years of Uniswap v1’s launch, dozens of DEXes were available with competing, and more problematically, fragmented liquidity. Traders optimizing for the best execution were required to source quotes from multiple venues, leading others to build aggregation layers above to aid in routing a trade optimally across DeFi.

A trade optimized into multi-leg splits on Paraswap, a DEX aggregation tool

CoW Protocol (a play on “coincidence of wants”), and its namesake exchange venue CowSwap, are a new take on this aggregation model with several innovations that combine to offer traders a “never worse but often better” execution price. Cleverly, it achieves the “never worse” aspect by sourcing quotes from underlying DEXes and DEX aggregators (showcasing DeFi’s native composability) and the “often better” aspect by finding peer-to-peer matches amongst multiple trades.

The magic in achieving both lies in the protocol processing batches (creating what’s sometimes known as a Walrasian market) rather than sequential trades, which is the norm for exchanges both centralized and decentralized. CoW Protocol collects trades over an interval of time into a batch, similar to a block of transactions in prototypical blockchains, which is then handed off to an external network of “solvers” who compete to provide the optimal clearing price for all tokens involved.

Being able to consider multiple trades at the same time allows the protocol to find the so-called “coincidence of wants” between multiple parties and provide a better price. For example, a user trading USDC for ETH can be matched with another user trading in the opposite direction (ETH for USDC) rather than having to incur both fees and a deteriorated price via an external exchange venue. In the case no match is found, the trade is settled with the best-priced external venue or route.

In theory, the sky’s the limit as the team explores similar ground to novel exchanges like OneChronos (for equities). CoW Protocol can already handle ring trades (see below), be supplied with otherwise proprietary liquidity from OTC desks or centralized exchanges, and be seamlessly upgraded to include new matching algorithms as the community develops them.

A ring trade between Alice, Bob, and Carol for equal amounts of ETH, USDC, and COW

The last important benefits provided by the protocol’s construction are elegant artefacts from its reliance on an external network of competing solvers. By pushing the responsibility of selecting a specific route or venue from the user to the solver, the protocol facilitates just-in-time routing for all internal trades. This technique counters specific nuances in how blockchain-based virtual machines work and protects users not only from being victimized by the MEV (miner extractable value) opportunities2 their trades create, such as sandwich attacks, but also from pre-committing to a route that becomes outdated by incoming market information while in queue for execution.

Although CowDAO is only just beginning, we’ve known Anna, Felix, and Chen from their early involvement in Gnosis and the several iterations they’ve taken over the last years to achieve this remarkable combination of product and community. We couldn’t be more excited to support them and the broader CowDAO community in their next steps on becoming DeFi’s ultimate trading venue.

Footnotes

  1. While there are several reasons a user may opt for a decentralized venue instead of a centralized version, amongst the two most important are:
    - No custodial risk : users do not have to trust a centralized counterpart to handle their funds before, during, and after an exchange; and,
    - Permissionless token listing : any party is empowered to list a token for exchange as long as they are also able to provide liquidity in that token.
    The latter, in particular, was instrumental as it provided a common exchange venue to facilitate trades and encourage price discovery for every token community—small or large, early or mature. Whereas prior, only the largest, most liquid token communities would be listed on centralized venues leaving small or illiquid projects with few viable means other than peer-to-peer OTC to disperse tokens into a wider group of stakeholders.
  2. A conservative lower-bound cumulative estimate of MEV extracted from users amounts to $600m thus far. In many ways this class of opportunities is reminiscent in structure to the various games played in the traditional equities and derivatives markets as discussed by Michael Lewis in Flash Boys.