Advanced
AMMs Deep Dive — Lesson outline
Build a minimal x·y=k AMM.
Developer Advanced
5/8 — AMMs Deep Dive — Lesson outline
Map the routeFollow this sequence to avoid mixing intuition, math, and code prematurely.
Talk is cheap. Show me the code.
Steps
- Warm-up:Sketch the x·y=k curve and fee flow on paper.
- Math drill:Compute outputs for sample trades and confirm k grows with fees.
- Design:Define events, fee BPS, and safety checks (non-zero liquidity, min output).
- Implement:Write mint/burn/swap with invariant checks and cumulative price updates.
- Test:Simulate swaps, edge cases (tiny/large trades), and IL scenarios.
- Review:Add view helpers and docs for LP/trader UX.