In-depth lesson · technique
Rounding and precision errors
What every disclosed Rounding and precision errors report in the index teaches, put together: how it works, how it changed year by year, where it turns up, and things to try. Every point shows the reports it is seen in.
- reports cited in this lesson
- 216
- median public bounty
- None
Learning Smart contracts, step 5
Overview
What it is and why programs pay for it.
Rounding and precision errors are a class of smart contract bug where arithmetic does not behave the way the developer assumed. Solidity integer division truncates, fixed point maths loses low order digits, and values cast between widths or precisions can silently drop information. When those losses land on the wrong side of a balance, a share count or a fee, the result is a real economic difference that someone can exploit or that strands user funds. This lesson covers how those errors appear in smart contracts and how to hunt them.
Programs care because these bugs are common, cheap to trigger and often directly profitable. A rounding direction that favours the user can be repeated in small steps to accumulate a gain, and a first depositor who sets the share price can turn a truncation into theft from later depositors. Even where no attacker is present, precision loss can lock rewards, leave dust unclaimable or break accounting so that a protocol drifts out of balance over time.
The usual outcomes are theft of a small or large share of pool funds, rewards that are under-paid or permanently stuck, fees that round to zero for low-decimal tokens, and broken invariants that let unbacked borrowing or failed liquidations through. It turns up most often in vault and pool share minting, staking and reward distribution, fee calculation, oracle and tick handling, commission accounting, liquidation settlement and ERC-4626 preview and limit functions.
Seen in these reports8
-
Medium -
High
-
High
Show all 8 reportsShow fewer
-
High
-
High -
Medium -
High
-
Medium
How it works
The mechanics, as the reports show them.
Start with the arithmetic itself. Integer division in smart contracts discards the remainder, so any expression that divides before multiplying throws away precision in the intermediate value. If the code computes a rate first and scales it up afterwards, small rates can truncate to zero entirely. The same happens when a scaling constant is too small for the value range, or when code assumes a fixed number of decimals that a low-decimal token does not have.
Next, look at direction. Rounding is only safe when it consistently favours the protocol. If a deposit rounds shares down but a withdrawal rounds assets up, or if two functions that should agree round in opposite directions, a user can move value across the boundary. Inconsistent rounding between modules is what makes health factor checks, collateral conversions and migration paths disagree about the same position.
Then consider the first depositor problem. When a vault or pool lets the first depositor set the share price with no virtual offset or minimum liquidity, a tiny initial deposit followed by a donation can inflate the price of a share. Later depositors then have their shares rounded down, sometimes to zero, and the attacker captures the difference. This is a precision error at heart: the share maths has no floor to protect small deposits.
Casting and truncation are the third mechanism. Converting a wider integer to a narrower one, or between signed and unsigned types, or between different precisions, drops the high or low bits without complaint. If the result feeds a balance, a claim or a counter, the truncated value can corrupt accounting. A fill counter reset this way can let the same order be sold twice.
Finally, think about repetition and amplification. A single rounding error is often a wei. But if the operation can be repeated, or if an attacker can manipulate the exchange rate or share price around it, the small loss compounds into a meaningful gain. Flash loans make the setup cheap, and small repeated operations turn dust into profit.
Seen in these reports9
-
Medium -
High
-
High
Show 5 moreShow fewer
-
High -
High
-
High -
Medium
-
High
Year by year
6 yearsWhat each year's disclosed reports show, newest first. A year with few reports says less.
| 2015 | 1 |
|---|---|
| 2021 | 11 |
| 2022 | 45 |
| 2023 | 64 |
| 2024 | 41 |
| 2025 | 87 |
| 2026 | 21 |
-
2026
New this year1
- Firelight reports cover ERC-4626 maxMint and maxDeposit rounding inconsistencies in the disclosed reports.
Kept working2
- Rounding direction on deposit and withdraw paths was checked for the wrong direction letting a user gain in the disclosed reports.
- Scaled-share conversions were checked for rounding mismatches breaking transfer and withdraw accounting in the disclosed reports.
-
2025
New this year3
- A cluster of Plume Network reports covers commission and yield rounding in the disclosed reports.
- Validator and delegator commission accounting first appears as a distinct target in the disclosed reports.
- A cluster of Alchemix V3 reports covers precision loss and permanent freezing in the disclosed reports.
Kept working5
- First depositor share inflation through a tiny deposit and donation or share price inflation remained a recurring pattern in the disclosed reports.
- Front running yield distribution as the last holder was tested for stealing the rounding remainder in the disclosed reports.
-
2024
New this year1
- Spot price deviation checks were first tested for low precision letting a manipulated price pass in the disclosed reports.
Kept working2
- Rounding direction on deposit and withdraw paths was checked for the wrong direction letting a user gain in the disclosed reports.
- First depositor share inflation through a tiny deposit and donation or share price inflation remained a recurring pattern in the disclosed reports.
Earlier years3
Where it is found
8The features and places the reports found it in, most-reported first.
-
Vault and pool share minting on the first deposit.
Seen in 10 reports
-
Validator and delegator commission accounting.
Seen in 6 reports
-
Oracle price and tick handling.
Seen in 3 reports
-
Staking and reward pool distribution functions.
-
ERC-4626 preview, maxMint and maxDeposit functions.
Technologies in these reports5
Root causes
6The mistakes in the code or configuration behind the reports.
-
Rounding in the wrong direction or inconsistently between functions.
Seen in 13 reports
-
Share price set by the first depositor without a virtual offset or minimum liquidity.
Seen in 10 reports
-
Casting or truncating integers between widths or precisions without bounds checks.
Seen in 3 reports
-
Dividing before multiplying so intermediate values truncate to zero or lose precision.
-
Precision constants or scaling factors that are too small for the value range.
Seen in 1 report
Things to try
The most-reported tests in the largest contexts. Tick what you have tried; ticks stay in this browser and carry over to the full checklist. Test only what a program's scope allows.
ticked in this lesson
Liquidation and bad debt
of 3 ticked-
Seen in 4 reports
-
Seen in 2 reports
-
Seen in 1 report
Vault share pricing and first depositor
of 3 ticked-
Seen in 10 reports
Oracle prices and spot offsets
of 3 ticked-
Seen in 4 reports
-
Seen in 3 reports
-
Seen in 3 reports
Fixed point and decimal libraries
of 3 ticked-
Seen in 9 reports
-
Seen in 5 reports
-
Seen in 3 reports
Bypasses and variations
3How reports got past filters, encoders and other defences.
-
Manipulate the exchange rate or share price to turn a rounding error into theft.
Seen in 4 reports
-
Repeat small operations to amplify a rounding error into a larger gain.
Seen in 3 reports
-
Force a staking rate to one so depositors suffer a large rounding error.
Payouts
Public bounties in US dollars, from the data. 0 of 289 reports show an amount.
None of these reports shows a public amount yet.
Typical fixes
4How programs fixed it, as the reports describe.
-
Use a virtual offset, minimum initial liquidity or dead shares to prevent first depositor inflation.
Seen in 10 reports
-
Round consistently in the protocol's favour, and round up where the specification requires it.
Seen in 9 reports
-
Bound and validate integer widths and precisions before casting or truncating.
Seen in 3 reports
-
Multiply before dividing and keep intermediate values at full precision.
Tips for beginners
8Advice for a first hunt, drawn from the reports.
-
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.
Guides and techniques
The best explainers, cheat sheets and technique posts on Rounding and precision errors, from around the web.
-
Breaking Business Logic: 7 Attack Scenarios in E-Commerce, Payments and Application WorkflowsCovers seven business logic attack scenarios across e-commerce and payment workflows, giving hunters practical testing ideas.
Technique infosecwriteups.com
-
Payment Bypass Guide for Bug Bounty | 69 case studiesWalks through payment logic flaws with many case studies showing how to bypass checkout and pricing controls.
Methodology medium.com
Keep learning
Where this lesson fits, and what to read next.
Learning paths
The whole class
Related techniques
How this is made: our model read every listed Rounding and precision errors report in the index (our own summary where we have one, otherwise the title and the platform's label), listed the patterns, and merged them. Each point was kept only if the reports it cites exist, are listed and belong here; payouts are computed from the data, not written by the model. Read the originals before relying on a point. Generated 27 Nov 2026 from 235 reports. All Rounding and precision errors reports.