Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

ast3ros - Incorrect decimal of the DAI/ETH price feed #395

Closed
sherlock-admin opened this issue May 23, 2023 · 0 comments
Closed

ast3ros - Incorrect decimal of the DAI/ETH price feed #395

sherlock-admin opened this issue May 23, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented May 23, 2023

ast3ros

medium

Incorrect decimal of the DAI/ETH price feed

Summary

The return value of the DAI/ETH price feed has 18 decimals. However, it is treated as 8 decimals.

Vulnerability Detail

The price feed of DAI/ETH is obtained from the contract: 0x773616E4d11A78F511299002da57A0a94577F1f4. The decimal of the return value is 18.

    (, int256 price, , , ) = priceFeedDAIETH.latestRoundData();

https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/oracles/StableOracleDAI.sol#L48

However, when calculating the price in USD of DAI, it was incorrectly scaled up by 1e10 (it incorrectly assumes that the decimal is 8). This leads to a wrong price of DAI.

    ((DAIWethPrice + uint256(price) * 1e10) / 2);

https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/oracles/StableOracleDAI.sol#L52

Impact

The StableOracleDAI returns an inaccurate price.

Code Snippet

https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/oracles/StableOracleDAI.sol#L52

Tool used

Manual Review

Recommendation

Remove the scale factor:

-    ((DAIWethPrice + uint256(price) * 1e10) / 2);
+    ((DAIWethPrice + uint256(price)) / 2);

Duplicate of #236

@github-actions github-actions bot closed this as completed Jun 5, 2023
@github-actions github-actions bot added High A valid High severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Jun 5, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant