sherlock-audit / 2023-06-Index-judging

6 stars 2 forks source link

Topmark - Possibility of Precision Lose #76

Closed sherlock-admin2 closed 1 year ago

sherlock-admin2 commented 1 year ago

Topmark

medium

Possibility of Precision Lose

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 uint256 for priceChange variable