HomeCybersecurityTWAP Oracle vs Flash-Loan Price Manipulation

TWAP Oracle vs Flash-Loan Price Manipulation

Interactive 3D DeFi security sim: trigger a flash-loan price-manipulation attack against an AMM pool and watch a spot-price oracle get spoofed instantly while a time-weighted-average (TWAP) oracle stays resistant.

Cybersecurity3DAdvanced60 FPS
exp-defi-security ↗ Open standalone

DeFi lending and liquidation logic often needs a live price for a pooled asset, and the cheapest source is the pool's own spot price. That convenience is also its weak point: a flash loan lets an attacker route an enormous, uncollateralized swap through the pool and back out again within a single atomic transaction, spiking the spot price for exactly one block at only the cost of gas and a swap fee. This simulator renders an AMM pool's constant-product curve as a live 3D block ring — spot price bars in red, a time-weighted-average (TWAP) ribbon in blue — and lets you trigger that attack yourself. Tune the flash-loan size and the TWAP window, watch a spot-reading oracle immediately flag a "loan approved" or "liquidation triggered" false positive, and watch the TWAP-reading oracle shrug the same block off because it averages across many blocks the attacker doesn't control. The mechanic is the same defensive lesson real protocols (Uniswap, Compound, Aave) adopted after the DeFi flash-loan attacks of 2020: never read an unaveraged instantaneous price for anything that gates money.

⚙ Under the hood

Trigger a flash-loan price-manipulation attack against a 3D AMM liquidity pool and compare a spot-price oracle, which gets spoofed for a single block, against a time-weighted-average (TWAP) oracle that resists it.

defiblockchaincybersecurityflash-loanoracleamm

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)