sherlock-audit / 2023-06-Index-judging

6 stars 2 forks source link

Topmark - Precision Lose Possibility #77

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

Topmark

medium

Precision Lose Possibility

Summary

priceChange calculation of Line 73 of BoundedStepwiseExponentialPriceAdapter.sol would give error if a negative integer result is gotten. Since priceChange could be on the positive or negative side, this would lead to a precision error in next series of calculations or priceChange usage

Detail

From the calculation @ https://github.com/sherlock-audit/2023-06-Index/blob/main/index-protocol/contracts/protocol/integration/auction-price/BoundedStepwiseExponentialPriceAdapter.sol#L73 , using uint256 priceChange would cause precision loss if the priceChange is negative

Tool used

Solidity, Hardhat

Recommendation

int256 should be used instead of unint256 for priceChange Variable