CowSwap: The Exchange Economy for Digital Asset Swaps

This report will introduce CowSwap and offer an analysis of the underlying protocol.

Ian Devendorf
13 min readMar 31, 2022

Due to high network congestion, fees on Ethereum have risen beyond what most users are comfortable with. Recently, It is not uncommon for gas fees to reach over $100 per transaction making it infeasible for users moving small amounts of money. This has trained user focus on minimizing the frictional costs associated with the network. In order to adapt to this new landscape and compete for order flow, there has been a series of innovations from DEXs and DEX aggregators attempting to offer a better user experience through lower fees and slippage.

CowSwap is a Meta-Dex aggregator that is able to benefit from these innovations while offering its own features to further improve the user experience. CowSwap uses batch auctions to settle trades made on the platform. First, CowSwap looks for trades that can be settled within the batch before routing excess orders to the best external on-chain liquidity sources. CowSwap was launched as a proof-of-concept for batch auction trading and quickly garnered a loyal and active community. Monthly trading volume on CowSwap has grown by over 15x to ~$7.9 billion since August 2021.

This report will introduce CowSwap and offer an analysis of the underlying protocol.

History

The idea for using batch auctions in the context of decentralized exchanges was first implemented by developers at Gnosis. Gnosis protocol’s original focus was aimed at building the infrastructure for decentralized and permissionless prediction markets where users can trade contracts based on the outcome of events. While attempting to build out the tools for prediction markets, the Gnosis team realized that much of the underlying infrastructure was missing. One issue the team foresaw was ensuring adequate liquidity for prediction market tokens. In order to solve this problem, the team considered a batch auction format in which long-tail assets inherent in prediction markets are able to share liquidity with other trading pairs rather than being siloed into individual order books. Gnosis developers also noticed an issue with existing AMM’s in that token pairs in the same block on Ethereum get different prices despite each transaction being simultaneously published to the blockchain. Presumably, these transactions could have been grouped together in one transaction and given a uniform clearing price given Ethereum’s discrete-time based settlement.

The first iteration of a batch auction DEX developed by Gnosis was called DutchX which failed to appeal to users due to long transaction times sometimes taking hours to execute. The batch auction system was revisited under Gnosis protocol and Gnosis protocol V2 which made improvements to the DutchX model including faster execution. CowSwap was launched in April of 2021 as a proof-of-concept user interface for the protocol available on Ethereum and Gnosis Chain. Over time, with a growing user base and a clear product-market fit, the CowSwap team spun out of Gnosis and rebranded Gnosis protocol V2 as Cow Protocol, realizing its purview is wider than prediction markets. The rebranding also included the creation of CowDAO and the vCOW governance token to support decentralization efforts and reward early users. With a more established brand identity and focused community, CowSwap is aimed at becoming the main front end for trading digital assets by offering the best execution available.

Functionality

Batch Auctions

Just as Uniswap uses a constant product function to dynamically adjust prices, CowSwap leverages batch auctions as a price-finding mechanism. A batch trade refers to the accumulation of orders that are executed simultaneously. Batch trades are used in the stock market at the opening to settle trades placed during non-market hours. Individual trades are aggregated and treated as one large transaction rather than continuously traded by an active market maker.

Batch trades have a number of applications within DeFi including initial token offerings, liquidations, and arbitrage. In the context of CowSwap, orders for any token pair are collected into batches every 30 seconds. External participants called solvers then compete with each other to propose a settlement solution for the batch that offers a uniform clearing price and maximizes trader welfare. The level of trader welfare is determined by optimization criteria encoded in the smart contract with the goal of obtaining the highest volume and profit for all traders.

Coincidence of Wants & Ring Trades

One of the main features of CowSwap is the ability to execute Coincidence of Wants, ring trades, and aggregate orders moving in the same direction. This allows the protocol to share liquidity across all listed tokens rather than separating liquidity into individual token pairs. Coincidence of wants refers to the concept that when two or more traders hold assets the others want, the tokens can be exchanged directly rather than through external liquidity. Ring trades occur when there is a coincidence of wants in the batch that allows for orders to be filled indirectly. Below is a simple example of a ring trade.

When transactions are broken down into their atomic paths, there is a much greater opportunity for solvers to increase trader welfare through sharing liquidity either directly or indirectly. First, solvers will look to fill Cows before routing any excess order amounts to existing on-chain liquidity.

Solvers

Solvers are third parties that compete for users’ order flow. Once a solver has proven that they have found the best settlement solution for current open orders, the solution is executed and the solver collects the protocol fee. Solvers will first look within the batch itself to fill orders before moving to on-chain liquidity sources including DEXs and DEX aggregators depending on the optimal path. Solvers compete to maximize trader welfare against a set of optimization criteria while also being subject to both hard and soft constraints. The hard constraints are enforced by the code of the smart contracts and ensure that the users’ signatures are valid and that the limit prices are satisfied. The soft constraints are enforced by the Cow DAO and include requirements such as:

  1. Clearing price is within a certain margin of error of the spot price of the most liquid on-chain pool;
  2. No transactions are maliciously or purposefully censored;
  3. There is a uniform clearing price for the same token pairs in a given batch.

