MATIC Price: $0.730858 (-2.06%)
Gas: 30 GWei
 

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

MATIC Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
0x60e06040312438252022-07-28 17:08:31670 days ago1659028111IN
 Create: MellowOracle
0 MATIC0.0311555455.89631848

Parent Transaction Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MellowOracle

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, None license
File 1 of 18 : MellowOracle.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.9;

import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "../interfaces/oracles/IChainlinkOracle.sol";
import "../interfaces/oracles/IUniV3Oracle.sol";
import "../interfaces/oracles/IUniV2Oracle.sol";
import "../interfaces/oracles/IMellowOracle.sol";
import "../utils/ContractMeta.sol";

contract MellowOracle is ContractMeta, IMellowOracle, ERC165 {
    /// @inheritdoc IMellowOracle
    IUniV2Oracle public immutable univ2Oracle;
    /// @inheritdoc IMellowOracle
    IUniV3Oracle public immutable univ3Oracle;
    /// @inheritdoc IMellowOracle
    IChainlinkOracle public immutable chainlinkOracle;

    constructor(
        IUniV2Oracle univ2Oracle_,
        IUniV3Oracle univ3Oracle_,
        IChainlinkOracle chainlinkOracle_
    ) {
        univ2Oracle = univ2Oracle_;
        univ3Oracle = univ3Oracle_;
        chainlinkOracle = chainlinkOracle_;
    }

    // -------------------------  EXTERNAL, VIEW  ------------------------------

    function priceX96(
        address token0,
        address token1,
        uint256 safetyIndicesSet
    ) external view returns (uint256[] memory pricesX96, uint256[] memory safetyIndices) {
        IOracle[] memory oracles = _oracles();
        pricesX96 = new uint256[](6);
        safetyIndices = new uint256[](6);
        uint256 len;
        for (uint256 i = 0; i < oracles.length; i++) {
            IOracle oracle = oracles[i];
            (uint256[] memory oPrices, uint256[] memory oSafetyIndixes) = oracle.priceX96(
                token0,
                token1,
                safetyIndicesSet
            );
            for (uint256 j = 0; j < oPrices.length; j++) {
                pricesX96[len] = oPrices[j];
                safetyIndices[len] = oSafetyIndixes[j];
                len += 1;
            }
        }
        assembly {
            mstore(pricesX96, len)
            mstore(safetyIndices, len)
        }
    }

    /// @inheritdoc IERC165
    function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
        return super.supportsInterface(interfaceId) || type(IOracle).interfaceId == interfaceId;
    }

    // -------------------------  INTERNAL, VIEW  ------------------------------

    function _contractName() internal pure override returns (bytes32) {
        return bytes32("MellowOracle");
    }

    function _contractVersion() internal pure override returns (bytes32) {
        return bytes32("1.0.0");
    }

    function _oracles() internal view returns (IOracle[] memory oracles) {
        oracles = new IOracle[](3);
        uint256 len;
        if (address(univ2Oracle) != address(0)) {
            oracles[len] = univ2Oracle;
            len += 1;
        }
        if (address(univ3Oracle) != address(0)) {
            oracles[len] = univ3Oracle;
            len += 1;
        }
        if (address(chainlinkOracle) != address(0)) {
            oracles[len] = chainlinkOracle;
            len += 1;
        }
        assembly {
            mstore(oracles, len)
        }
    }
}

File 1 of 18 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 1 of 18 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 1 of 18 : IAggregatorV3.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IAggregatorV3 {
    function decimals() external view returns (uint8);

    function description() external view returns (string memory);

    function version() external view returns (uint256);

    // getRoundData and latestRoundData should both raise "No data present"
    // if they do not have data to report, instead of returning unset values
    // which could be misinterpreted as actual reported values.
    function getRoundData(uint80 _roundId)
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );

    function latestRoundData()
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );
}

File 1 of 18 : IUniswapV2Factory.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

