MEV, Ethereum's Dark Forest, and KeeperDAO

March 1, 2024
Quantstamp Labs

Quantstamp recently completed its audit of kCompound, a new product from KeeperDAO. kCompound allows users to open loans using Compound that receive automatic default protection from the KeeperDAO just-in-time underwriter and preferred liquidation using the KeeperDAO Hiding Game. These features, designed to protect borrowers in times of high volatility and ensure they lose less collateral in the event of a liquidation, are only available through kCompound.

KeeperDAO provides unique products like kCompound by leveraging automated agents called "keepers" and advanced execution strategies collectively called “the hiding game” to protect users and minimize miner extractable value (MEV). This is especially important today, with the rising impact of MEV on users across all sectors of DeFi.

According to explore.flashbots.net, bots have extracted over 500 million USD worth of value from market participants from Jan 1, 2020 to May 9, 2021.

Predators Lurking in the Dark Forest

Arbitrageurs and liquidators play important roles in the Ethereum ecosystem. When someone successfully arbitrages the difference between the price of a particular asset on two different exchanges, other users of those exchanges benefit by receiving a price that reflects a wider market. When a loan is liquidated on lending protocols such as Compound, the liquidator is keeping that protocol healthy and solvent. In the case of debt-backed assets such as MakerDAO’s Dai stablecoin or Synthetix’s synths, liquidators are helping maintain the crucial balance between the collateral and the issued assets.

Ideally, competition for profit among arbitrageurs, liquidators, and other market participants would always lead to healthy, efficient markets and DeFi protocols. In recent years however, a destructive form of competition has emerged among specialized bots operating in the Ethereum mempool. With ever-increasing sophistication, they have deployed strategies that siphon profit from traders, liquidators, and other agents performing transactions, turning the mempool from a simple piece of infrastructure into what Dan Robinson and Georgios Konstantopoulos memorably called the “dark forest.”

Miner Extractable Value (MEV)

How do these bots end up with profit that should have belonged to you? One way is to watch the mempool closely for pending transactions, and when they spot a profitable one, they submit a nearly identical copy of that transaction except this transaction 1) replaces the address of the original transaction with their own and 2) submits a higher gas fee so that it gets processed before the original transaction. This practice is called front-running.

It doesn’t end there. Once a bot tries to front-run you, other bots will try to front-run the first bot, and this goes on, resulting in a frenzy called a gas war or priority gas auction, as the bots bid the gas fee higher and higher in order to be first in line. Eventually the bid will get high enough that the winner can end up paying more gas than the profit was worth to begin with, and all of the profit ends up going to the miner, who wasn’t even involved in the bidding but happily collects the winning gas fee.

This is how, bizarrely, a miner can end up with your profit. Profit that can be captured in this way is called miner extractable value, or MEV, and covers a broad range of strategies far more sophisticated than simple front-running. The impact of these developments has accelerated with the rise of DeFi and its many MEV-rich transactions, and the potential loss of mining revenues as a result of EIP-1559 may be pushing some miners into the practice of MEV capture, with Ethermine, the second-largest Ethereum mining pool, recently announcing that they have launched MEV-capturing software.


Ethermine, who recently launched MEV-capturing software, mined nearly 20 percent of Ethereum blocks over the last 7 days (May 2 - 7, 2021). source: etherscan

A Shepherd in the Dark Forest

KeeperDAO was created to give users, bots, and protocols a way to navigate Ethereum’s dark forest, by providing a system that hides MEV and ensures market participants stand to gain more by cooperating than competing.

Below is an excerpt from KeeperDAO’s Introducing kCompound post were KeeperDAO explains how kCompound works in greater detail:

“Here’s how it works: if a loan opened through kCompound falls below the health threshold, KeeperDAO’s JITU [Just-In-Time-Underwriter] will spring into action, automatically putting up additional collateral as a buffer to keep your position solvent. During this time, if the health of the loan recovers, or you add more of your own collateral, the JITU can withdraw the provided buffer, and you just avoided a costly liquidation.
On the other hand, if the health of your loan continues to fall after the JITU has intervened, liquidation will begin. But your position won’t be hunted on the open market. In fact, outside of the Hiding Game, your loan will appear to be in perfect health, “hiding in plain sight,” thanks to the buffer provided by the JITU. Instead, a KeeperDAO keeper will get to work finding the best price for your collateral, targeting a 5% profit margin (equal to Compound’s liquidation incentive). This profit will then be split between you, the keeper, and the KeeperDAO treasury, meaning that kCompound borrowers actually receive a portion of the profits from their own liquidation!”

In addition to kCompound, KeeperDAO offers users another hiding game called the Hiding Book, which allows users to execute gasless, zero-slippage limit orders that are protected from front-running and sandwich attacks. Quantstamp is proud to announce that we have had 4 separate security engagements with KeeperDAO.

Coordinating Win-Win Scenarios

What makes blockchain technology novel is that it allows humans to coordinate in ways that turn zero-sum games into “win-win” scenarios. In the case of KeeperDAO, it incentivizes market participants to work together to combat MEV, a practice that may even threaten Ethereum consensus if miners choose to 51% attack each other in order to steal MEV opportunities from other miners.

Quantstamp looks forward to working with projects like KeeperDAO to create further “win-win” scenarios for today’s digital nations and the digital nations of tomorrow.

Quantstamp Labs
May 5, 2021

Quantstamp recently completed its audit of kCompound, a new product from KeeperDAO. kCompound allows users to open loans using Compound that receive automatic default protection from the KeeperDAO just-in-time underwriter and preferred liquidation using the KeeperDAO Hiding Game. These features, designed to protect borrowers in times of high volatility and ensure they lose less collateral in the event of a liquidation, are only available through kCompound.

