Skip to content
NFTVenue Ledger
Directory

Cross Chain Bridge Validator Exploits

Solidity Fixed-Point Precision Audits: WAD/RAY Scaling, mulDiv Overflow & Rounding Exploits

Because the EVM lacks native floating-point opcodes, divide-before-multiply truncation, hardcoded 18-decimal assumptions on 6-decimal USDC, and reversed rounding drain vaults silently.

By Dr. Devon Kurosawa, PhDReview not recorded · Updated
Solidity Fixed-Point Precision Audits: WAD/RAY Scaling, mulDiv Overflow & Rounding Exploits — NFTVenue Ledger 2026 quantitative & supervisory data card
NFTVenue Ledger (Cross-Chain Bridge Verification Models, Oracle Manipulation & Exploit RCAs): 512-bit Math.mulDiv, 6/8/18-decimal WAD normalization, and SafeCast downcast guards.Source: NFTVenue Ledger Institutional Research DeskLicense: CC-BY-4.0

Deterministic consensus across thousands of EVM nodes forbids IEEE-754 floating-point instructions (whose NaN and subnormal rounding nuances vary subtly across CPU architectures). Every price, interest rate, LP share, and royalty across Ethereum DEXs and NFT venues in our marketplaces directory (from 9mm Pro and Beethoven X to Uniswap v3/v4) executes in 256-bit integer fixed-point arithmetic: WAD (10^18), RAY (10^27), RAD (10^45), or binary Q64.96 (2^96).

Anchored in our cross-chain bridge, oracle & exploit RCA master guide, four recurring integer-math anti-patterns account for hundreds of high-severity audit findings and live exploits (SushiSwap RouteProcessor, Yield Protocol, Hundred, Balancer V2 linear-pool 1-wei rounding drain)!

Four Classic Solidity Fixed-Point Bugs Caught in Every Audit!#

  1. *Bug 1 — Divide-Before-Multiply Precision Collapse (`(a / b) c == 0`)**:

Writing fee = (amount / 10_000) * feeBps truncates amount / 10_000 to 0 for every amount < 10,000 wei (on 6-decimal USDC, $0.009999 pays ZERO fee!)—and on interest rates (elapsedSeconds / 31_536_000) * aprWad, elapsedSeconds / 31_536_000 evaluates to 0 for every block interval under 1 full year (0% interest accrued forever!)! Always multiply ALL numerators first via Math.mulDiv(a, c, b)!

  1. Bug 2 — Hardcoding 1e18 on 6-Decimal USDC/USDT or 8-Decimal WBTC (10^12x Valuation Error!):

Multiplying amount_USDC (1e6) by price_USD_WAD (1e18) and dividing by 1e18 yields 1e6 instead of 1e18—undervaluing USDC debt by 1,000,000,000,000x (allowing $1 of ETH to borrow the entire USDC pool) or conversely overvaluing 2-decimal GUSD!

  1. Bug 3 — Intermediate uint256 Overflow Without 512-Bit FullMath.mulDiv:

In Solidity >=0.8.0, (x * y) / z reverts whenever x * y >= 2^256, even when the final quotient (x * y) / z fits comfortably inside uint128! OpenZeppelin Math.mulDiv (Remco Bloemen Chinese Remainder Theorem 512-bit trick) computes exact floor((x * y) / z) in ~95 gas without overflowing intermediate 512-bit products!

  1. Bug 4 — Reversed Rounding in Flash-Swap Loops (Balancer V2 Boosted Pool $2M+ Exploit):

In Balancer V2 Linear Pools, swapping 1 wei down to 0 wei input cost rounded in the attacker's favor once pool balances shrunk via flash swaps—letting an attacker execute 300 micro-swaps inside 1 transaction to siphon millions!

Solidity 512-bit Math.mulDiv pipeline normalizing heterogeneous token decimals and enforcing directional rounding
Solidity 512-bit Math.mulDiv pipeline normalizing heterogeneous token decimals and enforcing directional roundingVerified Exhibit

Heterogeneous Token + Oracle Decimal Normalization Matrix#

Whenever converting amount_A of Token A (decimals d_A, oracle price P_A with decimals o_A) into equivalent units of Token B (decimals d_B, oracle price P_B with decimals o_B), never eyeball powers of 10 in your head! Verify against the exact dimensional-analysis table:

