oracle-manipulation

Solid

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`.

AI & Automation 38 stars 5 forks Updated 2 days ago MIT

Install

View on GitHub

Quality Score: 82/100

Stars 20%
53
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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) ```solidity (uint112 r0, uint112 r1,) = pair.getReserves(); uint256 price = r1 * 1e18 / r0; // ← flash-loan manipulable in one block ``` ### Stale Chainlink data (HIGH) ```solidity (, int256 answer,,,) = feed.latestRoundData(); // ← ignores updatedAt and answeredInRound ``` Required checks: - `updatedAt != 0` - `block.timestamp - updatedAt <= heartbeat` (with chain-specific tolerance) - `answeredInRound >= roundId` - `answer > 0` - Heartbeat sanity: ETH/USD is 1h on mainnet but 24h on some L2s — verify ### `latestAnswer` (deprecated, no freshness) (HIGH) ```solidity int256 p = feed.latestAnswer(); // ← deprecated, prefer latestRoundData ``` ### Single-source dependence (HIGH) Only one oracle, no fallback, no cross-check against a second source. ### Uniswap V3 `slot0` without TWAP (CRITICAL) ```solidity (uint160 sqrtPriceX96,,,,,,) = pool.slot0(); // ← spot, manipulable ``` Use `observe()` for TWAP with suffic...

Details

Author
iktok90-design
Repository
iktok90-design/ai-smart-contract-auditor
Created
1 weeks ago
Last Updated
2 days ago
Language
JavaScript
License
MIT

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category