Source-linked AI summary
SoK: Decentralized Exchanges (DEX) with Automated Market Maker (AMM) Protocols
Jiahua Xu, Krzysztof Paruch, Simon Cousaert, Yebo Feng
TL;DR
AMM-based DEXs have grown rapidly, but their mechanisms, economic risks, and security and privacy concerns lack a comprehensive systematic treatment. The paper develops a general framework, compares major protocols, and systematizes risks and related research, finding important design trade-offs between low slippage and divergence loss.
Problem
AMM-based DEXs are fundamental DeFi infrastructure, yet comprehensive systematic studies of their mechanisms, economics, security, and privacy are scarce.
Method
The paper formalizes AMM algorithms with a state-space framework, applies it to major exchanges, and develops taxonomies of security, privacy, and related research.
Results
Lower slippage can trade off against higher divergence loss, while major AMM protocols differ through conservation functions, parameters, and mechanism adaptations.
Takeaways & Limitations
The systematization provides a basis for differentiating AMM innovations and extending research on AMM mechanisms, security, and privacy.
Takeaways & Limitations
Public pool-state changes can reveal transaction information, and existing privacy-preserving DEX designs are often difficult to reconcile with AMM protocols.
Abstract
from arXiv · showhide
As an integral part of the decentralized finance (DeFi) ecosystem, decentralized exchanges (DEXs) with automated market maker (AMM) protocols have gained massive traction with the recently revived interest in blockchain and distributed ledger technology (DLT) in general. Instead of matching the buy and sell sides, automated market makers (AMMs) employ a peer-to-pool method and determine asset price algorithmically through a so-called conservation function. To facilitate the improvement and development of automated market maker (AMM)-based decentralized exchanges (DEXs), we create the first systematization of knowledge in this area. We first establish a general automated market maker (AMM) framework describing the economics and formalizing the system's state-space representation. We then employ our framework to systematically compare the top automated market maker (AMM) protocols' mechanics, illustrating their conservation functions, as well as slippage and divergence loss functions. We further discuss security and privacy concerns, how they are enabled by automated market maker (AMM)-based decentralized exchanges (DEXs)' inherent properties, and explore mitigating solutions. Finally, we conduct a comprehensive literature review on related work covering both decentralized finance (DeFi) and conventional market microstructure.
1 INTRODUCTION
AMM-based DEXs have become prominent DeFi applications, using peer-to-pool trading and conservation functions to price assets algorithmically. This SoK formalizes their mechanisms, compares major protocols, and surveys their economic, security, privacy, and research dimensions.
- Motivation: AMM-based DEXs surpassed $100 billion in aggregate value locked amid a surge in crypto trading and DeFi development.
- AMM-based DEXs: Unlike order-book exchanges, AMM-based DEXs use liquidity pools as counterparties and conservation functions to determine prices along predefined trajectories.
- Research challenges: AMMs expose users and liquidity providers to high slippage and divergence loss, while also presenting security and privacy issues.
- Contributions: The paper addresses a literature gap as the first comprehensive SoK focused on DEXs with AMM protocols and deployed-protocol examples.
- Contributions: The authors formalize AMM economics with a state-space framework and compare major protocols using conservation functions, slippage, and divergence loss.
- Contributions: The paper establishes a security and privacy taxonomy, explores mitigation solutions, and reviews related work to identify future research directions.
2 AMM PRELIMINARIES
AMM-based DEXs organize trading and liquidity provision around pools, where smart contracts algorithmically determine exchange rates through conservation functions. Their economics involve participant roles, assets, rewards, fees, slippage, and divergence loss.
- Actors and Assets: Liquidity pools hold crypto-asset reserves supplied by liquidity providers, who receive proportional pool shares and earn transaction fees.Providers can generally withdraw funds by surrendering corresponding pool shares, although some protocols impose withdrawal penalties.
- Generalized Mechanism: Traders submit input and output assets or quantities, and smart contracts calculate exchange rates, fees, and execution using the conservation function.Arbitrageurs trade across markets to close price gaps and extract profits.
- Actors and Assets: AMM protocols use several asset categories and incentives, including risk assets, base assets, protocol tokens, liquidity shares, and rewards for liquidity, staking, governance, and security.Risk assets are often the primary trading assets, while protocol tokens can represent governance rights and incentivize liquidity participation.
- Economics: Trading costs include liquidity withdrawal penalties, swap fees, and gas fees, while withdrawal can alter pool composition and increase slippage.AMMs may levy withdrawal penalties because removing liquidity can reduce pool usability by elevating slippage.
- Economics: Slippage is the difference between spot and realized prices and increases with trade size relative to pool size and with the conservation-function design.Infinitesimally small trades approach the spot price, whereas larger trades deviate more.
- Economics: Divergence loss exposes liquidity providers to volatility risk because swaps change pool composition, update implied asset prices, and alter total pool value relative to holding assets externally.This risk is additional to the loss of time value associated with funds locked in the pool.
3 FORMALIZATION OF MECHANISMS
This section formalizes AMM operation as state transitions over liquidity-pool reserves, prices, invariants, and protocol hyperparameters. It then derives generalized conservation, swapping, slippage, and divergence-loss calculations.
- 3.1 State space representation: AMM functionality is represented by mechanisms that map user actions to protocol responses and state transitions.The state transition function maps a current state and action to a future state.
- 3.1 State space representation: The liquidity-pool state contains token reserves, spot prices, conservation invariants, and protocol hyperparameters, accommodating diverse AMM designs.Hyperparameters are fixed at pool creation, although governance can change them infrequently.
- 3.1 State space representation: The protocol-specific conservation function defines relationships among state variables and determines which mechanisms preserve the desired invariant properties.Typical invariant families include constant-sum, constant-product, geometric-mean, and combined functions.
- 3.2 Generalized formulas: Generalized formulas describe interdependence among invariants and state variables and support computation of slippage and divergence loss.The section provides mathematical notation and parameterized mechanisms for these calculations.
- 3.2 Generalized formulas: The invariant remains constant for swaps but changes with liquidity provision or withdrawal, while pure liquidity changes should not move asset prices.Trading changes relative asset prices through demand, whereas liquidity changes alter reserves without price impact in the idealized formulation.
- 3.2.1 Conservation function.: A conservation function, or bonding curve, relates the invariant to reserve quantities; its concavity, nonnegativity, and monotonicity constrain token-pair functions.Given one reserve change, the invariant determines the other reserve, and the spot exchange rate is the curve slope.
- 3.2.3 Swap amount.: A swap adds the input quantity to its reserve, solves the new output reserve using the conservation function, and takes the reserve difference as the amount received.Swap quantities are bounded below by pool depletion, while large inputs can theoretically produce high slippage.
- 3.2.5 Divergence loss.: Divergence loss compares the rebalanced pool value after an asset price change with the value of holding the original reserves outside the pool.The calculation values the original pool, computes held value, solves rebalanced reserves under the conservation function, and computes the new pool value.
4 COMPARISON OF AMM PROTOCOLS
The paper compares four representative AMMs by their pool structures, conservation functions, slippage, and divergence loss. Their designs trade off asset flexibility, liquidity concentration, oracle dependence, fee treatment, and price alignment.
- 4.1 Major AMM protocols: The comparison covers Uniswap, Balancer, Curve, and DODO, selected for Ethereum market share and mechanism representativeness.It derives and plots their conservation functions, slippage, and divergence loss under varying hyperparameters.
- 4.1.1 Uniswap V2.: Uniswap V2 uses a two-asset constant-product pool with balanced liquidity changes, output-bounded swaps, and fees retained in the pool.Retained fees cause swaps to update the bonding-curve invariant rather than remain pure asset swaps.
- 4.1.1 Uniswap V3.: Uniswap V3 concentrates liquidity over part of the bonding curve, virtually amplifying the invariant and reducing slippage.Its controller A determines concentration: larger A approaches the V2 range, while A near 1 supports swaps near the initial rate.
- 4.1.3 Balancer.: Balancer generalizes Uniswap to multi-asset pools with fixed weights; balanced liquidity changes avoid price impact, whereas single-asset changes induce it.Balancer supports output-boundedness, liquidity sensitivity, and demand sensitivity, while retained fees update the bonding curve after swaps.
- 4.1.4 Curve.: Curve combines constant-sum and constant-product components for similarly pegged assets and permits proportionate or disproportionate liquidity changes.Its invariant is updated after trades to account for retained swap fees, and the protocol is output-bounded and sensitive to liquidity and demand.
- 4.1.5 DODO.: DODO derives its conservation function from an externally informed exchange-rate formula and uses arbitrage to restore the LP-set equilibrium reserve ratio.Its bonding curve is redrawn after oracle-reported price changes, while slippage-controller A governs the strength of the pull toward equilibrium.
Summary.
AMM protocols differ in their conservation functions and design features, creating trade-offs among capital efficiency, slippage, divergence loss, and supported assets. Layer 2 deployments reduce transaction costs and improve speed, but do not eliminate frontrunning or sandwich attacks.
- Protocol comparison: AMMs vary in design: Uniswap V2 prioritizes low gas fees, Uniswap V3 capital efficiency, Balancer multi-asset pools, Curve similarly pegged assets, and DODO divergence-loss reduction.These differences reflect distinct conservation functions and protocol mechanisms.
- Protocol comparison: Most major AMMs are variations or clones of Uniswap’s constant-product protocol, often changing fee or reward structures.Sushiswap, PancakeSwap, VVS Finance, Quickswap, and BiSwap are identified as examples.
- Economic trade-offs: Conservation-function choices trade lower slippage against greater divergence loss, because larger asset withdrawals can increase LP exposure to loss.Uniswap V3 illustrates the extreme case discussed in the passage.
- Applications: AMM designs extend beyond spot trading into stablecoins, NFTs, options, fixed-yield tokens, and fixed-term lending markets.Examples include Gyroscope, EulerBeats, Pods, YieldSpace, and Notional Finance.
- AMMs on Layer 2: Layer 2 deployment does not appear to resolve frontrunning and sandwich attacks.These risks can remain when liquidity is aggregated across layer 1 and layer 2 pools.
- AMMs on Layer 2: Layer 2 AMMs provide faster transactions and lower or zero gas costs, enhancing user experience.Examples include ZKSwap, Sushiswap, Curve, QuickSwap, and dYdX deployments.
5 SECURITY AND PRIVACY CONCERNS
AMM-based DEXs face economic, security, and privacy risks arising from their layered architecture and public blockchain foundations. The paper organizes attacks by architectural layer and surveys their causes and mitigations.
- Scope: The security and privacy discussion complements earlier analysis of slippage and divergence loss as risks to AMM users and LPs.AMM-based DEXs are complex distributed systems with multiple interacting components.
- Taxonomy: The paper’s taxonomy classifies attacks as infrastructure-, middleware-, or application-layer threats, while noting that some attacks span multiple layers.Historical AMM attacks are compiled in Table 5.
- Infrastructure-layer attacks: Infrastructure threats include timestamp manipulation, transaction-sequence manipulation, spam, and denial-of-service attacks that can disrupt DEX operation or user experience.Mitigations include timestamp-independent contracts, reputable blockchains, and enforced transaction sequencing.
- Middleware-layer attacks: Smart-contract interactions create middleware vulnerabilities, including reentrancy, replay, exception mishandling, and integer underflow or overflow.The 2016 DAO reentrancy attack caused a reported $50 million token loss, and proposed defenses include runtime monitoring and security-aware languages.
- Application-layer attacks: Flash loans can support oracle attacks when lending platforms rely exclusively on a DEX for price information, while incentive schemes can siphon liquidity through vampire attacks.Sushiswap gained $830 million of liquidity from Uniswap through an incentive-driven migration in September 2020.
- Privacy concerns: AMM transparency and path determinism make swaps and pool activity potentially reverse-engineerable, creating significant privacy concerns.Researchers cited in the paper argue that complete privacy may be impossible for ordinary CFMM implementations under reasonable adversarial models.
Solution.
Privacy solutions can hide transaction and user information at infrastructure, middleware, or application layers, but AMM transparency makes complete confidentiality difficult. Stronger privacy can also reduce slippage efficiency, market visibility, governance, and regulatory oversight.
- Privacy objectives: Privacy-preserving designs target transaction amounts, assets, balances, identities, transaction order, MEV, and protocol information.Full confidentiality could address privacy concerns but may impair market visibility, governance, regulation, and operational efficiency.
- Mitigation approaches: Infrastructure-layer approaches use zero-knowledge proofs, homomorphic encryption, or identity obfuscation to improve transaction confidentiality and anonymity.These approaches may also defend against some infrastructure attacks affecting AMM-based DEXs.
- Mitigation approaches: Middleware and application layers can use privacy-enhanced smart contracts, multiparty computation, transaction obfuscation, and encrypted-data computation.Examples include Hawk, Ekiden, Submarine Commitments, P2DEX, Blank, and Enigma.
- Remaining privacy limits: Even when individual transaction details are hidden, public pool-state changes and AMM protocols can reveal rough traded assets and quantities.Computation parties may infer more granular transaction information from mempool state changes.
- Trade-offs: Non-constant market makers or fuzzified conservation functions may improve privacy but can cause larger slippage, while privacy enhancements complicate market supervision.The paper identifies balancing privacy protection with policy compliance as an open industry question.
6 AVENUES OF FUTURE RESEARCH
Future research addresses security, privacy, scalability, functionality, AMM design, and governance as AMM-based DEXs mature. The section identifies technical and institutional directions for mitigating current risks and expanding capabilities.
- Security: AMM-based DEXs face security risks because price manipulation can theoretically drain associated assets from liquidity pools.The paper also reports attacks arising from flaws across distributed-system components, including oracle attacks.
- Privacy: Public transaction records and AMM algorithms expose detailed trading information, enabling frontrunning, backrunning, and sandwich attacks.Existing privacy systems can reduce real-time efficiency and be expensive to deploy, motivating efficiency improvements in system and cryptographic design.
- Speed and scalability issues: Improving blockchain validation speed and throughput is a vital direction for increasing AMM-based DEX speed and scalability.The paper suggests new data structures, synchronization mechanisms, or validation approaches to process transactions more timely.
- Limited trading functionality: AMM-based DEXs currently provide mainly buying and selling, lacking stop-loss, margin trading, and put and call options.Suggested structural changes include bridging AMMs with order books and using smart-contract-based lending for trading margins.
- New design for AMM: Because most AMM-based DEXs use CFMMs related to Uniswap’s constant product protocol, novel bonding curves could balance slippage and impermanent loss differently.The paper also notes that derivative-market AMM protocols remain early-stage and insufficiently tested by markets or academia.
- Governance: Governance research must address concentrated voting power and regulatory concerns to support sustainable, legally compliant protocol development.The Uniswap fee-switch debate illustrates how potential security-token classification can affect governance decisions.
7 RELATED WORK
Related work spans AMM-based DEXs, conventional market microstructure, prediction-market makers, and blockchain-system formalization. The paper distinguishes itself through focused, comprehensive systematization across protocol mechanics, economics, security, and privacy.
- Scope and positioning: Existing surveys generally cover broader DeFi or other applications, whereas this work focuses specifically on DEX-based AMMs.The paper identifies a dearth of comprehensive systematic studies of this subject.
- Methodological distinction: The paper combines taxonomization, state-space modeling, numerical simulation, and empirical investigation to generalize and systematize AMM protocols.Related survey studies are described as using only subsets of these methods.
- Coverage: Unlike narrower surveys, this work examines architectural design, internal mechanisms, financial economics, and associated security and privacy concerns.These dimensions are presented as distinguishing the paper from related survey coverage.
- AMM-based DEX literature: Prior AMM-based DEX research studies arbitrage, price stability, reserve-price alignment, oracle suitability, transaction ordering, front-running, and flash-loan attacks.The cited literature includes both theoretical and empirical analyses of AMM behavior and attacks.
- Privacy literature: Prior privacy research argues that typical CFMMs make privacy impossible and proposes mitigating strategies for input privacy and cross-chain transfers.The cited cross-chain protocol remains susceptible to vampire attacks.
- Conventional market microstructure: Market-microstructure literature predates blockchain research and covers decentralized exchange and market-making as core topics.Existing work reports decentralized-market efficiency under specific conditions and greater crash immunity than centralized markets.
- Market-making foundations: AMM research also builds on LMSR and related market-making strategies, including liquidity-sensitive, reinforcement-learning, prediction-market, and CFMM designs.Reported comparisons examine profitability, forecast accuracy, losses, spread, utility, and computational efficiency.
- Formal foundations: Blockchain-system research provides conceptual engineering, state-machine, and dynamical-stochastic-game foundations for modeling tokenized economic systems.These foundations inform the paper’s formal treatment of AMM-based DEXs.
8 CONCLUSION
AMM-based DEXs are presented as important DeFi components enabled by trustless, verifiable, and censorship-resistant DLT. The paper systematizes their designs, economics, and security and privacy issues using a unified framework.
- Conclusion: AMM-based DEXs are integral DeFi components built on trustless, verifiable, and censorship-resistant distributed ledger technology.The paper describes the DeFi ecosystem as relatively new and rapidly innovative.
- Conclusion: The paper systematizes AMM-based DEX knowledge through state-space formalization, protocol comparison, economic-risk analysis, and security and privacy taxonomy.Major exchanges examined include Uniswap, Balancer, Curve, and DODO, with discussion of other exchanges.
A FORMULAS OF MAJOR AMM-BASED DEX
The appendix expresses major AMM-based DEX formulas within a unified state-space framework. It uses this representation to support protocol analysis and future quantitative comparison.
- A FORMULAS OF MAJOR AMM-BASED DEX: The state-space representation frames formulas, conservation functions, state updates, and metrics within one taxonomy.The paper presents this as enabling unified analysis across AMM specifications.
- A FORMULAS OF MAJOR AMM-BASED DEX: The framework is designed to formalize and generalize AMM algorithms across different protocol specifications.Its formulas adhere to the state-space representation introduced earlier.
- A FORMULAS OF MAJOR AMM-BASED DEX: Future numerical experiments and system-identification methods could enable quantitative comparisons within unified AMM frameworks.The stated applications include protocol construction, design, analysis, and maintenance.
- A FORMULAS OF MAJOR AMM-BASED DEX: The framework can derive system properties from a representation or find a representation conditioned on desired system requirements.This describes two complementary uses of the formal framework.
- A.1 Uniswap V2: In Uniswap V2, the product of the two token reserve quantities remains constant during swapping.The conservation relation is stated for token1 reserve r1 and token2 reserve r2.
- A.1.1 Conservation function: Under an equal-value pool assumption, the implied spot price is derived from the ratio of the two reserve quantities.The price is denominated in token1 and applies to token2.
A.1.2 Spot exchange rate.
Uniswap’s spot exchange-rate analysis derives rates from its conservation function and examines how concentrated liquidity changes the effective reserve structure. The section also connects the formulation to liquidity ranges and divergence loss.
- Spot exchange rate: Uniswap’s spot exchange rate is derived from its conservation function for swaps between token1 and token2.The derivation treats the other pool reserves as unchanged and expresses the received amount and slippage from the invariant.
- Spot exchange rate: Fig. 4a relates Uniswap slippage to the normalized change in token1 reserves.
- Divergence loss: Under Uniswap’s equal-value assumption, token1’s reserve value equals half of the pool’s original value.Token1 is used as the numéraire in this valuation.
- Divergence loss: Uniswap divergence loss compares the updated pool value with the value of the original token holdings after token2’s price changes.The analysis preserves the equal-value assumption while users’ swaps update the reserve ratio.
- Uniswap V3: Uniswap V3 aggregates individual LP conservation functions, each limited to the exchange-rate range selected by that LP.Its bonding curve is represented through an equivalent Uniswap V2 liquidity position shifted along the x-axis.
A.2.2 Exchange rate.
Uniswap V3’s exchange-rate formulation incorporates a preset range in which an LP’s liquidity is available. The resulting bonding curve and swap calculations are derived from the conservation function.
- Exchange rate: When token2 is depleted, Uniswap V3’s exchange rate reaches the boundary determined by the LP’s range parameter A.
- Exchange rate: The Uniswap V3 swap amount is derived directly from its conservation function.
- Exchange rate: Uniswap V3’s slippage has the same magnitude as Uniswap V2, with the effective token1 reserve amplified by the range parameter.
A.2.4 Slippage.
The section compares slippage and divergence-loss formulations across Uniswap V3, Balancer, Curve, and DODO. Their mechanisms differ through range concentration, weighted invariants, interpolation between invariants, and market-rate adjustment.
- Slippage: When A →1, Uniswap V3 slippage is restrained while liquidity exists for both assets; when A →∞, it approximates Uniswap V2 slippage.
- Balancer: Balancer derives swap amounts and slippage from its weighted-product conservation function and reserve quantities.The analysis also evaluates divergence loss when token2’s price changes while other token prices remain unchanged.
- Curve: Curve interpolates between constant-sum and constant-product invariants using A, allowing exchange rates to deviate from 1 while keeping slippage low.As A approaches 0, the function becomes constant-product; as A approaches positive infinity, it becomes effectively constant-sum.
- DODO: DODO adjusts its pool exchange rate around the market rate according to the pool composition and initial reserves.Its conservation function treats the initial reserve state as invariant during swaps, while liquidity operations update it.
- DODO: When A = 1 and the supplied asset values are equal, DODO’s conservation function is equivalent to Uniswap’s constant-product function.
A.5.4 Slippage.
The section places AMM protocols within a broader security, attack, and related-work context. It documents attack mechanisms, infrastructure threats, and the organization of attacks and mitigations.
- Slippage: DODO sets the pool’s equilibrium reserve ratio to the ratio supplied by liquidity providers, eliminating the previously described divergence loss.
- Security and attacks: The paper presents algorithms for flash-loan-funded price-oracle attacks, rug pulls, sandwich LP attacks, and sandwich price attacks.
- Security and attacks: Sandwich price attacks exploit mempool observation and transaction ordering, with slippage moving the asset price between front-running and back-running trades.
- Overview tables: Table 5 overviews theoretical and anecdotal attacks against AMM-based DEXs together with their mitigating solutions.