Misleading implementation of _divideCeil()
in LinearDistributionIntervalDecrease.sol
In LinearDistributionIntervalDecrease.sol
, _divideCeil()
function is used to round up the divide result as the name suggest. To be noted, ceil
is primarily used to refer round up
. However, the implementation does the opposite than the function is intended to. It round down the result instead of round up. This is due to incorrect implementation of _divideCeil()
.
consider a scenario,
a= 10 and b=5, then _divideCeil()
will equate to (10+5-1)/5 = 2.8
which the function will return the final result as 2
, Howver the return result is round down and not round up since 2.8 is returned as 2 here.
This implementation of _divideCeil() is extremely misleading, Therefore, i suggest to follow below implementation which is directly taken from openzeppelin.
Now, consider similar scenario here and see the difference to understand clearly,
a= 10 and b=5, then ceilDiv()
will equate to (10-1)/(5+1) = 9/6 = 1.5
which the ceilDiv()
function will return the final result as 2
which is absolutely correct.
Incorrect implementation of _divideCeil()
is misleading the return value. Function is designed for round up but it is returning round down result.
Manual review
Recommend to implement below function for divide ceil functionality i.e to round up.
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.