Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Lean formalization of MEV properties.

r-marche/MEV-formal

Repository files navigation

Formalization of MEV

The Maximal Extractible Value (MEV) is a central notion in smart contracts for decentralized finance. When an adversary proposes a new block of transactions, they can choose what to include in the block, and in which order. This privilege can be sometimes exploited to obtain a cryptocurrency gain: the MEV.

We formalize MEV in Lean 4. We provide a general framework providing the main definitions and related theorems, which can be applied to arbitrary smart contracts. We then put our tools to use, and establish the MEV of a few use cases.

Contents

HelpersLib/PReal

This helper library defines a type for positive reals and related results. It is akin to the NNReal library in Mathlib. Most results in this library are taken from this repository.

  • Basic.lean

    Contains coercions to NNReal and Real, and related properties.

  • Order.lean

    Contains basic propositions about inequalities of PReal values.

  • Sqrt.lean

    Defines the square root of a PReal value, and a few related propositions.

  • SqrtCalc.lean

    Contains ad hoc lemmas that simplify MEV calculations for AMM contracts.

  • Subtraction.lean

    Defines subtraction for PReal values, and related propositions.

MEVLib

The core library.

  • System.lean

    Defines a generic smart contract system, as well as MEV. Also contains our main theorem, MEV.characterization which allows us to establish the MEV of a contract.

  • Airdrop.lean

    Contains the simplest example of application of our theory, an Airdrop contract.

  • CoinPusher.lean

    Contains an implementation of a coin pushing game, and establishes its MEV when the blockchain mempool is empty, or when it has a single transaction.

  • AMM.Lean

    Defines our main example contract, a constant product Automated Market Maker.

  • AMMEmptyMempool.lean

    Establishes the MEV of an AMM with an empty mempool.

  • AMMOneTxMempool.lean

    Establishes the MEV of an AMM whose mempool has a single transaction.

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages