DSCEngine will not work with tokens that have no 18 decimals, because of incorrect handling of decimals.
In order to convert token amount into stablecoin amount, getUsdValue
function is used. It should return stablecoin amount in e18 scaling.
https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/src/DSCEngine.sol#L361-L367
This will work fine in case if collateral token has 18 decimals. But in case of other tokens, this calculation will not work.
For example 1000 usdc with price = e8
amount = e8 * e10 * 1000e6 / e18 = 1000e6
As you can see, in this case usd will be much less than it should be.
Health factor calculation will not work.
VsCode
You need to use decimals of collateral token in order to make e18 precision.
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.