The price will be wrong when the token's USD price feed's decimals != 8.
According to the project team's understanding, this contract supports tokens from all Chainlink price feeds.ChainlinkOracle assumes and inexplicitly requires the token's USD feed's decimals to be 8. However, there are certain token's USD feed has a different decimals.When the token's USD feed's decimals != 8,the getUsdValue
and getTokenAmountFromUsd
functions will return incorrect prices, leading to severe calculation errors and potential financial losses.This is the reference link to the previous vulnerability:https://github.com/sherlock-audit/2022-08-sentiment-judging/tree/main/019-H
This will result in severe calculation errors and financial losses.
vscode
Consider adding a check for feed.decimals() to make sure feed's decimals = 8.
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.