ADDITIONAL_FEED_PRECISION
is being hardcoded to 10
in DSCEngine.sol which would lead to an overvaluation in some cases, see Vulnerability Details.
As stated in Summary, ADDITIONAL_FEED_PRECISION
is being hardcoded to `10, this is probably implemented since initially the primary tokens would be BTC, ETH, but from the public discord chat Patrick has stated the below as reply to a question on what type of tokens would be used:
weth & wbtc are the intended tokens, but any token with a USD chainlink price feed can work
Further discussions in the public chat suggests that the stablecoin is now intended to work with any token that has a USD feed.
Now the DSCEngine.sol
contract assumes that all chainlink USD feeds return price in 8 decimals which is why the ADDITIONAL_FEED_PRECISION
is being hardcoded to `10 so as to normalise the price, but this is not always the case.
For example the AMPL/USD feed is denoted with 18 decimals.
As can be seen here
Now do note that the ADDITIONAL_FEED_PRECISION
is being used in 2 instances in to normalise price, i.e in the getTokenAmountFromUsd() and getUsdValue() functions, as can be seen below:
Would be important to note where as the getTokenAmountFromUsd()
function is not heavily used within the engine, aside being called externally it's still being used in the liquidate()
function, whereas the getUsdValue()
is massively implemented, for example while checking the health factor of an account, or while gettiing it's information, and multiple other instances within DSCEngine.sol
This means that all the calculation of user's current state or their collateral value would be massively mis-valued, since using this report's case study the AMPL/USD returned price would be unnecasirly normalized by 10 decimals, in short the collateral would be misvalued with 10 decimals.
Massive misvaluation of collateral's dollar value, difference of a whooping 10 decimals.
Manual Audit
ADDITIONAL_FEED_PRECISION
should not be hardcoded, since hardcoding most of the time leads to lack of flexibility of a protocol, in this instance too I'd suggest that the decimals of each feed should be queried and then ADDITIONAL_FEED_PRECISION
be set to 18-decimals
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.