KeeperDAO provides unique products like kCompound by leveraging automated agents called "keepers" and advanced execution strategies collectively called “the hiding game” to protect users and minimize miner extractable value (MEV). This is especially important today, with the rising impact of MEV on users across all sectors of DeFi.

According to explore.flashbots.net, bots have extracted over 500 million USD worth of value from market participants from Jan 1, 2020 to May 9, 2021.

Predators Lurking in the Dark Forest

Arbitrageurs and liquidators play important roles in the Ethereum ecosystem. When someone successfully arbitrages the difference between the price of a particular asset on two different exchanges, other users of those exchanges benefit by receiving a price that reflects a wider market. When a loan is liquidated on lending protocols such as Compound, the liquidator is keeping that protocol healthy and solvent. In the case of debt-backed assets such as MakerDAO’s Dai stablecoin or Synthetix’s synths, liquidators are helping maintain the crucial balance between the collateral and the issued assets.

Ideally, competition for profit among arbitrageurs, liquidators, and other market participants would always lead to healthy, efficient markets and DeFi protocols. In recent years however, a destructive form of competition has emerged among specialized bots operating in the Ethereum mempool. With ever-increasing sophistication, they have deployed strategies that siphon profit from traders, liquidators, and other agents performing transactions, turning the mempool from a simple piece of infrastructure into what Dan Robinson and Georgios Konstantopoulos memorably called the “dark forest.”

Miner Extractable Value (MEV)

How do these bots end up with profit that should have belonged to you? One way is to watch the mempool closely for pending transactions, and when they spot a profitable one, they submit a nearly identical copy of that transaction except this transaction 1) replaces the address of the original transaction with their own and 2) submits a higher gas fee so that it gets processed before the original transaction. This practice is called front-running.

It doesn’t end there. Once a bot tries to front-run you, other bots will try to front-run the first bot, and this goes on, resulting in a frenzy called a gas war or priority gas auction, as the bots bid the gas fee higher and higher in order to be first in line. Eventually the bid will get high enough that the winner can end up paying more gas than the profit was worth to begin with, and all of the profit ends up going to the miner, who wasn’t even involved in the bidding but happily collects the winning gas fee.

This is how, bizarrely, a miner can end up with your profit. Profit that can be captured in this way is called miner extractable value, or MEV, and covers a broad range of strategies far more sophisticated than simple front-running. The impact of these developments has accelerated with the rise of DeFi and its many MEV-rich transactions, and the potential loss of mining revenues as a result of EIP-1559 may be pushing some miners into the practice of MEV capture, with Ethermine, the second-largest Ethereum mining pool, recently announcing that they have launched MEV-capturing software.


Ethermine, who recently launched MEV-capturing software, mined nearly 20 percent of Ethereum blocks over the last 7 days (May 2 - 7, 2021). source: etherscan

A Shepherd in the Dark Forest

KeeperDAO was created to give users, bots, and protocols a way to navigate Ethereum’s dark forest, by providing a system that hides MEV and ensures market participants stand to gain more by cooperating than competing.

Below is an excerpt from KeeperDAO’s Introducing kCompound post were KeeperDAO explains how kCompound works in greater detail:

“Here’s how it works: if a loan opened through kCompound falls below the health threshold, KeeperDAO’s JITU [Just-In-Time-Underwriter] will spring into action, automatically putting up additional collateral as a buffer to keep your position solvent. During this time, if the health of the loan recovers, or you add more of your own collateral, the JITU can withdraw the provided buffer, and you just avoided a costly liquidation.
On the other hand, if the health of your loan continues to fall after the JITU has intervened, liquidation will begin. But your position won’t be hunted on the open market. In fact, outside of the Hiding Game, your loan will appear to be in perfect health, “hiding in plain sight,” thanks to the buffer provided by the JITU. Instead, a KeeperDAO keeper will get to work finding the best price for your collateral, targeting a 5% profit margin (equal to Compound’s liquidation incentive). This profit will then be split between you, the keeper, and the KeeperDAO treasury, meaning that kCompound borrowers actually receive a portion of the profits from their own liquidation!”

In addition to kCompound, KeeperDAO offers users another hiding game called the Hiding Book, which allows users to execute gasless, zero-slippage limit orders that are protected from front-running and sandwich attacks. Quantstamp is proud to announce that we have had 4 separate security engagements with KeeperDAO.

Coordinating Win-Win Scenarios

What makes blockchain technology novel is that it allows humans to coordinate in ways that turn zero-sum games into “win-win” scenarios. In the case of KeeperDAO, it incentivizes market participants to work together to combat MEV, a practice that may even threaten Ethereum consensus if miners choose to 51% attack each other in order to steal MEV opportunities from other miners.

Quantstamp looks forward to working with projects like KeeperDAO to create further “win-win” scenarios for today’s digital nations and the digital nations of tomorrow.

Keep up with Quantstamp and the latest industry trends 🛡
Sign up to our newsletter 📬
Keep up with Quantstamp and the latest industry trends 🛡
Sign up to our newsletter 📬
Quantstamp Announcements

Modular Account: How Audits Can Help Shape Standards And Catalyze Mass Adoption

Quantstamp recently conducted a smart contract audit for Alchemy’s Modular Account, a wallet implementation designed from the ground up for ERC-4337 and ERC-6900 compatibility including two plugins

Read more
Quantstamp Announcements

Quantstamp 2023 Web3 Security Year In Review

As the year comes to a close, we wanted to take a moment to reflect on this year’s biggest hacks, root causes, and noteworthy trends.

Read more