Quantitative Distribution · dA, oA
dA, oAdB, oB
01WETH -> USDC (Chainlink 8-d…18, 802USDC -> WETH (Chainlink 8-d…6, 803WBTC -> USDC (WBTC 8d, ETH-…8, 18
Token Pair & Oracle Setupd_A, o_Ad_B, o_BExact Unified Conversion Formula (Amt_B in native B units)
WETH -> USDC (Chainlink 8-dec USD)18, 86, 8mulDiv(amt_A, P_A, P_B * 10^(18 - 6)) = mulDiv(amt_A, P_A, P_B * 1e12)
USDC -> WETH (Chainlink 8-dec USD)6, 818, 8mulDiv(amt_A * 1e12, P_A, P_B)
WBTC -> USDC (WBTC 8d, ETH-quoted!)8, 186, 8Normalize both prices to 18-dec USD WAD first, then scale 10^(d_B - d_A)!
General Universal Formula (Any d, o <= 18)d_A, o_Ad_B, o_BValue_USD_WAD = mulDiv(amt_A, P_A * 10^(18 - o_A), 10^d_A)
Comparison of precision loss and overflow behavior across naive Solidity math, WAD math, RAY math, and Q64.96
Comparison of precision loss and overflow behavior across naive Solidity math, WAD math, RAY math, and Q64.96Verified Exhibit

Silent Downcast Truncation Trap (uint128(x) Does NOT Revert in Solidity 0.8!`)#

Read that metric card twice—it surprises 80% of developers! While Solidity 0.8+ checks +, -, and * for overflow, explicit type downcasting uint96(bigUint256) or int256(hugeUint256) silently truncates upper bits WITHOUT reverting! Always use OpenZeppelin SafeCast.toUint128(x) alongside virtual-share guards from ERC-4626 first-depositor share inflation!

Universal Dimensional-Safe Asset Conversion & Anti-Siphon Formula#

Formula or model from the articleNot independently verified
1) Universal Dimensional-Safe Asset Conversion (Token A [d_A] -> Token B [d_B] via normalized 18-dec USD WAD prices):
  • PAwad = PAraw * 10^(18 - oracleDecimals_A)
  • PBwad = PBraw * 10^(18 - oracleDecimals_B)
  • USDwad = Math.mulDiv( amountA, PAwad, 10^dA, RoundingMode ) [Exact 18-decimal USD value]
  • amountB = Math.mulDiv( USDwad, 10^dB, PBwad, RoundingMode ) [Exact native Token B units]
  • 2) Anti-Micro-Siphon Guard (Blocks Balancer Linear-Pool Style 1-Wei Loops):
  • If Rounding_Mode == Floor (User Output): require(amountIn > 0 && amountOut > 0, "ZeroOutputDustSwap!");
  • If Rounding_Mode == Ceil (User Input): require(amountOut > 0 && amountIn > 0, "FreeOutputExploit!");
  • // Plus always cast packed storage fields via SafeCast.toUint128(amount) — NEVER raw uint128(amount)!

Preventing Cross-Chain Relayer Replay & Reorg Double-Spends Next#

From bit-level EVM math, we return to cross-chain consensus edge cases: what happens when a fast bridge relayer pays out $2M on Arbitrum after 3 blocks on Polygon or an L1, and the source chain experiences a 12-block consensus reorganization (reorg) erasing the deposit? Audit finality depths next in bridge relayer message replay & chain-reorg finality depth inside our Cross-Chain Bridge & Oracle Security hub.

Frequently asked questions

Does Solidity 0.8.x automatically revert if uint256 overflows when cast to uint128 or uint96?

NO! Solidity 0.8 checked arithmetic only covers +, -, *, /, and ** operators; writing uint96(amount) silently masks off the upper 160 bits without reverting—requiring OpenZeppelin SafeCast.toUint96(amount).

How does OpenZeppelin Math.mulDiv avoid reverting when x * y exceeds 2^256 - 1?

Math.mulDiv computes the full 512-bit product (prod1, prod0) using EVM MUL and MULMOD (Chinese Remainder Theorem) and divides in assembly, reverting ONLY if the final quotient exceeds 2^256 - 1.

Why do lending protocols like Aave and MakerDAO use 27-decimal RAY for interest indices instead of 18-decimal WAD?

At a 1% annual rate compounded every 2-second L2 block, rate-per-block is ~6.3e-10; in 18-decimal WAD, compounding small principal slices loses significant significant digits, whereas 27-decimal RAY preserves 9 extra digits of precision.

How did 1-wei rounding drain over $2M from Balancer V2 Boosted Linear Pools?

By flash-borrowing almost all pool liquidity to shrink virtual balances, the attacker created an exchange rate where swapping tiny dust rounded input cost down to 0 while output rounded to >=1, repeating hundreds of times in 1 tx.

Publication record

Published
November 13, 2026
Updated
November 14, 2026
Author
Dr. Devon Kurosawa, PhD
Review
Review not recorded
Automated fact check
Passed in the stored pipeline record
Source URLs
3 recorded

AI assistance recorded: anthropic/claude-opus-4.6. This field does not establish human review or source verification.

Academic & Institutional Attribution

Cite This Research & Embed Live Data Card

Open Attribution License (CC BY 4.0)

Standard academic & institutional research paper citation format.

Dr. Devon Kurosawa, PhD. (2026, November 14). Solidity Fixed-Point Precision Audits: WAD/RAY Scaling, mulDiv Overflow & Rounding Exploits. NFTVenue Ledger. https://nftvenueledger.com/protocols/decimal-precision-truncation-wad-ray-rounding-direction
Explore Cross Chain Bridge Validator Exploits Hub (20) →

NFTVenue Ledger Data, Benchmarks & Contributor Records

Solidity WAD/RAY Precision, mulDiv & Rounding Exploit Audits | NFTVenue Ledger