Oracles
As of now, the developed oracle adapters are Chainlink and Dia oracle adapters. Both adapters include an ERC4626 base and quote vault converter. So if the market token is an ERC4626, you can easily convert this oracles underlying to the overlying ERC4626 price (exclusive of fees while minting and burning such ERC4626 token).
Another type of oracle exist allowing you to combine multiple Mangrove vaults oracle together. This can be used in case an oracle needs both chainlink and dia for example.
Querying an oracle
Here is how to query an oracle. The price adjustement is based on the WETH/USDC market (12 decimals shift).
Deploying a chainlink oracle adapter (v2)
Choosing the parameters
The parameters to provide are the feed addresses (2 base feed, and 2 quote feed at most allowing feed chaining). One base and one quote ERC4626 vaults can also be provided as well as an optional salt.
In order to chain feeds together, we need to specify the token decimals for each feed token. If the token does not exist, assuming 18 decimals is recommended.
For reference, ETH/USD feed, ETH is 18 decmals, and USD does not exist so we take 18 decimals (unless we assume USD to be USDC or USDT in which cas we choose 6). For USDC/USD, we will take 6 for USDC, and 18 for USD. Here is an example of a valid deployment on base for WETH/USDC market.
Checking if the oracle is already deployed
These oracles are deployed with CREATE2 allowing to share an oracle easily by finding vaults with same parameters. All values are immutable ensuring no changes have been done since deployment.
Then to check if it has been deployed, we just need to check the code size.
Deploying the oracle
To deploy the oracle we pass the very same parameters to the factory:
Deploying a Dia oracle adapter
Up to 4 feeds (2 base and 2 quote) in addition to one base and one quote vault can be combined.
Choosing the parameters
In order to choose the parameter, do the same as Choosing the parameters. But you also have to provide a string key. The string key then has to be packed encoded. The maximum size of the encoding is now limited to 32 bytes for efficiency.
Checking if the oracle is already deployed
Check the returned address code size to check if it is already deployed.
Deploying the oracle
Combining oracles together
An oracle combiner can combine up to 4 Mangrove compatible oracles together.
Checking existing oracle
Deploying the oracle
Last updated