This is a two-part article about Maximal Extractable Value (MEV) and front-running on Ethereum. The first part looks at what MEV is and why it poses a significant threat to the DeFi industry. The second part will explore how SKALE addresses MEV and eliminates the risk of front-running, and the benefits that brings for Ruby and the wider SKALE ecosystem.
Maximal (or Miner) Extractable Value (MEV) refers to the profits that miners and other entities can harvest by exploiting the transparency of the blockchain to front-run profitable transactions before they are confirmed. MEV, which almost always happens at the expense of regular users, is now a serious problem for Ethereum, and may ultimately undermine the stability of the network.
SKALE's L2 solution uses threshold encryption to protect users against front-running by default, hiding transactions from malicious entities until they are safely confirmed.
What Does MEV Look Like In Practice?
Transparency is a core feature and benefit of open blockchains. All transactions and assets are visible, searchable, and traceable. This property of blockchain stands in stark contrast to TradFi, which has suffered numerous crises stemming from its inherent opacity. As USDP issuer Paxos has noted, "The financial crisis exposed just how the current system wasn’t—and isn’t—set up to provide this transparency. (When financial markets switched from paper to electronic trading 50 years ago, the goal was to promote liquidity and volume at the expense of transparency around who owns what asset and when.)"
But there are times when transparency has its downsides. On Ethereum, one of the most serious drawbacks is the problem of Maximal Extractable Value or Miner Extractable Value (MEV), defined as:
The maximum value that can be extracted from block production in excess of the standard block reward and gas fees by including, excluding, and changing the order of transactions in a block.
The risk of MEV is an unintended consequence of the way Ethereum is designed. When a user submits a transaction, there is a period of time (which typically lasts anything from a few seconds up to several minutes under normal network conditions) during which it sits in the mempool—the queue of transactions that are waiting to be processed and included by miners in a block. Because the transaction has not yet been confirmed, another user can take advantage of any opportunity it embodies by arranging to have a similar transaction confirmed ahead of it.
This is particularly easy for miners, who can choose which transactions they process, but can be accomplished by anyone simply by paying a higher gas fee than the original transaction. Front-running transactions on Ethereum is a lucrative activity, and there are sophisticated predatory bots called "searchers" that trawl the mempool, looking for ways to profit from its transparency.
The ruthless environment of Ethereum's mempool, and the extreme lengths developers have to go to in order to avoid being front-run, have been explored at length in accounts like Ethereum Is A Dark Forest and Escaping The Dark Forest. These describe the writers' efforts to rescue large amounts of funds at risk, knowing that drawing any attention to their attempts would instantly make those tokens a target for searchers.
However, it's not just these big one-off heists that are the problem. Examples of transaction types that searchers routinely and automatically exploit include:
- DEX arbitrage: When prices for a token are different on two different AMMs, a trader can buy the token on one exchange and sell it on the other atomically (in the same block), profiting without risk.
- Liquidations: DeFi protocols like Maker and Aave allow anyone to start a liquidation on an under-collateralized Vault, for which they receive a fee from the protocol's liquidation penalty.
- Sandwiching: A searcher can see large incoming DEX trades and place buy/sell orders before and after they occur to profit from the resulting price movement.
Any regular Ethereum user seeking to profit from one of these events can expect to be front-run by searchers.
Beating Front Running
MEV is a growing problem for Ethereum. It represents a "hidden tax" on users, who either end up paying more for their trades or missing opportunities entirely. It even encourages consensus instability, since there is an incentive for miners to reorganize recent blocks and rewrite blockchain history to profit from the best opportunities—a kind of meta-attack by the ultimate predator.
Pmcgoohan, the pseudonymous researcher who discovered the MEV issue in Ethereum pre-Genesis in 2014, describes how the problem might affect everyday users in just a few years if left unchecked:
To our kids ether is the dominant global currency and it’s used everywhere: when you buy insurance, when you buy a train ticket, pay a restaurant bill, go to a game, buy a pizza, pay for your tuition.
You order some groceries from an open marketplace smart contract. A small local firm sees your order and can offer you the best price, including biking it over to you. But Mega-Corp has paid the MEV auction winner to censor all grocery transactions except theirs from the block. They don’t even have to compete on price. You overpay for your shopping and the local store closes down.
You manage to find an NFT [non-fungible token] ticket for the Dua Lipa comeback tour for $50 (in 2021 money) on an auction dapp. When you try to buy it, a bot sees your transaction and front-runs it for the same price. But, don’t worry, in the same block they’ve sold it back to you for your maximum bid of $100.
MEV is essentially a parasitic ecosystem that lives on Ethereum L1. It's getting worse, and it cannot easily be fixed without incurring serious unintended consequences. As Paradigm Capital's Charlie Noyes writes, "Ethereum’s application-layer complexity and MEV are continuing to grow exponentially. The known lower-bound on MEV revenues could be larger than the value of ETH miner security incentives within the year."
In other words, it may soon become more profitable for miners to harvest value at the expense of ordinary Ethereum users than it is for them to protect the network.
As more money moves into DeFi, the problem is only going to grow. It's now a routine feature of Ethereum L1, having increased exponentially over the last 18 months. In fact, a number of mining pools have publicly announced their MEV strategies, with others secretly front-running the transactions they process to squeeze extra value out of Ethereum users.
Additionally, as SKALE CTO and co-founder Stan Kladko explains, front-running is even more of a risk on Proof-of-Stake systems than for Proof-of-Work. Users will therefore become more vulnerable still, as PoS becomes a common basis for DeFi blockchains.
Every SKALE S-Chain is protected against front-running by default. Exactly how this works, and what it means for Ruby.Exchange, will be explored in the second part of this blog post.
Trading With Confidence On Ruby.Exchange
MEV is a significant and growing problem in the DeFi space, and one that impacts all users, whether they notice it or not. In the second part of this blog, we'll explore how SKALE's solution to front-running allows traders and liquidity providers to transact freely on Ruby, without worrying that they are being exploited by searchers.
Find out more about Ruby.Exchange by subscribing to our blog and following our Twitter and Telegram accounts.