Maximal Extractable Value (MEV) is where block producers try to extract their maximum value of profitable transactions by reorganising, including and excluding the transactions in a block – often by deploying complex algorithmic bots – as block producers have full autonomy in the inclusion and ordering process of transactions, with the goal of ultimately optimising their maximum profit.
How Does Maximal Extractable Value Work?
While validators in Proof of Stake (PoS) ensure the validity of transactions, miners in Proof of Work (PoW) blockchains are in control of ordering of transactions in each block, taking advantage of the waiting time since the pending transaction has yet to be confirmed, block producers can maximise their profit by paying a higher gas price for a higher chance of inclusion of their transactions being mined, known as MEV.
MEV can also be used for different malicious forms of value extraction, block rewards and fees. Attackers are usually the block producers who have the ability to order transactions within a block, in that sense, regular transactions made by less experienced users, using lower, average fees go to the mempool – a base of transactions waiting for approval by the miners – first.
Transactions with higher fees get verified first, whilst ones with lower fees have to wait. An issue is they (the ones with lower fees) might get front-runned, meaning if someone else spots a transaction (for example a DEX swap) they can create a transaction with a higher fee to prevent or at least affect the transaction in the mempool.
MEV Sandwich Attacks
Sandwich attacks are one of the bemoaned forms of MEV, where two adversarial transactions make a profit from a user’s victim transaction, resulting in price manipulation. A sandwich attack can be performed by using the front-running and back-running tactics, where two orders are placed – one before the front-running and one after the back-running after the trade, the attacker will then be able to sandwich the pending transaction in the middle of the trade, that is an example of manipulating the asset price. In the blockchain, transactions are transparently observed, with the attacker observing a victim’s pending transaction from trading one asset to another, then front-runs the victim by buying the targeted asset, and the victim executes the trade.
The attacker, meanwhile, back-runs by buying back the amount from the first trade – attackers by taking advantage of the transparency, puts up the trade price and buys at cheaper price so as to make a profit, meaning that the victim always have to buy sell at a higher price. This might as well reflect changing in market conditions in a victim’s transaction could be a factor for attackers in gaining profits specifically.