_isValidPrices function is used to calculate whether the difference between two prices exceeds a certain percentage, so as to determine whether the price is available. Generally speaking percentages should be divided by small numbers rather than large numbers. There will be a large numerical difference between the two.
For example, price0 is 100 and price1 is 120,
Normally their difference percentage is (120 - 100) / 100 = 20.00%
Calculated by _isValidPrices is (120 - 100) / 120 = 16.67%
Impact
This will lead to a wider range of price deviations than expected, which may ultimately lead to more volatile prices.
J4de
medium
BaseOracleExt.sol#_isValidPrices
should be divided byminPrice
instead ofmaxPrice
Summary
BaseOracleExt.sol#_isValidPrices
should be divided byminPrice
instead ofmaxPrice
Vulnerability Detail
_isValidPrices
function is used to calculate whether the difference between two prices exceeds a certain percentage, so as to determine whether the price is available. Generally speaking percentages should be divided by small numbers rather than large numbers. There will be a large numerical difference between the two.For example,
price0
is 100 andprice1
is 120,(120 - 100) / 100 = 20.00%
_isValidPrices
is(120 - 100) / 120 = 16.67%
Impact
This will lead to a wider range of price deviations than expected, which may ultimately lead to more volatile prices.
Code Snippet
https://github.com/sherlock-audit/2023-04-blueberry/blob/main/blueberry-core/contracts/oracle/BaseOracleExt.sol#L29-L30
Tool used
Manual Review
Recommendation