Goerli Testnet

Contract

0xf3A31679d22D0C320ca56f8E4bcE2274e34BF93A

Overview

ETH Balance

0 ETH

Multi Chain

Multichain Addresses

N/A
Transaction Hash
Method
Block
From
To
Value
0x6080604086933862023-03-21 13:30:48188 days 7 hrs ago1679405448IN
 Contract Creation
0 ETH0.2423912200

Latest 1 internal transaction

Advanced mode:
Parent Txn Hash Block From To Value
86933872023-03-21 13:31:00188 days 7 hrs ago1679405460
0xf3A316...e34BF93A
0 ETH
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x7AbE1b...0055708a
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
ReserveOracle

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 8 : ReserveOracle.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;

import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {IReserveOracleGetter} from "../interfaces/IReserveOracleGetter.sol";
import {BlockContext} from "../utils/BlockContext.sol";

contract ReserveOracle is IReserveOracleGetter, OwnableUpgradeable, BlockContext {
  uint256 private constant TOKEN_DIGIT = 10**18;

  event AggregatorAdded(address currencyKey, address aggregator);
  event AggregatorRemoved(address currencyKey, address aggregator);

  // key by currency symbol, eg USDT
  mapping(address => AggregatorV3Interface) public priceFeedMap;
  address[] public priceFeedKeys;

  address public weth;

  function initialize(address _weth) public initializer {
    __Ownable_init();
    weth = _weth;
  }

  /**
   * @notice sets the aggregators and pricefeedkeys
   * @param _priceFeedKeys the array of pricefeed keys
   * @param _aggregators the array of aggregators
   **/
  function setAggregators(address[] calldata _priceFeedKeys, address[] calldata _aggregators) external onlyOwner {
    uint256 priceFeedKeysLength = _priceFeedKeys.length;
    require(priceFeedKeysLength == _aggregators.length, "ReserveOracle: INCONSISTENT_PARAMS_LENGTH");
    for (uint256 i = 0; i < priceFeedKeysLength; ) {
      _addAggregator(_priceFeedKeys[i], _aggregators[i]);

      unchecked {
        ++i;
      }
    }
  }

  /**
   * @notice adds a single aggregator
   * @param _priceFeedKey the pricefeed key
   * @param _aggregator the aggregator to add
   **/
  function addAggregator(address _priceFeedKey, address _aggregator) external onlyOwner {
    _addAggregator(_priceFeedKey, _aggregator);
  }

  /**
   * @notice adds a single aggregator
   * @param _priceFeedKey the pricefeed key
   * @param _aggregator the aggregator to add
   **/
  function _addAggregator(address _priceFeedKey, address _aggregator) internal {
    requireNonEmptyAddress(_priceFeedKey);
    requireNonEmptyAddress(_aggregator);
    if (address(priceFeedMap[_priceFeedKey]) == address(0)) {
      priceFeedKeys.push(_priceFeedKey);
    }
    priceFeedMap[_priceFeedKey] = AggregatorV3Interface(_aggregator);
    emit AggregatorAdded(_priceFeedKey, address(_aggregator));
  }

  /**
   * @notice removes a single aggregator
   * @param _priceFeedKey the pricefeed key of the aggregator to remove
   **/
  function removeAggregator(address _priceFeedKey) external onlyOwner {
    address aggregator = address(priceFeedMap[_priceFeedKey]);
    requireNonEmptyAddress(aggregator);
    delete priceFeedMap[_priceFeedKey];

    uint256 length = priceFeedKeys.length;
    for (uint256 i = 0; i < length; ) {
      if (priceFeedKeys[i] == _priceFeedKey) {
        // if the removal item is the last one, just `pop`
        if (i != length - 1) {
          priceFeedKeys[i] = priceFeedKeys[length - 1];
        }
        priceFeedKeys.pop();
        emit AggregatorRemoved(_priceFeedKey, aggregator);
        break;
      }

      unchecked {
        ++i;
      }
    }
  }

  /**
   * @notice returns an aggregator gicen a pricefeed key
   * @param _priceFeedKey the pricefeed key of the aggregator to fetch
   **/
  function getAggregator(address _priceFeedKey) public view returns (AggregatorV3Interface) {
    return priceFeedMap[_priceFeedKey];
  }

  /**
   * @inheritdoc IReserveOracleGetter
   */
  function getAssetPrice(address _priceFeedKey) external view override returns (uint256) {
    if (_priceFeedKey == weth) {
      return 1 ether;
    }
    require(isExistedKey(_priceFeedKey), "ReserveOracle: key not existed");
    AggregatorV3Interface aggregator = getAggregator(_priceFeedKey);

    (, int256 _price, , , ) = aggregator.latestRoundData();
    require(_price >= 0, "ReserveOracle: negative answer");
    uint8 decimals = aggregator.decimals();

    return formatDecimals(uint256(_price), decimals);
  }

  /**
   * @notice returns the aggregator's latest timestamp
   * @param _priceFeedKey the pricefeed key of the aggregator to fetch
   **/
  function getLatestTimestamp(address _priceFeedKey) public view returns (uint256) {
    AggregatorV3Interface aggregator = getAggregator(_priceFeedKey);
    requireNonEmptyAddress(address(aggregator));

    (, , , uint256 timestamp, ) = aggregator.latestRoundData();

    return timestamp;
  }

  /**
   * @inheritdoc IReserveOracleGetter
   */
  function getTwapPrice(address _priceFeedKey, uint256 _interval) external view override returns (uint256) {
    require(isExistedKey(_priceFeedKey), "ReserveOracle: key not existed");
    require(_interval != 0, "ReserveOracle: interval can't be 0");

    AggregatorV3Interface aggregator = getAggregator(_priceFeedKey);
    (uint80 roundId, int256 _price, , uint256 timestamp, ) = aggregator.latestRoundData();
    require(_price >= 0, "ReserveOracle: negative answer");
    uint8 decimals = aggregator.decimals();

    uint256 latestPrice = formatDecimals(uint256(_price), decimals);

    require(roundId >= 0, "ReserveOracle: Not enough history");
    uint256 latestTimestamp = timestamp;
    uint256 baseTimestamp = _blockTimestamp() - _interval;
    // if latest updated timestamp is earlier than target timestamp, return the latest price.
    if (latestTimestamp < baseTimestamp || roundId == 0) {
      return latestPrice;
    }

    // rounds are like snapshots, latestRound means the latest price snapshot. follow chainlink naming
    uint256 cumulativeTime = _blockTimestamp() - latestTimestamp;
    uint256 previousTimestamp = latestTimestamp;
    uint256 weightedPrice = latestPrice * cumulativeTime;
    while (true) {
      if (roundId == 0) {
        // if cumulative time is less than requested interval, return current twap price
        return weightedPrice / cumulativeTime;
      }

      roundId = roundId - 1;
      // get current round timestamp and price
      (, int256 _priceTemp, , uint256 currentTimestamp, ) = aggregator.getRoundData(roundId);
      require(_priceTemp >= 0, "ReserveOracle: negative answer");

      uint256 price = formatDecimals(uint256(_priceTemp), decimals);

      // check if current round timestamp is earlier than target timestamp
      if (currentTimestamp <= baseTimestamp) {
        // weighted time period will be (target timestamp - previous timestamp). For example,
        // now is 1000, _interval is 100, then target timestamp is 900. If timestamp of current round is 970,
        // and timestamp of NEXT round is 880, then the weighted time period will be (970 - 900) = 70,
        // instead of (970 - 880)
        weightedPrice = weightedPrice + (price * (previousTimestamp - baseTimestamp));
        break;
      }

      uint256 timeFraction = previousTimestamp - currentTimestamp;
      weightedPrice = weightedPrice + (price * timeFraction);
      cumulativeTime = cumulativeTime + timeFraction;
      previousTimestamp = currentTimestamp;
    }
    return weightedPrice / _interval;
  }

  /**
   * @notice checks if a pricefeed key exists
   * @param _priceFeedKey the pricefeed key to check
   **/
  function isExistedKey(address _priceFeedKey) private view returns (bool) {
    uint256 length = priceFeedKeys.length;
    for (uint256 i = 0; i < length; ) {
      if (priceFeedKeys[i] == _priceFeedKey) {
        return true;
      }

      unchecked {
        ++i;
      }
    }
    return false;
  }

  /**
   * @notice checks if an address is 0
   * @param _addr the address to check
   **/
  function requireNonEmptyAddress(address _addr) internal pure {
    require(_addr != address(0), "ReserveOracle: empty address");
  }

  /**
   * @notice formats a price to the given decimals
   * @param _price the price to format
   * @param _decimals the decimals to format the price to
   **/
  function formatDecimals(uint256 _price, uint8 _decimals) internal pure returns (uint256) {
    return (_price * TOKEN_DIGIT) / (10**uint256(_decimals));
  }

  /**
   * @notice returns the price feed length
   **/
  function getPriceFeedLength() public view returns (uint256 length) {
    return priceFeedKeys.length;
  }
}

