sherlock-audit / 2023-05-USSD-judging

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bahurum - `price` is DAI/ETH instead of ETH/DAI in `StableOracleDAI.getPriceUSD()`

sherlock-admin opened this issue · comments

Bahurum

high

price is DAI/ETH instead of ETH/DAI in StableOracleDAI.getPriceUSD()

Summary

In StableOracleDAI, price is supposed to be the price of ETH in DAI, but is the price of DAI in ETH instead.

Vulnerability Detail

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

DAIWethPrice is the amount of DAI corresponding to 1 ETH, while price is the amount of ETH in 1 DAI. The average in:

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

is incorrect as price is much smaller than it should be.

When an user calls USSD.mintForToken() using DAI, he will obtain an incorrect amount of USSD.

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#L33-L53

Tool used

Manual Review

Recommendation

Compute the ETH/DAI price from the DAI/ETH chainlink feed.

        ...
        (, int256 price, , , ) = priceFeedDAIETH.latestRoundData();
+       price = 1e36 / uint256(price)
        ...

Duplicate of #102

Escalate for 10 USDC

This is not a duplicate of #909.
It tells about using DAI/ETH instead of ETH/DAI on Chainlink. And #909 tells about completely different issue with oracles

Escalate for 10 USDC

This is not a duplicate of #909.
It tells about using DAI/ETH instead of ETH/DAI on Chainlink. And #909 tells about completely different issue with oracles

You've created a valid escalation for 10 USDC!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

This is still a duplicate of #909

In this issue:

It tells about using DAI/ETH instead of ETH/DAI on Chainlink

In #909 WBTC should use WBTC/ETH ETH/DAI

Result:
High
Duplicate of #102

Escalations have been resolved successfully!

Escalation status: