Crypto / Evergreen
Rounding can redistribute value across repeated operations
Integer arithmetic and fixed-point representations require contracts to round values, and the direction of rounding can affect who gains or loses small residual amounts.
Rounding is part of the economic design, so its direction and composition deserve explicit analysis.
The distinction that matters
Integer arithmetic and fixed-point representations require contracts to round values, and the direction of rounding can affect who gains or loses small residual amounts. Smart-contract security combines software correctness, authorization, and economic assumptions. A program can follow its written code perfectly while producing an outcome its designers did not intend. Attackers can choose inputs, arrange transactions, interact through other contracts, and exploit the precise order in which state changes and external calls occur.
How the mechanism works
A tiny per-operation discrepancy can become economically important when an operation is repeated or combined with share-minting and redemption rules. Public code makes behavior inspectable, but inspection requires attention to all reachable paths and dependencies. Security reviews, formal methods, tests, and monitoring provide different kinds of evidence. None is a universal certificate covering every later upgrade, configuration change, or interaction with external systems. A review's scope, version, and unresolved findings matter, and a deployed contract can differ from the reviewed artifact.
A worked situation
Consider this hypothetical situation: A hypothetical vault rounds share issuance favorably to the depositor while rounding withdrawals unfavorably to the pool across a repeatable sequence. An attacker may exploit the mismatch even though each individual result looks like an insignificant numerical approximation.
Where interpretation can fail
Using more decimal places can reduce some errors but does not replace a consistent policy for rounding and invariant preservation. Examine boundary values, tiny deposits, and repeated conversions between assets and shares when evaluating arithmetic behavior. Rounding is part of the economic design, so its direction and composition deserve explicit analysis.
The wider technical implication
A common pressure point is converting between underlying assets and shares when the pool is very small or when one side of the ratio changes sharply. Rounding that is negligible at ordinary scale can dominate a tiny deposit. An invariant should specify who bears residual fractions and whether repeated deposit-withdrawal cycles can increase an actor's claim without adding equivalent value. Testing boundary sizes and adversarial sequences can reveal these issues more effectively than repeating a typical large deposit. Numerical precision and economic conservation are related, but precision alone does not establish a sound conversion rule.
A global perspective
A technical exploit, contractual breach, and regulatory violation are different classifications. Remedies and reporting duties depend on jurisdiction and the actual facts.
Sources & further reading
Ethereum.org — Smart contract security ↗OpenZeppelin Contracts — Access control ↗Sources checked Oct 27, 2026. Educational examples. Historical observations are attributed to their sources. No affiliation with cited organizations.
Make the idea stick.
Mark complete when you are ready. Reaching the end alone does not mark a lesson complete.
What assumption in this guide would change the result in a different situation? Revisit the example and explain that change in your own words.
Explore crypto →