Paper: arXiv 2602.00101

Authors: Marco Dessalvi, Massimo Bartoletti, Alberto Lluch-Lafuente

Abstract

Decentralized Finance (DeFi) has revolutionized financial markets by enabling complex asset-exchange protocols without trusted intermediaries. Automated Market Makers (AMMs) are a central component of DeFi, providing the core functionality of swapping assets of different types at algorithmically computed exchange rates. Several mainstream AMM implementations are based on the constant-product model, which ensures that swaps preserve the product of the token reserves in the AMM – up to a \emph{trading fee} used to incentivize liquidity provision. Trading fees substantially complicate the economic properties of AMMs, and for this reason some AMM models abstract them away in order to simplify the analysis. However, trading fees have a non-trivial impact on users’ trading strategies, making it crucial to develop refined AMM models that precisely account for their effects. We extend a foundational model of AMMs by introducing a new parameter, the trading fee $φ\in(0,1]$, into the swap rate function. Fee amounts increase inversely proportional to $φ$. When $φ= 1$, no fee is applied and the original model is recovered. We analyze the resulting fee-adjusted model from an economic perspective. We show that several key properties of the swap rate function, including output-boundedness and monotonicity, are preserved. At the same time, other properties - most notably additivity - no longer hold. We precisely characterize this deviation by deriving a generalized form of additivity that captures the effect of swaps in the presence of trading fees. We prove that when $φ< 1$, executing a single large swap yields strictly greater profit than splitting the trade into smaller ones. Finally, we derive a closed-form solution to the arbitrage problem in the presence of trading fees and prove its uniqueness. All results are formalized and machine-checked in the Lean 4 proof assistant.

Complexity vs Empirical Score

  • Math Complexity: 8.0/10
  • Empirical Rigor: 2.0/10
  • Quadrant: Lab Rats — theoretically deep, empirically untested

Why this score: This paper provides a rigorous formal verification of AMM fee mechanisms using the Lean 4 proof assistant, delivering closed-form solutions for arbitrage maximization. While theoretical and mathematical rigor are outstanding, empirical backtesting against real-world DEX market data is absent.

Research Flowchart

  flowchart TD
    A[Research Goal: Formally model AMM trading fees & properties in Lean 4] --> B[Input: Extended Constant-Product Model with Fee Parameter φ ∈ 0,1]
    B --> C[Methodology: Formalization & Machine-Checked Proofs in Lean 4 Assistant]
    C --> D[Economic & Structural Analysis of Swap Rate Function]
    C --> E[Arbitrage Optimization with Fees]
    D --> F[Outcome 1: Preserved Monotonicity & Boundedness; Lost Additivity]
    D --> G[Outcome 2: Proved Single Large Swaps Outperform Split Trades for φ < 1]
    E --> H[Outcome 3: Derived & Proved Unique Closed-Form Arbitrage Solution]

Cited References (249)

  1. A Formal Approach to AMM Fee Mechanisms with Lean 4 — → 2602.00101
  2. Netting-based Liquidity-saving Automated Market Makers (2025) — link
  3. A theory of Automated Market Makers in DeFi (2022) — link
  4. Maximizing Extractable Value from Automated Market Makers (2022) — link
  5. A Theory of Automated Market Makers in DeFi (2021) — link
  6. Towards a Theory of Decentralized Finance (2021) — link
  7. The Lean 4 Theorem Prover and Programming Language (2021) — link
  8. SoK : Mitigation of Front-running in Decentralized Finance (2021)
