⚡ Flash-loan swap executed — spot price spiked for 1 block
Spot price (per block) TWAP (window average) Attacked block

TWAP Oracle vs Flash-Loan Price Manipulation (2D)

This 2D companion to the 3D AMM flash-loan simulator drops the rotating block-ring visualization in favor of the mathematics itself: the pool's reserves are plotted as a single point on its own constant-product curve x·y=k, and the spot price is shown as exactly what it is — the magnitude of that curve's tangent slope at the pool's current point. Triggering a flash-loan attack slides the point sharply along the hyperbola for one simulated block — oversupplying token A flattens the tangent and drops the spot price away from baseline — before the atomic repayment snaps the point back. A second panel renders a genuine price-vs-time chart, tracking the per-block spot price against a rolling time-weighted-average (TWAP), so you can watch a naive spot-reading oracle trip a false liquidation while the TWAP-reading oracle barely moves. Ordinary (non-attack) blocks are driven by a partial-arbitrage rule — the same mechanism real arbitrage bots use to pull a mispriced pool back toward the wider market's reference price — rather than an artificial mean-reversion nudge.