What is MEV? - The Art of On-Chain Extortion

Written by andreydidovskiy | Published 2023/04/27
Tech Story Tags: web3 | blockchain | crypto | blockchain-technology | mev | defi | blockchain-development | hackernoon-top-story

TLDR- MEV stands for Miner/Maximum Extractable Value - It is a subtle form of extortion that steals money from end users - Miner/Block producers are the only users with the power of MEVvia the TL;DR App

Empowering people around the world with the freedom of transaction, blockchain technology has brought a radical new model of economic activity to the forefront.

From borderless, censorship-resistant P2P payments to autonomous exchanges to permissionless lending protocols; a slew of incredible innovations have created a promised land and a wealth of opportunities for all!

Or so they told us.

Seduced by the promises of a truly fair economic ecosystem, individuals and organizations from every corner of the globe flocked to experiment with cryptocurrency and claim their financial freedom.

Not long after struggling to deal with the clunky interfaces of siloed networks, egregious gas fees, and barrages of transaction failures, end users began to feel notably poorer with the decentralized infrastructure in their lives and ultimately fled.

Certainly, the cyclical nature of the industry drove interest in and out with its incredible financial gains; however, beneath the surface of user activity, there was something more insidious taking place. Players with an asymmetric informational advantage were manipulating the technology and stealing the opportunities from users right under their noses.

As an open, distributed cloud network, blockchain technology works through a hybrid competitive/cooperative mechanism where nodes such as miners (in POW) or block producers (in POS) package transactions into blocks, submit those blocks to other nodes, and propagate the blocks throughout the network, appending them to the top of the chain. In return for providing these computationally intensive services, nodes are incentivized through token emissions, transaction fees, or a combination of both. This model of earning is cycle neutral, whether bull or bear, if a transaction is broadcast nodes earn for their service.

Initially, network participants were just happy to be contributing to the developing digital economy and earning for doing so…

However, as is the case with any other vertical of great profit, less-than-honest players arrive on the scene and began milking non-technical users for everything they had.

Hello MEV

MEV or Maximal Extractable Value is the practice of organizing transactions to prioritize including the ones that will earn the most for the miner/block producer, even if it means creating such a transaction and withholding all the others.

In a utopian fair economy, transactions would be processed based on their chronological order, first in, first out.

However, market forces for public goods (such as transactional freedom) demand incentive structures. In the case of blockchain, these market forces are primarily denominated in fees. Whenever a user submits a transaction on-chain they must pay a fee for doing so. The amount they pay results in the speed with which their transaction is executed. The more you pay, the higher the likelihood that your transaction is confirmed quickly.

As a chain gains users/applications, the amount of constant activity begins to bloat the network with transactions, in turn forcing the participants to increase their fee bids in order to operate normally. If a user bids too low, their transaction can indefinitely be suspended in a mem-pool until fees come down (if they ever do!)

Given that most of the applications built on these chains typically have some kind of financial value attached to them, fee markets can form and permanently force inflated costs to utilize the network. Resulting in an ousting of users with smaller-value transactions.

This is just the most basic form of MEV, which I refer to as “transactional fees”. This one is the least detrimental as it does create operation friction, but it does not steal.

The devious MEV, that squeezes value out of its users exists in other forms.

What forms of MEV exist?

Generally speaking, there are five core variations of MEV based on their touchpoints:

  1. FrontRunning — DEXs
  2. Arbitrage — DEXs
  3. Liquidations — Lending/Borrowing
  4. Transactional Fees— transaction throughput (discussed above)
  5. Generalized — repurposing transactions

Let's review these from empirical observations:

Frontrunning

The act of replacing another transaction with your own.

Imagine you want to trade 1 ETH for LINK tokens. You go to a DEX (such as UniSwap) and get a price quote of 250 LINK for 1 ETH. You are OK with that rate and execute the trade with 0.001 ETH as a gas fee. Some frontrunning bot sees your bid, thinks the rate is way too good, and wants that trade for itself. It would copy your transaction, submit that transaction from its own wallet and just pay 0.002 ETH as the gas price. Effectively taking your trade, making your transaction fail because that price rate is no longer available for your trade, and forcing you to try making the trade again at a higher price. You don't know why/who/what happened, but because you were already set on the trade, you oblige. Putting in the same 1 ETH trade size again, the DEX is only able to offer you 246 LINK tokens. Upset but not totally discouraged you accept the trade and pay the 0.001 ETH as gas again… Guess who’s watching!

That damn bot comes right back, sees your persistence in making that trade, and does the same thing again! Once more you get a notification in the UniSwap dashboard that your transaction has failed due to insufficient gas fees. Now with the wrath of god, you are hell-bent on completing this damn trade! You enter the 1 ETH, get offered only 242 LINK tokens, think it's still worthwhile, enter the trade, but now provide 0.002 ETH as the gas fees to secure the trade. But it ain’t over! Our beloved bot comes galloping in, sees your trade, realizes that you have raised your gas, and decides to recoup its last trade by allowing your trade to execute, pushing up the LINK/ETH price to 238 tokens, and then sells 238 LINK back to the market.

