indexEN fallbackAutomated Market Makers y Liquidez#amm#liquidity#defi
Traducción pendiente: esta página conserva la fuente canónica en inglés mientras la navegación sigue disponible en español.

Automated Market Makers and Liquidity

Introduction

This branch builds automated market makers as accounting state machines, beginning with constant product and expanding carefully to concentrated, stable, weighted, and hook-enabled designs.

Why It Matters

AMMs compose assets, pricing, liquidity claims, callbacks, routers, arbitrage, and adversarial ordering. A small rounding or reserve-accounting mistake can become repeatable extraction.

Mental Model

The pool enforces an invariant over reserves after declared fees; LP tokens represent claims on that state. Market price emerges from marginal execution and arbitrage, not from an oracle of “true” value.

Questions This Branch Answers

  • How do swaps and liquidity changes preserve accounting constraints?
  • Where do slippage, price impact, arbitrage, and MEV enter?
  • Which token, callback, and router assumptions sit outside the invariant?

Scope

Order-book contrast, constant product, LP shares/fees/rounding, swaps/slippage, arbitrage/TWAP/manipulation, callbacks/routers, concentrated liquidity, and model contrasts.

Out of Scope

Trading advice, profitability strategies, production liquidity deployment, exhaustive DEX history, and claiming one invariant covers external token behavior.

Dependencies

token behavior, contract architecture, arithmetic precision, and invariant testing.

Candidate Note Roadmap

  • order-books-vs-automated-market-makers — Compare explicit orders with algorithmic reserve curves.
  • constant-product-invariant — Derive swap outputs and fee-adjusted reserve constraints.
  • liquidity-shares-fees-and-rounding — Account for deposits, withdrawals, fees, and minimum liquidity.
  • swaps-slippage-and-price-impact — Separate user bounds from curve-induced execution changes.
  • arbitrage-twap-and-manipulation — Connect reserve movement, time windows, and attack cost.
  • flash-callbacks-and-router-boundaries — Contain external control and approval surfaces.
  • concentrated-liquidity-ticks-and-ranges — Model positions and liquidity across discrete price ranges.
  • stable-weighted-hooks-and-fragmentation — Contrast specialized invariants and extension risk.

Future Project

A Constant-Product AMM with LP shares, fees, a minimal router, flash-callback fixture, reference model, invariant harness, and manipulation lab.

Initial Invariants

Fee-adjusted reserves preserve the product bound; LP claims remain proportional under declared rounding; pool liabilities never exceed controlled balances; swaps obey deadline and amount bounds.

Initial Threat Model

Spot-price manipulation, sandwiches, callback reentrancy, rounding extraction, first-liquidity edge cases, fee-on-transfer/rebasing tokens, approval abuse, reserve desynchronization, and unsafe hooks.

Primary Sources

Uniswap protocol specifications/whitepapers and maintained implementations, plus AMM references in SOURCES.md.

Connects to: oracles, MEV, and lending.