hats-finance / Origami-0x998f1b716a5022be026ca6b919c0ddf45ca31abd

GNU Affero General Public License v3.0
2 stars 0 forks source link

OrigamiWstEthToEthOracle return wrong price #4

Open hats-bug-reporter[bot] opened 7 months ago

hats-bug-reporter[bot] commented 7 months ago

Github username: @0xLogos Twitter username: -- Submission hash (on-chain): 0x37fc00d2a6b15947d735a80beae8f4695e9ffbd09148137a5e671b05a9d2fd5c Severity: high

Description: Description

Expected calculation for wstETH/ETH is wstETH/stETH * stETH/ETH from scope file description.

stETH/ETH is obtained from chainlink and is correct. But first component (wstETH/stETH) is obtained using stEth.getPooledEthByShares which is wrong. This method returns eth/stETH, not wstETH/stETH.

Let's query it on etherscan here https://etherscan.io/token/0xae7ab96520de3a18e5e111b5eaab095312d7fe84#readProxyContract#F22

Answer is ~1.15 which is expected value for eth/stETH, but not wstETH/stETH because stETH price < wstETH price so ration should be < 1.

https://coinmarketcap.com/currencies/lido-finance-wsteth/ https://coinmarketcap.com/currencies/steth/

0xLogos commented 7 months ago

There is also difference in comments

https://github.com/TempleDAO/origami-public/blob/185a93e25071b6a110ca190e94a6a826e982b2d6/apps/protocol/contracts/common/oracle/OrigamiWstEthToEthOracle.sol#L58

https://github.com/TempleDAO/origami-public/blob/185a93e25071b6a110ca190e94a6a826e982b2d6/apps/protocol/contracts/common/oracle/OrigamiWstEthToEthOracle.sol#L13

frontier159 commented 6 months ago

wstETH/ETH == ~1.15 as you shared from the coinmarketcap link:

image

(ensure to change your quote currency to ETH in the top right to see this.

Meaning for every wstETH sold you get 1.15 wETH. This matches the existing implementation within OrigamiWstEthToEthOracle

eg you can add this as a new test within OrigamiLovStEthIntegrationTest.t.sol#L20

This is using a forked mainnet of block 19238000

    function test_wstEthToEthPrice() public {
            assertEq(
                lovTokenContracts.wstEthToEthOracle.latestPrice(IOrigamiOracle.PriceType.SPOT_PRICE, OrigamiMath.Rounding.ROUND_DOWN),
                1.156862651867541366e18
            );