MEV: The Scalpers of Web3

Aw Kai Shin
10 min readJul 12, 2022

--

Source

Anywhere there is money to be made, scalpers will come to play. It is of no surprise that one of the acronyms which have popped up in the DeFi space recently is MEV: Miner Extractable Value. MEV sits at the pinnacle of scalper evolution whereby advancement in scalping technologies have enabled value extraction based on how public blockchains prioritise transactions. At the core of MEV lies the problem of information asymmetry and such asymmetry has enabled scalpers to extract more than 660M from unexpecting users.

Flashbots

Taking MEV by face value, it seems relatively harmless as miners are just extracting their fair value as payment for securing the network. However, where it starts to become detrimental is when these forms of value extraction goes beyond the conventional block mining rewards as miners/third-parties figure out unconventional ways to extract increasingly more from the network. This comes at the expense of the users and if bad enough, can even degrade network security.

The Information Premium

To understand MEV, we first need to go back to how transactions are confirmed on the network. Currently, for the majority of PoW or PoS chains, a user signals their willingness for their transaction to be finalized on the chain by paying a gas fee. This transaction processing fee is required to ensure that the user sends a genuine transaction as they stand to lose this fee if the transaction is malicious. Where this fee gets interesting is due to the fact that each new block on the network has a limited amount of space to which transactions can be added. In other words, the network is only able to process a limited number of transactions and needs a way to prioritise transactions.

Aside from validating new blocks, miners also have the responsibility to propose new blocks and this is where things start to get tricky. In a conventional scenario, a user signals their willingness for faster transaction confirmation times by increasing the gas fee which they are willing to pay. On the other side, miners would select the transaction with the highest gas prices from the transaction queue as this would maximize their profits. Plain and simple as this ensures that the miner is indifferent to the transaction contents and prioritizes based on the fee alone. The complication arises due to the presence of a publicly available transaction queue.

Photo by Krizjohn Rosales from Pexels: https://www.pexels.com/photo/group-of-men-forming-a-libe-761295/

All transactions on such networks will first have to be added to a queue (mempool) in order to be picked up by the miner. This queue is necessarily public given the transparency that public blockchains affords. Where an unsuspecting user might be caught off-guard is when the details of their transaction is used against them prior to being finalized on the network. Remember that it takes time for a transaction to be finalized (ie added to a block) and within this time, this information could be capitalized on as it had already been signed by the user. Of note, this is not only restricted to miners as third-parties who see such information are able to propose transactions with a higher gas fee to get their transaction priotitized.

The Time Premium

The information above is only valuable as long as the transaction has yet to be finalized. As such, the transaction confirmation duration sets an upper bound on the time value of such information, after which the information is essentially worthless to the MEV strategy. Given that ETH block times are approximately ~13 seconds, this doesn’t give much time for the MEV strategy to be carried out. As such, MEV is usually carried out by bots which generally does the following:

  • Monitor the transaction queue for transactions which meet their specific criteria
  • Calculate profitability based on available information. This will also have to take into account the gas costs
  • If there is a profit to be made, form a transaction based on the calculated parameters
  • Send the transaction with a higher gas fee to front-run the targeted transaction
  • Monitor the sequence of transaction confirmation as there is still the possibility of the target transaction being confirmed first. If so, cancel the MEV transaction

Efficiency is key here as every second the MEV transaction is delayed means the bot is closer to missing out on being included for that block. The above is taking into account a single bot but realistically, there would be plenty of bots each trying to get a piece of the pie. As such, in addition to having to be as efficient as the competition, network latency also plays a critical role to the success of the strategy.

Good read to understand how incentives could become so perverse

Those of you that have read Flashboys would remember the story where traders were fighting head over heels for their computer to be as close as possible to the exchange. Although the reason behind this was mundane, the implications were enormous. What they were all fighting for was to have the shortest internet cable to the exchange so that they would be first to front-run any trades that was on route to the exchange. This was due to the fact that exchanges then prioritized transactions by the sequence received.

As most blockchains default to gas fee to prioritize transactions, bots instead compete to be the the first in queue when a block is proposed. Notice that a block proposer has between the confirmation of the last block and the finalisation of the next block to propose a block. As such, the timing of block creation is not fixed and the only thing that the bots can do is outbid other bots in hopes that the block proposer will select their transaction upon finalizing the block template. Bots can submit a transaction with a prohibitively high gas fee but that would mean they significantly diminish their profits. What is more likely is that the bots will incrementally outbid each other by monitoring other bot transactions. This means that lower latency provides a competitive advantage to such strategies.

Capitalizing On The Premiums

Given the above background, there are a number of ways where profits can be extracted via reordering, including, or excluding transactions within a block. Do remember that all of the below strategies aim for their MEV transaction to be included in the same block or before the target transaction confirmation.

Sandwich Attack

A bot monitors the queue for a large incoming trade. Large trades would usually result in slippage which is the difference between the quoted price at the time when the user confirmed the trade and the effective price when the trade was confirmed.

Upon identifying a target trade, say in this case a trader is swapping 100ETH to wBTC, the bot will buy up wBTC before the target trade is approved. This increases the effective price of wBTC which the bot then sells back to the trader. From the trader’s perspective, this increases their slippage and hence their cost price of the equivalent wBTC received.

