Skip to content
medium Oracle / Price No SWC entry CWE-345

Insufficient TWAP Window / Manipulable TWAP

SAFE-0025 Oracle / Price Checked automatically by the scanner
1

What goes wrong

A TWAP oracle uses too short a window or too few observations, so a well-capitalized actor can still move the average across a couple of blocks, partially defeating the time-weighting.

2

How to fix it

the pattern that is safe
uint32 window = 1800; // 30-min TWAP; ensure pool cardinality & liquidity suffice
Size TWAP windows to manipulation cost; raise cardinality.
3

Where this has happened

Largest recorded losses in the same failure class — related, not the same bug:

Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0025 among them. Paste an address or the source itself — a small per-scan fee, shown before you sign, or unlimited on any plan.

Run the scanner See how it is attacked Read the docs