interface IUniswapV2Factory {
    function getPair(address token0, address token1) external view returns (address);
}

File 1 of 18 : IUniswapV3Factory.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.8.9;

/// @title The interface for the Uniswap V3 Factory
/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees
interface IUniswapV3Factory {
    /// @notice Emitted when the owner of the factory is changed
    /// @param oldOwner The owner before the owner was changed
    /// @param newOwner The owner after the owner was changed
    event OwnerChanged(address indexed oldOwner, address indexed newOwner);

    /// @notice Emitted when a pool is created
    /// @param token0 The first token of the pool by address sort order
    /// @param token1 The second token of the pool by address sort order
    /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
    /// @param tickSpacing The minimum number of ticks between initialized ticks
    /// @param pool The address of the created pool
    event PoolCreated(
        address indexed token0,
        address indexed token1,
        uint24 indexed fee,
        int24 tickSpacing,
        address pool
    );

    /// @notice Emitted when a new fee amount is enabled for pool creation via the factory
    /// @param fee The enabled fee, denominated in hundredths of a bip
    /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee
    event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);

    /// @notice Returns the current owner of the factory
    /// @dev Can be changed by the current owner via setOwner
    /// @return The address of the factory owner
    function owner() external view returns (address);

    /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled
    /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context
    /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee
    /// @return The tick spacing
    function feeAmountTickSpacing(uint24 fee) external view returns (int24);

    /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist
    /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
    /// @param tokenA The contract address of either token0 or token1
    /// @param tokenB The contract address of the other token
    /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
    /// @return pool The pool address
    function getPool(
        address tokenA,
        address tokenB,
        uint24 fee
    ) external view returns (address pool);

    /// @notice Creates a pool for the given two tokens and fee
    /// @param tokenA One of the two tokens in the desired pool
    /// @param tokenB The other of the two tokens in the desired pool
    /// @param fee The desired fee for the pool
    /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved
    /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments
    /// are invalid.
    /// @return pool The address of the newly created pool
    function createPool(
        address tokenA,
        address tokenB,
        uint24 fee
    ) external returns (address pool);

    /// @notice Updates the owner of the factory
    /// @dev Must be called by the current owner
    /// @param _owner The new owner of the factory
    function setOwner(address _owner) external;

    /// @notice Enables a fee amount with the given tickSpacing
    /// @dev Fee amounts may never be removed once enabled
    /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)
    /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount
    function enableFeeAmount(uint24 fee, int24 tickSpacing) external;
}

File 1 of 18 : IUniswapV3Pool.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import "./pool/IUniswapV3PoolActions.sol";
import "./pool/IUniswapV3PoolImmutables.sol";
import "./pool/IUniswapV3PoolState.sol";
import "./pool/IUniswapV3PoolDerivedState.sol";

/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
    IUniswapV3PoolImmutables,
    IUniswapV3PoolState,
    IUniswapV3PoolDerivedState,
    IUniswapV3PoolActions
{

}

