Skip to content
Smart contracts Audit finding Intermediate

Accumulated rewards per share can round to zero

The accumulated rewards per share calculation can round down to zero when the precision factor is too small relative to total shares, so a claim adds nothing to the accumulator. Users then miss out on rewards and the funds remain stuck in the Distributor contract.

hgrano Follow with AvantGard, BenRai and 9 others

Originally disclosed on Code4rena

Submitted by hgrano, also found by AvantGard, BenRai, HalfBloodPrince, KuwaTakushi, kwad, makarov, mbuba666, nuthan2x, prk0, ZeroEx, and zzebra83

launchpad/libraries/RewardsTracker.sol #L225

The accumulated rewards per share variables stored on the Distributor may round to zero, particularly for quote tokens with few decimals. The project has not specified the quote token, but it seems reasonable to expect USDC would be an option. Consider a scenario where USDC is the quote token and pendingQuoteRewards for the launched token is 1000 USDC. If a user calls Distributor::claim then the accumulated rewards per share will be calculated on RewardsTracker.sol:225:

accQuoteRewardsPerShare += ((self.pendingQuoteRewards * PRECISION_FACTOR) / uint128(totalShares));

The issue is that the PRECISION_FACTOR is only 1e12 so the numerator above is 1000e6 * 1e12 = 1000e18. Therefore if totalShares > 1000e18, zero will be added to accQuoteRewardsPerShare.

This scenario is not unlikely if using USDC because (1) totalShares is likely to be in the hundreds of millions of ether (based on the BONDING_SUPPLY which is hard coded as 800_000_000 ether) and (2) USDC earnings from the uniswap pair which add to the rewards will be small per each token swap (i.e. pendingQuoteRewards may be quite small).

Impact: users miss out on rewards and the funds are stuck in the Distributor contract.

Recommended mitigation steps

Consider increasing the PRECISION_FACTOR appropriately to handle this scenario.

View detailed Proof of Concept


The original report as published on Code4rena, by hgrano. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the precision factor used when dividing pending rewards by total shares is too small, so the integer division truncates to zero for low-decimal tokens and large share totals.

What the attacker needed

Quote token with few decimals, e.g. USDC; total shares above 1000e18; small pending quote rewards

The fix

The precision factor should be increased appropriately to handle this scenario.

How it was found

  1. Assume USDC is the quote token and pending quote rewards for the launched token are 1000 USDC.
  2. A user calls Distributor::claim, which recalculates accumulated quote rewards per share.
  3. The numerator is pending rewards multiplied by the precision factor, giving 1000e18.
  4. If total shares exceed 1000e18, the division yields zero and nothing is added to the accumulator.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Rewards are shared out by tracking how much each unit of stake has earned so far. That per-unit figure is stored as a whole number, so if the reward is small compared with the total stake, the division rounds down to zero and nothing is recorded. The result is that people claiming rewards receive nothing and the money stays in the contract.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by hgrano

View all

10 more disclosed reports, best first.

More from GTE Perps and Launchpad

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.