Skip to content

Commit 3743f80

Browse files
committed
refactor: use stETH instead of wstETH
1 parent d21e940 commit 3743f80

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22
pragma solidity 0.8.21;
33

4-
import {IWstEth} from "./interfaces/IWstEth.sol";
4+
import {IStEth} from "./interfaces/IStEth.sol";
55
import {MinimalAggregatorV3Interface} from "./interfaces/MinimalAggregatorV3Interface.sol";
66

77
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
@@ -15,17 +15,17 @@ contract WstEthEthExchangeRateChainlinkAdapter is MinimalAggregatorV3Interface {
1515
uint8 public constant decimals = 18;
1616
string public constant description = "wstETH/ETH exchange rate";
1717

18-
IWstEth public immutable WST_ETH;
18+
IStEth public immutable ST_ETH;
1919

20-
constructor(address wstEth) {
21-
require(wstEth != address(0), ErrorsLib.ZERO_ADDRESS);
20+
constructor(address stEth) {
21+
require(stEth != address(0), ErrorsLib.ZERO_ADDRESS);
2222

23-
WST_ETH = IWstEth(wstEth);
23+
ST_ETH = IStEth(stEth);
2424
}
2525

2626
/// @dev Silently overflows if `stEthPerToken` is greater than `type(int256).max`.
2727
function latestRoundData() external view returns (uint80, int256, uint256, uint256, uint80) {
28-
// It is assumed that `stEthPerToken` returns a price with 18 decimals precision.
29-
return (0, int256(WST_ETH.stEthPerToken()), 0, 0, 0);
28+
// It is assumed that `getPooledEthByShares` returns a price with 18 decimals precision.
29+
return (0, int256(ST_ETH.getPooledEthByShares(1 ether)), 0, 0, 0);
3030
}
3131
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
pragma solidity >=0.5.0;
3+
4+
interface IStEth {
5+
function getPooledEthByShares(uint256) external view returns (uint256);
6+
}

src/wsteth-exchange-rate-adapter/interfaces/IWstEth.sol

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/WstEthEthExchangeRateChainlinkAdapterTest.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import {ChainlinkOracle} from "../src/morpho-chainlink-v1/ChainlinkOracle.sol";
77
import "../src/wsteth-exchange-rate-adapter/WstEthEthExchangeRateChainlinkAdapter.sol";
88

99
contract WstEthEthExchangeRateChainlinkAdapterTest is Test {
10-
IWstEth internal constant WST_ETH = IWstEth(0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0);
10+
IStEth internal constant ST_ETH = IStEth(0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84);
1111

1212
WstEthEthExchangeRateChainlinkAdapter internal oracle;
1313
ChainlinkOracle internal chainlinkOracle;
1414

1515
function setUp() public {
1616
vm.createSelectFork(vm.envString("ETH_RPC_URL"));
17-
oracle = new WstEthEthExchangeRateChainlinkAdapter(address(WST_ETH));
17+
oracle = new WstEthEthExchangeRateChainlinkAdapter(address(ST_ETH));
1818
chainlinkOracle = new ChainlinkOracle(
1919
vaultZero, AggregatorV3Interface(address(oracle)), feedZero, feedZero, feedZero, 1, 18, 18
2020
);
@@ -37,7 +37,7 @@ contract WstEthEthExchangeRateChainlinkAdapterTest is Test {
3737
(uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) =
3838
oracle.latestRoundData();
3939
assertEq(roundId, 0);
40-
assertEq(uint256(answer), WST_ETH.stEthPerToken());
40+
assertEq(uint256(answer), ST_ETH.getPooledEthByShares(1 ether));
4141
assertEq(startedAt, 0);
4242
assertEq(updatedAt, 0);
4343
assertEq(answeredInRound, 0);

0 commit comments

Comments
 (0)