{"id":45545,"date":"2021-07-05T19:01:36","date_gmt":"2021-07-05T16:01:36","guid":{"rendered":"https:\/\/forklog.com\/en\/?p=45545"},"modified":"2025-09-01T11:42:46","modified_gmt":"2025-09-01T08:42:46","slug":"cows-in-the-dark-forest-a-review-of-the-cowswap-decentralized-exchange","status":"publish","type":"post","link":"https:\/\/forklog.com\/en\/cows-in-the-dark-forest-a-review-of-the-cowswap-decentralized-exchange\/","title":{"rendered":"Cows in the Dark Forest: A Review of the CowSwap Decentralized Exchange"},"content":{"rendered":"<p>In May, trading volume on Ethereum-based decentralized exchanges (DEX) <a href=\"https:\/\/forklog.com\/en\/news\/monthly-trading-volume-on-ethereums-decentralized-exchanges-tops-115-billion\">surpassed<\/a> the $115 billion mark. Almost 60% of this volume <a href=\"https:\/\/forklog.com\/en\/news\/defi-bulletin-may-19-panic-liquidations-thailand-regulation-and-spacex-launch-insurance\">was on<\/a> Uniswap.<\/p>\n<p>The growth of the DeFi sector <a href=\"https:\/\/forklog.com\/en\/news\/defi-bulletin-may-19-panic-liquidations-thailand-regulation-and-spacex-launch-insurance\">has been accompanied<\/a> by hacker attacks and fraudulent schemes. But a relatively new risk for users of decentralized exchanges has become Miner Extractable Value (MEV).<\/p>\n<p>In late April, the project <a class=\"tracking_link\" href=\"https:\/\/gnosis.io\/\" target=\"_blank\" rel=\"noopener noreferrer\">Gnosis<\/a> unveiled a protocol for decentralized exchanges with MEV protection and a Coincidence of Wants (CoWs) order-matching mechanism. We discuss Gnosis Protocol v2 (GPv2) and test the DEX <a class=\"tracking_link\" href=\"https:\/\/cowswap.exchange\" target=\"_blank\" rel=\"noopener noreferrer\">CowSwap<\/a>.<\/p>\n<h2 class=\"wp-block-heading\">What MEV Is<\/h2>\n<p>In 2019, cryptocurrency and smart-contracts researcher Phil Daian published the paper <a class=\"tracking_link\" href=\"http:\/\/www.pdaian.com\/flashboys2.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">\u201cFlash Boys 2.0: Front-running, Transaction Reordering, and Instability of Consensus on Decentralized Exchanges.\u201d<\/a> In it, Daian introduced Miner Extractable Value (MEV).<\/p>\n<p>MEV is the profit that miners can earn by selectively including or reordering transactions within blocks.<\/p>\n<p>Imagine: on Uniswap there is an arbitrage opportunity with potential profit of $10,000. A trading bot spots it and submits an Ethereum mempool transaction. There are two scenarios that may follow:<\/p>\n<ul class=\"wp-block-list\">\n<li>the miner refuses to include the transaction in the block and undertakes the arbitrage trade themselves. In that case, they would receive $10,000. This is MEV;<\/li>\n<li>other bots notice the transaction and offer the miner a higher fee. A race for the right to execute the arbitrage (Priority Gas Auction, PGA) ensues. The winner earns the arbitrage profit after deducting the fee. For example, $9,000 if the fee is $1,000.<\/li>\n<\/ul>\n<p>More about MEV can be read in Charles Noyes\u2019s <a class=\"tracking_link\" href=\"https:\/\/research.paradigm.xyz\/MEV\" target=\"_blank\" rel=\"noopener noreferrer\">\u201cMEV and I\u201d<\/a>, as well as Dan Robinson and Georgios Konstantopoulos\u2019s <a class=\"tracking_link\" href=\"https:\/\/medium.com\/@danrobinson\/ethereum-is-a-dark-forest-ecc5f0505dff\" target=\"_blank\" rel=\"noopener noreferrer\">\u201cEthereum Is a Dark Forest\u201d<\/a> and <a class=\"tracking_link\" href=\"https:\/\/samczsun.com\/escaping-the-dark-forest\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u201cEscape from the Dark Forest\u201d<\/a>.<\/p>\n<h2 class=\"wp-block-heading\">What CowSwap Is and the Gnosis Protocol<\/h2>\n<p><a class=\"tracking_link\" href=\"https:\/\/cowswap.exchange\" target=\"_blank\" rel=\"noopener noreferrer\">CowSwap<\/a> \u2014 a decentralized exchange with DEX-aggregator features based on Gnosis Protocol v2 (GPv2).<\/p>\n<p>The Gnosis team released the first version of the protocol in early 2020. Over the next six months, developers studied the protocol&#8217;s weaknesses. They found that gas costs prevented market makers from offering tight spreads. Fragmented liquidity also affected asset prices. In April 2021 the project introduced the second version of the protocol, which addresses this problem.<\/p>\n<p>By mid-year, Gnosis and the developers of the AMM protocol <a class=\"tracking_link\" href=\"https:\/\/balancer.fi\/\" target=\"_blank\" rel=\"noopener noreferrer\">Balancer<\/a> planned to deploy Balancer-Gnosis-Protocol (BGP) on Ethereum. It would combine Balancer V2&#8217;s gas-cost-reduction algorithm with the price-determination mechanism of Gnosis Protocol V2 with MEV protection. This integration would offer CowSwap users better prices.<\/p>\n<p>As of publication, CowSwap was in alpha testing.<\/p>\n<h2 class=\"wp-block-heading\">How GPv2 Works and How It Protects Against MEV<\/h2>\n<p>Gnosis Protocol v2 employs technologies such as:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Coincidence of Wants (CoWs)<\/strong>. When one trader wants to buy an asset and another wants to sell the same asset, there is a \u201ccoincidence of wants.\u201d The protocol executes such orders directly, without an external market maker or liquidity provider.<\/li>\n<li><strong>Batch Auctions (BA).<\/strong> The protocol groups orders into batches (BA). Inside a batch, token prices are homogeneous and do not depend on the order of orders. This helps protect traders from Miner Extractable Value.<\/li>\n<li><strong>Gas Free Transactions (GFT).<\/strong> A user confirms an order off\u2011chain, without paying gas. CowSwap, meanwhile, optimises the cost of execution: applying CoWs, monitoring prices on other DEXs and considering the gas price to include the transaction in a block. Users pay a fee if the protocol executes the transaction on their terms.<\/li>\n<\/ul>\n<p>CowSwap submits users&#8217; orders to GPv2. The protocol bundles orders into batches (BA) and passes them to the solving participants (solvers). The solvers search for the most advantageous market price and are rewarded in Gnosis tokens (GNO).<\/p>\n<p>Any user can become a solver. To do so, one must:<\/p>\n<ul>\n<li>lock 100 GNO in <a class=\"tracking_link\" href=\"https:\/\/gnosis.io\/gnosisdao\/\" target=\"_blank\" rel=\"noopener noreferrer\">GnosisDAO<\/a>;<\/li>\n<li>obtain the approval of participants in the decentralized autonomous organization;<\/li>\n<li><a class=\"tracking_link\" href=\"https:\/\/docs.gnosis.io\/protocol\/docs\/tutorial-solver\/\" target=\"_blank\" rel=\"noopener noreferrer\">install the software<\/a> to create a BA.<\/li>\n<\/ul>\n<p>When the best prices are found, the protocol executes the orders in the batch. First it looks for CoWs trades: when there is a match of wants, the smaller order is executed against the larger one. It then searches for liquidity on other DEXs to complete the remaining orders.<\/p>\n<p>After the Balancer-Gnosis Protocol integration, Balancer will become one of CowSwap&#8217;s main liquidity sources.<\/p>\n<h2 class=\"wp-block-heading\">Testing the Exchange: Exploring the Interface and Executing a Swap<\/h2>\n<p>We tested CowSwap by swapping Wrapped Ether (WETH) for the Gnosis token (GNO). To do so, we visited <a class=\"tracking_link\" href=\"https:\/\/cowswap.exchange\" target=\"_blank\" rel=\"noopener noreferrer\">CowSwap.exchange<\/a> and connected an Ethereum wallet.<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/SFwFFdqnHUolAS4IrwcU9Am8rHITPLbAOv8zS72rnPx16yNsytuYatvHulEuL7IN-mpKx5UxvmcWz22KPC3ZOwbPBKdaG9WRJPNRQKBo_jSHAaqn_J8_x2UJccGaWFbSRgazgRzm\" alt=\"Cows in the Dark Forest: A Review of the CowSwap Decentralized Exchange\"\/><figcaption>As of publication, CowSwap supports MetaMask and WalletConnect.<\/figcaption><\/figure>\n<p>We selected tokens for swapping. By default CowSwap shows Gemini&#8217;s tokens. You can connect tokens from other exchanges \u2014 click the <strong>Manage<\/strong> button. You can also input a token address manually.<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"974\" height=\"472\" src=\"https:\/\/forklog.com\/wp-content\/uploads\/Bez-zagolovka-10.png\" alt=\"Cows in the Dark Forest: A Review of the CowSwap Decentralized Exchange\" class=\"wp-image-141392\" srcset=\"https:\/\/forklog.com\/wp-content\/uploads\/Bez-zagolovka-10.png 974w, https:\/\/forklog.com\/wp-content\/uploads\/Bez-zagolovka-10-300x145.png 300w, https:\/\/forklog.com\/wp-content\/uploads\/Bez-zagolovka-10-768x372.png 768w\" sizes=\"auto, (max-width: 974px) 100vw, 974px\" \/><figcaption>Enter the token ticker in the quick search field.<\/figcaption><\/figure>\n<p>We specified the amount of tokens and configured the transaction. Selected:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Price slippage tolerance.<\/strong> CowSwap will execute the order within a tight spread \u2014 0.1\u20131% of the quoted price.<\/li>\n<li><strong>Deadline.<\/strong> The exchange will cancel the order if it cannot execute the transaction within the specified period.<\/li>\n<\/ul>\n<p>CowSwap offers an Expert mode. In this mode the exchange does not require confirmation before submitting transactions and allows trades with high slippage.<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"974\" height=\"474\" src=\"https:\/\/forklog.com\/wp-content\/uploads\/Bez-zagolovka-11.png\" alt=\"Cows in the Dark Forest: A Review of the CowSwap Decentralized Exchange\" class=\"wp-image-141398\" srcset=\"https:\/\/forklog.com\/wp-content\/uploads\/Bez-zagolovka-11.png 974w, https:\/\/forklog.com\/wp-content\/uploads\/Bez-zagolovka-11-300x146.png 300w, https:\/\/forklog.com\/wp-content\/uploads\/Bez-zagolovka-11-768x374.png 768w\" sizes=\"auto, (max-width: 974px) 100vw, 974px\" \/><figcaption>The exchange does not recommend beginners enable Expert mode.<\/figcaption><\/figure>\n<p>When attempting to sell 0.1 ETH, the exchange offered to wrap the cryptocurrency into an ERC20 token called WETH. We bought the token and paid a transaction fee of 0.0011591 ETH.<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/t3nLlTRSxGEssRcg7_8gENdyP0FkozUaFymustgwwLz6-dpWYGUtWdweHTSpjj3bDvhadefCEYCWRy9DMpX3FedtVd2vxy3NNR7brf7-7IsF0Fvn2mMoz2fiqainWZZMraOSMF6p\" alt=\"Cows in the Dark Forest: A Review of the CowSwap Decentralized Exchange\"\/><figcaption>CowSwap will wrap Ether when needed during a swap.<\/figcaption><\/figure>\n<p>We then checked the transaction settings and authorised CowSwap to spend tokens from the wallet. We clicked Approve WETH and confirmed the operation in MetaMask.<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/PjOd48x3_93ca6dwiBPcC6ogtFQDPGDdXMSsoGgbeOKnCr1klXqo7DX6abWveCSxXCTliVbmHuUs8ONw4ywCRuv1QfeJebqqf9hY69F5bH_QBVnNAJ-46rlVRgn5Vj1ZdHPTlRFB\" alt=\"Cows in the Dark Forest: A Review of the CowSwap Decentralized Exchange\"\/><figcaption>CowSwap will automatically calculate the swap price.<\/figcaption><\/figure>\n<p>We moved on to the swap itself: clicked <strong>Swap<\/strong> and confirmed the transaction in MetaMask.<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/Hm6tRzLYKW4CHIGt1yjqNfpLaOKgTGJyHwopedw5PkghE6Kwl32yiVaxmDfPMxlLdXyJBQtraIEyK5IBnrMGKCToTaD8VvKuafYhDfv_rz3r9DlyQXTrCj_Z-H9mfhP4XnloSLk8\" alt=\"Cows in the Dark Forest: A Review of the CowSwap Decentralized Exchange\"\/><figcaption>CowSwap will highlight the Swap button after confirming the transaction.<\/figcaption><\/figure>\n<p>CowSwap charges a swap fee equal to the value of the trade. In our case it amounted to 0.0540555 GNO.<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"974\" height=\"479\" src=\"https:\/\/forklog.com\/wp-content\/uploads\/Bez-zagolovka-13.png\" alt=\"Cows in the Dark Forest: A Review of the CowSwap Decentralized Exchange\" class=\"wp-image-141412\" srcset=\"https:\/\/forklog.com\/wp-content\/uploads\/Bez-zagolovka-13.png 974w, https:\/\/forklog.com\/wp-content\/uploads\/Bez-zagolovka-13-300x148.png 300w, https:\/\/forklog.com\/wp-content\/uploads\/Bez-zagolovka-13-768x378.png 768w\" sizes=\"auto, (max-width: 974px) 100vw, 974px\" \/><figcaption>Transaction status can be checked in the <a href=\"https:\/\/gnosis-protocol.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">Gnosis Protocol Explorer<\/a>.<\/figcaption><\/figure>\n<p>Each transaction is accompanied by the sound of cows\u2019 mooing. Do not panic.<\/p>\n<h2 class=\"wp-block-heading\">Conclusions<\/h2>\n<p>According to the Flashbots team, since January 2020 Ethereum arbitrage bots have earned almost $750 million from MEV.<\/p>\n<p>Behind CowSwap\u2019s playful interface lie the sophisticated technical solutions of Gnosis Protocol v2: the exchange protects users from MEV, optimises gas costs, and enables trades at prices better than the market through a combination of CoWs and Gas-Free Transactions with DEX-aggregator features.<\/p>\n<p>Follow ForkLog news on Twitter!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In late April, the Gnosis project unveiled a protocol for decentralized exchanges with MEV protection and a Coincidence of Wants (CoWs) order-matching mechanism. We describe Gnosis Protocol v2 (GPv2) and test the DEX CowSwap.<\/p>\n","protected":false},"author":1,"featured_media":45546,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"select":"2","news_style_id":"1","cryptorium_level":"","_short_excerpt_text":"","creation_source":"","_metatest_mainpost_news_update":false,"footnotes":""},"categories":[1144],"tags":[1768,787],"class_list":["post-45545","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-longreads","tag-cowswap","tag-dex"],"aioseo_notices":[],"amp_enabled":true,"views":"41","promo_type":"2","layout_type":"1","short_excerpt":"","is_update":"","_links":{"self":[{"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/posts\/45545","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/comments?post=45545"}],"version-history":[{"count":1,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/posts\/45545\/revisions"}],"predecessor-version":[{"id":45547,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/posts\/45545\/revisions\/45547"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/media\/45546"}],"wp:attachment":[{"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/media?parent=45545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/categories?post=45545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/forklog.com\/en\/wp-json\/wp\/v2\/tags?post=45545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}