Mirage AI
  • Overview
    • Intro
    • Mirage AI Protocol
    • HOT AMM
    • Mirage AI Pro
  • Developer Docs
    • Mirage AI Modular
      • Architecture
      • Quickstart: Public Vaults
      • Price Oracles
    • HOT AMM
    • Uniswap v4 Hook (Soon)
Powered by GitBook
On this page
  1. Developer Docs
  2. Mirage AI Modular

Price Oracles

PreviousQuickstart: Public VaultsNextHOT AMM

Last updated 4 months ago

All Mirage AI Vaults have a concept of a price oracle set by vault owners on the MirageAIStandardManager. These price oracles are used as a third-party check on executor management calls to a vault.

We use our own standard interface for oracle reads and thus we can seamlessly integrate any type of onchain oracle price feed no matter the interfaces/patterns (RedStone, Chainlink, Uni V3 TWAP, etc) -- just by defining a simple Oracle Wrapper smart contract.

To accelerate the integration of safe public and private Meta Vaults for newer tokens that may not already have performant oracle feeds onchain, we refer clients to our oracle partner .

Methodology

Mirage AI implements a standard oracle interface that must be followed:

interface IOracleWrapper {
    /// @notice function used to get price0.
    /// @return price0 price of token0/token1.
    function getPrice0() external view returns (uint256 price0);

    /// @notice function used to get price1.
    /// @return price1 price of token1/token0.
    function getPrice1() external view returns (uint256 price1);
}

Any smart contract that utilizes this interface can function as an oracle on the Mirage AI standard manager. This interface is consumed during MirageAIStandardManager.rebalance here:

        uint256 price0 = info.oracle.getPrice0();

        uint256 vaultInToken1BeforeRebalance = FullMath.mulDiv(
            amount0, price0, 10 ** token0Decimals
        ) + amount1;

we store vaultInToken1BeforeRebalance and then compare it to the value after rebalance. Further checks can be implemented at the module level with oracle price feeds thanks to this call here:

    module.validateRebalance(info.oracle, info.maxDeviation);
RedStone