Skip to content
Audit finding Intermediate

Permanent loss of yield for stakers in reward pools due to precision loss.

The reward rate calculation in LockingMultiRewards divides the reward amount by the remaining time without sufficient precision, causing a loss of up to 604799 units of the reward token per notification. This loss is shared among stakers, resulting in permanent yield reduction, with potential losses of $0.6 for USDC and $423 for WBTC per occurrence.

Trust Follow with AgileJune, Bigsam and 1 other

Originally disclosed on Code4rena

Submitted by Trust, also found by AgileJune, Bigsam, and grearlake

The LockingMultiRewards contract facilitates distribution of rewards across the remaining epoch duration. The calculation for reward rate is provided below: reward.rewardRate = amount / _remainingRewardTime;

The rate is later multiplied by the duration to get the total rewards for elapsed time, demonstrated below:

function rewardsForDuration(address rewardToken) external view returns (uint256) {
    return _rewardData[rewardToken].rewardRate * rewardsDuration;
}

An issue occurs because there is no sufficient wrapping of the amount before dividing by _remainingRewardTime. The number is divided and later multiplied by elapsed time, causing a loss of precision of the amount modulo remaining time. For the provided period of 1 week by the sponsor, the maximum amount lost can be calculated: 7 * 24 * 3600 - 1 = 604799. Note that the average case loss is half of the worst case assuming even distribution across time. However since rewards are usually not sent at the low end of remaining time (see the minRemainingTime variable, the actual average would be higher).

The effect of this size of loss depends on the decimals and value of the reward token. For USDC, this would be $0.6. For WBTC, it would be$423 (at time of writing). The loss is shared between all stakers relative to their stake amount. The loss occurs for every notification, so it is clear losses will be severe.

Sponsor remarked in the channel that reward tokens would be real, popular tokens. We believe USDC / WBTC on ARB are extremely popular tokens and therefore remain fully in scope as reward tokens.

Severity Rationalization

Impact - high Likelihood - medium -> Severity - high

Impact

Permanent loss of yield for stakers in reward pools due to precision loss.

Proof of Concept

  • Reward pool offers WBTC rewards
  • Epoch has just started,

Recommended Mitigation Steps

Store the rewardRate scaled by 1e18, so loss of precision will be lower by magnitude of 1e18.

0xCalibur (Abracadabra) disputed and commented via duplicate #166:

No factor.

Trust (Warden) commented:

Hi,

The duplicate has been closed due to loss of “dust amounts”. However I show in my submission that it is far from dust, I believe any submissions that have identified material loss of funds should be awarded appropriately.


The original report as published on Code4rena, by Trust. 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 reward rate is computed by integer division without scaling, so the remainder from dividing the amount by the remaining time is discarded.

What the attacker needed

Reward pool with WBTC or USDC; epoch just started

The fix

The reward rate should be stored scaled by 1e18 to reduce precision loss by that magnitude.

How it was found

  1. A reward pool offers WBTC rewards.
  2. An epoch has just started.

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.

When a reward pool calculates how much each staker earns per second, it divides the total reward by the time left. If that division doesn't keep enough decimal places, a small remainder is lost. Over many rewards, these lost remainders add up, so stakers get slightly less than they should.

More by Trust

View all

77 more disclosed reports, best first.

More from Abracadabra Mimswap

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.