TempleGold

TempleDAO
Foundry
25,000 USDC
View results
Submission Details
Severity: low
Invalid

Incorrect comparison for minimum rewards in reward distribution logic

Summary

TempleGoldStaking::distributeRewards contains an incorrect comparison that checks if the reward amount is less than the reward duration. This comparison is conceptually incorrect as it compares an amount of tokens to a time duration, potentially leading to undesired behavior in the reward distribution process.

Vulnerability Details

In the TempleGoldStaking::distributeRewards function, the following line of code is intended to prevent the distribution of trivial or negligible reward amounts:

if (rewardAmount < rewardDuration) revert CommonEventsAndErrors.ExpectedNonZero();

However, this line compares rewardAmount (a quantity of tokens) to rewardDuration (a time duration), which is conceptually incorrect and can lead to improper handling of reward distribution.

Also, given the fact that the rewardDuration is most likely going to be measured in weeks, which is an increment of 604800 seconds, it will use that value as the number of wei for comparison, which in case of rewardDuration = 1 weeks produces 0.0000000000006048 ether worth of tokens in the other side of the comparison. This is considered a dust amount and is most likely not enough to meaningfully distribute between multiple users.

Impact

The incorrect comparison can lead to scenarios where trivial amounts of rewards are distributed, which might be inefficient or meaningless.

Tools Used

Manual code review

Recommendations

To ensure that only significant reward amounts are distributed, we recommend defining a minimum reward amount threshold and adjusting the check accordingly. Here is the suggested revision:

function distributeRewards() external updateReward(address(0), 0) {
// Previous code
uint256 rewardAmount = nextRewardAmount;
- if (rewardAmount < rewardDuration) revert CommonEventsAndErrors.ExpectedNonZero();
+ if (rewardAmount < MINIMUM_REWARD_AMOUNT) revert CommonEventsAndErrors.ExpectedSufficientRewardAmount();
nextRewardAmount = 0;
// Later code...
}

where the MINIMUM_REWARD_AMOUNT is a preset minimum value, which could also be updatable instead of constant.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.