@@ -33,7 +33,7 @@ contract ChainlinkOracleTest is Test {
33
33
}
34
34
35
35
function testOracleWbtcUsdc () public {
36
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, wBtcBtcFeed, btcUsdFeed, usdcUsdFeed, feedZero, 1 , 8 , 6 );
36
+ ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , wBtcBtcFeed, btcUsdFeed, usdcUsdFeed, feedZero, 8 , 6 );
37
37
(, int256 firstBaseAnswer ,,,) = wBtcBtcFeed.latestRoundData ();
38
38
(, int256 secondBaseAnswer ,,,) = btcUsdFeed.latestRoundData ();
39
39
(, int256 quoteAnswer ,,,) = usdcUsdFeed.latestRoundData ();
@@ -45,7 +45,7 @@ contract ChainlinkOracleTest is Test {
45
45
}
46
46
47
47
function testOracleUsdcWbtc () public {
48
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, usdcUsdFeed, feedZero, wBtcBtcFeed, btcUsdFeed, 1 , 6 , 8 );
48
+ ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , usdcUsdFeed, feedZero, wBtcBtcFeed, btcUsdFeed, 6 , 8 );
49
49
(, int256 baseAnswer ,,,) = usdcUsdFeed.latestRoundData ();
50
50
(, int256 firstQuoteAnswer ,,,) = wBtcBtcFeed.latestRoundData ();
51
51
(, int256 secondQuoteAnswer ,,,) = btcUsdFeed.latestRoundData ();
@@ -57,58 +57,56 @@ contract ChainlinkOracleTest is Test {
57
57
}
58
58
59
59
function testOracleWbtcEth () public {
60
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, wBtcBtcFeed, btcEthFeed, feedZero, feedZero, 1 , 8 , 18 );
60
+ ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , wBtcBtcFeed, btcEthFeed, feedZero, feedZero, 8 , 18 );
61
61
(, int256 firstBaseAnswer ,,,) = wBtcBtcFeed.latestRoundData ();
62
62
(, int256 secondBaseAnswer ,,,) = btcEthFeed.latestRoundData ();
63
63
assertEq (oracle.price (), (uint256 (firstBaseAnswer) * uint256 (secondBaseAnswer) * 10 ** (36 + 18 - 8 - 8 - 18 )));
64
64
}
65
65
66
66
function testOracleStEthUsdc () public {
67
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, stEthEthFeed, feedZero, usdcEthFeed, feedZero, 1 , 18 , 6 );
67
+ ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , stEthEthFeed, feedZero, usdcEthFeed, feedZero, 18 , 6 );
68
68
(, int256 baseAnswer ,,,) = stEthEthFeed.latestRoundData ();
69
69
(, int256 quoteAnswer ,,,) = usdcEthFeed.latestRoundData ();
70
70
assertEq (oracle.price (), uint256 (baseAnswer) * 10 ** (36 + 18 + 6 - 18 - 18 ) / uint256 (quoteAnswer));
71
71
}
72
72
73
73
function testOracleEthUsd () public {
74
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, ethUsdFeed, feedZero, feedZero, feedZero, 1 , 18 , 0 );
74
+ ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , ethUsdFeed, feedZero, feedZero, feedZero , 18 , 0 );
75
75
(, int256 expectedPrice ,,,) = ethUsdFeed.latestRoundData ();
76
76
assertEq (oracle.price (), uint256 (expectedPrice) * 10 ** (36 - 18 - 8 ));
77
77
}
78
78
79
79
function testOracleStEthEth () public {
80
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, stEthEthFeed, feedZero, feedZero, feedZero, 1 , 18 , 18 );
80
+ ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , stEthEthFeed, feedZero, feedZero, feedZero , 18 , 18 );
81
81
(, int256 expectedPrice ,,,) = stEthEthFeed.latestRoundData ();
82
82
assertEq (oracle.price (), uint256 (expectedPrice) * 10 ** (36 + 18 - 18 - 18 ));
83
83
assertApproxEqRel (oracle.price (), 1e36 , 0.01 ether);
84
84
}
85
85
86
86
function testOracleEthStEth () public {
87
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, feedZero, feedZero, stEthEthFeed, feedZero, 1 , 18 , 18 );
87
+ ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , feedZero, feedZero, stEthEthFeed, feedZero, 18 , 18 );
88
88
(, int256 expectedPrice ,,,) = stEthEthFeed.latestRoundData ();
89
89
assertEq (oracle.price (), 10 ** (36 + 18 + 18 - 18 ) / uint256 (expectedPrice));
90
90
assertApproxEqRel (oracle.price (), 1e36 , 0.01 ether);
91
91
}
92
92
93
93
function testOracleUsdcUsd () public {
94
- ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, usdcUsdFeed, feedZero, feedZero, feedZero, 1 , 6 , 0 );
94
+ ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , usdcUsdFeed, feedZero, feedZero, feedZero , 6 , 0 );
95
95
assertApproxEqRel (oracle.price (), 1e36 / 1e6 , 0.01 ether);
96
96
}
97
97
98
98
function testNegativeAnswer (int256 price ) public {
99
99
price = bound (price, type (int256 ).min, - 1 );
100
100
ChainlinkAggregatorMock aggregator = new ChainlinkAggregatorMock ();
101
- ChainlinkOracle oracle = new ChainlinkOracle (
102
- vaultZero, AggregatorV3Interface (address (aggregator)), feedZero, feedZero, feedZero, 1 , 18 , 0
103
- );
101
+ ChainlinkOracle oracle = new ChainlinkOracle (vaultZero, 1 , vaultZero, 1 , AggregatorV3Interface (address (aggregator)), feedZero, feedZero, feedZero, 18 , 0 );
104
102
aggregator.setAnwser (price);
105
103
vm.expectRevert (bytes (ErrorsLib.NEGATIVE_ANSWER));
106
104
oracle.price ();
107
105
}
108
106
109
107
function testSDaiEthOracle () public {
110
108
ChainlinkOracle oracle =
111
- new ChainlinkOracle (sDaiVault, daiEthFeed, feedZero, feedZero, feedZero, 10 ** 18 , 18 , 18 );
109
+ new ChainlinkOracle (sDaiVault, 10 ** 18 , vaultZero, 1 , daiEthFeed, feedZero, feedZero, feedZero , 18 , 18 );
112
110
(, int256 expectedPrice ,,,) = daiEthFeed.latestRoundData ();
113
111
assertEq (
114
112
oracle.price (),
@@ -118,7 +116,7 @@ contract ChainlinkOracleTest is Test {
118
116
119
117
function testSDaiUsdcOracle () public {
120
118
ChainlinkOracle oracle =
121
- new ChainlinkOracle (sDaiVault, daiEthFeed, feedZero, usdcEthFeed, feedZero, 10 ** 18 , 18 , 6 );
119
+ new ChainlinkOracle (sDaiVault, 10 ** 18 , vaultZero, 1 , daiEthFeed, feedZero, usdcEthFeed, feedZero , 18 , 6 );
122
120
(, int256 baseAnswer ,,,) = daiEthFeed.latestRoundData ();
123
121
(, int256 quoteAnswer ,,,) = usdcEthFeed.latestRoundData ();
124
122
assertEq (
@@ -135,13 +133,17 @@ contract ChainlinkOracleTest is Test {
135
133
136
134
function testConstructorZeroVaultConversionSample () public {
137
135
vm.expectRevert (bytes (ErrorsLib.VAULT_CONVERSION_SAMPLE_IS_ZERO));
138
- new ChainlinkOracle (sDaiVault, daiEthFeed, feedZero, usdcEthFeed, feedZero, 0 , 18 , 6 );
136
+ new ChainlinkOracle (sDaiVault, 0 , vaultZero, 1 , daiEthFeed, feedZero, usdcEthFeed, feedZero, 18 , 6 );
137
+ vm.expectRevert (bytes (ErrorsLib.VAULT_CONVERSION_SAMPLE_IS_ZERO));
138
+ new ChainlinkOracle (vaultZero, 1 , sDaiVault, 0 , daiEthFeed, feedZero, usdcEthFeed, feedZero, 18 , 6 );
139
139
}
140
140
141
141
function testConstructorVaultZeroNonOneSample (uint256 vaultConversionSample ) public {
142
142
vaultConversionSample = bound (vaultConversionSample, 2 , type (uint256 ).max);
143
143
144
144
vm.expectRevert (bytes (ErrorsLib.VAULT_CONVERSION_SAMPLE_IS_NOT_ONE));
145
- new ChainlinkOracle (vaultZero, daiEthFeed, feedZero, usdcEthFeed, feedZero, vaultConversionSample, 18 , 6 );
145
+ new ChainlinkOracle (vaultZero, 0 , vaultZero, 1 , daiEthFeed, feedZero, usdcEthFeed, feedZero, 18 , 6 );
146
+ vm.expectRevert (bytes (ErrorsLib.VAULT_CONVERSION_SAMPLE_IS_NOT_ONE));
147
+ new ChainlinkOracle (vaultZero, 1 , vaultZero, 0 , daiEthFeed, feedZero, usdcEthFeed, feedZero, 18 , 6 );
146
148
}
147
149
}
0 commit comments