Skip to content

Commit 93cb98d

Browse files
authored
Merge pull request #85 from morpho-org/test/double-vault
Test oracle with 2 vaults
2 parents af1a0d3 + 380cbc9 commit 93cb98d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

test/MorphoChainlinkOracleV2Test.sol

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,21 @@ contract MorphoChainlinkOracleV2Test is Test {
157157
assertApproxEqRel(oracle.price(), expectedPrice, deviation);
158158
}
159159

160+
function testSfrxEthSDaiOracle() public {
161+
MorphoChainlinkOracleV2 oracle = new MorphoChainlinkOracleV2(
162+
sfrxEthVault, 1e18, feedZero, feedZero, 18, sDaiVault, 1e18, daiEthFeed, feedZero, 18
163+
);
164+
(, int256 quoteAnswer,,,) = daiEthFeed.latestRoundData();
165+
// 1e(36 + dQ1 + fpQ1 + fpQ2 - dB1 - fpB1 - fpB2) * qCS / bCS
166+
uint256 scaleFactor = 10 ** (36 + 18 + 18 + 0 - 18 - 0 - 0) * 1e18 / 1e18;
167+
assertEq(
168+
oracle.price(),
169+
scaleFactor.mulDiv(
170+
sfrxEthVault.convertToAssets(1e18), (sDaiVault.convertToAssets(1e18) * uint256(quoteAnswer))
171+
)
172+
);
173+
}
174+
160175
function testConstructorZeroVaultConversionSample() public {
161176
vm.expectRevert(bytes(ErrorsLib.VAULT_CONVERSION_SAMPLE_IS_ZERO));
162177
new MorphoChainlinkOracleV2(sDaiVault, 0, daiEthFeed, feedZero, 18, vaultZero, 1, usdcEthFeed, feedZero, 6);

test/helpers/Constants.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ AggregatorV3Interface constant daiEthFeed = AggregatorV3Interface(0x773616E4d11A
2424

2525
IERC4626 constant vaultZero = IERC4626(address(0));
2626
IERC4626 constant sDaiVault = IERC4626(0x83F20F44975D03b1b09e64809B757c47f942BEeA);
27+
IERC4626 constant sfrxEthVault = IERC4626(0xac3E018457B222d93114458476f3E3416Abbe38F);

0 commit comments

Comments
 (0)