TWAP Oracle vs Flash-Loan Price Manipulation (2D)
A 2D companion to the 3D AMM flash-loan sim: watch the constant-product curve x·y=k directly, see the swap point and its tangent-slope price move during an atomic flash-loan attack, and compare a spot-price oracle against a time-weighted-average (TWAP) oracle on a real price-history chart.
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.
A 2D companion to the 3D AMM flash-loan sim: watch the constant-product curve x·y=k directly, see the reserve point and its tangent-slope price move during an atomic flash-loan attack, and compare a spot-price oracle against a time-weighted-average (TWAP) oracle on a real price-history chart.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install