Skip to content

Commit 330faa2

Browse files
committed
refactor: revert on version and getRoundData
1 parent d0e1327 commit 330faa2

File tree

2 files changed

+16
-40
lines changed

2 files changed

+16
-40
lines changed

src/adapters/WstEthChainlinkAdapter.sol

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {ErrorsLib} from "../libraries/ErrorsLib.sol";
1414
contract WstEthChainlinkAdapter is AggregatorV3Interface {
1515
uint8 public constant decimals = uint8(18);
1616
string public constant description = "wstETH/ETH exchange rate";
17-
uint256 public constant version = 1;
1817

1918
IStEth public immutable ST_ETH;
2019

@@ -23,8 +22,14 @@ contract WstEthChainlinkAdapter is AggregatorV3Interface {
2322
ST_ETH = IStEth(stEth);
2423
}
2524

26-
function getRoundData(uint80) external view returns (uint80, int256, uint256, uint256, uint80) {
27-
return latestRoundData();
25+
/// @notice Reverts as no Chainlink aggregator is used.
26+
function version() external pure override returns (uint256) {
27+
revert();
28+
}
29+
30+
/// @notice Reverts as it's not necessary for the ChainlinkOracle contract.
31+
function getRoundData(uint80) external pure returns (uint80, int256, uint256, uint256, uint80) {
32+
revert();
2833
}
2934

3035
function latestRoundData() public view returns (uint80, int256, uint256, uint256, uint80) {

test/WstEthChainlinkAdapterTest.sol

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@ contract WstEthChainlinkAdapterTest is Test {
2828
oracle.latestRoundData();
2929
}
3030

31-
function testGetRoundDataOverflow(uint256 ethByShares) public {
32-
ethByShares = bound(ethByShares, uint256(type(int256).max) + 1, type(uint256).max);
33-
34-
vm.mockCall(
35-
address(ST_ETH),
36-
abi.encodeWithSelector(ST_ETH.getPooledEthByShares.selector, 10 ** 18),
37-
abi.encode(ethByShares)
38-
);
39-
vm.expectRevert(bytes(ErrorsLib.OVERFLOW));
40-
oracle.getRoundData(1);
41-
}
42-
4331
function testDecimals() public {
4432
assertEq(oracle.decimals(), uint8(18));
4533
}
@@ -49,24 +37,20 @@ contract WstEthChainlinkAdapterTest is Test {
4937
new WstEthChainlinkAdapter(address(0));
5038
}
5139

52-
function testConfig() public {
40+
function testDescription() public {
5341
assertEq(oracle.description(), "wstETH/ETH exchange rate");
54-
assertEq(oracle.version(), 1);
5542
}
43+
function testReverts() public {
44+
vm.expectRevert();
45+
oracle.version();
5646

57-
function testLatestRoundData() public {
58-
(uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) =
59-
oracle.latestRoundData();
60-
assertEq(roundId, 0);
61-
assertEq(uint256(answer), ST_ETH.getPooledEthByShares(10 ** 18));
62-
assertEq(startedAt, 0);
63-
assertEq(updatedAt, 0);
64-
assertEq(answeredInRound, 0);
47+
vm.expectRevert();
48+
oracle.getRoundData(0);
6549
}
6650

67-
function testGetRoundData() public {
51+
function testLatestRoundData() public {
6852
(uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) =
69-
oracle.getRoundData(1);
53+
oracle.latestRoundData();
7054
assertEq(roundId, 0);
7155
assertEq(uint256(answer), ST_ETH.getPooledEthByShares(10 ** 18));
7256
assertEq(startedAt, 0);
@@ -87,19 +71,6 @@ contract WstEthChainlinkAdapterTest is Test {
8771
assertEq(uint256(answer), ethByShares);
8872
}
8973

90-
function testGetRoundDataNoOverflow(uint256 ethByShares) public {
91-
ethByShares = bound(ethByShares, 0, uint256(type(int256).max));
92-
93-
vm.mockCall(
94-
address(ST_ETH),
95-
abi.encodeWithSelector(ST_ETH.getPooledEthByShares.selector, 10 ** 18),
96-
abi.encode(ethByShares)
97-
);
98-
99-
(, int256 answer,,,) = oracle.getRoundData(1);
100-
assertEq(uint256(answer), ethByShares);
101-
}
102-
10374
function testLatestRoundDataBounds() public {
10475
(, int256 answer,,,) = oracle.latestRoundData();
10576
assertGe(uint256(answer), 1154690031824824994); // Exchange rate queried at block 19070943

0 commit comments

Comments
 (0)