Arbitrage

A bot monitors the queue for a large incoming trade. Upon identifying the target trade, the bot calculates the implied price movement on the specific exchange where the trade is placed. The bot queries the price across other exchanges (decentralised but also centralised if they have sufficient capital) and compares the price impact above to determine profitability.

Using the same example above, the bot buys wBTC from other exchanges and immediately sells it to the exchange where the target trade is taking place. This increases the effective price of wBTC for the trader.

Sniping

A bot monitors the queue for transactions which are intended to buy newly released tokens/NFTs. As there is usually a rush of users trying to get their hands on the new token, the price of the token tends to increase rapidly upon launch. Based on the purchase transactions submitted by the users, the bot can determine if it is able to obtain the token by front running the user and then selling it to them at a significantly higher price.

Liquidation

A bot monitors the queue for liquidator transactions. Upon identifying a target transaction, the bot forms a liquidation transaction and sends it to the network with a higher fee. As such, the bot did not actually identify the liquidation event that was triggered but instead capitalised on the liquidators’ slower transaction.

Miners ++, MEV-Party +, Users --

Of note, the strategies above could be used by both miners or MEV-parties but in either case, the miner still stands to benefit the most form such strategies. This is especially so if the miner is also the MEV-party as block producers do not need to include a transaction fee to incentivize transactions to be included in a block.

The MEV-party stands to pocket the additional slippage in trades or front-running key token events. The miner benefits from the increased gas prices due to MEV bots outbidding each other. All the above comes at the expense of a degraded user experience as trades are always settled at the highest price, fees are consistently high, and any profit opportunities identified are effectively snatched away. Moreover, these MEV strategies tend to lead to negative externalities such as network congestion (i.e. p2p network load) and chain congestion (i.e. blockspace usage).

Protocol +/- ?

While it could be argued that MEV is part of the market efficiency in order to iron out information asymmetries, where the line is blurred is in access to the MEV tooling. Much of the MEV strategies detailed above require a fair bit of know-how in order to be executed. Moreover, the initial capital required might be quite significant to the average person especially when the gas fees are high, which is likely to be the case with all the MEV bots. This means that knowledgeable parties with sufficient capital reap the rewards in terms of MEV but this could potentially come at the cost of protocol security.

As a start, if the degraded user experience outweighs the benefits of using the network, community members might choose to leave the network. For the DeFi space, this has to be taken into account within the context of centralised exchanges which would technically do not face such problems. Users might move their trades to centralised exchanges which then reduces decentralisation guarantees.

A more existential question is what happens when the MEV to block rewards ratio starts tilting in favor of MEV. In this scenario, it is more profitable for miners (who themselves are assumed to have a pure profit incentive) to start using MEV strategies instead of securing the network. Of course the MEV strategies wouldn’t exist without the blocks being created. However, taken as a whole, the network will not be able to provide reasonable guarantees that a transaction would be included based purely on the gas fee.

Taking this a step further, miners could even rewrite blockchain history in what is called a time-bandit attack. By re-mining past blocks, all MEV extracted in the previous blocks could be used to subsidise the attack. This makes rational sense the higher the MEV to block reward ratio.

Timing The Market

The explosion of DeFi total value locked

This transaction queue design has been a core design of crypto projects since its inception so why the sudden interest? The answer to this is due to a confluence of factors (reference):

  • The explosion of DeFi meant significantly more value being transacted on-chain. Moreover, the market cap of ERC20 tokens has exploded relative to ETH.
  • During the bull run, transaction fees managed to outpace block rewards meaning that more value is being extracted through unconventional means.
  • Increased sophistication and adoption of MEV strategies meaning that this is no longer limited to a niche group of traders.

The second point above is what is concerning as it is hard to argue that such unconventional MEV strategies are of more value than securing the network.

Minimizing MEV Consequences

There are many brilliant minds which are currently working on minimising the negative externalities brought about by MEV strategies. Key amongst this group is the team at Flashbots, whose name is an ingenious play on the book Flashboys and bots, both of which are core pillars to MEV. I would highly recommend checking out their docs if you’re interested in learning more. Flashbots focuses on bringing transparency to the MEV ecosystem whilst also democratising MEV extraction.

While Flashbots focuses on working within the technical limitations of the transaction queue implementation, ChainLink labs are directly rewriting the rules of the game via their Fair Sequencing Services. At a high-level, this involves encrypting transaction data prior to being ordered by a decentralised oracle network. Effectively, transaction details are only visible on-chain at the point of execution while block proposal is no longer limited to just a single proposer.

All of these bid well for the future of public blockchains as so many bright minds are coming together; each focusing on a very niche aspect of the network but all contributing towards securing the network in a decentralised manner.

Thanks for staying till the end. Would love to hear your thought/comments so do drop a comment. I’m active on twitter @AwKaiShin if you would like to receive more digestible tidbits of crypto-related info or visit my personal website if you would like my services :)

--

--

Aw Kai Shin

Web3, Crypto & Blockchain: Building a More Equitable Web | Technical Writer @FactorDAO | www.awkaishin.com