and 241 more
  1. SoK: Decentralized Exchanges (DEX) with Automated Market Maker (AMM) protocols (2022) — link
  2. Formalising Decentralised Exchanges in Coq (2023) — link
  3. ConCert: a smart contract certification framework in Coq (2020) — link
  4. CeFi vs. DeFi - Comparing Centralized to Decentralized Finance (2021) — link
  5. Certifying optimal MEV strategies with Lean (2025) — link
  6. Clockwork Finance: Automated Analysis of Economic Security in Smart Contracts (2023) — link
  7. Formalizing Automated Market Makers in the Lean 4 Theorem Prover (2024) — link
  8. SoK : Lending Pools in Decentralized Finance (2021) — link
  9. Automated Market Making and Arbitrage Profits in the Presence of Fees — → 2305.14604
  10. Automated Market Making and Arbitrage Profits in the Presence of Fees — → 2305.14604
  11. Automated Market Making and Loss‐Versus‐Rebalancing (2022) — link
  12. Global Order Routing on Exchange Networks (2021) — link
  13. Dynamic Curves for Decentralized Autonomous Cryptocurrency Exchanges (2021) — link
  14. Towards a Theory of Maximal Extractable Value I: Constant Function Market Makers (2022) — link
  15. Quantifying Blockchain Extractable Value: How dark is the forest? (2021) — link
  16. SoK: Transparent Dishonesty: Front-Running Attacks on Blockchain (2020) — link
  17. Flash Boys 2.0: Frontrunning in Decentralized Exchanges, Miner Extractable Value, and Consensus Instability (2020) — link
  18. Smart Derivatives: On-Chain Forwards for Digital Assets (2020) — link
  19. SoK : Preventing Transaction Reordering Manipulations in Decentralized Finance (2022) — link
  20. High-Frequency Trading on Decentralized On-Chain Exchanges (2021) — link
  21. On the Just-In-Time Discovery of Profit-Generating Transactions in DeFi Protocols (2021) — link
  22. Attacking the DeFi Ecosystem with Flash Loans for Fun and Profit (2021) — link
  23. Liquidations: DeFi on a Knife-Edge (2021) — link
  24. Towards understanding flash loan and its applications in DeFi ecosystem (2020) — link
  25. SoK : Decentralized Finance ( DeFi ) (2022) — link
  26. The Decentralized Financial Crisis (2020) — link
  27. DeFi protocols for loanable funds: Interest rates, liquidity and market efficiency (2020) — link
  28. An Analysis of the Market Risk to Participants in the Compound Protocol
  29. Competitive equilibria between staking and on-chain lending (2019) — link
  30. Why Stake When You Can Borrow? (2020)
  31. A First Look into DeFi Oracles (2020) — link
  32. SoK: A Classification Framework for Stablecoin Designs (2020) — link
  33. Stablecoins 2.0: Economic Foundations and Risk-based Models (2020) — link
  34. Monetary stabilization in cryptocurrencies–design approaches and open questions (2019) — link
  35. Empirical measurements on pricing oracles and decentralized governance for stablecoins (2020)
  36. Optimal Bidding Strategy for Maker Auctions (2020) — link
  37. What is Stablecoin?: A Survey on Price Stabilization Mechanisms for Decentralized Payment Systems (2019) — link
  38. Automated Market Makers for Decentralized Finance (DeFi) (2020) — link
  39. An Analysis of Uniswap markets (2021) — link
  40. Improved Price Oracles: Constant Function Market Makers (2020) — link
  41. When does the tail wag the dog? Curvature and market making (2020) — link
  42. Differential Privacy in Constant Function Market Makers (2022) — link
  43. Optimal Fees for Geometric Mean Market Makers (2021) — link
  44. Liquidity provider returns in geometric mean markets (2020) — link
  45. Formal Specification of Constant Product Market Maker Model & Implementation (2018)
  46. Compound implementation (2020)
  47. Compound simplified interest (2020)
  48. Compound maximum liquidation amount (2020)
  49. Compound valuation of cTokens (2020)
  50. Compound comptroller setter (2020)
  51. Aave v1 simplified interest (2020)
  52. Aave maximum liquidation amount (2020)
  53. Aave valuation of aTokens (2020)
  54. Aave v1 flashloan receiver interface (2020)
  55. Aave v1 implementation (2020)
  56. Compound website (2020)
  57. Compound markets website (2020)
  58. Aave website (2020)
  59. Aave markets website (2020)
  60. MEV -geth (2022)
  61. Total Value Locked Volatility in DeFi: Empirical Evidence from Market Crashes (2025)
  62. mStable — Introducing Constant Sum Bonding Curves for Tokenised Assets (2020)
  63. Uniswap website (2020)
  64. Uniswap v2 Core (2020)
  65. Uniswap v3 Core (2021)
  66. Uniswap token pair implementation (2021)
  67. Uniswap statistics (2022)
  68. Uniswap oracle template (2020)
  69. Uniswap flash loan implementation (2020)
  70. Uniswap Documentation: Understanding Returns (2020)
  71. Balancer whitepaper (2019)
  72. Curve website (2020) — link
  73. Curve statistics (2022)
  74. StableSwap - efficient mechanism for Stablecoin (2019)
  75. Curve token pair implementation (2021)
  76. Curve computation of invariant constant (2021)
  77. Curve computation of swap amount (2021)
  78. Mooniswap implementation (2020)
  79. Mooniswap whitepaper (2020)
  80. Improving frontrunning resistance of x*y=k market makers (2018)
  81. Defi pulse website (2020)
  82. MakerDAO website (2020)
  83. bZx Fulcrum website (2020)
  84. dYdX website (2020)
  85. Coindesk: Value DeFi attack (2020)
  86. Harvest Finance flashloan attack post-mortem (2020)
  87. Origin Dollar attack (2020)
  88. Akropolis Defi attack (2020)
  89. Compound oracle attack (2020)
  90. SushiSwap token pair implementation (2021)
  91. Tinyman : Official Announcement About the Incidents of 01.01.2022 (2022)
  92. Documented Timeline of Exchange Hacks (2022)
  93. CashScript — Writing covenants (2019) — link
  94. Bitcoin Covenants Unchained (2020) — link
  95. BitML : a calculus for Bitcoin smart contracts (2018) — link
  96. Fun with Bitcoin Smart Contracts (2018) — link
  97. Verifying liquidity of Bitcoin contracts (2019)
  98. SoK : unraveling Bitcoin smart contracts (2018) — link
  99. A formal model of Bitcoin transactions (2018) — link
  100. Developing secure Bitcoin contracts with BitML (2019) — link
  101. Dissecting Ponzi schemes on Ethereum: Identification, analysis, and impact (2020) — link
  102. Disentangling Decentralized Finance ( DeFi ) Compositions (2023) — link
  103. UTxO - vs account-based smart contract blockchain programming paradigms (2020) — link
  104. IVY (2017)
  105. BALZaC: Bitcoin Abstract Language, analyZer and Compiler (2018)
  106. Multi-stage Contracts in the UTXO Model (2019) — link
  107. SoK: Off The Chain Transactions (2019)
  108. Resource-Aware Session Types for Digital Contracts (2019)
  109. Improved Price Oracles: Constant Function Market Makers (2020) — link
  110. Modeling Bitcoin contracts by timed automata (2014) — link
  111. The Economics of Automated Market Makers (2022) — link
  112. The Extended UTXO Model (2020)
  113. A fair protocol for data trading based on Bitcoin transactions (2017) — link
  114. Constant-deposit multiparty lotteries on Bitcoin (2017) — link
  115. An empirical analysis of smart contracts: platforms, applications, and design patterns (2017)
  116. A Journey into Bitcoin Metadata (2019) — link
  117. Enhancing Bitcoin transactions with covenants (2017) — link
  118. Simplicity: A New Language for Blockchains (2017) — link
  119. Bitcoin covenants (2016) — link
  120. Fair Two-Party Computations via Bitcoin Deposits (2014) — link
  121. Secure Multiparty Computations on Bitcoin (2014) — link
  122. On the Malleability of Bitcoin Transactions (2015) — link
  123. Secure multiparty computations on Bitcoin (2016) — link
  124. Hijacking Bitcoin : Routing Attacks on Cryptocurrencies (2017) — link
  125. Note on fair coin toss via Bitcoin (2013)
  126. Efficient Zero-Knowledge Contingent Payments in Cryptocurrencies Without Scripts (2016) — link
  127. Bitcoin as a Transaction Ledger: A Composable Treatment (2017) — link
  128. How to Use Bitcoin to Design Fair Protocols (2014) — link
  129. Validation of Decentralised Smart Contracts Through Game Theory and Formal Methods (2015) — link
  130. Peer-to-peer affine commitment using Bitcoin (2015) — link
  131. The Bitcoin Backbone Protocol: Analysis and Applications (2015) — link
  132. Majority Is Not Enough: Bitcoin Mining Is Vulnerable (2014) — link
  133. Fair and Robust Multi-party Computation Using a Global Transaction Ledger (2016) — link
  134. How to Use Bitcoin to Incentivize Correct Computations (2014) — link
  135. How to Use Bitcoin to Play Decentralized Poker (2015) — link
  136. Improvements to Secure Computation with Penalties (2016) — link
  137. Amortizing Secure Computation with Penalties (2016) — link
  138. Zero-Collateral Lotteries in Bitcoin and Ethereum (2017) — link
  139. A Fast and Scalable Payment Network with Bitcoin Duplex Micropayment Channels (2015) — link
  140. The Bitcoin Lightning Network : Scalable Off-Chain Instant Payments (2015) — link
  141. Sprites: Payment Channels that Go Faster than Lightning (2017) — link
  142. Bitcoin : a peer-to-peer electronic cash system (2008)
  143. SoK : Research Perspectives and Challenges for Bitcoin and Cryptocurrencies (2015) — link
  144. Pricing via Processing or Combatting Junk Mail (1993) — link
  145. On Bitcoin and red balloons (2012) — link
  146. Two Bitcoins at the Price of One? Double-Spending Attacks on Fast Payments in Bitcoin (2012)
  147. Misbehavior in Bitcoin : A Study of Double-Spending and Accountability (2015) — link
  148. Analysis of Hashrate-Based Double Spending (2014) — link
  149. Liar, Liar, Coins on Fire!: Penalizing Equivocation By Loss of Bitcoins (2015) — link
  150. Liquid: a Bitcoin Sidechain (2020)
  151. Bitcoin Covenants: Three Ways to Control the Future (2020)
  152. Formalizing and Securing Relationships on Public Networks (1997)
  153. Marlowe: Financial Contracts on Blockchain (2018) — link
  154. Multi-Currency Ledgers (2020)
  155. An Abstract Model of UTxO -based Cryptocurrencies with Scripts (2018)
  156. Sharing Decryption in the Context of Voting or Lotteries (2000) — link
  157. Publicly Verifiable Lotteries: Applications of Delaying Functions (1998) — link
  158. Temporarily hidden bit commitment and lottery applications (2010) — link
  159. Electronic Lottery Tickets as Micropayments (1997) — link
  160. Weakly Secret Bit Commitment: Applications to Lotteries and Fair Exchange (1998) — link
  161. Certifying Findel Derivatives for Blockchain (2020) — link
  162. A Survey of Attacks on Ethereum Smart Contracts (SoK) (2017) — link
  163. Formal Verification of Smart Contracts (2016)
  164. Dependent types and multi-monadic effects in F * (2016) — link
  165. Defining the Ethereum Virtual Machine for Interactive Theorem Provers (2017) — link
  166. Isabelle/HOL : a proof assistant for higher-order logic (2002) — link
  167. Demystifying Incentives in the Consensus Computer (2015) — link
  168. Designing Secure Ethereum Smart Contracts: A Finite State Machine Based Approach (2018)
  169. Automated Execution of Financial Contracts on Blockchains (2017) — link
  170. A Semantic Framework for the Security Analysis of Ethereum Smart Contracts (2018) — link
  171. Foundations and Tools for the Static Analysis of Ethereum Smart Contracts (2018) — link
  172. Hyperledger Fabric : a distributed operating system for permissioned blockchains (2018) — link
  173. Ethereum : a next generation smart contract and decentralized application platform (2013)
  174. Ethereum : a secure decentralised generalised transaction ledger (2014)
  175. Step by Step Towards Creating a Safe Smart Contract: Lessons and Insights from a Cryptocurrency Lab (2016)
  176. The Ring of Gyges : Investigating the Future of Criminal Smart Contracts (2016) — link
  177. Hawk: The Blockchain Model of Cryptography and Privacy-Preserving Smart Contracts (2016) — link
  178. Scripting smart contracts for distributed ledger technology (2016)
  179. Making Smart Contracts Smarter (2016) — link
  180. The Postmodern Ponzi Scheme: Empirical Analysis of High-Yield Investment Programs (2012) — link
  181. A fistful of Bitcoins : characterizing payments among men with no names (2016) — link
  182. The promise and perils of digital currencies (2013) — link
  183. BitIodine: Extracting Intelligence from the Bitcoin Network (2014) — link
  184. Empirical Analysis of Denial-of-Service Attacks in the Bitcoin Ecosystem (2014) — link
  185. There’s No Free Lunch, Even Using Bitcoin : Tracking the Popularity and Profits of Virtual Currency Scams (2015) — link
  186. Segregated Witness (Consensus layer) (2015)
  187. Securify: Practical Security Analysis of Smart Contracts (2018)
  188. Scilla: a Smart Contract Intermediate-Level LAnguage (2018)
  189. Quantitative Analysis of Smart Contracts (2018) — link
  190. Algorand Developer Docs - Assets (2020)
  191. EPOBC protocol specification (2020)
  192. OpenAssets protocol (2020)
  193. Colu website (2020)
  194. Counterpary website (2020)
  195. Reconciling Two Views of Cryptography (The Computational Soundness of Formal Encryption) (2007) — link
  196. Random Oracles Are Practical: A Paradigm for Designing Efficient Protocols (1993) — link
  197. Coin Flipping by Telephone (1981)
  198. Timed Commitments (2000) — link
  199. A method for obtaining digital signatures and public-key cryptosystems (1978)
  200. Logical reversibility of computation (1973)
  201. Software and Reversible Systems: A Survey of Recent Activities (2020) — link
  202. An Overview and Synthesis on Timed Process Algebras (1991) — link
  203. Corda : An Introduction (2016)
  204. From Institutions to Code: towards Automated Generation of Smart Contracts (2016)
  205. Findel: Secure Derivative Contracts for Ethereum (2017) — link
  206. Composing contracts: an adventure in financial engineering, functional pearl (2000) — link
  207. Two Probability Models of Pyramid or Chain Letter Schemes Demonstrating That Their Promotional Claims Are Unreliable (1984)
  208. Bitcoin: Questions, Answers, and Analysis of Legal Issues (2015)
  209. A Normalized Levenshtein Distance Metric (2007) — link
  210. Taking A Bit Out of Crime: Bitcoin and Cross-Border Tax Evasion (2014)
  211. Bitcoin: A primer for policymakers (2013)
  212. Understanding the DAO attack (2016)
  213. Parity Wallet Security Alert (2017)
  214. A Postmortem on the Parity Multi-Sig Library Self-Destruct (2017)
  215. Silk Road: eBay for drugs (2012)
  216. The mathematics of Ponzi schemes (2009) — link
  217. Ethical issues connected with multi-level marketing schemes (2001)
  218. Ethtrade Review -– Is Ethtrade a Scam or Legitimate? Read Before You Invest (2016)
  219. BadBitcoin: the Bad list
  220. The first successful Zero-Knowledge Contingent Payment (2016)
  221. Bitcoin wiki - Contracts - Using external state (2012)
  222. Bitcoin wiki - Contracts - Assurance contracts (2012)
  223. Bitcoin wiki - Contracts (2012)
  224. Bitcoin developer guide - Escrow and arbitration (2015)
  225. Smart Contracts on Bitcoin Blockchain (2015)
  226. King ot the Ether Throne (2016)
  227. ERC-20 Token Standard (2015)
  228. EIP 721 : ERC-721 Non-Fungible Token Standard
  229. CoinCovenants using SCIP signatures, an amusingly bad idea (2013)
  230. CHECKTEMPLATEVERIFY (2020)
  231. Taproot: SegWit version 1 spending rules (2020)
  232. BIP 0002 (2016)
  233. Tokens, Types, and Standards: Identification and Utilization in Ethereum (2020) — link
  234. Detecting Token Systems on Ethereum (2019) — link
  235. Ethereum token dynanics
  236. Concave function (n.d.)
  237. Counter machines and counter languages (1968) — link
  238. How to Generate and Exchange Secrets (Extended Abstract) (1986) — link
  239. How to Play any Mental Game or A Completeness Theorem for Protocols with Honest Majority (1987) — link
  240. Basic notions of trace theory (1988) — link
  241. cite-lean (2025)

3 of 249 cited works are in the corpus; resolved via arXiv source bundles, Semantic Scholar and OpenAlex. Corpus-wide: 2518 linked papers.