15,000 USDC
View results
Submission Details
Severity: low
Valid

division before multiplication result in precision loss

Vulnerability details

division before multiplication result in precision loss

at src/DSCEngine.sol
347: -> return (usdAmountInWei * PRECISION) / (uint256(price) * ADDITIONAL_FEED_PRECISION);

Impact

division before multiplication result in precision loss which may cause loss of funds of the user,
and if the usdAmountInWei is much more bigger than price it will lead to round down to zero that will cause huge loss of funds

Recommendations

perform the multiplication first then the division

347: -> return (usdAmountInWei * PRECISION) / uint256(price) / ADDITIONAL_FEED_PRECISION);

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.