oracle-manipulation
Skill36 starsChanged 5 months agoMITView on GitHub
Detect oracle manipulation risks — spot-price reads from AMMs, stale Chainlink answers, single-source dependence, TWAP gaming. Activate whenever code reads a price, conversion rate, exchange rate, or `getReserves`, `latestAnswer`, `latestRoundData`, `consult`, `quote`, `slot0`, `observe`, `getAmountsOut`.
In this repository44 other files it gives its agents.
- access-controlSkill
- approval-issuesSkill
- caching-and-incrementalSkill
- centralization-riskSkill
- confidence-scoringSkill
- cosmwasmSkill
- cross-chain-messagingSkill
- cross-contract-stateSkill
- delegatecall-risksSkill
- diamond-eip2535Skill
- dos-vectorsSkill
- erc1271-contract-signaturesSkill
- erc4337-account-abstractionSkill
- erc4626-inflationSkill
- false-positive-feedback-loopSkill
- fee-on-transferSkill
- flash-loan-attacksSkill
- initializationSkill
- inline-assemblySkill
- integer-issuesSkill
- intents-erc7683Skill
- known-good-comparisonSkill
- liquidation-cascadeSkill
- mev-frontrunningSkill
- mev-pbsSkill
- multi-pass-self-critiqueSkill
- oracle-redundancySkill
- permit2-patternsSkill
- pragma-and-addressesSkill
- progress-and-streamingSkill
- reentrancySkill
- restaking-eigenlayerSkill
- selfdestruct-eip6780Skill
- signature-malleabilitySkill
- signature-replaySkill
- solana-anchorSkill
- storage-layoutSkill
- stylus-rustSkill
- token-compatibilitySkill
- tx-context-misuseSkill
- unchecked-callsSkill
- ve-lock-governanceSkill
- vyper-specificSkill
- zk-verifier-bugsSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 45
Only one oracle, no fallback, no cross-check against a second source.
- Very specific: line 51
Use observe() for TWAP with sufficient lookback (≥30min for shallow pools).
- Distinctive: line 86
Use multiple oracles with deviation check (e.g.
- Very specific: line 89
Avoid slot0 and spot-price reads for anything that affects user funds.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Oracle manipulation detection
When this applies
Any code that consumes a price feed or derives a price from on-chain state:
- Chainlink:
latestAnswer,latestRoundData,getRoundData - Uniswap V2:
getReserves,getAmountsOut,price0Average - Uniswap V3/V4:
slot0,observe,consult - Curve:
get_virtual_price,get_dy - Balancer:
getRate - Custom oracle modules, on-chain TWAPs
- LP token pricing, collateral valuation, liquidation thresholds, mint/burn rates
Detection patterns
Spot price from AMM (CRITICAL — funds at risk)
(uint112 r0, uint112 r1,) = pair.getReserves();
uint256 price = r1 * 1e18 / r0; // ← flash-loan manipulable in one blockStale Chainlink data (HIGH)
(, int256 answer,,,) = feed.latestRoundData(); // ← ignores updatedAt and answeredInRoundRequired checks:
updatedAt != 0block.timestamp - updatedAt <= heartbeat(with chain-specific tolerance)answeredInRound >= roundIdanswer > 0- Heartbeat sanity: ETH/USD is 1h on mainnet but 24h on some L2s — verify
latestAnswer (deprecated, no freshness) (HIGH)
int256 p = feed.latestAnswer(); // ← deprecated, prefer latestRoundDataSingle-source dependence (HIGH)
Only one oracle, no fallback, no cross-check against a second source.
Uniswap V3 slot0 without TWAP (CRITICAL)
(uint160 sqrtPriceX96,,,,,,) = pool.slot0(); // ← spot, manipulableUse observe() for TWAP with sufficient lookback (≥30min for shallow pools).
Insufficient TWAP window (HIGH)
TWAP < 5 min on volatile assets or low-liquidity pools is gameable across two blocks.
Read-only reentrancy on oracle (HIGH)
Reading getVirtualPrice / getReserves mid-callback — see [[reentrancy]] §Read-only.
LP token priced via reserves directly (CRITICAL)
LP token price should use the fair LP price formula (Alpha Homora's method), not reserve / totalSupply.
Price scaling errors (HIGH)
Chainlink answers come in feed-specific decimals; mixing ETH/USD (8 decimals) with token (18 decimals) without normalizing produces silent off-by-1e10 errors.
Sequencer uptime ignored (HIGH on L2s)
On Arbitrum, Optimism, Base — must check SequencerUptimeFeed to avoid stale prices when sequencer is down.
Severity rubric
| Pattern | Severity |
| Spot-price from AMM used in liquidation/mint | Critical |
Uniswap V3 slot0 used for collateral pricing | Critical |
LP token priced via raw reserve / totalSupply | Critical |
latestRoundData without freshness/round checks | High |
| Single oracle, no fallback, financial-critical path | High |
| Sequencer uptime check missing on L2 | High |
| Insufficient TWAP window (<5min on shallow pool) | High |
| Stale heartbeat for known-volatile asset | High |
latestAnswer (deprecated) used | Medium |
| Decimal-scaling mistake | High |
Remediation patterns
- For Chainlink: validate
(roundId, answer, , updatedAt, answeredInRound)— guard against stale + zero + non-positive + round-mismatch. - Use multiple oracles with deviation check (e.g. Chainlink + Uniswap V3 TWAP with ≥30min window).
- For LP tokens, use fair-LP-price math:
2 * sqrt(r0 * r1 * p0 * p1) / totalSupply. - On L2s, integrate Chainlink's
SequencerUptimeFeed(Arbitrum, Optimism, Base). - Avoid
slot0and spot-price reads for anything that affects user funds.
False-positive notes
- Display-only prices (UI/event metadata, not affecting fund flow) — Info-only.
getReservesused purely for ratio diagnostics with no downstream effect — Info.
Related
- [[flash-loan-attacks]] — most oracle attacks are funded by flash loans
- [[reentrancy]] — read-only reentrancy is an oracle-staleness issue
- [[mev-frontrunning]] — TWAP-window timing
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

