diff --git a/src/wsteth-exchange-rate-adapter/interfaces/IStEth.sol b/src/interfaces/IStEth.sol similarity index 100% rename from src/wsteth-exchange-rate-adapter/interfaces/IStEth.sol rename to src/interfaces/IStEth.sol diff --git a/src/wsteth-exchange-rate-adapter/interfaces/MinimalAggregatorV3Interface.sol b/src/interfaces/MinimalAggregatorV3Interface.sol similarity index 100% rename from src/wsteth-exchange-rate-adapter/interfaces/MinimalAggregatorV3Interface.sol rename to src/interfaces/MinimalAggregatorV3Interface.sol diff --git a/src/morpho-chainlink/MorphoChainlinkOracleV2.sol b/src/morpho-chainlink/MorphoChainlinkOracleV2.sol index 48f8298..6b5386c 100644 --- a/src/morpho-chainlink/MorphoChainlinkOracleV2.sol +++ b/src/morpho-chainlink/MorphoChainlinkOracleV2.sol @@ -7,7 +7,7 @@ import {IMorphoChainlinkOracleV2} from "./interfaces/IMorphoChainlinkOracleV2.so import {ErrorsLib} from "./libraries/ErrorsLib.sol"; import {IERC4626, VaultLib} from "./libraries/VaultLib.sol"; import {Math} from "../../lib/openzeppelin-contracts/contracts/utils/math/Math.sol"; -import {AggregatorV3Interface, ChainlinkDataFeedLib} from "./libraries/ChainlinkDataFeedLib.sol"; +import {MinimalAggregatorV3Interface, ChainlinkDataFeedLib} from "./libraries/ChainlinkDataFeedLib.sol"; /// @title MorphoChainlinkOracleV2 /// @author Morpho Labs @@ -16,7 +16,7 @@ import {AggregatorV3Interface, ChainlinkDataFeedLib} from "./libraries/Chainlink contract MorphoChainlinkOracleV2 is IMorphoChainlinkOracleV2 { using Math for uint256; using VaultLib for IERC4626; - using ChainlinkDataFeedLib for AggregatorV3Interface; + using ChainlinkDataFeedLib for MinimalAggregatorV3Interface; /* IMMUTABLES */ @@ -33,16 +33,16 @@ contract MorphoChainlinkOracleV2 is IMorphoChainlinkOracleV2 { uint256 public immutable QUOTE_VAULT_CONVERSION_SAMPLE; /// @inheritdoc IMorphoChainlinkOracleV2 - AggregatorV3Interface public immutable BASE_FEED_1; + MinimalAggregatorV3Interface public immutable BASE_FEED_1; /// @inheritdoc IMorphoChainlinkOracleV2 - AggregatorV3Interface public immutable BASE_FEED_2; + MinimalAggregatorV3Interface public immutable BASE_FEED_2; /// @inheritdoc IMorphoChainlinkOracleV2 - AggregatorV3Interface public immutable QUOTE_FEED_1; + MinimalAggregatorV3Interface public immutable QUOTE_FEED_1; /// @inheritdoc IMorphoChainlinkOracleV2 - AggregatorV3Interface public immutable QUOTE_FEED_2; + MinimalAggregatorV3Interface public immutable QUOTE_FEED_2; /// @inheritdoc IMorphoChainlinkOracleV2 uint256 public immutable SCALE_FACTOR; @@ -73,13 +73,13 @@ contract MorphoChainlinkOracleV2 is IMorphoChainlinkOracleV2 { constructor( IERC4626 baseVault, uint256 baseVaultConversionSample, - AggregatorV3Interface baseFeed1, - AggregatorV3Interface baseFeed2, + MinimalAggregatorV3Interface baseFeed1, + MinimalAggregatorV3Interface baseFeed2, uint256 baseTokenDecimals, IERC4626 quoteVault, uint256 quoteVaultConversionSample, - AggregatorV3Interface quoteFeed1, - AggregatorV3Interface quoteFeed2, + MinimalAggregatorV3Interface quoteFeed1, + MinimalAggregatorV3Interface quoteFeed2, uint256 quoteTokenDecimals ) { // The ERC4626 vault parameters are used to price their respective conversion samples of their respective diff --git a/src/morpho-chainlink/MorphoChainlinkOracleV2Factory.sol b/src/morpho-chainlink/MorphoChainlinkOracleV2Factory.sol index c2b51dc..54d5b8f 100644 --- a/src/morpho-chainlink/MorphoChainlinkOracleV2Factory.sol +++ b/src/morpho-chainlink/MorphoChainlinkOracleV2Factory.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.21; import {IMorphoChainlinkOracleV2} from "./interfaces/IMorphoChainlinkOracleV2.sol"; import {IMorphoChainlinkOracleV2Factory} from "./interfaces/IMorphoChainlinkOracleV2Factory.sol"; -import {AggregatorV3Interface} from "./libraries/ChainlinkDataFeedLib.sol"; +import {MinimalAggregatorV3Interface} from "./libraries/ChainlinkDataFeedLib.sol"; import {IERC4626} from "./libraries/VaultLib.sol"; import {MorphoChainlinkOracleV2} from "./MorphoChainlinkOracleV2.sol"; @@ -24,13 +24,13 @@ contract MorphoChainlinkOracleV2Factory is IMorphoChainlinkOracleV2Factory { function createMorphoChainlinkOracleV2( IERC4626 baseVault, uint256 baseVaultConversionSample, - AggregatorV3Interface baseFeed1, - AggregatorV3Interface baseFeed2, + MinimalAggregatorV3Interface baseFeed1, + MinimalAggregatorV3Interface baseFeed2, uint256 baseTokenDecimals, IERC4626 quoteVault, uint256 quoteVaultConversionSample, - AggregatorV3Interface quoteFeed1, - AggregatorV3Interface quoteFeed2, + MinimalAggregatorV3Interface quoteFeed1, + MinimalAggregatorV3Interface quoteFeed2, uint256 quoteTokenDecimals, bytes32 salt ) external returns (MorphoChainlinkOracleV2 oracle) { diff --git a/src/morpho-chainlink/interfaces/AggregatorV3Interface.sol b/src/morpho-chainlink/interfaces/AggregatorV3Interface.sol deleted file mode 100644 index 481516f..0000000 --- a/src/morpho-chainlink/interfaces/AggregatorV3Interface.sol +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.5.0; - -/// @dev From -/// https://github.com/smartcontractkit/chainlink/blob/master/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol -interface AggregatorV3Interface { - function decimals() external view returns (uint8); - - function description() external view returns (string memory); - - function version() external view returns (uint256); - - function getRoundData(uint80 _roundId) - external - view - returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); - - function latestRoundData() - external - view - returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); -} diff --git a/src/morpho-chainlink/interfaces/IMorphoChainlinkOracleV2.sol b/src/morpho-chainlink/interfaces/IMorphoChainlinkOracleV2.sol index 1e65aae..1e0f618 100644 --- a/src/morpho-chainlink/interfaces/IMorphoChainlinkOracleV2.sol +++ b/src/morpho-chainlink/interfaces/IMorphoChainlinkOracleV2.sol @@ -3,7 +3,7 @@ pragma solidity >=0.5.0; import {IERC4626} from "./IERC4626.sol"; import {IOracle} from "../../../lib/morpho-blue/src/interfaces/IOracle.sol"; -import {AggregatorV3Interface} from "./AggregatorV3Interface.sol"; +import {MinimalAggregatorV3Interface} from "../../interfaces/MinimalAggregatorV3Interface.sol"; /// @title IMorphoChainlinkOracleV2 /// @author Morpho Labs @@ -23,16 +23,16 @@ interface IMorphoChainlinkOracleV2 is IOracle { function QUOTE_VAULT_CONVERSION_SAMPLE() external view returns (uint256); /// @notice Returns the address of the first base feed. - function BASE_FEED_1() external view returns (AggregatorV3Interface); + function BASE_FEED_1() external view returns (MinimalAggregatorV3Interface); /// @notice Returns the address of the second base feed. - function BASE_FEED_2() external view returns (AggregatorV3Interface); + function BASE_FEED_2() external view returns (MinimalAggregatorV3Interface); /// @notice Returns the address of the first quote feed. - function QUOTE_FEED_1() external view returns (AggregatorV3Interface); + function QUOTE_FEED_1() external view returns (MinimalAggregatorV3Interface); /// @notice Returns the address of the second quote feed. - function QUOTE_FEED_2() external view returns (AggregatorV3Interface); + function QUOTE_FEED_2() external view returns (MinimalAggregatorV3Interface); /// @notice Returns the price scale factor, calculated at contract creation. function SCALE_FACTOR() external view returns (uint256); diff --git a/src/morpho-chainlink/interfaces/IMorphoChainlinkOracleV2Factory.sol b/src/morpho-chainlink/interfaces/IMorphoChainlinkOracleV2Factory.sol index 64f8e6e..90bd1b0 100644 --- a/src/morpho-chainlink/interfaces/IMorphoChainlinkOracleV2Factory.sol +++ b/src/morpho-chainlink/interfaces/IMorphoChainlinkOracleV2Factory.sol @@ -3,7 +3,7 @@ pragma solidity >=0.5.0; import {MorphoChainlinkOracleV2} from "../MorphoChainlinkOracleV2.sol"; import {IERC4626} from "../libraries/VaultLib.sol"; -import {AggregatorV3Interface} from "../libraries/ChainlinkDataFeedLib.sol"; +import {MinimalAggregatorV3Interface} from "../libraries/ChainlinkDataFeedLib.sol"; /// @title IMorphoChainlinkOracleV2Factory /// @author Morpho Labs @@ -43,13 +43,13 @@ interface IMorphoChainlinkOracleV2Factory { function createMorphoChainlinkOracleV2( IERC4626 baseVault, uint256 baseVaultConversionSample, - AggregatorV3Interface baseFeed1, - AggregatorV3Interface baseFeed2, + MinimalAggregatorV3Interface baseFeed1, + MinimalAggregatorV3Interface baseFeed2, uint256 baseTokenDecimals, IERC4626 quoteVault, uint256 quoteVaultConversionSample, - AggregatorV3Interface quoteFeed1, - AggregatorV3Interface quoteFeed2, + MinimalAggregatorV3Interface quoteFeed1, + MinimalAggregatorV3Interface quoteFeed2, uint256 quoteTokenDecimals, bytes32 salt ) external returns (MorphoChainlinkOracleV2 oracle); diff --git a/src/morpho-chainlink/libraries/ChainlinkDataFeedLib.sol b/src/morpho-chainlink/libraries/ChainlinkDataFeedLib.sol index 10da74e..be057f9 100644 --- a/src/morpho-chainlink/libraries/ChainlinkDataFeedLib.sol +++ b/src/morpho-chainlink/libraries/ChainlinkDataFeedLib.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; -import {AggregatorV3Interface} from "../interfaces/AggregatorV3Interface.sol"; +import {MinimalAggregatorV3Interface} from "../../interfaces/MinimalAggregatorV3Interface.sol"; import {ErrorsLib} from "./ErrorsLib.sol"; @@ -17,7 +17,7 @@ library ChainlinkDataFeedLib { /// - Staleness is not checked because it's assumed that the Chainlink feed keeps its promises on this. /// - The price is not checked to be in the min/max bounds because it's assumed that the Chainlink feed keeps its /// promises on this. - function getPrice(AggregatorV3Interface feed) internal view returns (uint256) { + function getPrice(MinimalAggregatorV3Interface feed) internal view returns (uint256) { if (address(feed) == address(0)) return 1; (, int256 answer,,,) = feed.latestRoundData(); @@ -28,7 +28,7 @@ library ChainlinkDataFeedLib { /// @dev Returns the number of decimals of a `feed`. /// @dev When `feed` is the address zero, returns 0. - function getDecimals(AggregatorV3Interface feed) internal view returns (uint256) { + function getDecimals(MinimalAggregatorV3Interface feed) internal view returns (uint256) { if (address(feed) == address(0)) return 0; return feed.decimals(); diff --git a/src/wsteth-exchange-rate-adapter/WstEthStEthExchangeRateChainlinkAdapter.sol b/src/wsteth-exchange-rate-adapter/WstEthStEthExchangeRateChainlinkAdapter.sol index 6341c13..0df65f2 100644 --- a/src/wsteth-exchange-rate-adapter/WstEthStEthExchangeRateChainlinkAdapter.sol +++ b/src/wsteth-exchange-rate-adapter/WstEthStEthExchangeRateChainlinkAdapter.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.21; -import {IStEth} from "./interfaces/IStEth.sol"; -import {MinimalAggregatorV3Interface} from "./interfaces/MinimalAggregatorV3Interface.sol"; +import {IStEth} from "../interfaces/IStEth.sol"; +import {MinimalAggregatorV3Interface} from "../interfaces/MinimalAggregatorV3Interface.sol"; /// @title WstEthStEthExchangeRateChainlinkAdapter /// @author Morpho Labs diff --git a/test/MorphoChainlinkOracleV2FactoryTest.sol b/test/MorphoChainlinkOracleV2FactoryTest.sol index ee7e89c..b287437 100644 --- a/test/MorphoChainlinkOracleV2FactoryTest.sol +++ b/test/MorphoChainlinkOracleV2FactoryTest.sol @@ -7,7 +7,7 @@ import "../src/morpho-chainlink/MorphoChainlinkOracleV2Factory.sol"; import {ChainlinkDataFeedLib} from "../src/morpho-chainlink/libraries/ChainlinkDataFeedLib.sol"; contract ChainlinkOracleFactoryTest is Test { - using ChainlinkDataFeedLib for AggregatorV3Interface; + using ChainlinkDataFeedLib for MinimalAggregatorV3Interface; MorphoChainlinkOracleV2Factory factory; diff --git a/test/MorphoChainlinkOracleV2Test.sol b/test/MorphoChainlinkOracleV2Test.sol index 989e6d1..0fdf5cc 100644 --- a/test/MorphoChainlinkOracleV2Test.sol +++ b/test/MorphoChainlinkOracleV2Test.sol @@ -92,7 +92,16 @@ contract MorphoChainlinkOracleV2Test is Test { price = bound(price, type(int256).min, -1); ChainlinkAggregatorMock aggregator = new ChainlinkAggregatorMock(); MorphoChainlinkOracleV2 oracle = new MorphoChainlinkOracleV2( - vaultZero, 1, AggregatorV3Interface(address(aggregator)), feedZero, 18, vaultZero, 1, feedZero, feedZero, 0 + vaultZero, + 1, + MinimalAggregatorV3Interface(address(aggregator)), + feedZero, + 18, + vaultZero, + 1, + feedZero, + feedZero, + 0 ); aggregator.setAnwser(price); vm.expectRevert(bytes(ErrorsLib.NEGATIVE_ANSWER)); diff --git a/test/WstEthStEthExchangeRateChainlinkAdapterTest.sol b/test/WstEthStEthExchangeRateChainlinkAdapterTest.sol index a2e43cb..fdaf60f 100644 --- a/test/WstEthStEthExchangeRateChainlinkAdapterTest.sol +++ b/test/WstEthStEthExchangeRateChainlinkAdapterTest.sol @@ -17,7 +17,16 @@ contract WstEthStEthExchangeRateChainlinkAdapterTest is Test { require(block.chainid == 1, "chain isn't Ethereum"); adapter = new WstEthStEthExchangeRateChainlinkAdapter(); morphoOracle = new MorphoChainlinkOracleV2( - vaultZero, 1, AggregatorV3Interface(address(adapter)), feedZero, 18, vaultZero, 1, feedZero, feedZero, 18 + vaultZero, + 1, + MinimalAggregatorV3Interface(address(adapter)), + feedZero, + 18, + vaultZero, + 1, + feedZero, + feedZero, + 18 ); } diff --git a/test/helpers/Constants.sol b/test/helpers/Constants.sol index 7fdc911..00035c1 100644 --- a/test/helpers/Constants.sol +++ b/test/helpers/Constants.sol @@ -2,25 +2,33 @@ pragma solidity ^0.8.0; import {IERC4626} from "../../src/morpho-chainlink/interfaces/IERC4626.sol"; -import {AggregatorV3Interface} from "../../src/morpho-chainlink/interfaces/AggregatorV3Interface.sol"; +import {MinimalAggregatorV3Interface} from "../../src/interfaces/MinimalAggregatorV3Interface.sol"; -AggregatorV3Interface constant feedZero = AggregatorV3Interface(address(0)); +MinimalAggregatorV3Interface constant feedZero = MinimalAggregatorV3Interface(address(0)); // 8 decimals of precision -AggregatorV3Interface constant btcUsdFeed = AggregatorV3Interface(0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c); +MinimalAggregatorV3Interface constant btcUsdFeed = + MinimalAggregatorV3Interface(0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c); // 8 decimals of precision -AggregatorV3Interface constant usdcUsdFeed = AggregatorV3Interface(0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6); +MinimalAggregatorV3Interface constant usdcUsdFeed = + MinimalAggregatorV3Interface(0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6); // 18 decimals of precision -AggregatorV3Interface constant btcEthFeed = AggregatorV3Interface(0xdeb288F737066589598e9214E782fa5A8eD689e8); +MinimalAggregatorV3Interface constant btcEthFeed = + MinimalAggregatorV3Interface(0xdeb288F737066589598e9214E782fa5A8eD689e8); // 8 decimals of precision -AggregatorV3Interface constant wBtcBtcFeed = AggregatorV3Interface(0xfdFD9C85aD200c506Cf9e21F1FD8dd01932FBB23); +MinimalAggregatorV3Interface constant wBtcBtcFeed = + MinimalAggregatorV3Interface(0xfdFD9C85aD200c506Cf9e21F1FD8dd01932FBB23); // 18 decimals of precision -AggregatorV3Interface constant stEthEthFeed = AggregatorV3Interface(0x86392dC19c0b719886221c78AB11eb8Cf5c52812); +MinimalAggregatorV3Interface constant stEthEthFeed = + MinimalAggregatorV3Interface(0x86392dC19c0b719886221c78AB11eb8Cf5c52812); // 18 decimals of precision -AggregatorV3Interface constant usdcEthFeed = AggregatorV3Interface(0x986b5E1e1755e3C2440e960477f25201B0a8bbD4); +MinimalAggregatorV3Interface constant usdcEthFeed = + MinimalAggregatorV3Interface(0x986b5E1e1755e3C2440e960477f25201B0a8bbD4); // 8 decimals of precision -AggregatorV3Interface constant ethUsdFeed = AggregatorV3Interface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419); +MinimalAggregatorV3Interface constant ethUsdFeed = + MinimalAggregatorV3Interface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419); // 18 decimals of precision -AggregatorV3Interface constant daiEthFeed = AggregatorV3Interface(0x773616E4d11A78F511299002da57A0a94577F1f4); +MinimalAggregatorV3Interface constant daiEthFeed = + MinimalAggregatorV3Interface(0x773616E4d11A78F511299002da57A0a94577F1f4); IERC4626 constant vaultZero = IERC4626(address(0)); IERC4626 constant sDaiVault = IERC4626(0x83F20F44975D03b1b09e64809B757c47f942BEeA);