Home▸Cybersecurity▸Flash Loan Oracle Manipulation: 2D Constant-Product Curve Lab

Flash Loan Oracle Manipulation: 2D Constant-Product Curve Lab

The constant-product curve with the pool state moving along it through the five steps of the block, the fair-price line against the spot-price tangent, a price comparison and a waterfall of borrowed funds, collateral lost, costs and net result. Same shared model and numerical checks as the 3D lab.

Cybersecurity2DAdvanced60 FPS📱 Mobile-adapted🟠 Blender⇄ 3D version
Flash Loan Oracle Manipulation: 2D Constant-Product Curve Lab ↗ Open standalone

This simulator recreates the core mechanic behind DeFi's most infamous exploits: a flash loan used to distort a constant-product AMM's spot price for one block, tricking a lending protocol's price oracle into over-valuing collateral. Watch reserves shift in the pool as the attacker's swap goes through, a lending vault release borrowed funds against the inflated price, and the pool settle back down after the repay swap — then switch the oracle from raw spot price to a time-weighted average and see the same attack turn unprofitable, exactly why every major lending protocol now defends against single-block price spikes.

⚙ Under the hood

The constant-product curve with the pool state moving along it through the five steps of the block, the fair-price line against the spot-price tangent, a price comparison and a waterfall of borrowed funds, collateral lost, costs and net result. Same shared model and numerical checks as the 3D lab.

Flash LoanPrice OracleTWAPConstant-Product AMMOracle RiskDeFi Security

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)