Skip to content
high Arithmetic No SWC entry CWE-682

Incorrect Decimal / Token Unit Handling

SAFE-0084 Arithmetic Checked automatically by the scanner
1

What goes wrong

Mixing tokens of different decimals (e.g. USDC 6 vs WETH 18) without normalization produces valuations off by orders of magnitude, enabling theft or mispricing.

2

How to fix it

the pattern that is safe
uint8 d = IERC20Metadata(usdc).decimals();
uint v = amountUSDC * price / (10 ** d);
Normalize decimals explicitly.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0084 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