* Quick recap, the bot acquired 250 LINK tokens for 1 ETH, then 246 LINK for 1 ETH, and just sold 238 LINK tokens for 1 ETH. As a result, its currently pocketed 8 LINK tokens (minus gas) and has a 250 LINK position that is up 3% If it sells through the current spot price to recoup its 1ETH, it would need to sell ~244 tokens. Finally giving it an operational profit of ~14 LINK tokens (minus gas fees).

Arbitrage

Taking advantage of price discrepancies.

Another trade-related scenario. This time with a little less pain to the end user. Arbitraging is an actual job. People find market inefficiencies and profit by stabilizing them, pocketing the spread in price (minus gas fees).

If 1inch exchange has a trade rate of 1 ETH to 500 UNI tokens but Matcha has a trade rate of 1 ETH to 510 UNI tokens. Then an arbitrageur might want to step in, buy the UNI tokens on Matcha, driving the trade rate to 1:503, and then sell them on 1inch driving the trade rate to match Matcha. As a result of its operations, the arbitrageur should be able to keep 4 UNI tokens (minus gas fees) as profits.

Not so fast. As soon as that arbitrageur broadcasts his operational intention, here comes an arbitrage bot! Seeing the potential for profit in this scenario, the arb bot would pluck that transaction, duplicate the logic and submit its own transaction with a higher gas fee; rendering the manual arbitrageurs obsolete.

Liquidations

Forcing more pain into an already painful situation.

There are two vectors for MEV extraction in liquidation scenarios.

The first scenario is replacing the liquidators themselves. Let's use AAVE as an example platform. User A has deposited 5 ETH at $4,000 for a $10,000 USDT loan. Whenever the price of ETH plummeted below $2,100, their position was automatically liquidated to pay back the lender. Liquidation bots can monitor these events and at the exact moment of liquidation being engaged, they step in to conduct the liquidation, collecting the fee for doing so.

The second scenario is the liquidation premium that borrowers have to pay for violating their agreement. In addition to collecting to the fee for providing the service a liquidation bot would also collect the surcharge fee from the borrower's side.

Transactional Fees

Prioritizing pricier transactions.

Already mentioned earlier, this is the foundational form of MEV. Here users are subjected to floating prices of gas fees. Wealthier users that have more capital to expend for speed and security guarantees end up pushing out less funded users and ultimately don’t give them a fair chance to content on the same opportunities.

Say User A has $100,000 and User B has $5,000. Both of them see an arbitrage opportunity worth $1,000. If they both submit their transactions at the same time, but User A is willing to pay $900 in gas fees while User B is only willing to pay $750, then the playing field is not “fair”. Over the long term, this would result in the better-funded user taking advantage of all such opportunities, capturing all of the potential profits (even at tighter margins), and denying the smaller user any hope of growing their portfolio.

Generalized

Perpetually denying backlogged transactions.

This is a more advanced version of the transactional fee in the sense that they have no set purpose or discrimination of transactional activity. They serve the single purpose of denying all other users any opportunity for profit.

Even if a user decides that they are willing to wait for a transaction to go through by submitting it to the mempool, they are ultimately subjected to the same concept as the transactional fee. Where MEV bots scan all logged activity and always replace them with their own.

Is MEV good or bad?

Depends who’s asking.

It is both good and bad… Good for long-term chain security and price accuracy. Bad for end users.

On one hand, MEV does incentivize economic coherence. By incessantly monitoring prices, arbitration bots tighten price spreads and minimize discrepancies, ultimately providing more accurate, consistent prices. Additionally, high network fees ultimately translate to higher security guarantees. Given that more profits are made potentially available, more machines get involved in the computation processes, decentralizing the network. Higher decentralization tends to correlate with higher participant contribution to keep the mining/validating nodes online at all times, increasing security.

On the other hand, these forces are destructive to the end users. These tight operations confine the potential user bases to wealthy individuals and exclude the vast majority of the population. Not to mention that they take advantage of the less funded, less knowledgeable participants and without remorse rob them blindly.


As the technology evolves and more people become aware of the full scope of impact that MEV has on the greater industry, this “opportunity” will likely dwindle away.

One solution that has already been proposed to solve the MEV problem is Chainlink’s FSS (Fair Sequencing Service) which works in a two-pronged way. First, it aggregates transactions off-chain into blocks and published them in chronological order. Second, it encrypts the data on-chain to protect it from being revealed to miners/block producers until after they include the transaction. It intends on making this activity provably fair through the use of a smart contract for this function rather than individual nodes. (Section 5 of the Chainlink 2.0)

At this time there is only one thing that we as users can really do if we want to keep using cryptocurrency. Minimize on-chain interaction.

I hope this was able to shine some light on the inner workings of this less-than-transparent action.

Thank you so much for reading.

May this serve you well and protect you from needlessly paying fees.

Live long and prosper 🥂.


Here are some extra resources if you want to dive deeper into understanding the dark art of MEV:

Flash Boys 2.0 (This one is a must-read)

Chainlink on MEV

Ethereum on MEV

Also published here.


Written by andreydidovskiy | Digital Asset Investor & technology connoisseur laser focused on bringing incredible decentralized applications to life | Technical Writing with creative flare | Solve for solution's sake 🌟
Published by HackerNoon on 2023/04/27