File 1 of 18 : IUniswapV3PoolActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
    /// @notice Sets the initial price for the pool
    /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
    /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
    function initialize(uint160 sqrtPriceX96) external;

    /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
    /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
    /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
    /// on tickLower, tickUpper, the amount of liquidity, and the current price.
    /// @param recipient The address for which the liquidity will be created
    /// @param tickLower The lower tick of the position in which to add liquidity
    /// @param tickUpper The upper tick of the position in which to add liquidity
    /// @param amount The amount of liquidity to mint
    /// @param data Any data that should be passed through to the callback
    /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
    /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
    function mint(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount,
        bytes calldata data
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Collects tokens owed to a position
    /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
    /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
    /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
    /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
    /// @param recipient The address which should receive the fees collected
    /// @param tickLower The lower tick of the position for which to collect fees
    /// @param tickUpper The upper tick of the position for which to collect fees
    /// @param amount0Requested How much token0 should be withdrawn from the fees owed
    /// @param amount1Requested How much token1 should be withdrawn from the fees owed
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);

    /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
    /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
    /// @dev Fees must be collected separately via a call to #collect
    /// @param tickLower The lower tick of the position for which to burn liquidity
    /// @param tickUpper The upper tick of the position for which to burn liquidity
    /// @param amount How much liquidity to burn
    /// @return amount0 The amount of token0 sent to the recipient
    /// @return amount1 The amount of token1 sent to the recipient
    function burn(
        int24 tickLower,
        int24 tickUpper,
        uint128 amount
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Swap token0 for token1, or token1 for token0
    /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
    /// @param recipient The address to receive the output of the swap
    /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
    /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
    /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
    /// value after the swap. If one for zero, the price cannot be greater than this value after the swap
    /// @param data Any data to be passed through to the callback
    /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
    /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
    function swap(
        address recipient,
        bool zeroForOne,
        int256 amountSpecified,
        uint160 sqrtPriceLimitX96,
        bytes calldata data
    ) external returns (int256 amount0, int256 amount1);

    /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
    /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
    /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
    /// with 0 amount{0,1} and sending the donation amount(s) from the callback
    /// @param recipient The address which will receive the token0 and token1 amounts
    /// @param amount0 The amount of token0 to send
    /// @param amount1 The amount of token1 to send
    /// @param data Any data to be passed through to the callback
    function flash(
        address recipient,
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    ) external;

    /// @notice Increase the maximum number of price and liquidity observations that this pool will store
    /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
    /// the input observationCardinalityNext.
    /// @param observationCardinalityNext The desired minimum number of observations for the pool to store
    function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}

File 1 of 18 : IUniswapV3PoolDerivedState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IUniswapV3PoolDerivedState {
    /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
    /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
    /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
    /// you must call it with secondsAgos = [3600, 0].
    /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
    /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
    /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
    /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
    /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
    /// timestamp
    function observe(uint32[] calldata secondsAgos)
        external
        view
        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);
}

File 1 of 18 : IUniswapV3PoolImmutables.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
    /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
    /// @return The contract address
    function factory() external view returns (address);

    /// @notice The first of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token0() external view returns (address);

    /// @notice The second of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token1() external view returns (address);

    /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
    /// @return The fee
    function fee() external view returns (uint24);

    /// @notice The pool tick spacing
    /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
    /// This value is an int24 to avoid casting even though it is always positive.
    /// @return The tick spacing
    function tickSpacing() external view returns (int24);

    /// @notice The maximum amount of position liquidity that can use any tick in the range
    /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
    /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
    /// @return The max amount of liquidity per tick
    function maxLiquidityPerTick() external view returns (uint128);
}

File 1 of 18 : IUniswapV3PoolState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.8.9;

