sherlock-audit / 2022-10-merit-circle-judging

1 stars 0 forks source link

hickuphh3 - Curve is not guaranteed to be monotonically increasing #52

Closed sherlock-admin closed 2 years ago

sherlock-admin commented 2 years ago

hickuphh3

medium

Curve is not guaranteed to be monotonically increasing

Summary

getMultiplier() fails if the curve is not monotonically increasing. However, this condition is not enforced.

Vulnerability Detail

Subtraction overflow is encountered in getMultiplier() when curve[n + 1] < curve[n].

return 1e18 + curve[n] + (_lockDuration - n * unit) * (curve[n + 1] - curve[n]) / unit;

Impact

Attempts to deposit, increase lock duration or amount may revert.

Code Snippet

https://github.com/Merit-Circle/merit-liquidity-mining/blob/ce5feaae19126079d309ac8dd9a81372648437f1/contracts/TimeLockPool.sol#L245

Tool used

Manual Review

Recommendation

When setting a new curve or a new point, the monotonic increase condition should be checked.

Duplicate of #111