Automated Market Maker (AMM)
An automated market maker is a decentralized exchange mechanism that uses mathematical formulas to price assets and execute trades without traditional order books.
In Depth
AMMs like Uniswap, Curve, and Balancer replace order book matching with pricing functions. The constant product formula (x × y = k) is the simplest — as one asset is bought, its price increases and the other decreases, maintaining the invariant. Concentrated liquidity (Uniswap V3+) lets LPs provide liquidity within specific price ranges for capital efficiency. AMMs introduce unique security concerns: sandwich attacks (where attackers front-run and back-run trades to extract value), price manipulation through flash loans, rounding errors in LP share calculations, and fee accounting bugs. Invariant testing is particularly effective for AMMs because the mathematical properties (constant product, no free tokens, LP share correctness) are well-defined and testable. See the AMM invariant testing guide for the complete property suite.
Frequently Asked Questions
What is an AMM in DeFi?
An automated market maker (AMM) is a decentralized exchange that uses mathematical formulas instead of order books to price trades. Liquidity providers deposit token pairs, and traders swap against the pool. The pricing formula (like x×y=k) ensures prices adjust based on supply and demand.
How do you test AMM security?
AMMs have well-defined mathematical invariants (constant product, no free tokens, LP share accounting) that are ideal for invariant testing. You fuzz with random swap, deposit, and withdraw sequences while checking that these properties always hold. See the AMM testing guide.