Skip to content

Commit 1ae09fc

Browse files
Merge pull request #86 from morpho-org/feat/update-read-me
feat(readme): explaining the oracle creation from the factory
2 parents 4697388 + dda86ee commit 1ae09fc

File tree

1 file changed

+82
-16
lines changed

1 file changed

+82
-16
lines changed

README.md

Lines changed: 82 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Morpho Blue Oracles
22

3-
43
Morpho Blue Oracles are contracts that can be used as oracles for markets on [Morpho Blue](https://github.com/morpho-org/morpho-blue).
54
The oracles implement the `IOracle` interface defined in [`IOracle.sol`](https://github.com/morpho-org/morpho-blue/blob/main/src/interfaces/IOracle.sol#L9): they return the price of 1 asset of collateral token quoted in 1 asset of loan token.
65

7-
## ChainlinkOracle
6+
## MorphoChainlinkOracleV2
87

9-
The `ChainlinkOracle` is an oracle that uses Chainlink-compliant feeds to provide price data.
8+
The `MorphoChainlinkOracleV2` is an oracle that uses Chainlink-interface-compliant feeds to provide price data.
109

1110
This oracle handles the following cases among others (let's say that our pair is A/B):
11+
1212
- A/B is a feed (typically, stETH/ETH).
1313
- B/A is a feed (typically, ETH/USDC).
1414
- A/C and B/C are feeds (typically, stETH/ETH and USDC/ETH).
@@ -18,32 +18,98 @@ This oracle handles the following cases among others (let's say that our pair is
1818
- A/C and C/B are feeds (typically, WBTC/BTC and BTC/ETH).
1919
- A'/C and B/C are feeds, and there is an exchange rate between A and A'. (typically A=sDAI and A'=DAI).
2020

21-
## Getting Started
21+
## WstETH/stETH Exchange Rate Adapter
2222

23-
Install dependencies: `forge install`
23+
A specific implementation, the `WstEthStEthExchangeRateChainlinkAdapter`, provides the exchange rate between wstETH and stETH as a Chainlink-interface-compliant feed.
2424

25-
In a `.env` file, set `ETH_RPC_URL` to the URL of an Ethereum provider.
25+
This adapter is deployed on Ethereum Mainnet at the address [0x905b7dAbCD3Ce6B792D874e303D336424Cdb1421](https://etherscan.io/address/0x905b7dabcd3ce6b792d874e303d336424cdb1421#code).
2626

27-
Run test: `forge test`
27+
## MorphoChainlinkOracleV2Factory
2828

29-
## Deploy an Oracle
29+
The `MorphoChainlinkOracleV2Factory` is a factory that deploys `MorphoChainlinkOracleV2` instances.
3030

31-
For example, to deploy a `ChainlinkOracle` on the Ethereum mainnet for the sDAI/USDC market, run:
31+
The factory facilitates the creation and indexing of `MorphoChainlinkOracleV2` oracles. This factory contract streamlines the process of deploying new oracles, catering to various market pairs without the need to deploy individual contracts manually for each pair.
3232

33-
```bash
34-
forge create src/ChainlinkOracle.sol:ChainlinkOracle --constructor-args "0x83F20F44975D03b1b09e64809B757c47f942BEeA" "0xAed0c38402a5d19df6E4c03F4E2DceD6e29c1ee9" "0x0000000000000000000000000000000000000000" "0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6" "0x0000000000000000000000000000000000000000" "1000000000000000000" "18" "6" --rpc-url https://eth-mainnet.g.alchemy.com/v2/<alchemy-key> --from <deployer-address> --ledger
35-
``````
33+
### Usage
3634

37-
And for the rETH/WETH market, run:
35+
The Ethereum Mainnet address of this factory is [0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766](https://etherscan.io/address/0x3a7bb36ee3f3ee32a60e9f2b33c1e5f2e83ad766#code).
3836

39-
```bash
40-
forge create src/ChainlinkOracle.sol:ChainlinkOracle --constructor-args "0x0000000000000000000000000000000000000000" "0x536218f9E9Eb48863970252233c8F271f554C2d0" "0x0000000000000000000000000000000000000000" "0x0000000000000000000000000000000000000000" "0x0000000000000000000000000000000000000000" "1" "18" "18" --rpc-url https://eth-mainnet.g.alchemy.com/v2/<alchemy-key> --from <deployer-address> --ledger
37+
To create a new `MorphoChainlinkOracleV2` oracle using the factory, call the `createMorphoChainlinkOracleV2` function with the following parameters:
38+
39+
- `baseVault`: The ERC4626 token vault for the base asset.
40+
- `baseVaultConversionSample`: A sample amount for converting base vault units.
41+
- `baseFeed1`, `baseFeed2`: Chainlink-interface-compliant data feeds for the base asset.
42+
- `baseTokenDecimals`: Decimal precision of the base asset.
43+
- `quoteVault`: The ERC4626 token vault for the quote asset.
44+
- `quoteVaultConversionSample`: A sample amount for converting quote vault units.
45+
- `quoteFeed1`, `quoteFeed2`: Chainlink-interface-compliant data feeds for the quote asset.
46+
- `quoteTokenDecimals`: Decimal precision of the quote asset.
47+
- `salt`: A unique identifier to create deterministic addresses for deployed oracles.
48+
49+
### Deploy an Oracle
50+
51+
To deploy a `MorphoChainlinkOracleV2` on the Ethereum mainnet, use the `MorphoChainlinkOracleV2Factory` to create a new oracle.
52+
53+
Below are the arguments to fill for the creation of the WETH/USDT oracle:
54+
55+
```json
56+
- `baseVault`: "0x0000000000000000000000000000000000000000",
57+
- `baseVaultConversionSample`: 1,
58+
- `baseFeed1`: "0x0000000000000000000000000000000000000000",
59+
- `baseFeed2`: "0x0000000000000000000000000000000000000000",
60+
- `baseTokenDecimals`: 18,
61+
- `quoteVault`:"0x0000000000000000000000000000000000000000",
62+
- `quoteVaultConversionSample`: 1,
63+
- `quoteFeed1`: "0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46",
64+
- `quoteFeed2`: "0x0000000000000000000000000000000000000000",
65+
- `quoteTokenDecimals`: 6,
66+
- `salt`: <user-defined value used to make the address unique>,
4167
```
4268

69+
and for the sDAI/USDC oracle:
70+
71+
```json
72+
- `baseVault`: "0x83F20F44975D03b1b09e64809B757c47f942BEeA",
73+
- `baseVaultConversionSample`: 1000000000000000000, // 1e18
74+
- `baseFeed1`: "0xAed0c38402a5d19df6E4c03F4E2DceD6e29c1ee9",
75+
- `baseFeed2`: "0x0000000000000000000000000000000000000000",
76+
- `baseTokenDecimals`: 18,
77+
- `quoteVault`: "0x0000000000000000000000000000000000000000",
78+
- `quoteVaultConversionSample`: 1,
79+
- `quoteFeed1`: "0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6",
80+
- `quoteFeed2`: "0x0000000000000000000000000000000000000000",
81+
- `quoteTokenDecimals`: 6,
82+
- `salt`: <user-defined value used to make the address unique>,
83+
```
84+
85+
and for the wstETH/ETH oracle:
86+
87+
```json
88+
- `baseVault`: "0x0000000000000000000000000000000000000000",
89+
- `baseVaultConversionSample`: 1,
90+
- `baseFeed1`: "0x905b7dAbCD3Ce6B792D874e303D336424Cdb1421",
91+
- `baseFeed2`: "0x86392dC19c0b719886221c78AB11eb8Cf5c52812",
92+
- `baseTokenDecimals`: 18,
93+
- `quoteVault`: "0x0000000000000000000000000000000000000000",
94+
- `quoteVaultConversionSample`: 1,
95+
- `quoteFeed1`: "0x0000000000000000000000000000000000000000",
96+
- `quoteFeed2`: "0x0000000000000000000000000000000000000000",
97+
- `quoteTokenDecimals`: 18,
98+
- `salt`: <user-defined value used to make the address unique>,
99+
```
100+
101+
## Getting Started
102+
103+
Install dependencies: `forge install`
104+
105+
In a `.env` file, set `ETH_RPC_URL` to the URL of an Ethereum provider.
106+
107+
Run test: `forge test`
108+
43109
## Audits
44110

45111
All audits are stored in the [audits](./audits/)' folder.
46112

47113
## License
48114

49-
Morpho Blue Oracles are licensed under `GPL-2.0-or-later`, see [`LICENSE`](./LICENSE).
115+
Morpho Blue Oracles are licensed under `GPL-2.0-or-later`, see [`LICENSE`](./LICENSE).

0 commit comments

Comments
 (0)