Oracles

The first component of a vault is its

The first component of a vault is its oracle. The oracle is used to compute initial shares minting. When a deposit and burn event, it is also use to get the current price of the market and have an up to date price.

These oracles are adapters from existing oracles like chainlink.

Reading a Mangrove Vault Oracle

An oracle just contains a single definition which is its tick (in a base/quote market). Here is a quick definition of the mangrove Tick​.

https://github.com/mangrovedao/mangrove-vault/blob/899abdb187f1801ba44621c0e25a697edda859e7/src/oracles/IOracle.sol#L12-L17

If the market in question was WETH/USDC, with p being the price and t being the tick, assuming the current price of ETH is 2500 USDC, WETH has 18 decimals, USDC has 6 decimals, we would have the following:

p=2500e61e18p = \frac{2500e6}{1e18}
t=ln(p)ln(1.0001)=ln(2.5e9)ln(1.0001)=198079t = \frac{ln(p)}{ln(1.0001)} = \frac{ln(2.5e-9)}{ln(1.0001)} = -198079

This formula is such that same decimals and price makes a tick of 0, in the market USDC/USDT for example.

By reversing the formula, computing the price from the tick is as follows for the same market.

p=1.0001tp = 1.0001^{t}

Last updated