In LinearDistributionIntervalDecrease::_calculateFullPeriodReward()
total interval passed in a period is calculated. However the calculation is bit complex which expenses more gas. We can oversimplify it.
We can structure the time passed thing like this:
Here interval passed over a period was calculated here:
If we look more into intervalPassedBefore
we can see how it was calculated, an private function, _divideCeil(uint256 a_, uint256 b_)
, was called, where a = timePassedBefore_
and b = interval_
.
timePassedBefore
is the timestamp from startTime
to payoutStart
, as we can see in the starting of the _calculateFullPeriodReward()
:
As uint256 intervalsPassedBefore_ = _divideCeil(timePassedBefore_, interval_);
we can say timePassedBefore_ = intervalsPassedBefore_ * interval_
.
So, while calculating the total interval period i.e ip_
we can use timePassedBefore_
instead of intervalsPassedBefore_ * interval_
.
So if we simplify the calculation of ip_
it will look like :
As we can see we can get the interval passed over a period just by substracting the startTime
from endTime
.
Here we are unnecessarily calling a function and made the process complicated.
Manual analysis.
Calculate the ip_
like this: (endTime_ - startTime_) / 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.