morpho-org / morpho-blue-oracles

Morpho Blue Oracles
https://morpho.org
Other
29 stars 25 forks source link
chainlink decentralized defi lending morpho oracle

Morpho Blue Oracles

Morpho Blue Oracles are contracts that can be used as oracles for markets on Morpho Blue. The oracles implement the IOracle interface defined in IOracle.sol: they return the price of 1 asset of collateral token quoted in 1 asset of loan token.

MorphoChainlinkOracleV2

The MorphoChainlinkOracleV2 is an oracle that uses Chainlink-interface-compliant feeds to provide price data.

This oracle handles the following cases among others (let's say that our pair is A/B):

Deploy an Oracle

To deploy a MorphoChainlinkOracleV2 on Ethereum, it is highly recommended to use the factory MorphoChainlinkOracleV2Factory. To do so, call the createMorphoChainlinkOracleV2 function with the following parameters:

Warning: If there is an ERC4626-compliant vault for baseVault or quoteVault, the baseTokenDecimals or quoteTokenDecimals are still the decimals of the underlying asset of the vault, and not the decimals of the Vault itself. E.g: for a MetaMorpho WETH vault, as baseVault, the baseTokenDecimals is 18 as WETH has 18 decimals.

Addresses

The address on Ethereum of this factory is 0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766.

Examples

Below are the arguments to fill for the creation of the WETH/USDT oracle:

"baseVault": "0x0000000000000000000000000000000000000000",
"baseVaultConversionSample": 1,
"baseFeed1": "0x0000000000000000000000000000000000000000",
"baseFeed2": "0x0000000000000000000000000000000000000000",
"baseTokenDecimals": 18,
"quoteVault":"0x0000000000000000000000000000000000000000",
"quoteVaultConversionSample": 1,
"quoteFeed1": "0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46",
"quoteFeed2": "0x0000000000000000000000000000000000000000",
"quoteTokenDecimals": 6,
"salt": "<user-defined value used to make the address unique>",

and for the sDAI/USDC oracle:

"baseVault": "0x83F20F44975D03b1b09e64809B757c47f942BEeA",
"baseVaultConversionSample": 1000000000000000000,
"baseFeed1": "0xAed0c38402a5d19df6E4c03F4E2DceD6e29c1ee9",
"baseFeed2": "0x0000000000000000000000000000000000000000",
"baseTokenDecimals": 18,
"quoteVault": "0x0000000000000000000000000000000000000000",
"quoteVaultConversionSample": 1,
"quoteFeed1": "0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6",
"quoteFeed2": "0x0000000000000000000000000000000000000000",
"quoteTokenDecimals": 6,
"salt": "<user-defined value used to make the address unique>",

and for the wstETH/ETH oracle:

"baseVault": "0x0000000000000000000000000000000000000000",
"baseVaultConversionSample": 1,
"baseFeed1": "0x905b7dAbCD3Ce6B792D874e303D336424Cdb1421",
"baseFeed2": "0x86392dC19c0b719886221c78AB11eb8Cf5c52812",
"baseTokenDecimals": 18,
"quoteVault": "0x0000000000000000000000000000000000000000",
"quoteVaultConversionSample": 1,
"quoteFeed1": "0x0000000000000000000000000000000000000000",
"quoteFeed2": "0x0000000000000000000000000000000000000000",
"quoteTokenDecimals": 18,
"salt": "<user-defined value used to make the address unique>",

WstETH/stETH Exchange Rate Adapter

A specific implementation, the WstEthStEthExchangeRateChainlinkAdapter, provides the exchange rate between wstETH and stETH as a Chainlink-interface-compliant feed.

This adapter is deployed on the Ethereum Mainnet at the address 0x905b7dAbCD3Ce6B792D874e303D336424Cdb1421.

Getting Started

Install dependencies: forge install

In a .env file, set ETH_RPC_URL to the URL of an Ethereum provider.

Run test: forge test

Audits

All audits are stored in the audits' folder.

License

Morpho Blue Oracles are licensed under GPL-2.0-or-later, see LICENSE.