← ClaudeAtlas

defi-and-amm-mechanicslisted

TRIGGER - AMM, constant-product pool, x*y=k, Uniswap v2 or v3, concentrated liquidity, LP position, impermanent loss, divergence loss, fee income versus IL, pool price impact, out-of-range liquidity, DEX quote versus fill, sandwich, MEV or gas. SKIP for funding, mark price and liquidation (perpetuals-and-funding), rebases and token swaps (crypto-token-events), calendars, venue outages and stablecoin depegs (crypto-market-structure), centralised exchange clients (crypto-data-and-execution), and quoting on an order book (market-making-models).
howard-lynn-ye/fin-skills · ★ 1 · AI & Automation · score 80
Install: claude install-skill howard-lynn-ye/fin-skills
# DeFi and AMM mechanics Pool arithmetic can validate a quote. Realized execution also needs transaction ordering, actual reserves, fees and routing. Do not apply constant-product formulas to a different invariant merely because the venue calls itself an AMM. ✅ Source-verified 2026-09-14 through extracted PDF text: the [Uniswap v2 whitepaper](https://app.uniswap.org/whitepaper.pdf) describes the reserve invariant, input fee and optional protocol fee. The [Uniswap v3 whitepaper](https://app.uniswap.org/whitepaper-v3.pdf) describes concentrated ranges, separate fee balances and inactive liquidity outside a range. Those are historical protocol specifications, not a claim that today's deployed pools use only their initial fee tiers. All measurements below were reproduced on 2026-09-14 by `scripts/amm.py`, seed 20260910. The simulations use continuous quantities and ignore on-chain integer rounding. ## Constant-product impact: account for the fee retained in reserves For reserves `(x, y)`, selling `dx` of X, fee `f`, `g = 1-f`, and `u = dx/x`: ``` dy = g * dx * y / (x + g * dx) x_after = x + dx y_after = y - dy execution_price / initial_spot = g / (1 + g*u) post_trade_spot / initial_spot = 1 / ((1 + u) * (1 + g*u)) ``` 🚨 `1/(1+u)^2` is the pool-price ratio **only at zero fee**. The full input enters reserves, while the fee-reduced input determines output. `cp_impact()` is tested against the reserve changes in `cp_swap()` at nonzero fees as well as at zero. ✅ Measured: a z