DeFiHardhatFoundry
250,000 USDC
View results
Submission Details
Severity: low
Valid

`LibIncentive.fracExp()` omits one case.

Title

LibIncentive.fracExp() omits one case.

Github link

https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/9c7b9fd521ad7cbe65cc788df181887c0eb39c6d/protocol/contracts/libraries/LibIncentive.sol#L440

Summary

LibIncentive.fracExp() omits one case.

Vulnerability Details

fracExp() returns the scaled sunrise reward according to secondsLate.

File: LibIncentive.sol
63: function fracExp(
64: uint256 beans,
65: uint256 secondsLate
66: ) internal pure returns (uint256 scaledSunriseReward) {
...
400: } else if (secondsLate <= 240) {
...
440: if (secondsLate <= 238) { //@audit missing 239~240
441: return _scaleReward(beans, 10_677_927);
442: }
443: } else if (secondsLate <= 270) {
444: if (secondsLate <= 242) {
445: return _scaleReward(beans, 11_111_494);
446: }

But while checking multiple cases, it doesn't return a proper result when secondsLate is between 239 and 240.

So fracExp() will return scaledSunriseReward = 0 in this case and users might get no rewards after calling sunrise().

Impact

Users wouldn't get rewards after calling sunrise().

Tools Used

Manual Review

Recommendations

fracExp() should have one more case for secondsLate of (238, 240).

Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Validated
Assigned finding tags:

LibIncentive misses `240` case

Support

FAQs

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