sherlock-audit / 2024-08-sentiment-v2-judging

5 stars 5 forks source link

Spare Chrome Oyster - ChainlinkUsdOracle incorrectly handles tokens with > 18 decimals #624

Closed sherlock-admin2 closed 3 months ago

sherlock-admin2 commented 3 months ago

Spare Chrome Oyster

Low/Info

ChainlinkUsdOracle incorrectly handles tokens with > 18 decimals

Summary

https://github.com/sherlock-audit/2024-08-sentiment-v2/blob/main/protocol-v2/src/oracle/ChainlinkUsdOracle.sol#L86

Mitigation

        if (decimals <= 18) return (amt * 10 ** (18 - decimals)).mulDiv(uint256(assetUsdPrice), uint256(ethUsdPrice));
-       else return (amt / (10 ** decimals - 18)).mulDiv(uint256(assetUsdPrice), uint256(ethUsdPrice));
+       else return (amt / (10 ** (decimals - 18))).mulDiv(uint256(assetUsdPrice), uint256(ethUsdPrice));