ETH Price: $1,830.60 (-1.10%)

Contract

0xdB2D0baae78f1dc2A8504B471F3cea257b2C3766
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Update Token Ora...155834612022-09-21 18:14:35920 days ago1663784075IN
0xdB2D0baa...57b2C3766
0 ETH0.0011602937.4568051
Update Token Ora...155834602022-09-21 18:14:23920 days ago1663784063IN
0xdB2D0baa...57b2C3766
0 ETH0.0011840738.22440269
Update Token Ora...155834592022-09-21 18:14:11920 days ago1663784051IN
0xdB2D0baa...57b2C3766
0 ETH0.0012319839.77080668
Update Token Ora...155834572022-09-21 18:13:47920 days ago1663784027IN
0xdB2D0baa...57b2C3766
0 ETH0.0012467240.2624635
Update Token Ora...155834102022-09-21 18:04:23920 days ago1663783463IN
0xdB2D0baa...57b2C3766
0 ETH0.0025292781.65013401
Update Token Ora...155463382022-09-16 13:00:47925 days ago1663333247IN
0xdB2D0baa...57b2C3766
0 ETH0.00023088.1879418
Update Token Ora...155463362022-09-16 13:00:23925 days ago1663333223IN
0xdB2D0baa...57b2C3766
0 ETH0.000368827.6696921
Update Token Ora...155463362022-09-16 13:00:23925 days ago1663333223IN
0xdB2D0baa...57b2C3766
0 ETH0.000368827.6696921
Update Token Ora...155463342022-09-16 12:59:59925 days ago1663333199IN
0xdB2D0baa...57b2C3766
0 ETH0.000371627.72784172
Update Token Ora...155463342022-09-16 12:59:59925 days ago1663333199IN
0xdB2D0baa...57b2C3766
0 ETH0.000371627.72784172
Update Token Ora...155463262022-09-16 12:58:23925 days ago1663333103IN
0xdB2D0baa...57b2C3766
0 ETH0.000411318.55325182
Update Token Ora...155463242022-09-16 12:57:59925 days ago1663333079IN
0xdB2D0baa...57b2C3766
0 ETH0.000439189.13284133
Update Token Ora...155463242022-09-16 12:57:59925 days ago1663333079IN
0xdB2D0baa...57b2C3766
0 ETH0.000439189.13284133
Update Token Ora...155463222022-09-16 12:57:35925 days ago1663333055IN
0xdB2D0baa...57b2C3766
0 ETH0.000424088.81876719
Update Token Ora...155463212022-09-16 12:57:23925 days ago1663333043IN
0xdB2D0baa...57b2C3766
0 ETH0.000401278.34449881
Update Token Ora...155463192022-09-16 12:56:59925 days ago1663333019IN
0xdB2D0baa...57b2C3766
0 ETH0.000446099.27651933
Update Token Ora...155463182022-09-16 12:56:47925 days ago1663333007IN
0xdB2D0baa...57b2C3766
0 ETH0.000405578.43379625
Update Token Ora...155463182022-09-16 12:56:47925 days ago1663333007IN
0xdB2D0baa...57b2C3766
0 ETH0.000405578.43379625
Update Token Ora...155463162022-09-16 12:56:23925 days ago1663332983IN
0xdB2D0baa...57b2C3766
0 ETH0.000435219.05013056
Update Token Ora...155463052022-09-16 12:54:11925 days ago1663332851IN
0xdB2D0baa...57b2C3766
0 ETH0.000461039.58719216
Update Token Ora...155463042022-09-16 12:53:59925 days ago1663332839IN
0xdB2D0baa...57b2C3766
0 ETH0.000419618.72802094
Update Token Ora...155463032022-09-16 12:53:47925 days ago1663332827IN
0xdB2D0baa...57b2C3766
0 ETH0.000453729.43512441
Update Token Ora...155463012022-09-16 12:53:23925 days ago1663332803IN
0xdB2D0baa...57b2C3766
0 ETH0.000452929.42090164
Update Token Ora...155463002022-09-16 12:53:11925 days ago1663332791IN
0xdB2D0baa...57b2C3766
0 ETH0.000429168.92653557
Update Token Ora...153522982022-08-16 12:17:04956 days ago1660652224IN
0xdB2D0baa...57b2C3766
0 ETH0.000394468.2028947
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MasterOracle

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 5000 runs

Other Settings:
default evmVersion, MIT license
File 1 of 10 : MasterOracle.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "../interfaces/periphery/IOracle.sol";
import "../access/Governable.sol";

/**
 * @title MasterOracle
 */
contract MasterOracle is IOracle, Governable {
    /**
     * @notice Default oracle to use when token hasn't custom oracle
     */
    IOracle public defaultOracle;

    /**
     * @notice Custom tokens' oracles
     * @dev Useful when dealing with special tokens (e.g. LP, IB, etc)
     */
    mapping(address => IOracle) public oracles;

    /// @notice Emitted when a token's oracle is set
    event TokenOracleUpdated(address indexed token, IOracle indexed oracle);

    /// @notice Emitted when the default oracle is updated
    event DefaultOracleUpdated(IOracle indexed defaultOracle);

    constructor(IOracle defaultOracle_) {
        defaultOracle = defaultOracle_;
    }

    /// @inheritdoc IOracle
    function getPriceInUsd(address token_) public view override returns (uint256 _priceInUsd) {
        IOracle _oracle = oracles[token_];

        if (address(_oracle) == address(0)) {
            return defaultOracle.getPriceInUsd(token_);
        }

        return _oracle.getPriceInUsd(token_);
    }

    /// @inheritdoc IOracle
    function quote(
        address tokenIn_,
        address tokenOut_,
        uint256 amountIn_
    ) external view virtual override returns (uint256 _amountOut) {
        uint256 _amountInUsd = quoteTokenToUsd(tokenIn_, amountIn_);
        _amountOut = quoteUsdToToken(tokenOut_, _amountInUsd);
    }

    /// @inheritdoc IOracle
    function quoteTokenToUsd(address token_, uint256 amountIn_) public view override returns (uint256 _amountOut) {
        uint256 _price = getPriceInUsd(token_);
        _amountOut = (amountIn_ * _price) / 10**IERC20Metadata(token_).decimals();
    }

    /// @inheritdoc IOracle
    function quoteUsdToToken(address token_, uint256 amountIn_) public view override returns (uint256 _amountOut) {
        uint256 _price = getPriceInUsd(token_);
        _amountOut = (amountIn_ * 10**IERC20Metadata(token_).decimals()) / _price;
    }

    /// @notice Set custom oracle for a token_
    function updateTokenOracle(address token_, IOracle oracle_) external onlyGovernor {
        oracles[token_] = oracle_;
        emit TokenOracleUpdated(token_, oracle_);
    }

    /// @notice Update the default oracle
    function updateDefaultOracle(IOracle defaultOracle_) external onlyGovernor {
        defaultOracle = defaultOracle_;
        emit DefaultOracleUpdated(defaultOracle_);
    }
}

File 2 of 10 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/Address.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = _setInitializedVersion(1);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        bool isTopLevelCall = _setInitializedVersion(version);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(version);
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */
    function _disableInitializers() internal virtual {
        _setInitializedVersion(type(uint8).max);
    }

    function _setInitializedVersion(uint8 version) private returns (bool) {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, and for the lowest level
        // of initializers, because in other contexts the contract may have been reentered.
        if (_initializing) {
            require(
                version == 1 && !Address.isContract(address(this)),
                "Initializable: contract is already initialized"
            );
            return false;
        } else {
            require(_initialized < version, "Initializable: contract is already initialized");
            _initialized = version;
            return true;
        }
    }
}

File 3 of 10 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 4 of 10 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 5 of 10 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 6 of 10 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 7 of 10 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a / b + (a % b == 0 ? 0 : 1);
    }
}

File 8 of 10 : Governable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "../interfaces/IGovernable.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (governor) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the governor account will be the one that deploys the contract. This
 * can later be changed with {transferGovernorship}.
 *
 */
abstract contract Governable is IGovernable, Context, Initializable {
    address public governor;
    address private proposedGovernor;

    event UpdatedGovernor(address indexed previousGovernor, address indexed proposedGovernor);

    /**
     * @dev Initializes the contract setting the deployer as the initial governor.
     */
    constructor() {
        address msgSender = _msgSender();
        governor = msgSender;
        emit UpdatedGovernor(address(0), msgSender);
    }

    /**
     * @dev If inheriting child is using proxy then child contract can use
     * __Governable_init() function to initialization this contract
     */
    // solhint-disable-next-line func-name-mixedcase
    function __Governable_init() internal initializer {
        address msgSender = _msgSender();
        governor = msgSender;
        emit UpdatedGovernor(address(0), msgSender);
    }

    /**
     * @dev Throws if called by any account other than the governor.
     */
    modifier onlyGovernor() {
        require(governor == _msgSender(), "not-governor");
        _;
    }

    /**
     * @dev Transfers governorship of the contract to a new account (`proposedGovernor`).
     * Can only be called by the current owner.
     */
    function transferGovernorship(address _proposedGovernor) external onlyGovernor {
        require(_proposedGovernor != address(0), "proposed-governor-is-zero");
        proposedGovernor = _proposedGovernor;
    }

    /**
     * @dev Allows new governor to accept governorship of the contract.
     */
    function acceptGovernorship() external {
        require(proposedGovernor == _msgSender(), "not-the-proposed-governor");
        emit UpdatedGovernor(governor, proposedGovernor);
        governor = proposedGovernor;
        proposedGovernor = address(0);
    }
}