/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
    /// when accessed externally.
    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
    /// tick The current tick of the pool, i.e. according to the last tick transition that was run.
    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
    /// boundary.
    /// observationIndex The index of the last oracle observation that was written,
    /// observationCardinality The current maximum number of observations stored in the pool,
    /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
    /// feeProtocol The protocol fee for both tokens of the pool.
    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
    /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
    /// unlocked Whether the pool is currently locked to reentrancy
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint8 feeProtocol,
            bool unlocked
        );

    /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal0X128() external view returns (uint256);

    /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal1X128() external view returns (uint256);

    /// @notice The amounts of token0 and token1 that are owed to the protocol
    /// @dev Protocol fees will never exceed uint128 max in either token
    function protocolPerformanceFees() external view returns (uint128 token0, uint128 token1);

    /// @notice The currently in range liquidity available to the pool
    /// @dev This value has no relationship to the total liquidity across all ticks
    function liquidity() external view returns (uint128);

    /// @notice Look up information about a specific tick in the pool
    /// @param tick The tick to look up
    /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
    /// tick upper,
    /// liquidityNet how much liquidity changes when the pool price crosses the tick,
    /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
    /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
    /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
    /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
    /// secondsOutside the seconds spent on the other side of the tick from the current tick,
    /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
    /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
    /// In addition, these values are only relative and must be used only in comparison to previous snapshots for
    /// a specific position.
    function ticks(int24 tick)
        external
        view
        returns (
            uint128 liquidityGross,
            int128 liquidityNet,
            uint256 feeGrowthOutside0X128,
            uint256 feeGrowthOutside1X128,
            int56 tickCumulativeOutside,
            uint160 secondsPerLiquidityOutsideX128,
            uint32 secondsOutside,
            bool initialized
        );

    /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
    function tickBitmap(int16 wordPosition) external view returns (uint256);

    /// @notice Returns the information about a position by the position's key
    /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
    /// @return _liquidity The amount of liquidity in the position,
    /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
    /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
    /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
    /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
    function positions(bytes32 key)
        external
        view
        returns (
            uint128 _liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    /// @notice Returns data about a specific observation index
    /// @param index The element of the observations array to fetch
    /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
    /// ago, rather than at a specific index in the array.
    /// @return blockTimestamp The timestamp of the observation,
    /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
    /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
    /// Returns initialized whether the observation has been initialized and the values are safe to use
    function observations(uint256 index)
        external
        view
        returns (
            uint32 blockTimestamp,
            int56 tickCumulative,
            uint160 secondsPerLiquidityCumulativeX128,
            bool initialized
        );
}

File 1 of 18 : IChainlinkOracle.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.9;

import "../external/chainlink/IAggregatorV3.sol";
import "./IOracle.sol";

interface IChainlinkOracle is IOracle {
    /// @notice Index of safety bit
    function safetyIndex() external view returns (uint8);

    /// @notice Checks if token has chainlink oracle
    /// @param token token address
    /// @return `true` if token is allowed, `false` o/w
    function hasOracle(address token) external view returns (bool);

    /// @notice A list of supported tokens
    function supportedTokens() external view returns (address[] memory);

    /// @notice Chainlink oracle for a ERC20 token
    /// @param token The address of the ERC20 token
    /// @return Address of the chainlink oracle
    function oraclesIndex(address token) external view returns (address);

    /// @notice Negative sum of decimals of token and chainlink oracle data for this token
    /// @param token The address of the ERC20 token
    /// @return Negative sum of decimals of token and chainlink oracle data for this token
    function decimalsIndex(address token) external view returns (int256);

    /// Add a Chainlink price feed for a token
    /// @param tokens ERC20 tokens for the feed
    /// @param oracles Chainlink oracle price feeds (token / USD)
    function addChainlinkOracles(address[] memory tokens, address[] memory oracles) external;
}

File 1 of 18 : IMellowOracle.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.9;

import "../external/univ3/IUniswapV3Factory.sol";
import "../external/univ3/IUniswapV3Pool.sol";
import "./IOracle.sol";
import "./IUniV2Oracle.sol";
import "./IUniV3Oracle.sol";
import "./IChainlinkOracle.sol";

interface IMellowOracle is IOracle {
    /// @notice Reference to UniV2 oracle
    function univ2Oracle() external view returns (IUniV2Oracle);

    /// @notice Reference to UniV3 oracle
    function univ3Oracle() external view returns (IUniV3Oracle);

    /// @notice Reference to Chainlink oracle
    function chainlinkOracle() external view returns (IChainlinkOracle);
}

File 1 of 18 : IOracle.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

