Skip to content

Commit

Permalink
refactor: only use MinimalAggregatorV3Interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Grimal committed Apr 9, 2024
1 parent 07a9a69 commit 22bebcc
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 52 deletions.
File renamed without changes.
20 changes: 10 additions & 10 deletions src/morpho-chainlink/MorphoChainlinkOracleV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/morpho-chainlink/MorphoChainlinkOracleV2Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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) {
Expand Down
22 changes: 0 additions & 22 deletions src/morpho-chainlink/interfaces/AggregatorV3Interface.sol

This file was deleted.

10 changes: 5 additions & 5 deletions src/morpho-chainlink/interfaces/IMorphoChainlinkOracleV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/morpho-chainlink/libraries/ChainlinkDataFeedLib.sol
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 22bebcc

Please sign in to comment.