A Formal Approach to AMM Fee Mechanisms with Lean 4

By Marco Dessalvi, Massimo Bartoletti, Alberto Lluch-Lafuente

Rating

1614
Battle Count: 80

Relevance

6/10
The paper is highly relevant to DeFi quantitative trading, particularly for understanding optimal arbitrage strategies in fee-bearing AMMs. The closed-form solution for the maximum-gain swap (Theorem 13) and the proof that single large swaps outperform split trades (Theorem 8) have direct practical implications for automated trading bots on DEXes. However, the paper is purely theoretical/formal and does not provide empirical backtesting, market data analysis, or implementation of trading strategies. It is more relevant to protocol-level understanding and smart contract verification than to traditional quantitative trading signal generation.

Implementation Complexity

9/10
The paper requires deep expertise in formal methods, Lean 4 theorem proving, and mathematical finance. The formalization involves ~3500 lines of Lean code with complex algebraic manipulations. The mathematical content includes proving properties of the constant-product swap rate function, deriving closed-form solutions for equilibrium and optimal arbitrage values, and establishing uniqueness results. Reproducing the formal verification requires proficiency in Lean 4 and familiarity with the Mathlib 4 library. The theoretical results themselves are accessible to those with a background in mathematical economics, but the machine-checked proofs are highly specialized.

Reproducibility

5/5
The complete Lean 4 formalization (~3500 lines) is publicly available at https://mamboleano.github.io/lean4-amm-fees. All theorems and lemmas are machine-checked, guaranteeing mathematical correctness. Pen-and-paper proofs are also provided in a supplementary document. The model is fully specified with explicit definitions of the swap rate function, gain function, and all economic properties.

About this paper

Methodology: Formal Verification with Lean 4 Proof Assistant. Problem types: Market Making, Optimization, Formal Verification, Arbitrage Analysis.

The interactive Everscope explorer (charts, battles, favorites) loads below.