In-depth lesson · Rounding and precision errors
Tips for beginners
Every point the Rounding and precision errors reports back under this heading, best-backed first, each with the reports it is seen in.
-
Begin with the share maths in vaults and pools. Read how the first deposit sets the price, whether there is a virtual offset or minimum liquidity, and what happens to a later depositor's shares when the price is inflated. That single flow accounts for many of the reports behind this lesson.
Seen in 3 reports
-
Examine oracle and tick handling. Prices and ticks rounded in the wrong direction can let a swapper trade below the signed value or overpay. Check spot price deviation checks for precision too low to catch a manipulated price.
Seen in 3 reports
-
Compare rounding direction across paired functions. Deposit against withdraw, mint against redeem, preview against actual. If one rounds up and the other rounds down in a way that lets a user gain, you have a finding. Check ERC-4626 preview, maxMint and maxDeposit for consistency with the spec.
-
Look at reward and commission distribution. Check whether division before multiplication leaves rewards locked or under-distributed, and whether commission rounding between users and validators is asymmetric enough to cause drift or theft.
-
Try to amplify. If you find a small rounding gain, check whether it can be repeated or combined with an exchange rate manipulation or a flash loan. A wei per call becomes a finding when it compounds.
-
Show impact with numbers from the protocol's own maths. State the inputs, the expected value and the actual value after truncation, and explain who loses and who gains. A report that only says rounding exists, without a concrete loss, is usually closed.
-
Check the fix direction when you write up. The strongest reports explain the correct rounding direction or the missing virtual offset, so the team can see the fix as well as the bug.
-
Grep for division and multiplication in the same expression. Any place that divides before multiplying is a candidate. Check whether the intermediate value can truncate to zero for realistic inputs, especially small rates and low-decimal tokens.
Seen in 1 report