Halborn Logo

// Blog

Blockchain Security

What Is Miner Extractable Value (MEV)?


profile

Rob Behnke

August 5th, 2021


Miner Extractable Value (MEV) is behind the rash of bots performing arbitrage on cryptocurrency exchanges.  They exploit the rules of the blockchain to make a profit at the expense of blockchain users.

Inside Block Creation

MEV is made possible by the rules governing how blocks are created on the blockchain.  Blockchain uses consensus algorithms like Proof of Work (PoW) to select a miner to create the next block in the chain.  While this process can vary greatly, the goal is to have a single valid version of each block created.

The legitimate creator of a block has a great deal of autonomy regarding what they put in those blocks.  Blockchains typically have the concept of transaction fees, which are paid by the account making a transaction to the creator of the block that adds it to the distributed ledger.

Transactions do not have to be added to the blockchain in any order, and block creators are allowed (and expected) to be greedy about transaction fees.  The higher the fee associated with a given transaction, the faster it will likely be added to the ledger.

Introducing MEV

The concept of MEV comes from the fact that block creators (called “miners” in Proof of Work or PoW blockchains) have the ability to order the transactions contained within a block that they create however they wish.  They also have an incentive to maximize their profits in terms of the transaction fees paid to them.

Some traders exploit these factors by creating bots that perform arbitrage across different cryptocurrency exchanges.  When an imbalance exists between the price of an asset on different crypto exchanges, traders can make a profit by buying on one exchange and selling on another.  

However, the ability to exploit these imbalances is dependent on how transactions are ordered within a block because the transactions that exploit the price imbalance also help to rebalance prices by redistributing the supply of the asset across exchanges.

MEV comes into play here because these cryptocurrency bots enter into bidding wars to be the first to make these transactions.  The transaction with the highest fee – or the one that the miner decides to include first – wins the race and makes the profit.

MEV, Frontrunning, and DeFi Hacks

MEV bots race to be the first to exploit imbalanced prices or “slippage,” and the best way to accomplish this is to exploit the slippage before it happens. Any large trade on a cryptocurrency exchange will cause some slippage because it changes the supply of the asset being traded.

MEV bots exploit this by monitoring the blockchain network for transactions containing large trades that have not yet been added to a block.  If a bot sees an upcoming buy, it will frontrun the buy, decreasing the asset’s supply and causing the price to go up.  When the original trade goes through, supply decreases further and price increases even more.  The bot can then sell its assets, making a tidy profit off of the trade.

MEV bots have an impact on cryptocurrency arbitrage, but they’re also showing up in DeFi hacks as well.  A recent hack against the DODO DEX was frontrun by a MEV bot, whose owner later returned the funds, decreasing the impact of the attack.  And on July 31, 2021, a MEV bot was exploited by a malicious smart contract in a targeted attack against vulnerable MEV scripts.

MEV and Blockchain Security

MEV can be extremely profitable to a trader, meaning that every transaction on many blockchains is monitored and potentially at risk of frontrunning by MEV bots.  When performing transactions or developing contracts on blockchain platforms, it is important to consider the potential for frontrunning and its impacts.