Solana glossary / Arithmetic overflow

Arithmetic overflow

Definition

A calculation whose result does not fit its integer type. In Rust release builds it wraps around silently unless overflow checks are on, so a balance or a price can end up wrong without any error.

Why it matters

Token amounts, fees, rewards and prices are all integer maths. An overflow or a rounding error can mint more than intended, zero out a fee or lock funds, and it often shows only with extreme inputs that normal tests never use.

What to check

How it works in practice

Rust only panics on overflow when overflow checks are on. Anchor projects normally set overflow-checks to true in the release profile, and careful code also uses checked_add, checked_sub and checked_mul and returns an error on failure.

Fee and reward formulas also need a rounding rule. Rounding in the user’s favour on every call can drain a pool slowly, so the rounding direction is chosen on purpose.

Common mistakes

Related terms

Guides

Describe your project in plain English. Smart Match suggests verified Solana providers with a reason for each match. Free for teams.

Get matched →

← All Solana terms