It has been mentioned by Protocol members that they will be using any token as a collateral as long as token/usd pricefeed is available in chainlink pricefeed.
But at many places it is hardcoded that token/usd pricefeed always return price in 8 decimals.
There are many tokens that don't return price in 8 decimals on different chains
e.g On Mainnet - LDO / USD
Avalanche - AAPL / USD , AMZN / USD,Calculated SAVAX / USD, GOOGL / USD NFLX / USD, TSLA / USD
Arbitrum - PEPE / USD
Optimism - PEPE / USD
for these tokens pricefeed would not return price in 8 decimals causing incorrect values
See Summary
https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/src/DSCEngine.sol#L340C1-L348C6
https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/src/DSCEngine.sol#L361C5-L368C1
most of the time getTokenAmountFromUsd
will return zero as these will returns price in 18 decimals making denominatore of the order of (1018) * (1010)= 10**28 and getUsdValue
will return more than expected usd value
Manual Review
One solution can be only allow tokens which returns price in 8 decimal
but as it intented to use for most of the tokens
Rathar than using hardcoded 8 decimals use returns price and scale into 18 decimal
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.