@@ -33,7 +33,8 @@ contract ChainlinkOracleTest is Test {
33
33
}
34
34
35
35
function testOracleWbtcUsdc () public {
36
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , wBtcBtcFeed, btcUsdFeed, usdcUsdFeed, feedZero, 8 , 6 );
36
+ ChainlinkOracle oracle =
37
+ new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , wBtcBtcFeed, btcUsdFeed, usdcUsdFeed, feedZero, 8 , 6 );
37
38
(, int256 firstBaseAnswer ,,,) = wBtcBtcFeed.latestRoundData ();
38
39
(, int256 secondBaseAnswer ,,,) = btcUsdFeed.latestRoundData ();
39
40
(, int256 quoteAnswer ,,,) = usdcUsdFeed.latestRoundData ();
@@ -45,7 +46,8 @@ contract ChainlinkOracleTest is Test {
45
46
}
46
47
47
48
function testOracleUsdcWbtc () public {
48
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , usdcUsdFeed, feedZero, wBtcBtcFeed, btcUsdFeed, 6 , 8 );
49
+ ChainlinkOracle oracle =
50
+ new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , usdcUsdFeed, feedZero, wBtcBtcFeed, btcUsdFeed, 6 , 8 );
49
51
(, int256 baseAnswer ,,,) = usdcUsdFeed.latestRoundData ();
50
52
(, int256 firstQuoteAnswer ,,,) = wBtcBtcFeed.latestRoundData ();
51
53
(, int256 secondQuoteAnswer ,,,) = btcUsdFeed.latestRoundData ();
@@ -57,48 +59,56 @@ contract ChainlinkOracleTest is Test {
57
59
}
58
60
59
61
function testOracleWbtcEth () public {
60
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , wBtcBtcFeed, btcEthFeed, feedZero, feedZero, 8 , 18 );
62
+ ChainlinkOracle oracle =
63
+ new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , wBtcBtcFeed, btcEthFeed, feedZero, feedZero, 8 , 18 );
61
64
(, int256 firstBaseAnswer ,,,) = wBtcBtcFeed.latestRoundData ();
62
65
(, int256 secondBaseAnswer ,,,) = btcEthFeed.latestRoundData ();
63
66
assertEq (oracle.price (), (uint256 (firstBaseAnswer) * uint256 (secondBaseAnswer) * 10 ** (36 + 18 - 8 - 8 - 18 )));
64
67
}
65
68
66
69
function testOracleStEthUsdc () public {
67
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , stEthEthFeed, feedZero, usdcEthFeed, feedZero, 18 , 6 );
70
+ ChainlinkOracle oracle =
71
+ new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , stEthEthFeed, feedZero, usdcEthFeed, feedZero, 18 , 6 );
68
72
(, int256 baseAnswer ,,,) = stEthEthFeed.latestRoundData ();
69
73
(, int256 quoteAnswer ,,,) = usdcEthFeed.latestRoundData ();
70
74
assertEq (oracle.price (), uint256 (baseAnswer) * 10 ** (36 + 18 + 6 - 18 - 18 ) / uint256 (quoteAnswer));
71
75
}
72
76
73
77
function testOracleEthUsd () public {
74
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , ethUsdFeed, feedZero, feedZero, feedZero, 18 , 0 );
78
+ ChainlinkOracle oracle =
79
+ new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , ethUsdFeed, feedZero, feedZero, feedZero, 18 , 0 );
75
80
(, int256 expectedPrice ,,,) = ethUsdFeed.latestRoundData ();
76
81
assertEq (oracle.price (), uint256 (expectedPrice) * 10 ** (36 - 18 - 8 ));
77
82
}
78
83
79
84
function testOracleStEthEth () public {
80
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , stEthEthFeed, feedZero, feedZero, feedZero, 18 , 18 );
85
+ ChainlinkOracle oracle =
86
+ new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , stEthEthFeed, feedZero, feedZero, feedZero, 18 , 18 );
81
87
(, int256 expectedPrice ,,,) = stEthEthFeed.latestRoundData ();
82
88
assertEq (oracle.price (), uint256 (expectedPrice) * 10 ** (36 + 18 - 18 - 18 ));
83
89
assertApproxEqRel (oracle.price (), 1e36 , 0.01 ether);
84
90
}
85
91
86
92
function testOracleEthStEth () public {
87
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , feedZero, feedZero, stEthEthFeed, feedZero, 18 , 18 );
93
+ ChainlinkOracle oracle =
94
+ new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , feedZero, feedZero, stEthEthFeed, feedZero, 18 , 18 );
88
95
(, int256 expectedPrice ,,,) = stEthEthFeed.latestRoundData ();
89
96
assertEq (oracle.price (), 10 ** (36 + 18 + 18 - 18 ) / uint256 (expectedPrice));
90
97
assertApproxEqRel (oracle.price (), 1e36 , 0.01 ether);
91
98
}
92
99
93
100
function testOracleUsdcUsd () public {
94
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , usdcUsdFeed, feedZero, feedZero, feedZero, 6 , 0 );
101
+ ChainlinkOracle oracle =
102
+ new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , usdcUsdFeed, feedZero, feedZero, feedZero, 6 , 0 );
95
103
assertApproxEqRel (oracle.price (), 1e36 / 1e6 , 0.01 ether);
96
104
}
97
105
98
106
function testNegativeAnswer (int256 price ) public {
99
107
price = bound (price, type (int256 ).min, - 1 );
100
108
ChainlinkAggregatorMock aggregator = new ChainlinkAggregatorMock ();
101
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , AggregatorV3Interface (address (aggregator)), feedZero, feedZero, feedZero, 18 , 0 );
109
+ ChainlinkOracle oracle = new ChainlinkOracle (
110
+ vaultZero, 1 , vaultZero, 1 , AggregatorV3Interface (address (aggregator)), feedZero, feedZero, feedZero, 18 , 0
111
+ );
102
112
aggregator.setAnwser (price);
103
113
vm.expectRevert (bytes (ErrorsLib.NEGATIVE_ANSWER));
104
114
oracle.price ();
0 commit comments