-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from morpho-org/post-cantina
Post cantina
- Loading branch information
Showing
6 changed files
with
59 additions
and
17 deletions.
There are no files selected for viewing
Submodule morpho-blue
updated
63 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity 0.8.21; | ||
|
||
import {IChainlinkOracle} from "./interfaces/IChainlinkOracle.sol"; | ||
import {IOracle} from "../lib/morpho-blue/src/interfaces/IOracle.sol"; | ||
|
||
import {AggregatorV3Interface, ChainlinkDataFeedLib} from "./libraries/ChainlinkDataFeedLib.sol"; | ||
|
@@ -12,27 +13,32 @@ import {Math} from "../lib/openzeppelin-contracts/contracts/utils/math/Math.sol" | |
/// @author Morpho Labs | ||
/// @custom:contact [email protected] | ||
/// @notice Morpho Blue oracle using Chainlink-compliant feeds. | ||
contract ChainlinkOracle is IOracle { | ||
contract ChainlinkOracle is IChainlinkOracle { | ||
using Math for uint256; | ||
using VaultLib for IERC4626; | ||
using ChainlinkDataFeedLib for AggregatorV3Interface; | ||
|
||
/* IMMUTABLES */ | ||
|
||
/// @notice Vault. | ||
/// @inheritdoc IChainlinkOracle | ||
IERC4626 public immutable VAULT; | ||
/// @notice Vault conversion sample. The sample amount of shares used to convert to the underlying asset. | ||
/// @notice Should be chosen such that converting `VAULT_CONVERSION_SAMPLE` to assets has enough precision. | ||
|
||
/// @inheritdoc IChainlinkOracle | ||
uint256 public immutable VAULT_CONVERSION_SAMPLE; | ||
/// @notice First base feed. | ||
|
||
/// @inheritdoc IChainlinkOracle | ||
AggregatorV3Interface public immutable BASE_FEED_1; | ||
/// @notice Second base feed. | ||
|
||
/// @inheritdoc IChainlinkOracle | ||
AggregatorV3Interface public immutable BASE_FEED_2; | ||
/// @notice First quote feed. | ||
|
||
/// @inheritdoc IChainlinkOracle | ||
AggregatorV3Interface public immutable QUOTE_FEED_1; | ||
/// @notice Second quote feed. | ||
|
||
/// @inheritdoc IChainlinkOracle | ||
AggregatorV3Interface public immutable QUOTE_FEED_2; | ||
/// @notice Price scale factor, computed at contract creation. | ||
|
||
/// @inheritdoc IChainlinkOracle | ||
uint256 public immutable SCALE_FACTOR; | ||
|
||
/* CONSTRUCTOR */ | ||
|
@@ -50,7 +56,9 @@ contract ChainlinkOracle is IOracle { | |
/// @param baseFeed2 Second base feed. Pass address zero if the price = 1. | ||
/// @param quoteFeed1 First quote feed. Pass address zero if the price = 1. | ||
/// @param quoteFeed2 Second quote feed. Pass address zero if the price = 1. | ||
/// @param vaultConversionSample Vault conversion sample. Pass 1 if the oracle does not use a vault. | ||
/// @param vaultConversionSample The sample amount of vault shares used to convert to the underlying asset. | ||
/// Pass 1 if the oracle does not use a vault. Should be chosen such that converting `vaultConversionSample` to | ||
/// assets has enough precision. | ||
/// @param baseTokenDecimals Base token decimals. | ||
/// @param quoteTokenDecimals Quote token decimals. | ||
constructor( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity >=0.5.0; | ||
|
||
import {IERC4626} from "./IERC4626.sol"; | ||
import {AggregatorV3Interface} from "./AggregatorV3Interface.sol"; | ||
import {IOracle} from "../../lib/morpho-blue/src/interfaces/IOracle.sol"; | ||
|
||
/// @title IChainlinkOracle | ||
/// @author Morpho Labs | ||
/// @custom:contact [email protected] | ||
/// @notice Interface of ChainlinkOracle. | ||
interface IChainlinkOracle is IOracle { | ||
/// @notice Returns the address of the ERC4626 vault. | ||
function VAULT() external view returns (IERC4626); | ||
|
||
/// @notice Returns the vault conversion sample. | ||
function VAULT_CONVERSION_SAMPLE() external view returns (uint256); | ||
|
||
/// @notice Returns the address of the first Chainlink base feed. | ||
function BASE_FEED_1() external view returns (AggregatorV3Interface); | ||
|
||
/// @notice Returns the address of the second Chainlink base feed. | ||
function BASE_FEED_2() external view returns (AggregatorV3Interface); | ||
|
||
/// @notice Returns the address of the first Chainlink quote feed. | ||
function QUOTE_FEED_1() external view returns (AggregatorV3Interface); | ||
|
||
/// @notice Returns the address of the second Chainlink quote feed. | ||
function QUOTE_FEED_2() external view returns (AggregatorV3Interface); | ||
|
||
/// @notice Returns the price scale factor, calculated at contract creation. | ||
function SCALE_FACTOR() external view returns (uint256); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters