A constant-product AMM (the mechanism behind Uniswap-style decentralized exchanges) holds two token reserves, A and B, bound by one invariant:
x · y = k (constant, apart from fee accrual)
trade in Δx (after fee f):
Δx_eff = Δx · (1 − f)
Δy_out = y − k / (x + Δx_eff)
spot price: P = y / x
slippage: (executed price − spot price) / spot price
This 2D view plots the pool state directly in reserve space: the top panel is the (x, y) plane with the live hyperbola y = k/x traced through it. The bright dot is the current reserve pair; the dashed line through it is the tangent (slope −y/x, the instantaneous spot price direction), while the solid line to the last trade's start point is the secant — its slope is the executed price. The gap between tangent and secant steepness is the slippage, drawn geometrically rather than only as a number.
The bottom panel plots the slippage function itself: executed slippage vs. trade size, computed analytically for the current reserves and fee, for both trade directions. It shows why slippage grows non-linearly as a trade drains one side of the curve — something no single swap readout can show on its own.
Impermanent loss compares a liquidity provider's current pool value to simply holding the original two tokens: IL = 2√(P/P₀)/(1+P/P₀) − 1, always ≤ 0, vanishing only if price returns to its starting ratio.
- Swap A → B / B → A — executes a trade of the chosen size against the current curve, deducting the fee first.
- Fee slider — the cut taken from every trade before it hits the invariant; higher fees widen slippage but reward liquidity providers.
- Reset Pool — restores the 1000/1000 starting reserves (P = 1, k = 1,000,000) for a clean run.