interface IOracle {
    /// @notice Oracle price for tokens as a Q64.96 value.
    /// @notice Returns pricing information based on the indexes of non-zero bits in safetyIndicesSet.
    /// @notice It is possible that not all indices will have their respective prices returned.
    /// @dev The price is token1 / token0 i.e. how many weis of token1 required for 1 wei of token0.
    /// The safety indexes are:
    ///
    /// 1 - unsafe, this is typically a spot price that can be easily manipulated,
    ///
    /// 2 - 4 - more or less safe, this is typically a uniV3 oracle, where the safety is defined by the timespan of the average price
    ///
    /// 5 - safe - this is typically a chailink oracle
    /// @param token0 Reference to token0
    /// @param token1 Reference to token1
    /// @param safetyIndicesSet Bitmask of safety indices that are allowed for the return prices. For set of safety indexes = { 1 }, safetyIndicesSet = 0x2
    /// @return pricesX96 Prices that satisfy safetyIndex and tokens
    /// @return safetyIndices Safety indices for those prices
    function priceX96(
        address token0,
        address token1,
        uint256 safetyIndicesSet
    ) external view returns (uint256[] memory pricesX96, uint256[] memory safetyIndices);
}

File 1 of 18 : IUniV2Oracle.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.9;

import "../external/univ2/IUniswapV2Factory.sol";
import "./IOracle.sol";

interface IUniV2Oracle is IOracle {
    /// @notice Reference to UniV2 factory
    function factory() external returns (IUniswapV2Factory);

    /// @notice Index of safety bit
    function safetyIndex() external view returns (uint8);
}

File 1 of 18 : IUniV3Oracle.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.9;

import "../external/univ3/IUniswapV3Factory.sol";
import "../external/univ3/IUniswapV3Pool.sol";
import "./IOracle.sol";

interface IUniV3Oracle is IOracle {
    /// @notice Reference to UniV3 factory
    function factory() external view returns (IUniswapV3Factory);

    /// @notice The number of seconds for time delta between observations for oracle safety index 2 twap
    function LOW_OBS_DELTA() external view returns (uint32);

    /// @notice The number of seconds for time delta between observations for oracle safety index 3 twap
    function MID_OBS_DELTA() external view returns (uint32);

    /// @notice The number of seconds for time delta between observations for oracle safety index 4 twap
    function HIGH_OBS_DELTA() external view returns (uint32);

    /// @notice Available UniV3 pools for tokens
    /// @param token0 First ERC20 token
    /// @param token1 Second ERC20 token
    /// @return UniV3 pool or 0 if the pool is not available for oracle
    function poolsIndex(address token0, address token1) external view returns (IUniswapV3Pool);

    /// @notice Add UniV3 pools for prices.
    /// @param pools Pools to add
    function addUniV3Pools(IUniswapV3Pool[] memory pools) external;
}

File 1 of 18 : IContractMeta.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.9;

interface IContractMeta {
    function contractName() external view returns (string memory);
    function contractNameBytes() external view returns (bytes32);

    function contractVersion() external view returns (string memory);
    function contractVersionBytes() external view returns (bytes32);
}

File 2 of 18 : ContractMeta.sol
// SPDX-License-Identifier: BSL-1.1
pragma solidity 0.8.9;

import "../interfaces/utils/IContractMeta.sol";

abstract contract ContractMeta is IContractMeta {
    // -------------------  EXTERNAL, VIEW  -------------------

    function contractName() external pure returns (string memory) {
        return _bytes32ToString(_contractName());
    }

    function contractNameBytes() external pure returns (bytes32) {
        return _contractName();
    }

    function contractVersion() external pure returns (string memory) {
        return _bytes32ToString(_contractVersion());
    }

    function contractVersionBytes() external pure returns (bytes32) {
        return _contractVersion();
    }

    // -------------------  INTERNAL, VIEW  -------------------

    function _contractName() internal pure virtual returns (bytes32);

    function _contractVersion() internal pure virtual returns (bytes32);

    function _bytes32ToString(bytes32 b) internal pure returns (string memory s) {
        s = new string(32);
        uint256 len = 32;
        for (uint256 i = 0; i < 32; ++i) {
            if (uint8(b[i]) == 0) {
                len = i;
                break;
            }
        }
        assembly {
            mstore(s, len)
            mstore(add(s, 0x20), b)
        }
    }
}

