At line 49, when it's checked if an interval is lesser than the interval range, the formula is inefficient.
Current formula is the following:
uint256 timePassedBefore_ = startTime_ - payoutStart_;
if ((timePassedBefore_ / interval_) == ((endTime_ - payoutStart_) / interval_))
Computing the operation doesn't even require the "payoutStart" varaible, as it would be equivalent with testing (endTime - startTime) / interval_ == 0.
A small optimization can be further performed by storing (endTime - startTime) in an uint128 variable (proposing name timeDelta) and using it on line 53. By performing this substitution, readability is also improved.
Extra gas cost for operation
Manual inspection
Rewrite formula as suggested:
if (((endTime - startTime) / interval) == 0)
And for further optimization & readability:
uint128 timeDelta = endTime - startTime
if((timeDelta / interval) == 0) {
...
return (intervalFullReward_ * timeDelta) / interval_
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.