Since each solver is required to stake a bond to the protocol, the Cow DAO can choose to slash the bond when a solver breaks these soft constraints. The use of solvers opens up transaction execution to open market competition.

Fee Mechanism

Users on CowSwap execute a one-time transaction to approve their tokens to be used by the vault relayer contract. Once the tokens are approved, users submit orders via signed off-chain messages that contain the trade’s details including limit price and amount. The trade details also include a protocol fee that covers the solver’s gas fees and includes a reward for winning the competition. CowSwap will specify the minimum fee that makes it viable for a solver to include an order along with a validity period which guarantees the order submission won’t be rejected for that period. These variables are based on the order’s parameters including type, sell token, buy token, and volume. The winning solver earns all of the fees from a batch which is denominated in each user’s sell tokens.

In this way, the user transfers the execution risk of the trade to the solver. If a trade fails, the solver will incur the associated gas fee and not pass it onto the user. This means users can have a trade fail or re-routed without incurring gas fees.

Trading Cycle Overview

  1. Users place limit orders by signing off-chain messages. The user specifies a protocol fee and signals their “intent to sell” to the protocol. The open order is then added to an off-chain orderbook;
  2. Batch auctions run every 30 seconds. At the start of an auction, all open orders are considered by solvers;
  3. Solvers compete to find the optimal settlement solution that maximizes trader welfare;
  4. The protocol selects the winning order settlement solution and all matched orders are settled on-chain. The solver collects the protocol fee.

Benefits of Using Cowswap

MEV Protection

Users transacting on Ethereum are subject to a hidden cost called Miner Extractable Value. MEV is profit that miners can extract from users by arbitrarily reordering, including, or excluding transactions within a given block. Miners have full autonomy in selecting transactions to include in their block from the mempool. The mempool is the location miners store pending transactions off-chain. Most forms of MEV today are taken from third-party bots that manipulate the order of transactions by changing the fee they pay to miners. There are multiple strategies that produce MEV and result in a worse user experience. MEV attacks can cause a user’s trade to execute at suboptimal levels by increasing the associated slippage or gas fee. At the time of writing, Flashbots estimates roughly $12.7 million has been extracted through MEV on the Ethereum network in the last 30 days.

CowSwap significantly reduces the surface area for MEV attacks. Since CowSwap offers a uniform clearing price for all trades in the same batch there is no need for ordering the transactions within a single batch. Also, the open market competition for settlement solutions ensures that solvers use professional transaction management techniques to set very tight slippage bounds on any interaction with external liquidity. Additionally, solvers can use tools like Flashbots and MEV-Geth to further protect its trades and increase its chances of winning a batch auction. As the ecosystem matures, the competition in the solver ecosystem will expand resulting in even stronger MEV protection. Moreover, with more volume, the increased level of Cows will dramatically reduce the volume exposed to external MEV-prone liquidity sources as only the excess order amounts need to be routed.

Professional Transaction Management

Solvers offer a way for users to leverage professional transaction management techniques without needing technical expertise. Even if CowSwap offers zero coincidence of wants in a given batch, users benefit from solvers using tight slippage, tools like flashbots, and assuming the risk of failed transactions. If an order route becomes unfillable, the solver can re-route the trade to the newly optimal path, all done on the backend and hidden from the user. Additionally, solvers are able to consider all the available on-chain liquidity sources to find the best option for execution, which is generally beyond the capabilities of novice traders. From the user’s point of view, all of these benefits are accessed through a simple and easy-to-use interface.

Network Effects

CoW protocol is structured to benefit significantly from network effects. As CowSwap’s order volume grows, solvers will consider a larger set of orders for settlement solutions and there will be more opportunity to share liquidity both directly and indirectly across token pairs. This results in a better trading experience which leads to increased order flow. As order volume grows, the competition in the solver ecosystem will likely intensify as the costs incurred by settlement execution will decrease relative to the accrued protocol fees. Along this line of thinking, the CoW protocol team has launched various trader incentives in the past to set the flywheel in motion.

Governance & Token Economics

vCOW Airdrop

CowSwap recently airdropped vCOW which is an initially non-transferable governance token that entitles holders with voting rights in the CowDAO. CowDAO will govern and curate critical infrastructure components of CoW protocol and implement community-directed initiatives. vCOW is a crucial step along Cow Protocol’s vision for progressive decentralization. CowDAO will be responsible for implementing changes to the protocol including the following:

  • System Parameters including the objective function for trader welfare and solver penalty conditions, for example
  • Allocation of treasury holdings and protocol revenue
  • Staking dynamics and requirements within the ecosystem

