The Math Behind Automated Market Makers
A technical deep-dive into the invariant curves that power decentralized exchanges — deriving price impact, impermanent loss, concentrated liquidity, and StableSwap from scratch.
The Problem with Order Books On-Chain
Picture a traditional stock exchange. A buyer submits a bid at a specific price, a seller posts an ask, and a matching engine somewhere in the middle brings them together. This works well enough when the infrastructure is centralized — latency is low, storage is cheap, and a central operator manages the book. Port that same model onto a public blockchain, though, and the economics fall apart almost immediately. Every new order, every update, every cancellation requires a transaction. On Ethereum, that means gas. In 2020, during peak DeFi activity, a single Uniswap swap cost less than five dollars while a comparable on-chain order book operation could run twenty times that — before the trade even happened.
Automated Market Makers sidestepped...
Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE