integer-issues

Solid

Detect integer over/underflow in `unchecked` blocks, downcasting losses, fixed-point precision errors, division-before-multiplication, signed/unsigned mixing. Activate on any arithmetic in `unchecked { }`, `SafeCast`, `uintN(uintM(x))` casts, division and modulo, percentage/basis-points math, AMM share/asset math.

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

# Integer issues detection ## When this applies - `unchecked { … }` blocks (Solidity ≥0.8) - Downcasts: `uint128(x)`, `int256(uint256(x))`, `uint8(...)` - Division and modulo - Fixed-point math with custom decimal scales - Share/asset math in vaults, lending, AMMs - Pre-0.8 Solidity code (no built-in overflow checks) - Vyper code with unbounded loops - Inline assembly arithmetic ## Detection patterns ### Unchecked overflow on user input (HIGH) ```solidity unchecked { balance[to] += amount; // ← if amount controlled, can overflow back to 0 } ``` `unchecked` is fine for proven-safe accumulators (e.g. `++i` in bounded loops), not for value math. ### Division before multiplication (HIGH) ```solidity uint256 fee = (amount / 100) * feeBps; // ← truncation; do (amount * feeBps) / 100 ``` ### Decimal mismatch (HIGH) USDC = 6 decimals, WETH = 18, WBTC = 8. Mixing without scaling produces silent 1e10–1e12 errors. ```solidity uint256 wethValue = amountUsdc * price; // ← USDC 6dp × price 8dp = 14dp, need 18dp ``` ### Downcast loss (HIGH) ```solidity uint128 sharesU128 = uint128(shares); // ← silently truncates if shares > 2^128 ``` Use OZ `SafeCast`. ### Fixed-point precision loss (HIGH) Compounding interest done as `principal * (1 + rate)^t` with too-few-decimal `rate`. Use ray (1e27) or wad (1e18) math via PRBMath / Solady. ### Round-direction asymmetry (HIGH for vaults) ERC-4626 must round shares *down* on deposit (favor vault) and *up* on withdraw (favor vau...

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