The contract does not validate or handle decimal precision of price values returned from ChainlinkPriceFeeds, which could lead to loss of precision during price calculations.
The consult() and consultIn18Decimals() functions directly use the int256 price returned from Chainlink without checking its decimal precision against the recorded decimals value.
For example, if a price is returned with only 2 decimal places of precision but recorded as having 8 decimal places, calculations using that price could lose significant precision.
Specifically, the price deviation calculation in _badPriceDeviation() performs division and multiplication on the raw int256 price values. Any loss of trailing zeros due to unequal decimals could skew the percentage deviation calculated.
Even if the recorded decimals are correct, the contract makes no effort to scale price values to a common decimal place before calculations. This risks mathematical errors over multiple calculation steps
Loss of decimal precision in price values could cause calculated percentages like maximum deviations to be inaccurate.
This could allow price feeds that should fail validity checks to still be considered valid due to flaws in the calculation logic.
Over time, repeated calculations on imprecise values risk drifting calculated results like historical price averages.
Manual Reveiw
Validate recorded decimals against the number of decimal places actually present in returned int256 price values
Perform price calculations using a common scaling factor to homogenize decimals before mathematical operations
Add decimal place verification whenever prices are retrieved, not just on initial recording
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.