Settings
{
  "evmVersion": "istanbul",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IUniV2Oracle","name":"univ2Oracle_","type":"address"},{"internalType":"contract IUniV3Oracle","name":"univ3Oracle_","type":"address"},{"internalType":"contract IChainlinkOracle","name":"chainlinkOracle_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"chainlinkOracle","outputs":[{"internalType":"contract IChainlinkOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"contractNameBytes","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"contractVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"contractVersionBytes","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint256","name":"safetyIndicesSet","type":"uint256"}],"name":"priceX96","outputs":[{"internalType":"uint256[]","name":"pricesX96","type":"uint256[]"},{"internalType":"uint256[]","name":"safetyIndices","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"univ2Oracle","outputs":[{"internalType":"contract IUniV2Oracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"univ3Oracle","outputs":[{"internalType":"contract IUniV3Oracle","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

60e060405234801561001057600080fd5b50604051610a20380380610a2083398101604081905261002f91610064565b6001600160a01b0392831660805290821660a0521660c0526100b1565b6001600160a01b038116811461006157600080fd5b50565b60008060006060848603121561007957600080fd5b83516100848161004c565b60208501519093506100958161004c565b60408501519092506100a68161004c565b809150509250925092565b60805160a05160c051610917610109600039600081816101960152818161052f015261055e01526000818161016f015281816104a701526104d601526000818160f20152818161041f015261044e01526109176000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c80636d80125b116100665780636d80125b1461012c57806375d0c0dc1461014d578063a0a8e46014610162578063b9fdd5fa1461016a578063ef06e72c1461019157600080fd5b806301ffc9a71461009857806306a46239146100c05780630e3e80ac146100d8578063665658be146100ed575b600080fd5b6100ab6100a6366004610626565b6101b8565b60405190151581526020015b60405180910390f35b640312e302e360dc1b5b6040519081526020016100b7565b6b4d656c6c6f774f7261636c6560a01b6100ca565b6101147f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100b7565b61013f61013a366004610673565b6101f4565b6040516100b79291906106ea565b6101556103cc565b6040516100b79190610718565b6101556103e6565b6101147f000000000000000000000000000000000000000000000000000000000000000081565b6101147f000000000000000000000000000000000000000000000000000000000000000081565b60006301ffc9a760e01b6001600160e01b0319831614806101e95750636d80125b60e01b6001600160e01b03198316145b92915050565b905090565b60608060006102016103f9565b60408051600680825260e082019092529192506020820160c080368337505060408051600680825260e0820190925292955090506020820160c0803683370190505091506000805b82518110156103bb57600083828151811061026657610266610783565b6020908102919091010151604051636d80125b60e01b81526001600160a01b038b811660048301528a81166024830152604482018a9052919250600091829190841690636d80125b9060640160006040518083038186803b1580156102ca57600080fd5b505afa1580156102de573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526103069190810190610834565b9150915060005b82518110156103a45782818151811061032857610328610783565b602002602001015189878151811061034257610342610783565b60200260200101818152505081818151811061036057610360610783565b602002602001015188878151811061037a5761037a610783565b60209081029190910101526103906001876108ae565b95508061039c816108c6565b91505061030d565b5050505080806103b3906108c6565b915050610249565b508084528083525050935093915050565b60606101ef6b4d656c6c6f774f7261636c6560a01b6105ba565b60606101ef640312e302e360dc1b6105ba565b6040805160038082526080820190925260609160208201838036833701905050905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316156104a5577f000000000000000000000000000000000000000000000000000000000000000082828151811061047f5761047f610783565b6001600160a01b03909216602092830291909101909101526104a26001826108ae565b90505b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03161561052d577f000000000000000000000000000000000000000000000000000000000000000082828151811061050757610507610783565b6001600160a01b039092166020928302919091019091015261052a6001826108ae565b90505b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316156105b5577f000000000000000000000000000000000000000000000000000000000000000082828151811061058f5761058f610783565b6001600160a01b03909216602092830291909101909101526105b26001826108ae565b90505b815290565b604080516020808252818301909252606091602082018180368337019050509050602060005b6020811015610618578381602081106105fb576105fb610783565b1a61060857809150610618565b610611816108c6565b90506105e0565b508152602081019190915290565b60006020828403121561063857600080fd5b81356001600160e01b03198116811461065057600080fd5b9392505050565b80356001600160a01b038116811461066e57600080fd5b919050565b60008060006060848603121561068857600080fd5b61069184610657565b925061069f60208501610657565b9150604084013590509250925092565b600081518084526020808501945080840160005b838110156106df578151875295820195908201906001016106c3565b509495945050505050565b6040815260006106fd60408301856106af565b828103602084015261070f81856106af565b95945050505050565b600060208083528351808285015260005b8181101561074557858101830151858201604001528201610729565b81811115610757576000604083870101525b50601f01601f1916929092016040019392505050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b600082601f8301126107aa57600080fd5b8151602067ffffffffffffffff808311156107c7576107c761076d565b8260051b604051601f19603f830116810181811084821117156107ec576107ec61076d565b60405293845285810183019383810192508785111561080a57600080fd5b83870191505b8482101561082957815183529183019190830190610810565b979650505050505050565b6000806040838503121561084757600080fd5b825167ffffffffffffffff8082111561085f57600080fd5b61086b86838701610799565b9350602085015191508082111561088157600080fd5b5061088e85828601610799565b9150509250929050565b634e487b7160e01b600052601160045260246000fd5b600082198211156108c1576108c1610898565b500190565b60006000198214156108da576108da610898565b506001019056fea2646970667358221220072f81b72e9e0c8b81fa5d4658d49c8ef5611ea27709115d6cc70d3baef5280564736f6c634300080900330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f5eaa5ff25fe48d9f91f05aa517d95e50d14228000000000000000000000000045ce8c3ddd839f09ab15641176f6b26cbc411130

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100935760003560e01c80636d80125b116100665780636d80125b1461012c57806375d0c0dc1461014d578063a0a8e46014610162578063b9fdd5fa1461016a578063ef06e72c1461019157600080fd5b806301ffc9a71461009857806306a46239146100c05780630e3e80ac146100d8578063665658be146100ed575b600080fd5b6100ab6100a6366004610626565b6101b8565b60405190151581526020015b60405180910390f35b640312e302e360dc1b5b6040519081526020016100b7565b6b4d656c6c6f774f7261636c6560a01b6100ca565b6101147f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100b7565b61013f61013a366004610673565b6101f4565b6040516100b79291906106ea565b6101556103cc565b6040516100b79190610718565b6101556103e6565b6101147f000000000000000000000000f5eaa5ff25fe48d9f91f05aa517d95e50d14228081565b6101147f00000000000000000000000045ce8c3ddd839f09ab15641176f6b26cbc41113081565b60006301ffc9a760e01b6001600160e01b0319831614806101e95750636d80125b60e01b6001600160e01b03198316145b92915050565b905090565b60608060006102016103f9565b60408051600680825260e082019092529192506020820160c080368337505060408051600680825260e0820190925292955090506020820160c0803683370190505091506000805b82518110156103bb57600083828151811061026657610266610783565b6020908102919091010151604051636d80125b60e01b81526001600160a01b038b811660048301528a81166024830152604482018a9052919250600091829190841690636d80125b9060640160006040518083038186803b1580156102ca57600080fd5b505afa1580156102de573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526103069190810190610834565b9150915060005b82518110156103a45782818151811061032857610328610783565b602002602001015189878151811061034257610342610783565b60200260200101818152505081818151811061036057610360610783565b602002602001015188878151811061037a5761037a610783565b60209081029190910101526103906001876108ae565b95508061039c816108c6565b91505061030d565b5050505080806103b3906108c6565b915050610249565b508084528083525050935093915050565b60606101ef6b4d656c6c6f774f7261636c6560a01b6105ba565b60606101ef640312e302e360dc1b6105ba565b6040805160038082526080820190925260609160208201838036833701905050905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316156104a5577f000000000000000000000000000000000000000000000000000000000000000082828151811061047f5761047f610783565b6001600160a01b03909216602092830291909101909101526104a26001826108ae565b90505b7f000000000000000000000000f5eaa5ff25fe48d9f91f05aa517d95e50d1422806001600160a01b03161561052d577f000000000000000000000000f5eaa5ff25fe48d9f91f05aa517d95e50d14228082828151811061050757610507610783565b6001600160a01b039092166020928302919091019091015261052a6001826108ae565b90505b7f00000000000000000000000045ce8c3ddd839f09ab15641176f6b26cbc4111306001600160a01b0316156105b5577f00000000000000000000000045ce8c3ddd839f09ab15641176f6b26cbc41113082828151811061058f5761058f610783565b6001600160a01b03909216602092830291909101909101526105b26001826108ae565b90505b815290565b604080516020808252818301909252606091602082018180368337019050509050602060005b6020811015610618578381602081106105fb576105fb610783565b1a61060857809150610618565b610611816108c6565b90506105e0565b508152602081019190915290565b60006020828403121561063857600080fd5b81356001600160e01b03198116811461065057600080fd5b9392505050565b80356001600160a01b038116811461066e57600080fd5b919050565b60008060006060848603121561068857600080fd5b61069184610657565b925061069f60208501610657565b9150604084013590509250925092565b600081518084526020808501945080840160005b838110156106df578151875295820195908201906001016106c3565b509495945050505050565b6040815260006106fd60408301856106af565b828103602084015261070f81856106af565b95945050505050565b600060208083528351808285015260005b8181101561074557858101830151858201604001528201610729565b81811115610757576000604083870101525b50601f01601f1916929092016040019392505050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b600082601f8301126107aa57600080fd5b8151602067ffffffffffffffff808311156107c7576107c761076d565b8260051b604051601f19603f830116810181811084821117156107ec576107ec61076d565b60405293845285810183019383810192508785111561080a57600080fd5b83870191505b8482101561082957815183529183019190830190610810565b979650505050505050565b6000806040838503121561084757600080fd5b825167ffffffffffffffff8082111561085f57600080fd5b61086b86838701610799565b9350602085015191508082111561088157600080fd5b5061088e85828601610799565b9150509250929050565b634e487b7160e01b600052601160045260246000fd5b600082198211156108c1576108c1610898565b500190565b60006000198214156108da576108da610898565b506001019056fea2646970667358221220072f81b72e9e0c8b81fa5d4658d49c8ef5611ea27709115d6cc70d3baef5280564736f6c63430008090033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f5eaa5ff25fe48d9f91f05aa517d95e50d14228000000000000000000000000045ce8c3ddd839f09ab15641176f6b26cbc411130

-----Decoded View---------------
Arg [0] : univ2Oracle_ (address): 0x0000000000000000000000000000000000000000
Arg [1] : univ3Oracle_ (address): 0xf5Eaa5ff25fE48D9f91F05aa517d95E50d142280
Arg [2] : chainlinkOracle_ (address): 0x45ce8C3DDd839f09Ab15641176f6B26Cbc411130

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [1] : 000000000000000000000000f5eaa5ff25fe48d9f91f05aa517d95e50d142280
Arg [2] : 00000000000000000000000045ce8c3ddd839f09ab15641176f6b26cbc411130


Block Transaction Gas Used Reward
view all blocks produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.