With the advent of blockchain, Decentralised Finance (DeFi) has become an accessible and decentralised method for financial services. One of the most important components of DeFi is the Decentralised Exchanges (DEXs), smart contracts that let users exchange tokens with each other. Trading through DEXs has become crucial in the blockchain ecosystem; however, new malicious activities have begun to spread in parallel. The Maximal Extractable Value (MEV) is becoming pervasive. In this paper, we propose an analysis of the magnitude of MEV activities and a new solution to prevent sandwich attacks after a deep overview of the current anti-MEV approaches. We focused on sandwich attacks because they are the most common MEV attacks (1,330,732 attacks within our 3-year-wide dataset) and cause significant losses to end users ($809,453,320 recorded in our dataset). Our proposed solution prevents sandwich attacks by enhancing token contracts to enforce a cooldown for transferring tokens. Unlike existing approaches, this solution can be easily integrated into any token contract, providing developers with a versatile and customisable MEV solution. Additionally, we extensively evaluate our solution and show that it successfully blocks all sandwich attacks, prove that it does not cause any harm to normal users, and compute that it only introduces a small 3 % gas fee increase.
An anti-sandwich mechanism for EVM's smart contracts
Guidi B.;Michienzi A.
2026-01-01
Abstract
With the advent of blockchain, Decentralised Finance (DeFi) has become an accessible and decentralised method for financial services. One of the most important components of DeFi is the Decentralised Exchanges (DEXs), smart contracts that let users exchange tokens with each other. Trading through DEXs has become crucial in the blockchain ecosystem; however, new malicious activities have begun to spread in parallel. The Maximal Extractable Value (MEV) is becoming pervasive. In this paper, we propose an analysis of the magnitude of MEV activities and a new solution to prevent sandwich attacks after a deep overview of the current anti-MEV approaches. We focused on sandwich attacks because they are the most common MEV attacks (1,330,732 attacks within our 3-year-wide dataset) and cause significant losses to end users ($809,453,320 recorded in our dataset). Our proposed solution prevents sandwich attacks by enhancing token contracts to enforce a cooldown for transferring tokens. Unlike existing approaches, this solution can be easily integrated into any token contract, providing developers with a versatile and customisable MEV solution. Additionally, we extensively evaluate our solution and show that it successfully blocks all sandwich attacks, prove that it does not cause any harm to normal users, and compute that it only introduces a small 3 % gas fee increase.I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.