File 2 of 8 : AggregatorV3Interface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

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

  function version() external view returns (uint256);

  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 3 of 8 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
    uint256[49] private __gap;
}

File 4 of 8 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "../../utils/AddressUpgradeable.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 a proxied contract can't have 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.
 *
 * 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 initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // 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, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

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

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 5 of 8 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 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 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 8 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @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 ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
        __Context_init_unchained();
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 7 of 8 : IReserveOracleGetter.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;

/************
@title IReserveOracleGetter interface
@notice Interface for getting Reserve price oracle.*/
interface IReserveOracleGetter {
  /* CAUTION: Price uint is ETH based (WEI, 18 decimals) */
  /***********
    @dev returns the asset price in ETH
     */
  function getAssetPrice(address asset) external view returns (uint256);

  // get twap price depending on _period
  function getTwapPrice(address _priceFeedKey, uint256 _interval) external view returns (uint256);
}

File 8 of 8 : BlockContext.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;

// wrap block.xxx functions for testing
// only support timestamp and number so far
abstract contract BlockContext {
  //◥◤◥◤◥◤◥◤◥◤◥◤◥◤◥◤ add state variables below ◥◤◥◤◥◤◥◤◥◤◥◤◥◤◥◤//

  //◢◣◢◣◢◣◢◣◢◣◢◣◢◣◢◣ add state variables above ◢◣◢◣◢◣◢◣◢◣◢◣◢◣◢◣//
  uint256[50] private __gap;

  function _blockTimestamp() internal view virtual returns (uint256) {
    return block.timestamp;
  }

  function _blockNumber() internal view virtual returns (uint256) {
    return block.number;
  }
}

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

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"currencyKey","type":"address"},{"indexed":false,"internalType":"address","name":"aggregator","type":"address"}],"name":"AggregatorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"currencyKey","type":"address"},{"indexed":false,"internalType":"address","name":"aggregator","type":"address"}],"name":"AggregatorRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"_priceFeedKey","type":"address"},{"internalType":"address","name":"_aggregator","type":"address"}],"name":"addAggregator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_priceFeedKey","type":"address"}],"name":"getAggregator","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_priceFeedKey","type":"address"}],"name":"getAssetPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_priceFeedKey","type":"address"}],"name":"getLatestTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPriceFeedLength","outputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_priceFeedKey","type":"address"},{"internalType":"uint256","name":"_interval","type":"uint256"}],"name":"getTwapPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_weth","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"priceFeedKeys","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"priceFeedMap","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_priceFeedKey","type":"address"}],"name":"removeAggregator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_priceFeedKeys","type":"address[]"},{"internalType":"address[]","name":"_aggregators","type":"address[]"}],"name":"setAggregators","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100f55760003560e01c8063521173c111610097578063b3596f0711610066578063b3596f071461020f578063c4d66de814610222578063eedf6a4f14610235578063f2fde38b1461024857600080fd5b8063521173c1146101d0578063715018a6146101e35780638c651f11146101eb5780638da5cb5b146101fe57600080fd5b80633fc8cef3116100d35780633fc8cef31461016b57806341a6990f1461017e5780634238dc471461019f5780634cea5ee8146101c857600080fd5b806329a42d56146100fa5780632a0ab1dd146101435780633f9fb50514610156575b600080fd5b61012661010836600461110b565b6001600160a01b039081166000908152609760205260409020541690565b6040516001600160a01b0390911681526020015b60405180910390f35b6101266101513660046111e9565b61025b565b610169610164366004611180565b610285565b005b609954610126906001600160a01b031681565b61019161018c36600461110b565b6103a7565b60405190815260200161013a565b6101266101ad36600461110b565b6097602052600090815260409020546001600160a01b031681565b609854610191565b6101696101de366004611125565b610456565b61016961048e565b6101696101f936600461110b565b6104c4565b6033546001600160a01b0316610126565b61019161021d36600461110b565b6106d3565b61016961023036600461110b565b610891565b610191610243366004611157565b61096d565b61016961025636600461110b565b610d30565b6098818154811061026b57600080fd5b6000918252602090912001546001600160a01b0316905081565b6033546001600160a01b031633146102b85760405162461bcd60e51b81526004016102af906112a8565b60405180910390fd5b8281811461031a5760405162461bcd60e51b815260206004820152602960248201527f526573657276654f7261636c653a20494e434f4e53495354454e545f5041524160448201526809aa6be988a9c8ea8960bb1b60648201526084016102af565b60005b8181101561039f5761039786868381811061034857634e487b7160e01b600052603260045260246000fd5b905060200201602081019061035d919061110b565b85858481811061037d57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610392919061110b565b610dcb565b60010161031d565b505050505050565b6000806103cc836001600160a01b039081166000908152609760205260409020541690565b90506103d781610eb3565b6000816001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561041257600080fd5b505afa158015610426573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044a9190611201565b50979650505050505050565b6033546001600160a01b031633146104805760405162461bcd60e51b81526004016102af906112a8565b61048a8282610dcb565b5050565b6033546001600160a01b031633146104b85760405162461bcd60e51b81526004016102af906112a8565b6104c26000610f09565b565b6033546001600160a01b031633146104ee5760405162461bcd60e51b81526004016102af906112a8565b6001600160a01b038082166000908152609760205260409020541661051281610eb3565b6001600160a01b038216600090815260976020526040812080546001600160a01b0319169055609854905b818110156106cd57836001600160a01b03166098828154811061057057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156106c55761059660018361146a565b81146106305760986105a960018461146a565b815481106105c757634e487b7160e01b600052603260045260246000fd5b600091825260209091200154609880546001600160a01b03909216918390811061060157634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b609880548061064f57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190556040517f7c1eef80e148cc5d7cff87f7f44e7427da8a0147543936730af0a5e447c4bc0d906106b890869086906001600160a01b0392831681529116602082015260400190565b60405180910390a16106cd565b60010161053d565b50505050565b6099546000906001600160a01b03838116911614156106fb5750670de0b6b3a7640000919050565b61070482610f5b565b6107505760405162461bcd60e51b815260206004820152601e60248201527f526573657276654f7261636c653a206b6579206e6f742065786973746564000060448201526064016102af565b6001600160a01b0380831660009081526097602052604081205490911690506000816001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b1580156107aa57600080fd5b505afa1580156107be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e29190611201565b50505091505060008112156108095760405162461bcd60e51b81526004016102af90611271565b6000826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561084457600080fd5b505afa158015610858573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061087c9190611250565b90506108888282610fcd565b95945050505050565b600054610100900460ff166108ac5760005460ff16156108b0565b303b155b6109135760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016102af565b600054610100900460ff16158015610935576000805461ffff19166101011790555b61093d611000565b609980546001600160a01b0319166001600160a01b038416179055801561048a576000805461ff00191690555050565b600061097883610f5b565b6109c45760405162461bcd60e51b815260206004820152601e60248201527f526573657276654f7261636c653a206b6579206e6f742065786973746564000060448201526064016102af565b81610a1c5760405162461bcd60e51b815260206004820152602260248201527f526573657276654f7261636c653a20696e74657276616c2063616e2774206265604482015261020360f41b60648201526084016102af565b6001600160a01b0380841660009081526097602052604081205490911690506000806000836001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015610a7957600080fd5b505afa158015610a8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab19190611201565b50935050925092506000821215610ada5760405162461bcd60e51b81526004016102af90611271565b6000846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610b1557600080fd5b505afa158015610b29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4d9190611250565b90506000610b5b8483610fcd565b9050826000610b6a8a4261146a565b905080821080610b8157506001600160501b038716155b15610b96578298505050505050505050610d2a565b6000610ba2834261146a565b9050826000610bb1838761144b565b90505b6001600160501b038a16610bde57610bcc8382611340565b9b505050505050505050505050610d2a565b610be960018b611481565b604051639a6fc8f560e01b81526001600160501b0382166004820152909a5060009081906001600160a01b038e1690639a6fc8f59060240160a06040518083038186803b158015610c3957600080fd5b505afa158015610c4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c719190611201565b509350509250506000821215610c995760405162461bcd60e51b81526004016102af90611271565b6000610ca5838b610fcd565b9050868211610cd657610cb8878661146a565b610cc2908261144b565b610ccc9085611328565b9350505050610d12565b6000610ce2838761146a565b9050610cee818361144b565b610cf89086611328565b9450610d048188611328565b965082955050505050610bb4565b610d1c8d82611340565b9b5050505050505050505050505b92915050565b6033546001600160a01b03163314610d5a5760405162461bcd60e51b81526004016102af906112a8565b6001600160a01b038116610dbf5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102af565b610dc881610f09565b50565b610dd482610eb3565b610ddd81610eb3565b6001600160a01b0382811660009081526097602052604090205416610e4857609880546001810182556000919091527f2237a976fa961f5921fd19f2b03c925c725d77b20ce8f790c19709c03de4d8140180546001600160a01b0319166001600160a01b0384161790555b6001600160a01b0382811660008181526097602090815260409182902080546001600160a01b031916948616948517905581519283528201929092527fd0fba1bf19483034d35babed2c54b89fb8cbe1fac33ac43b2a36d81be7c91e79910160405180910390a15050565b6001600160a01b038116610dc85760405162461bcd60e51b815260206004820152601c60248201527f526573657276654f7261636c653a20656d70747920616464726573730000000060448201526064016102af565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b609854600090815b81811015610fc357836001600160a01b031660988281548110610f9657634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03161415610fbb575060019392505050565b600101610f63565b5060009392505050565b6000610fdd60ff8316600a6113a3565b610fef670de0b6b3a76400008561144b565b610ff99190611340565b9392505050565b600054610100900460ff166110275760405162461bcd60e51b81526004016102af906112dd565b61102f611037565b6104c261105e565b600054610100900460ff166104c25760405162461bcd60e51b81526004016102af906112dd565b600054610100900460ff166110855760405162461bcd60e51b81526004016102af906112dd565b6104c233610f09565b80356001600160a01b03811681146110a557600080fd5b919050565b60008083601f8401126110bb578182fd5b50813567ffffffffffffffff8111156110d2578182fd5b6020830191508360208260051b85010111156110ed57600080fd5b9250929050565b80516001600160501b03811681146110a557600080fd5b60006020828403121561111c578081fd5b610ff98261108e565b60008060408385031215611137578081fd5b6111408361108e565b915061114e6020840161108e565b90509250929050565b60008060408385031215611169578182fd5b6111728361108e565b946020939093013593505050565b60008060008060408587031215611195578182fd5b843567ffffffffffffffff808211156111ac578384fd5b6111b8888389016110aa565b909650945060208701359150808211156111d0578384fd5b506111dd878288016110aa565b95989497509550505050565b6000602082840312156111fa578081fd5b5035919050565b600080600080600060a08688031215611218578081fd5b611221866110f4565b9450602086015193506040860151925060608601519150611244608087016110f4565b90509295509295909350565b600060208284031215611261578081fd5b815160ff81168114610ff9578182fd5b6020808252601e908201527f526573657276654f7261636c653a206e6567617469766520616e737765720000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000821982111561133b5761133b6114a9565b500190565b60008261135b57634e487b7160e01b81526012600452602481fd5b500490565b600181815b8085111561139b578160001904821115611381576113816114a9565b8085161561138e57918102915b93841c9390800290611365565b509250929050565b6000610ff983836000826113b957506001610d2a565b816113c657506000610d2a565b81600181146113dc57600281146113e657611402565b6001915050610d2a565b60ff8411156113f7576113f76114a9565b50506001821b610d2a565b5060208310610133831016604e8410600b8410161715611425575081810a610d2a565b61142f8383611360565b8060001904821115611443576114436114a9565b029392505050565b6000816000190483118215151615611465576114656114a9565b500290565b60008282101561147c5761147c6114a9565b500390565b60006001600160501b03838116908316818110156114a1576114a16114a9565b039392505050565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220faf861ed6ad34989e6e2b1d7936f41827ffcd6fd3841708de36ea6f19bc1cf2464736f6c63430008040033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ 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.