Technology

MEV Bots and Sandwich Attacks: How Do They Work?

monsitj / iStock via Getty Images

A Maximal Extractable Value (MEV) bot using a subway-themed identifier recently made over a million dollars in profit using sandwich attacks. MEV bots are not new; now, sandwich attacks are becoming familiar enough for developers to think about and deploy countermeasures. But what are MEV bots, and how does a sandwich attack work?

MEV’s Role in the Blockchain Networks

Maximal Extractable Value (MEV) is the function of monetization present in blockchain networks. Network participants in charge of processing transactions, miners or validators, order their selection and execution. This architecture allows MEV bots to profit from price discrepancies (arbitrage).

For example, an MEV arbitrage bot could be deployed to monitor trades on decentralized exchanges (DEXes). If there is an incoming large buy order in play, this will point toward the price increase of a particular cryptocurrency.

When identifying such a sizeable incoming trade, the MEV bot executes its order. This way, it would take advantage of the price shift likely resulting from the DEX order. The MEV bot would typically place a buy order at a lower price just moments before the DEX order is executed.

As the asset price increases following the DEX trade, the MEV arbitrage bot would extract the value – profits – from the price discrepancy. Therefore, although MEV bots are independent of miners/validators, they take advantage of their transaction ordering.

However, some MEV profit extraction strategies are more manipulative than others.

MEVs: Sandwiching and Frontrunning

Another way to extract value from incoming trades is to submit a sell/buy order between trades. For example, if the MEV bot places a large sell order just before a large buy order, it could decrease the asset price. The goal is to repurchase the asset at a lower price, which the bot would sell for a higher price.

This MEV strategy is called a “sandwich attack” because the bot inserts its trades between the large buy order and the follow-up sell orders. Based on the market liquidity at the time and the buy order size, sandwich-based MEV extraction has a varying degree of success.

In April, sandwich-based MEV profits more than doubled compared to standard MEV arbitrage.

MEV bots can also front-run users’ transactions just before they are confirmed on the network. They do so by copying them but setting a higher gas fee to push transactions through ahead of the original one.

Of course, the network throughput is burdened as a side effect of people deploying MEV bots to insert orders to extract value. Consequently, transaction fees go up as the network gets congested, which happened in April with increased bot activity.

Suffice it to say the resulting fees, averaging $29 on Uniswap, do not constitute a welcoming user experience. Even simple stablecoin transfers, at $8.54, makes it exceedingly difficult to make a case for mass DeFi adoption.

MEV Bots: Exploiting Complexity

Technically, Bitcoin has smart contracts, but they are severely limited in scope. They focus on basic financial transactions, such as sending and receiving BTC and enforcing multi-sig requirements. In contrast, Ethereum’s Solidity programming language supports complex smart contracts and functions.

This difference in smart contract complexity mirrors the difference between MEV on Bitcoin vs. MEV on Ethereum. On the Bitcoin network, MEV bots are limited due to the UTXO (Unspent Transaction Output) model, which straightforwardly handles transactions.

For instance, Bitcoin miners could deploy MEV bots to extract value by including the transactions they mine or by reordering the mempool transactions to take advantage of price movements.

However, unlike Ethereum, Bitcoin’s mempool doesn’t include the entire transaction pool because transactions have to become eligible to be included, following strict criteria such as non-conflicting transaction ID, fees, and valid signatures. This makes it exceedingly difficult for MEV bots to manipulate transaction orders.

Moreover, Bitcoin’s 10-minute block interval, compared to Ethereum’s 12-second block finalization time, creates drastically fewer opportunities to front-run transactions. Ironically, this creates a situation in which Bitcoin inherently disincentivizes excessive network load, leading to lower transaction fees and lesser fee volatility.

This article originally appeared on The Tokenist

 

Thank you for reading! Have some feedback for us?
Contact the 24/7 Wall St. editorial team.