Skip to content

Commit 875667c

Browse files
committed
feat(ifc): add interfaces
1 parent ac9b8ba commit 875667c

File tree

3 files changed

+48
-11
lines changed

3 files changed

+48
-11
lines changed

src/ChainlinkOracle.sol

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22
pragma solidity 0.8.21;
33

4+
import {IChainlinkOracle} from "./interfaces/IChainlinkOracle.sol";
45
import {IOracle} from "../lib/morpho-blue/src/interfaces/IOracle.sol";
56

67
import {AggregatorV3Interface, ChainlinkDataFeedLib} from "./libraries/ChainlinkDataFeedLib.sol";
@@ -12,27 +13,32 @@ import {Math} from "../lib/openzeppelin-contracts/contracts/utils/math/Math.sol"
1213
/// @author Morpho Labs
1314
/// @custom:contact [email protected]
1415
/// @notice Morpho Blue oracle using Chainlink-compliant feeds.
15-
contract ChainlinkOracle is IOracle {
16+
contract ChainlinkOracle is IChainlinkOracle {
1617
using Math for uint256;
1718
using VaultLib for IERC4626;
1819
using ChainlinkDataFeedLib for AggregatorV3Interface;
1920

2021
/* IMMUTABLES */
2122

22-
/// @notice Vault.
23+
/// @inheritdoc IChainlinkOracle
2324
IERC4626 public immutable VAULT;
24-
/// @notice Vault conversion sample. The sample amount of shares used to convert to the underlying asset.
25-
/// @notice Should be chosen such that converting `VAULT_CONVERSION_SAMPLE` to assets has enough precision.
25+
26+
/// @inheritdoc IChainlinkOracle
2627
uint256 public immutable VAULT_CONVERSION_SAMPLE;
27-
/// @notice First base feed.
28+
29+
/// @inheritdoc IChainlinkOracle
2830
AggregatorV3Interface public immutable BASE_FEED_1;
29-
/// @notice Second base feed.
31+
32+
/// @inheritdoc IChainlinkOracle
3033
AggregatorV3Interface public immutable BASE_FEED_2;
31-
/// @notice First quote feed.
34+
35+
/// @inheritdoc IChainlinkOracle
3236
AggregatorV3Interface public immutable QUOTE_FEED_1;
33-
/// @notice Second quote feed.
37+
38+
/// @inheritdoc IChainlinkOracle
3439
AggregatorV3Interface public immutable QUOTE_FEED_2;
35-
/// @notice Price scale factor, computed at contract creation.
40+
41+
/// @inheritdoc IChainlinkOracle
3642
uint256 public immutable SCALE_FACTOR;
3743

3844
/* CONSTRUCTOR */
@@ -50,7 +56,9 @@ contract ChainlinkOracle is IOracle {
5056
/// @param baseFeed2 Second base feed. Pass address zero if the price = 1.
5157
/// @param quoteFeed1 First quote feed. Pass address zero if the price = 1.
5258
/// @param quoteFeed2 Second quote feed. Pass address zero if the price = 1.
53-
/// @param vaultConversionSample Vault conversion sample. Pass 1 if the oracle does not use a vault.
59+
/// @param vaultConversionSample The sample amount of vault shares used to convert to the underlying asset.
60+
/// Pass 1 if the oracle does not use a vault. Should be chosen such that converting `vaultConversionSample` to
61+
/// assets has enough precision.
5462
/// @param baseTokenDecimals Base token decimals.
5563
/// @param quoteTokenDecimals Quote token decimals.
5664
constructor(

src/interfaces/IChainlinkOracle.sol

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
pragma solidity ^0.8.0;
3+
4+
import {IERC4626} from "./IERC4626.sol";
5+
import {AggregatorV3Interface} from "./AggregatorV3Interface.sol";
6+
import {IOracle} from "../../lib/morpho-blue/src/interfaces/IOracle.sol";
7+
8+
interface IChainlinkOracle is IOracle {
9+
/// @notice Returns the address of the ERC4626 vault.
10+
function VAULT() external view returns (IERC4626);
11+
12+
/// @notice Returns the vault conversion sample.
13+
function VAULT_CONVERSION_SAMPLE() external view returns (uint256);
14+
15+
/// @notice Returns the address of the first Chainlink base feed.
16+
function BASE_FEED_1() external view returns (AggregatorV3Interface);
17+
18+
/// @notice Returns the address of the second Chainlink base feed.
19+
function BASE_FEED_2() external view returns (AggregatorV3Interface);
20+
21+
/// @notice Returns the address of the first Chainlink quote feed.
22+
function QUOTE_FEED_1() external view returns (AggregatorV3Interface);
23+
24+
/// @notice Returns the address of the second Chainlink quote feed.
25+
function QUOTE_FEED_2() external view returns (AggregatorV3Interface);
26+
27+
/// @notice Returns the price scale factor, calculated at contract creation.
28+
function SCALE_FACTOR() external view returns (uint256);
29+
}

0 commit comments

Comments
 (0)