File 9 of 10 : IGovernable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @notice Governable interface
 */
interface IGovernable {
    function governor() external view returns (address _governor);

    function transferGovernorship(address _proposedGovernor) external;
}

File 10 of 10 : IOracle.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

interface IOracle {
    /**
     * @notice Get USD (or equivalent) price of an asset
     * @param token_ The address of asset
     * @return _priceInUsd The USD price
     */
    function getPriceInUsd(address token_) external view returns (uint256 _priceInUsd);

    /**
     * @notice Get quote
     * @param tokenIn_ The address of assetIn
     * @param tokenOut_ The address of assetOut
     * @param amountIn_ Amount of input token
     * @return _amountOut Amount out
     */
    function quote(
        address tokenIn_,
        address tokenOut_,
        uint256 amountIn_
    ) external view returns (uint256 _amountOut);

    /**
     * @notice Get quote in USD (or equivalent) amount
     * @param token_ The address of assetIn
     * @param amountIn_ Amount of input token.
     * @return amountOut_ Amount in USD
     */
    function quoteTokenToUsd(address token_, uint256 amountIn_) external view returns (uint256 amountOut_);

    /**
     * @notice Get quote from USD (or equivalent) amount to amount of token
     * @param token_ The address of assetOut
     * @param amountIn_ Input amount in USD
     * @return _amountOut Output amount of token
     */
    function quoteUsdToToken(address token_, uint256 amountIn_) external view returns (uint256 _amountOut);
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract IOracle","name":"defaultOracle_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IOracle","name":"defaultOracle","type":"address"}],"name":"DefaultOracleUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"contract IOracle","name":"oracle","type":"address"}],"name":"TokenOracleUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGovernor","type":"address"},{"indexed":true,"internalType":"address","name":"proposedGovernor","type":"address"}],"name":"UpdatedGovernor","type":"event"},{"inputs":[],"name":"acceptGovernorship","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultOracle","outputs":[{"internalType":"contract IOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"}],"name":"getPriceInUsd","outputs":[{"internalType":"uint256","name":"_priceInUsd","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"oracles","outputs":[{"internalType":"contract IOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn_","type":"address"},{"internalType":"address","name":"tokenOut_","type":"address"},{"internalType":"uint256","name":"amountIn_","type":"uint256"}],"name":"quote","outputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"uint256","name":"amountIn_","type":"uint256"}],"name":"quoteTokenToUsd","outputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"uint256","name":"amountIn_","type":"uint256"}],"name":"quoteUsdToToken","outputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_proposedGovernor","type":"address"}],"name":"transferGovernorship","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IOracle","name":"defaultOracle_","type":"address"}],"name":"updateDefaultOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"contract IOracle","name":"oracle_","type":"address"}],"name":"updateTokenOracle","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50604051610cf8380380610cf883398101604081905261002f9161009e565b6000805462010000600160b01b03191633620100008102919091178255604051909182917fd4459d5b8b913cab0244230fd9b1c08b6ceace7fe9230e60d0f74cbffdf849d0908290a350600280546001600160a01b0319166001600160a01b03929092169190911790556100ce565b6000602082840312156100b057600080fd5b81516001600160a01b03811681146100c757600080fd5b9392505050565b610c1b806100dd6000396000f3fe608060405234801561001057600080fd5b50600436106100c95760003560e01c8063addd509911610081578063b6aa515b1161005b578063b6aa515b146101e3578063c1934d9b146101f6578063f3b27bc31461020957600080fd5b8063addd509914610187578063b5e9bef5146101bd578063b6466384146101d057600080fd5b80633e797970116100b25780633e7979701461013f57806380dce169146101545780638d0dba001461017457600080fd5b806307ee40bf146100ce5780630c340a24146100f4575b600080fd5b6100e16100dc366004610968565b610211565b6040519081526020015b60405180910390f35b60005461011a9062010000900473ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100eb565b61015261014d366004610968565b61033f565b005b60025461011a9073ffffffffffffffffffffffffffffffffffffffff1681565b6100e1610182366004610985565b61043b565b61011a610195366004610968565b60036020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6100e16101cb366004610985565b6104ee565b6100e16101de3660046109b1565b610590565b6101526101f1366004610968565b6105b2565b6101526102043660046109f2565b6106fe565b610152610802565b73ffffffffffffffffffffffffffffffffffffffff808216600090815260036020526040812054909116806102eb576002546040517f07ee40bf00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152909116906307ee40bf906024015b60206040518083038186803b1580156102ac57600080fd5b505afa1580156102c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e49190610a2b565b9392505050565b6040517f07ee40bf00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301528216906307ee40bf90602401610294565b60005473ffffffffffffffffffffffffffffffffffffffff620100009091041633146103cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f6e6f742d676f7665726e6f72000000000000000000000000000000000000000060448201526064015b60405180910390fd5b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517f1bc296d82f6c12b9613275344793ebdb1c8ed5dca91d1699898b5c9adf1e997890600090a250565b60008061044784610211565b90508373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561048f57600080fd5b505afa1580156104a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104c79190610a44565b6104d290600a610b7c565b6104dc8285610b8b565b6104e69190610baa565b949350505050565b6000806104fa84610211565b9050808473ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561054357600080fd5b505afa158015610557573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057b9190610a44565b61058690600a610b7c565b6104dc9085610b8b565b60008061059d858461043b565b90506105a984826104ee565b95945050505050565b60005473ffffffffffffffffffffffffffffffffffffffff6201000090910416331461063a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f6e6f742d676f7665726e6f72000000000000000000000000000000000000000060448201526064016103c3565b73ffffffffffffffffffffffffffffffffffffffff81166106b7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f70726f706f7365642d676f7665726e6f722d69732d7a65726f0000000000000060448201526064016103c3565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff62010000909104163314610786576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f6e6f742d676f7665726e6f72000000000000000000000000000000000000000060448201526064016103c3565b73ffffffffffffffffffffffffffffffffffffffff82811660008181526003602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169486169485179055517f38af5c16b8276594303df55e002ec2a4e461e676aa19663bcb1ff9e1823acdf79190a35050565b60015473ffffffffffffffffffffffffffffffffffffffff163314610883576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f6e6f742d7468652d70726f706f7365642d676f7665726e6f720000000000000060448201526064016103c3565b6001546000805460405173ffffffffffffffffffffffffffffffffffffffff9384169362010000909204909116917fd4459d5b8b913cab0244230fd9b1c08b6ceace7fe9230e60d0f74cbffdf849d091a360018054600080547fffffffffffffffffffff0000000000000000000000000000000000000000ffff1673ffffffffffffffffffffffffffffffffffffffff831662010000021790557fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b73ffffffffffffffffffffffffffffffffffffffff8116811461096557600080fd5b50565b60006020828403121561097a57600080fd5b81356102e481610943565b6000806040838503121561099857600080fd5b82356109a381610943565b946020939093013593505050565b6000806000606084860312156109c657600080fd5b83356109d181610943565b925060208401356109e181610943565b929592945050506040919091013590565b60008060408385031215610a0557600080fd5b8235610a1081610943565b91506020830135610a2081610943565b809150509250929050565b600060208284031215610a3d57600080fd5b5051919050565b600060208284031215610a5657600080fd5b815160ff811681146102e457600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600181815b80851115610ad1578160001904821115610ab757610ab7610a67565b80851615610ac457918102915b93841c9390800290610a9b565b509250929050565b600082610ae857506001610b76565b81610af557506000610b76565b8160018114610b0b5760028114610b1557610b31565b6001915050610b76565b60ff841115610b2657610b26610a67565b50506001821b610b76565b5060208310610133831016604e8410600b8410161715610b54575081810a610b76565b610b5e8383610a96565b8060001904821115610b7257610b72610a67565b0290505b92915050565b60006102e460ff841683610ad9565b6000816000190483118215151615610ba557610ba5610a67565b500290565b600082610be0577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50049056fea26469706673582212206595012a5465009227bc27aa49d544cab0dc71409b207e25bd304affa6af8eec64736f6c634300080900330000000000000000000000008e4f0e00904d03b2fa805c2b07c436e7a76110bf

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100c95760003560e01c8063addd509911610081578063b6aa515b1161005b578063b6aa515b146101e3578063c1934d9b146101f6578063f3b27bc31461020957600080fd5b8063addd509914610187578063b5e9bef5146101bd578063b6466384146101d057600080fd5b80633e797970116100b25780633e7979701461013f57806380dce169146101545780638d0dba001461017457600080fd5b806307ee40bf146100ce5780630c340a24146100f4575b600080fd5b6100e16100dc366004610968565b610211565b6040519081526020015b60405180910390f35b60005461011a9062010000900473ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100eb565b61015261014d366004610968565b61033f565b005b60025461011a9073ffffffffffffffffffffffffffffffffffffffff1681565b6100e1610182366004610985565b61043b565b61011a610195366004610968565b60036020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6100e16101cb366004610985565b6104ee565b6100e16101de3660046109b1565b610590565b6101526101f1366004610968565b6105b2565b6101526102043660046109f2565b6106fe565b610152610802565b73ffffffffffffffffffffffffffffffffffffffff808216600090815260036020526040812054909116806102eb576002546040517f07ee40bf00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152909116906307ee40bf906024015b60206040518083038186803b1580156102ac57600080fd5b505afa1580156102c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e49190610a2b565b9392505050565b6040517f07ee40bf00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301528216906307ee40bf90602401610294565b60005473ffffffffffffffffffffffffffffffffffffffff620100009091041633146103cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f6e6f742d676f7665726e6f72000000000000000000000000000000000000000060448201526064015b60405180910390fd5b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517f1bc296d82f6c12b9613275344793ebdb1c8ed5dca91d1699898b5c9adf1e997890600090a250565b60008061044784610211565b90508373ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561048f57600080fd5b505afa1580156104a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104c79190610a44565b6104d290600a610b7c565b6104dc8285610b8b565b6104e69190610baa565b949350505050565b6000806104fa84610211565b9050808473ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561054357600080fd5b505afa158015610557573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057b9190610a44565b61058690600a610b7c565b6104dc9085610b8b565b60008061059d858461043b565b90506105a984826104ee565b95945050505050565b60005473ffffffffffffffffffffffffffffffffffffffff6201000090910416331461063a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f6e6f742d676f7665726e6f72000000000000000000000000000000000000000060448201526064016103c3565b73ffffffffffffffffffffffffffffffffffffffff81166106b7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f70726f706f7365642d676f7665726e6f722d69732d7a65726f0000000000000060448201526064016103c3565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff62010000909104163314610786576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f6e6f742d676f7665726e6f72000000000000000000000000000000000000000060448201526064016103c3565b73ffffffffffffffffffffffffffffffffffffffff82811660008181526003602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169486169485179055517f38af5c16b8276594303df55e002ec2a4e461e676aa19663bcb1ff9e1823acdf79190a35050565b60015473ffffffffffffffffffffffffffffffffffffffff163314610883576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f6e6f742d7468652d70726f706f7365642d676f7665726e6f720000000000000060448201526064016103c3565b6001546000805460405173ffffffffffffffffffffffffffffffffffffffff9384169362010000909204909116917fd4459d5b8b913cab0244230fd9b1c08b6ceace7fe9230e60d0f74cbffdf849d091a360018054600080547fffffffffffffffffffff0000000000000000000000000000000000000000ffff1673ffffffffffffffffffffffffffffffffffffffff831662010000021790557fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b73ffffffffffffffffffffffffffffffffffffffff8116811461096557600080fd5b50565b60006020828403121561097a57600080fd5b81356102e481610943565b6000806040838503121561099857600080fd5b82356109a381610943565b946020939093013593505050565b6000806000606084860312156109c657600080fd5b83356109d181610943565b925060208401356109e181610943565b929592945050506040919091013590565b60008060408385031215610a0557600080fd5b8235610a1081610943565b91506020830135610a2081610943565b809150509250929050565b600060208284031215610a3d57600080fd5b5051919050565b600060208284031215610a5657600080fd5b815160ff811681146102e457600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600181815b80851115610ad1578160001904821115610ab757610ab7610a67565b80851615610ac457918102915b93841c9390800290610a9b565b509250929050565b600082610ae857506001610b76565b81610af557506000610b76565b8160018114610b0b5760028114610b1557610b31565b6001915050610b76565b60ff841115610b2657610b26610a67565b50506001821b610b76565b5060208310610133831016604e8410600b8410161715610b54575081810a610b76565b610b5e8383610a96565b8060001904821115610b7257610b72610a67565b0290505b92915050565b60006102e460ff841683610ad9565b6000816000190483118215151615610ba557610ba5610a67565b500290565b600082610be0577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50049056fea26469706673582212206595012a5465009227bc27aa49d544cab0dc71409b207e25bd304affa6af8eec64736f6c63430008090033

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

0000000000000000000000008e4f0e00904d03b2fa805c2b07c436e7a76110bf

-----Decoded View---------------
Arg [0] : defaultOracle_ (address): 0x8e4F0E00904D03b2FA805c2B07C436E7A76110Bf

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000008e4f0e00904d03b2fa805c2b07c436e7a76110bf


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ 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.