MorphoChainlinkOracleV2
Inherits: IMorphoChainlinkOracleV2
Morpho Blue oracle using Chainlink-compliant feeds.
State Variables
BASE_VAULT
Returns the address of the base ERC4626 vault.
IERC4626 public immutable BASE_VAULTBASE_VAULT_CONVERSION_SAMPLE
Returns the base vault conversion sample.
uint256 public immutable BASE_VAULT_CONVERSION_SAMPLEQUOTE_VAULT
Returns the address of the quote ERC4626 vault.
IERC4626 public immutable QUOTE_VAULTQUOTE_VAULT_CONVERSION_SAMPLE
Returns the quote vault conversion sample.
uint256 public immutable QUOTE_VAULT_CONVERSION_SAMPLEBASE_FEED_1
Returns the address of the first base feed.
AggregatorV3Interface public immutable BASE_FEED_1BASE_FEED_2
Returns the address of the second base feed.
AggregatorV3Interface public immutable BASE_FEED_2QUOTE_FEED_1
Returns the address of the first quote feed.
AggregatorV3Interface public immutable QUOTE_FEED_1QUOTE_FEED_2
Returns the address of the second quote feed.
AggregatorV3Interface public immutable QUOTE_FEED_2SCALE_FACTOR
Returns the price scale factor, calculated at contract creation.
uint256 public immutable SCALE_FACTORFunctions
constructor
Here is the list of assumptions that guarantees the oracle behaves as expected:
- The vaults, if set, are ERC4626-compliant.
- The feeds, if set, are Chainlink-interface-compliant.
- Decimals passed as argument are correct.
- The base vaults's sample shares quoted as assets and the base feed prices don't overflow when multiplied.
- The quote vault's sample shares quoted as assets and the quote feed prices don't overflow when multiplied.
Properly configured Morpho Blue markets should ensure that price of the oracle cannot change instantly such that the new price is less than the old price multiplied by LLTV*LIF. So in particular, vaults that can receive donations shouldn't be used as loan/quote assets.
The base asset should be the collateral token and the quote asset the loan token.
constructor(
IERC4626 baseVault,
uint256 baseVaultConversionSample,
AggregatorV3Interface baseFeed1,
AggregatorV3Interface baseFeed2,
uint256 baseTokenDecimals,
IERC4626 quoteVault,
uint256 quoteVaultConversionSample,
AggregatorV3Interface quoteFeed1,
AggregatorV3Interface quoteFeed2,
uint256 quoteTokenDecimals
) ;Parameters
| Name | Type | Description |
|---|---|---|
baseVault | IERC4626 | Base vault. Pass address zero to omit this parameter. |
baseVaultConversionSample | uint256 | The sample amount of base vault shares used to convert to underlying. Pass 1 if the base asset is not a vault. Should be chosen such that converting baseVaultConversionSample to assets has enough precision. |
baseFeed1 | AggregatorV3Interface | First base feed. Pass address zero if the price = 1. |
baseFeed2 | AggregatorV3Interface | Second base feed. Pass address zero if the price = 1. |
baseTokenDecimals | uint256 | Base token decimals. |
quoteVault | IERC4626 | Quote vault. Pass address zero to omit this parameter. |
quoteVaultConversionSample | uint256 | The sample amount of quote vault shares used to convert to underlying. Pass 1 if the quote asset is not a vault. Should be chosen such that converting quoteVaultConversionSample to assets has enough precision. |
quoteFeed1 | AggregatorV3Interface | First quote feed. Pass address zero if the price = 1. |
quoteFeed2 | AggregatorV3Interface | Second quote feed. Pass address zero if the price = 1. |
quoteTokenDecimals | uint256 | Quote token decimals. |
price
Returns the price of 1 asset of collateral token quoted in 1 asset of loan token, scaled by 1e36.
It corresponds to the price of 10**(collateral token decimals) assets of collateral token quoted in 10**(loan token decimals) assets of loan token with 36 + loan token decimals - collateral token decimals decimals of precision.
function price() external view returns (uint256);