sherlock-audit / 2023-12-dodo-gsp-judging

6 stars 5 forks source link

mike-watson - Missing Invariant Check in `DODOMath.sol` #88

Closed sherlock-admin closed 6 months ago

sherlock-admin commented 6 months ago

mike-watson

high

Missing Invariant Check in DODOMath.sol

Summary

The DODOMath.sol contract lacks a critical invariant check to ensure that the values V0, V1, and V2 follow the required condition V0 >= V1 >= V2 > 0. This missing check could lead to incorrect calculations or unintended behavior in the contract's mathematical operations.

Vulnerability Detail

In the DODOMath.sol contract, the function responsible for certain calculations does not validate that the input values satisfy the condition V0 >= V1 >= V2 > 0. This invariant is crucial for the correct functioning of the mathematical logic in the contract. Without this check, the function might process invalid or nonsensical inputs, potentially leading to erroneous outcomes.

Impact

Failing to enforce this invariant could result in calculations that do not reflect the intended logic of the contract. This might lead to issues such as incorrect token pricing, flawed reward distributions, or other critical financial inaccuracies within the contract's operations.

Code Snippet

Tool used

Manual Review

Recommendation

add this code in _GeneralIntegrate function

require(V0 >= V1 && V1 >= V2 && V2 > 0, "Invariant V0 >= V1 >= V2 > 0 not satisfied");
nevillehuang commented 6 months ago

Invalid, this is enforced in the calling functions, where underflow will occur if the requirement is not met