Home▸Cybersecurity▸Flash Loan Oracle Manipulation: AMM Price Impact and the TWAP Defence

Flash Loan Oracle Manipulation: AMM Price Impact and the TWAP Defence

Follow one blockchain block in which a flash loan pushes a constant-product AMM pool price and a lending protocol trusts that price. Set pool depth, loan size, swap fee, collateral, collateral factor and the oracle (spot or TWAP window) and watch the reserves in two vats, the price on a gauge and the coin flows between attacker, pool and lender. The model reports the over-borrowing, the lender loss, the swap and flash-loan costs, the longest TWAP window the attack still beats and the smallest paying loan. Blender-built vats, vault, terminal and coins, with independent numerical checks built in. A defensive educational model of oracle risk, not a trading tool.

Cybersecurity3DAdvanced60 FPS📱 Mobile-adapted🟠 Blender⇄ 2D version
Flash Loan Oracle Manipulation: AMM Price Impact and the TWAP Defence ↗ 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

Follow one blockchain block in which a flash loan pushes a constant-product AMM pool price and a lending protocol trusts that price. Set pool depth, loan size, swap fee, collateral, collateral factor and the oracle (spot or TWAP window) and watch the reserves in two vats, the price on a gauge and the coin flows between attacker, pool and lender. The model reports the over-borrowing, the lender loss, the swap and flash-loan costs, the longest TWAP window the attack still beats and the smallest paying loan. Blender-built vats, vault, terminal and coins, with independent numerical checks built in. A defensive educational model of oracle risk, not a trading tool.

blockchainDeFiflash loanAMMprice oraclecybersecurityFlash LoanPrice OracleTWAPConstant-Product AMMOracle RiskDeFi Security

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

What did you find?

Add reproduction steps (optional)