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

Bahurum - Incorrect decimals for price in StableOracleDAI.getPriceUSD() #796

Closed
sherlock-admin opened this issue May 24, 2023 · 0 comments
Closed
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 24, 2023

Bahurum

high

Incorrect decimals for price in StableOracleDAI.getPriceUSD()

Summary

In StableOracleDAI, price is treated in computations as if it was 8 decimals, while it is in 18 decimals.

Vulnerability Detail

StableOracleDAI.getPriceUSD() takes the average of the UniV3 WETH-DAI TWAP price and the DAI/ETH Chainlink oracle price:

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

Since DAI/ETH feed is in 18 decimals, the multiplication by 1e10 is incorrect.

Impact

DAI price used is incorrect, causing amounts minted with DAI to be incorrect.

Code Snippet

https://github.com/USSDofficial/ussd-contracts/blob/f44c726371f3152634bcf0a3e630802e39dec49c/contracts/oracles/StableOracleDAI.sol#L52

Tool used

Manual Review

Recommendation

Remove multiplication of price by 1e10.

        ...
-           ((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