The COW token will have immediate tangible utility as users who lock COW tokens will receive a fee discount on trades. Further value accrual through distribution of protocol revenue or other means will be subject to voting by vCOW holders. One idea that hasn’t been voted on yet is a requirement to stake COW tokens to become a solver and participate in batch auction settlement competitions. This would improve the tokenomics of the COW token by reducing the circulating supply and aligning the incentives of solvers with the protocol.

The initial 1 Billion COW token supply was distributed across a range of stakeholders including early users, the CowDAO treasury, the GnosisDAO, the CoW advisory team, and the CoW team investment partners.

The 10% allocation to airdrop holders are the only tokens that are unlocked immediately. All other allocations are vested linearly over four years. Given that vCOW tokens are initially non-transferrable, the token allocation and vesting schedule ensures that early community members have outsized voting rights in the first year.

With the launch of vCOW, Cow Protocol now has a unified brand, dedicated team, and a strong community empowered with governance rights to shape the direction of the ecosystem.

The Future / Roadmap

Progressive Decentralization

CoW protocol has a three phase plan to reach a meaningful level of decentralization. The smart contracts and UI associated with the protocol are already fully decentralized. The smart contracts have no admin key and hold no user’s balances. The UI can be used by anyone without the possibility of blocking any users as it is stored in IFPS.

Two other components, specifically the off-chain orderbook and solver ecosystem will be progressively decentralized according to the below phases:

Phase 1: In the first phase, only trusted solvers approved by the Cow DAO are allowed to compete for order flow. In this phase, the DAO will pay close attention to authenticated solvers and will enforce slashing of bonds and pay out rewards

Phase 2: In the second phase, the DAO plans to implement a permissionless solver authentication model in which anyone can become a solver by staking the asset and amount required by the Cow DAO. The DAO would agree on a set of rules that could trigger a slashing vote when violated.

Phase 3: The third phase would change the centrally hosted orderbook to a distributed peer-to-peer network that reaches consensus on the state of open orders that solvers consider when creating settlement solutions.

Partner Program

Another Interesting avenue for CowSwap to explore is partnership with DEXs and DEX aggregators. By acting as a front-end for CoW protocol, other platforms will be able to offer their users the best execution possible. It is also possible for partners to closely integrate with CowSwap, so that solvers are more likely to route excess order flow to their platform. This factor could drive a game theoretic desire for DEXs and DEX aggregators to integrate with CowSwap early and reap the benefit of the increased order flow.

CowSwap has already begun to partner with DEXs. The most notable partnership to date is with Balancer V2. Balancer has set the default for ERC-20 order flow on their platform to be routed through the CoW protocol. This allows Balancer to leverage CoW protocol’s infrastructure to provide their users with MEV protections, gasless trading, smart order routing, and professional transaction techniques. Balancer benefits by being able to offer a better user experience and CoW protocol benefits from elevated order flow. Additionally, the CoW Protocol settlement contract is tightly integrated with Balancer’s V2 and even holds token balances within the vault. This provides a gas efficiency which will cause solvers to route orders to Balancer given the prices are roughly the same as on other platforms.

Challenges & Risks

Although CowSwap has gained market traction, the DEX space is fragmented and competitive. DEXs and DEX aggregators could potentially leverage their existing order flow and create their own batch auction trading system rather than routing through Cow Protocol. If batch auction trading does prove to be a more efficient method of trading, other protocols will likely try to recreate the infrastructure on their own platform. In order to combat this, it’s important for CowSwap to build a competitive moat through network effects and garner significant order flow.

The other challenge involves the disruption of the base liquidity layer. Although the goal of CowSwap is to match as many trades as possible within a given batch, much of the order flow is routed to decentralized exchanges that are powered through liquidity providers. If Cowswap were to have the majority of order flow running through their platform, the level of Cows could significantly reduce the utilization of AMMs which decreases the amount of trading fees that LPs are earning and disincentivizes the marginal liquidity provider. While the level of Cows would increase, those trades exposed to external liquidity would have worse slippage and therefore worse prices given that arbitrage would be less profitable. In order to compensate, CowSwap could match active market makers directly with retail traders. The CoW protocol team could create a system in which active market makers view the off-chain orderbook of open orders and match trades. These market makers could even hold balances on CoW protocol’s smart contract to allow for gas efficiency, making execution more competitive compared to on-chain liquidity. If CowSwap were to succeed, it might mean the restructuring of the entire base liquidity layer of DeFi which could prove difficult.

Conclusion

As the decentralized exchange space continues to grow and innovate, CowSwap is able to offer a better trading experience for its users. Rather than competing with new or existing liquidity sources, CowSwap is able to tap into them to increase trader welfare. CowSwap differentiates itself from the market by leveraging batch auctions and open market competition for settlement execution to offer unique value including:

  • MEV protection
  • No gas paid for failed transactions
  • Equal to or better than other on-chain prices
  • Professional transaction techniques
  • Uniform clearing price

Although CowSwap has already found product-market fit proven by its traction in the market, there is a long road ahead to achieve the team’s vision of becoming the foundational liquidity hub for digital assets.

--

--