← All papers
First page of Certifying optimal MEV strategies with Lean

Certifying optimal MEV strategies with Lean

Massimo Bartoletti, Riccardo Marchesin, Roberto Zunino

cs.CR Oct 16, 2025 · v1
Provides the first mechanized formalization of Maximal Extractable Value in Lean, with machine-checked proofs of MEV upper bounds for DeFi protocols.
Maximal Extractable Value (MEV) refers to a class of attacks to decentralized applications where the adversary profits by manipulating the ordering, inclusion, or exclusion of transactions in a blockchain. Decentralized Finance (DeFi) protocols are a primary target of these attacks, as their logic depends critically on transaction sequencing. To date, MEV attacks have already extracted billions of dollars in value, underscoring their systemic impact on blockchain security. Verifying the absence of MEV attacks requires determining suitable upper bounds, i.e. proving that no adversarial strategy can extract more value (if any) than expected by protocol designers. This problem is notoriously difficult: the space of adversarial strategies is extremely vast, making empirical studies and pen-and-paper reasoning insufficiently rigorous. In this paper, we present the first mechanized formalization of MEV in the Lean theorem prover. We introduce a methodology to construct machine-checked proofs of MEV bounds, providing correctness guarantees beyond what is possible with existing techniques. To demonstrate the generality of our approach, we model and analyse the MEV of two paradigmatic DeFi protocols. Notably, we develop the first machine-checked proof of the optimality of sandwich attacks in Automated Market Makers, a fundamental DeFi primitive.

Maximal Extractable Value (MEV) attacks on DeFi protocols have extracted billions of dollars. Verifying the absence of MEV attacks requires proving upper bounds showing that no adversarial strategy can exceed a certain profit, but no rigorous framework existed for certifying such bounds.

The paper develops a framework for certifying optimal MEV strategies using Lean. It models DeFi protocols and adversarial transaction orderings formally, defines what constitutes an optimal MEV strategy (one that maximizes extractable value), and constructs Lean proofs that a given bound is tight. The certification proves both that an adversarial strategy achieves the bound (lower bound) and that no strategy can exceed it (upper bound).

The Lean formalization certifies optimal MEV strategy bounds for specific DeFi protocol models. The framework provides machine-checked guarantees that the computed upper bounds on adversarial profit are correct, establishing a methodology for formally verified MEV analysis.