ETH Price: $2,472.77 (+0.74%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Set Sequential P...119248192021-02-25 6:57:431347 days ago1614236263IN
0xBCF720D5...e45fE290f
0 ETH0.15370474113
0x61014060119247302021-02-25 6:39:141347 days ago1614235154IN
 Create: RegularIntervalOracle
0 ETH0.22516434180

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RegularIntervalOracle

Compiler Version
v0.7.1+commit.f4a555be

Optimization Enabled:
Yes with 200 runs

Other Settings:
constantinople EvmVersion, None license

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2021-02-25
*/

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.1;

// File: contracts/oracle/RegularIntervalOracleInterface.sol




/**
 * @dev Interface of the regular interval price oracle.
 */
interface RegularIntervalOracleInterface {
  function setPrice(uint256 roundId) external returns (bool);

  function setOptimizedParameters(uint16 lambdaE4) external returns (bool);

  function updateQuantsAddress(address quantsAddress) external returns (bool);

  function getNormalizedTimeStamp(uint256 timestamp)
    external
    view
    returns (uint256);

  function getDecimals() external view returns (uint8);

  function getInterval() external view returns (uint256);

  function getLatestTimestamp() external view returns (uint256);

  function getOldestTimestamp() external view returns (uint256);

  function getVolatility() external view returns (uint256 volE8);

  function getInfo() external view returns (address chainlink, address quants);

  function getPrice() external view returns (uint256);

  function setSequentialPrices(uint256[] calldata roundIds)
    external
    returns (bool);

  function getPriceTimeOf(uint256 unixtime) external view returns (uint256);

  function getVolatilityTimeOf(uint256 unixtime)
    external
    view
    returns (uint256 volE8);

  function getCurrentParameters()
    external
    view
    returns (uint16 lambdaE4, uint16 dataNum);

  function getVolatility(uint64 untilMaturity)
    external
    view
    returns (uint64 volatilityE8);
}

// File: contracts/ChainLinkAggregator/ChainLinkAggregatorInterface.sol




// https://github.com/smartcontractkit/chainlink/blob/feature/whitelisted-interface/evm-contracts/src/v0.6/interfaces/AggregatorV3Interface.sol
// https://github.com/smartcontractkit/chainlink/blob/feature/whitelisted-interface/evm-contracts/src/v0.6/interfaces/AggregatorInterface.sol
interface AggregatorInterface {
  function latestAnswer() external view returns (int256);

  function latestTimestamp() external view returns (uint256);

  function latestRound() external view returns (uint256);

  function getAnswer(uint256 roundId) external view returns (int256);

  function getTimestamp(uint256 roundId) external view returns (uint256);

  function decimals() external view returns (uint8);

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

// File: @openzeppelin/contracts/utils/SafeCast.sol






/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCast {

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128) {
        require(value >= -2**127 && value < 2**127, "SafeCast: value doesn\'t fit in 128 bits");
        return int128(value);
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64) {
        require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits");
        return int64(value);
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32) {
        require(value >= -2**31 && value < 2**31, "SafeCast: value doesn\'t fit in 32 bits");
        return int32(value);
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16) {
        require(value >= -2**15 && value < 2**15, "SafeCast: value doesn\'t fit in 16 bits");
        return int16(value);
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8) {
        require(value >= -2**7 && value < 2**7, "SafeCast: value doesn\'t fit in 8 bits");
        return int8(value);
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        require(value < 2**255, "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

// File: @openzeppelin/contracts/math/SafeMath.sol





/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

// File: contracts/oracle/RegularIntervalOracle.sol








/**
 * @dev Record chainlink price once a day
 */
contract RegularIntervalOracle is RegularIntervalOracleInterface {
  using SafeCast for uint16;
  using SafeCast for uint32;
  using SafeCast for uint256;
  using SafeMath for uint256;

  struct PriceData {
    uint64 priceE8;
    uint64 ewmaVolatilityE8;
  }

  // Max ETH Price = $1 million per ETH
  int256 constant MAX_VALID_ETHPRICE = 10**14;

  /* ========== CONSTANT VARIABLES ========== */
  AggregatorInterface immutable internal _chainlinkOracle;
  uint256 immutable internal _interval;
  uint8 immutable internal _decimals;
  uint128 immutable internal _timeCorrectionFactor;
  uint128 immutable internal _oldestTimestamp;
  uint16 immutable internal _dataNum;

  /* ========== STATE VARIABLES ========== */
  address internal _quantsAddress;
  uint256 internal _latestTimestamp;
  mapping(uint256 => PriceData) internal _regularIntervalPriceData;
  uint16 internal lambdaE4;

  event LambdaChanged(uint16 newLambda);
  event QuantsChanged(address newQuantsAddress);

  /* ========== CONSTRUCTOR ========== */

  /**
   * @param quantsAddress can set optimized parameters
   * @param chainlinkOracleAddress Chainlink price oracle
   * @param startTimestamp Recording timestamp is startTimestamp +- n * interval
   * @param interval Daily record = 3600*24
   * @param decimals Decimals of price
   */
  constructor(
    uint8 decimals,
    uint16 initialLambdaE4,
    uint16 initialDataNum,
    uint32 initialVolE4,
    address quantsAddress,
    address chainlinkOracleAddress,
    uint256 startTimestamp,
    uint256 interval,
    uint256 initialRoundId
  ) {
    _dataNum = initialDataNum;
    lambdaE4 = initialLambdaE4;
    _quantsAddress = quantsAddress;
    _chainlinkOracle = AggregatorInterface(chainlinkOracleAddress);
    _interval = interval;
    _decimals = decimals;
    _timeCorrectionFactor = uint128(startTimestamp % interval);
    initialRoundId = _getValidRoundIDWithAggregator(initialRoundId, startTimestamp, AggregatorInterface(chainlinkOracleAddress));
    int256 priceE8 = _getPriceFromChainlinkWithAggregator(initialRoundId, AggregatorInterface(chainlinkOracleAddress));
    _regularIntervalPriceData[startTimestamp] = PriceData(
      uint256(priceE8).toUint64(),
      uint64(initialVolE4)
    );
    _latestTimestamp = uint128(startTimestamp);
    _oldestTimestamp = uint128(startTimestamp);
    require(initialDataNum > 1, "Error: Decimals should be more than 0");
    require(quantsAddress != address(0), "Error: Invalid initial quant address");
    require(chainlinkOracleAddress != address(0), "Error: Invalid chainlink address");
    require(interval != 0, "Error: Interval should be more than 0");
  }

  /* ========== MUTABLE FUNCTIONS ========== */

  /**
   * @notice Set new price
   * @dev Prices must be updated by regular interval
   * @param roundId is chainlink roundId
   */
  function setPrice(uint256 roundId) public override returns (bool) {
    _latestTimestamp += _interval;
    require(_latestTimestamp <= block.timestamp, "Error: This function should be after interval");
    //If next oldestTimestamp == _latestTimestamp

    roundId = _getValidRoundID(roundId, _latestTimestamp);
    _setPrice(roundId, _latestTimestamp);
    return true;
  }

  /**
   * @notice Set sequential prices
   * @param roundIds Array of roundIds which contain the first timestamp after the regular interval timestamp
   */
  function setSequentialPrices(uint256[] calldata roundIds)
    external
    override
    returns (bool)
  {
    uint256 roundIdsLength = roundIds.length;
    uint256 normalizedCurrentTimestamp =
      getNormalizedTimeStamp(block.timestamp);
    require(_latestTimestamp <= normalizedCurrentTimestamp, "Error: This function should be after interval");
    // If length of roundIds is too short or too long, return false
    if (
      (normalizedCurrentTimestamp - _latestTimestamp) / _interval <
      roundIdsLength ||
      roundIdsLength < 2
    ) {
      return false;
    }

    for (uint256 i = 0; i < roundIdsLength; i++) {
      setPrice(roundIds[i]);
    }
    return true;
  }

  /**
   * @notice Set optimized parameters for EWMA only by quants address
   * Recalculate latest Volatility with new lambda
   * Recalculation starts from price at `latestTimestamp - _dataNum * _interval`
   */
  function setOptimizedParameters(uint16 newLambdaE4)
    external
    override
    onlyQuants
    returns (bool)
  {
    
    require(
      newLambdaE4 > 9000 && newLambdaE4 < 10000,
      "new lambda is out of valid range"
    );
    require(
      (_latestTimestamp - _oldestTimestamp) / _interval > _dataNum,
      "Error: Insufficient number of data registered"
    );
    lambdaE4 = newLambdaE4;
    uint256 oldTimestamp = _latestTimestamp - _dataNum * _interval;
    uint256 pNew = _getPrice(oldTimestamp + _interval);
    uint256 updatedVol = _getVolatility(oldTimestamp);
    for (uint256 i = 0; i < _dataNum; i++) {
      updatedVol = _getEwmaVolatility(oldTimestamp, pNew, updatedVol);
      oldTimestamp += _interval;
      pNew = _getPrice(oldTimestamp + _interval);
    }

    _regularIntervalPriceData[_latestTimestamp].ewmaVolatilityE8 = updatedVol
      .toUint64();
    emit LambdaChanged(newLambdaE4);
    return true;
  }

  /**
   * @notice Update quants address only by quants address
   */
  function updateQuantsAddress(address quantsAddress)
    external
    override
    onlyQuants
    returns (bool)
  {
    _quantsAddress = quantsAddress;
    require(quantsAddress != address(0), "Error: Invalid new quant address");
    emit QuantsChanged(quantsAddress);
  }

  /* ========== MODIFIERS ========== */

  modifier onlyQuants() {
    require(msg.sender == _quantsAddress, "only quants address can call");
    _;
  }

  /* ========== INTERNAL FUNCTIONS ========== */

  /**
   * @return price at the `unixtime`
   */
  function _getPrice(uint256 unixtime) internal view returns (uint256) {
    return _regularIntervalPriceData[unixtime].priceE8;
  }

  /**
   * @return Volatility at the `unixtime`
   */
  function _getVolatility(uint256 unixtime) internal view returns (uint256) {
    return _regularIntervalPriceData[unixtime].ewmaVolatilityE8;
  }

  /**
   * @notice Get annualized ewma volatility.
   * @param oldTimestamp is the previous term to calculate volatility
   */
  function _getEwmaVolatility(
    uint256 oldTimestamp,
    uint256 pNew,
    uint256 oldVolE8
  ) internal view returns (uint256 volE8) {
    uint256 pOld = _getPrice(oldTimestamp);
    uint256 rrE8 =
      pNew >= pOld
        ? ((pNew * (10**4)) / pOld - (10**4))**2
        : ((10**4) - (pNew * (10**4)) / pOld)**2;
    uint256 vol_2E16 =
      (oldVolE8**2 * lambdaE4) / 10**4 + (10**4 - lambdaE4) * rrE8 * 10**4;
    volE8 = _sqrt(vol_2E16);
  }

  /**
   * @dev Calcurate an approximation of the square root of x by Babylonian method.
   */
  function _sqrt(uint256 x) internal pure returns (uint256 y) { 
    if (x > 3) {
      uint z = x / 2 + 1; y = x;
      while (z < y) {
        y = z;
        z = (x / z + z) / 2; 
      }
    } else if (x != 0) { 
      y = 1;
    } 
  }

  function _getValidRoundID(uint256 hintID, uint256 targetTimeStamp)
    internal
    view
    returns (uint256 roundID)
  {
    return _getValidRoundIDWithAggregator(hintID, targetTimeStamp, _chainlinkOracle);
  }

  function _getValidRoundIDWithAggregator(uint256 hintID, uint256 targetTimeStamp, AggregatorInterface _chainlinkAggregator)
    internal
    view
    returns (uint256 roundID)
  {
    if (hintID == 0) {
      hintID = _chainlinkAggregator.latestRound();
    }
    uint256 timeStampOfHintID = _chainlinkAggregator.getTimestamp(hintID);
    require(
      timeStampOfHintID >= targetTimeStamp,
      "Hint round or Latest round should be registered after target time"
    );
    require(hintID != 0, "Invalid hint ID");
    for (uint256 index = hintID - 1; index > 0; index--) {
      uint256 timestamp = _chainlinkAggregator.getTimestamp(index);
      if (timestamp != 0 && timestamp <= targetTimeStamp) {
        return index + 1;
      }
    }
    require(false, "No valid round ID found");
  }

  function _setPrice(uint256 roundId, uint256 timeStamp) internal {
    int256 priceE8 = _getPriceFromChainlink(roundId);
    require(priceE8 > 0, "Should return valid price");
    uint256 ewmaVolatilityE8 =
      _getEwmaVolatility(
        timeStamp - _interval,
        uint256(priceE8),
        _getVolatility(timeStamp - _interval)
      );
    _regularIntervalPriceData[timeStamp] = PriceData(
      uint256(priceE8).toUint64(),
      ewmaVolatilityE8.toUint64()
    );
  }

   function _getPriceFromChainlink(uint256 roundId)
    internal
    view
    returns (int256 priceE8) {
      return _getPriceFromChainlinkWithAggregator(roundId, _chainlinkOracle);
    }


  function _getPriceFromChainlinkWithAggregator(uint256 roundId, AggregatorInterface _chainlinkAggregator)
    internal
    view
    returns (int256 priceE8)
  {
    while (true) {
      priceE8 = _chainlinkAggregator.getAnswer(roundId);
      if (priceE8 > 0 &&  priceE8 < MAX_VALID_ETHPRICE ) {
        break;
      }
      roundId -= 1;
    }
  }

  /* ========== CALL FUNCTIONS ========== */

  /**
   * @notice Calculate normalized timestamp to get valid value
   */
  function getNormalizedTimeStamp(uint256 timestamp)
    public
    view
    override
    returns (uint256)
  {
    return
      ((timestamp.sub(_timeCorrectionFactor)) / _interval) *
      _interval +
      _timeCorrectionFactor;
  }

  function getInfo()
    external
    view
    override
    returns (address chainlink, address quants)
  {
    return (address(_chainlinkOracle), _quantsAddress);
  }

  /**
   * @return Decimals of price
   */
  function getDecimals() external view override returns (uint8) {
    return _decimals;
  }

  /**
   * @return Interval of historical data
   */
  function getInterval() external view override returns (uint256) {
    return _interval;
  }

  /**
   * @return Latest timestamp in this oracle
   */
  function getLatestTimestamp() external view override returns (uint256) {
    return _latestTimestamp;
  }

  /**
   * @return Oldest timestamp in this oracle
   */
  function getOldestTimestamp() external view override returns (uint256) {
    return _oldestTimestamp;
  }

  function getPrice() external view override returns (uint256) {
    return _getPrice(_latestTimestamp);
  }

  function getCurrentParameters()
    external
    view
    override
    returns (uint16 lambda, uint16 dataNum)
  {
    return (lambdaE4, _dataNum);
  }

  function getPriceTimeOf(uint256 unixtime)
    external
    view
    override
    returns (uint256)
  {
    uint256 normalizedUnixtime = getNormalizedTimeStamp(unixtime);
    return _getPrice(normalizedUnixtime);
  }

  function _getCurrentVolatility() internal view returns (uint256 volE8) {
    uint256 latestRound = _chainlinkOracle.latestRound();
    uint256 latestVolatility = _getVolatility(_latestTimestamp);
    uint256 currentVolatility =
      _getEwmaVolatility(
        _latestTimestamp,
        uint256(_getPriceFromChainlink(latestRound)),
        _getVolatility(_latestTimestamp)
      );
    volE8 = latestVolatility >= currentVolatility
      ? latestVolatility
      : currentVolatility;
  }

  /**
   * @notice Calculate lastest ewmaVolatility
   * @dev Calculate new volatility with chainlink price at latest round
   * @param volE8 Return the larger of `latestVolatility` and `currentVolatility`
   */
  function getVolatility() external view override returns (uint256 volE8) {
    volE8 = _getCurrentVolatility();
  }

  /**
   * @notice This function has the same interface with Lien Volatility Oracle
   */
  function getVolatility(uint64)
    external
    view
    override
    returns (uint64 volatilityE8)
  {
    uint256 volE8 = _getCurrentVolatility();
    return volE8.toUint64();
  }

  /**
   * @notice Get registered ewmaVolatility of given timestamp
   */
  function getVolatilityTimeOf(uint256 unixtime)
    external
    view
    override
    returns (uint256 volE8)
  {
    uint256 normalizedUnixtime = getNormalizedTimeStamp(unixtime);
    return _regularIntervalPriceData[normalizedUnixtime].ewmaVolatilityE8;
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"uint16","name":"initialLambdaE4","type":"uint16"},{"internalType":"uint16","name":"initialDataNum","type":"uint16"},{"internalType":"uint32","name":"initialVolE4","type":"uint32"},{"internalType":"address","name":"quantsAddress","type":"address"},{"internalType":"address","name":"chainlinkOracleAddress","type":"address"},{"internalType":"uint256","name":"startTimestamp","type":"uint256"},{"internalType":"uint256","name":"interval","type":"uint256"},{"internalType":"uint256","name":"initialRoundId","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"newLambda","type":"uint16"}],"name":"LambdaChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newQuantsAddress","type":"address"}],"name":"QuantsChanged","type":"event"},{"inputs":[],"name":"getCurrentParameters","outputs":[{"internalType":"uint16","name":"lambda","type":"uint16"},{"internalType":"uint16","name":"dataNum","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInfo","outputs":[{"internalType":"address","name":"chainlink","type":"address"},{"internalType":"address","name":"quants","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInterval","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLatestTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"getNormalizedTimeStamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOldestTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"unixtime","type":"uint256"}],"name":"getPriceTimeOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVolatility","outputs":[{"internalType":"uint256","name":"volE8","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"","type":"uint64"}],"name":"getVolatility","outputs":[{"internalType":"uint64","name":"volatilityE8","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"unixtime","type":"uint256"}],"name":"getVolatilityTimeOf","outputs":[{"internalType":"uint256","name":"volE8","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"newLambdaE4","type":"uint16"}],"name":"setOptimizedParameters","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"roundId","type":"uint256"}],"name":"setPrice","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"roundIds","type":"uint256[]"}],"name":"setSequentialPrices","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"quantsAddress","type":"address"}],"name":"updateQuantsAddress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]

6101406040523480156200001257600080fd5b5060405162001c3538038062001c3583398181016040526101208110156200003957600080fd5b5080516020820151604083015160608085015160808087015160a08089015160c0808b015160e08c0151610100909c015160f08a901b7fffff00000000000000000000000000000000000000000000000000000000000016610120526003805461ffff191661ffff8d16179055600080546001600160a01b0319166001600160a01b0388161790559783901b6001600160601b031916909552918a905260f889901b7fff0000000000000000000000000000000000000000000000000000000000000016909152969795969495929490939092908183816200011757fe5b0660801b6001600160801b03191660e052620001358184866200038a565b905060006200014582866200065e565b9050604051806040016040528062000168836200070a60201b62000acc1760201c565b6001600160401b03908116825263ffffffff8a166020928301526000878152600283526040902083518154949093015182166801000000000000000002600160401b600160801b0319939092166001600160401b031990941693909317919091161790556001600160801b03841660019081556001600160801b0319608086901b166101005261ffff8916116200024b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018062001c106025913960400191505060405180910390fd5b6001600160a01b038616620002ac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018062001bc76024913960400191505060405180910390fd5b6001600160a01b0385166200032257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4572726f723a20496e76616c696420636861696e6c696e6b2061646472657373604482015290519081900360640190fd5b826200037a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018062001beb6025913960400191505060405180910390fd5b5050505050505050505062000773565b600083620003fd57816001600160a01b031663668a0f026040518163ffffffff1660e01b815260040160206040518083038186803b158015620003cc57600080fd5b505afa158015620003e1573d6000803e3d6000fd5b505050506040513d6020811015620003f857600080fd5b505193505b6000826001600160a01b031663b633620c866040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156200044457600080fd5b505afa15801562000459573d6000803e3d6000fd5b505050506040513d60208110156200047057600080fd5b5051905083811015620004cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252604181526020018062001b606041913960600191505060405180910390fd5b846200053c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f496e76616c69642068696e742049440000000000000000000000000000000000604482015290519081900360640190fd5b60001985015b8015620005ef576000846001600160a01b031663b633620c836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156200059057600080fd5b505afa158015620005a5573d6000803e3d6000fd5b505050506040513d6020811015620005bc57600080fd5b505190508015801590620005d05750858111155b15620005e457506001019150620006579050565b506000190162000542565b50604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4e6f2076616c696420726f756e6420494420666f756e64000000000000000000604482015290519081900360640190fd5b9392505050565b60005b816001600160a01b031663b5ab58dc846040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015620006a657600080fd5b505afa158015620006bb573d6000803e3d6000fd5b505050506040513d6020811015620006d257600080fd5b50519050600081138015620006ec5750655af3107a400081125b15620006f85762000704565b60018303925062000661565b92915050565b60006801000000000000000082106200076f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018062001ba16026913960400191505060405180910390fd5b5090565b60805160601c60a05160c05160f81c60e05160801c6101005160801c6101205160f01c6113446200081c600039806103e4528061050652806105fe528061066952508061054c52806107905250806103505250806109cc525080610372528061052b52806105dd528061062f52806106a252806106ca52806107b552806107dd5280610a475280610d8152508061040c5280610b775280610cf45280610eda52506113446000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c806391b7f5ed11610097578063ea89c8c811610066578063ea89c8c814610288578063f0141d84146102ae578063f43b52cb146102cc578063f6a26384146102d457610100565b806391b7f5ed1461020257806398d5fdca1461021f578063c8f3e55514610227578063e5373d0e1461026b57610100565b80635a9b0b89116100d35780635a9b0b891461018657806365b45a33146101bd5780638bd74ebb146101f257806391ad27b4146101fa57610100565b80632133cdac146101055780632f9ae429146101345780633af2888b1461015157806348257dab14610159575b600080fd5b6101226004803603602081101561011b57600080fd5b5035610344565b60408051918252519081900360200190f35b6101226004803603602081101561014a57600080fd5b50356103ae565b6101226103cc565b6101616103db565b604051808361ffff1681526020018261ffff1681526020019250505060405180910390f35b61018e610407565b60405180836001600160a01b03168152602001826001600160a01b031681526020019250505060405180910390f35b6101de600480360360208110156101d357600080fd5b503561ffff16610439565b604080519115158252519081900360200190f35b610122610786565b6101226107b3565b6101de6004803603602081101561021857600080fd5b50356107d7565b610122610864565b61024e6004803603602081101561023d57600080fd5b503567ffffffffffffffff16610871565b6040805167ffffffffffffffff9092168252519081900360200190f35b6101226004803603602081101561028157600080fd5b5035610887565b6101de6004803603602081101561029e57600080fd5b50356001600160a01b03166108ba565b6102b66109ca565b6040805160ff9092168252519081900360200190f35b6101226109ee565b6101de600480360360208110156102ea57600080fd5b81019060208101813564010000000081111561030557600080fd5b82018360208201111561031757600080fd5b8035906020019184602083028401116401000000008311171561033957600080fd5b5090925090506109f4565b60006001600160801b037f0000000000000000000000000000000000000000000000000000000000000000167f00000000000000000000000000000000000000000000000000000000000000008061039c8584610b14565b816103a357fe5b04020190505b919050565b6000806103ba83610344565b90506103c581610b56565b9392505050565b60006103d6610b72565b905090565b60035461ffff167f00000000000000000000000000000000000000000000000000000000000000009091565b6000547f0000000000000000000000000000000000000000000000000000000000000000906001600160a01b03169091565b600080546001600160a01b03163314610499576040805162461bcd60e51b815260206004820152601c60248201527f6f6e6c79207175616e747320616464726573732063616e2063616c6c00000000604482015290519081900360640190fd5b6123288261ffff161180156104b357506127108261ffff16105b610504576040805162461bcd60e51b815260206004820181905260248201527f6e6577206c616d626461206973206f7574206f662076616c69642072616e6765604482015290519081900360640190fd5b7f000000000000000000000000000000000000000000000000000000000000000061ffff167f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006001600160801b0316600154038161057f57fe5b04116105bc5760405162461bcd60e51b815260040180806020018281038252602d81526020018061128f602d913960400191505060405180910390fd5b81600360006101000a81548161ffff021916908361ffff16021790555060007f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000061ffff160260015403905060006106557f00000000000000000000000000000000000000000000000000000000000000008301610b56565b9050600061066283610c49565b905060005b7f000000000000000000000000000000000000000000000000000000000000000061ffff168110156106fa5761069e848484610c6c565b91507f0000000000000000000000000000000000000000000000000000000000000000840193506106f07f00000000000000000000000000000000000000000000000000000000000000008501610b56565b9250600101610667565b5061070481610acc565b600154600090815260026020908152604091829020805467ffffffffffffffff94909416600160401b0267ffffffffffffffff60401b1990941693909317909255805161ffff8816815290517f3fa957e75488388eac4866f43f24ba3419064a952e2ffc44167109d1aa53ba36929181900390910190a1506001949350505050565b6001600160801b037f00000000000000000000000000000000000000000000000000000000000000001690565b7f000000000000000000000000000000000000000000000000000000000000000090565b600180547f000000000000000000000000000000000000000000000000000000000000000001908190556000904210156108425760405162461bcd60e51b815260040180806020018281038252602d8152602001806112e2602d913960400191505060405180910390fd5b61084e82600154610ceb565b915061085c82600154610d18565b506001919050565b60006103d6600154610b56565b60008061087c610b72565b90506103c581610acc565b60008061089383610344565b600090815260026020526040902054600160401b900467ffffffffffffffff169392505050565b600080546001600160a01b0316331461091a576040805162461bcd60e51b815260206004820152601c60248201527f6f6e6c79207175616e747320616464726573732063616e2063616c6c00000000604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b038416908117909155610989576040805162461bcd60e51b815260206004820181905260248201527f4572726f723a20496e76616c6964206e6577207175616e742061646472657373604482015290519081900360640190fd5b604080516001600160a01b038416815290517fdec341224043dcab8bced0d5eb60424f94ca517de1a336792e446eaf77c808099181900360200190a1919050565b7f000000000000000000000000000000000000000000000000000000000000000090565b60015490565b60008181610a0142610344565b9050806001541115610a445760405162461bcd60e51b815260040180806020018281038252602d8152602001806112e2602d913960400191505060405180910390fd5b817f0000000000000000000000000000000000000000000000000000000000000000600154830381610a7257fe5b041080610a7f5750600282105b15610a8f57600092505050610ac6565b60005b82811015610abe57610ab5868683818110610aa957fe5b905060200201356107d7565b50600101610a92565b506001925050505b92915050565b6000600160401b8210610b105760405162461bcd60e51b81526004018080602001828103825260268152602001806112bc6026913960400191505060405180910390fd5b5090565b60006103c583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610e3b565b60009081526002602052604090205467ffffffffffffffff1690565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663668a0f026040518163ffffffff1660e01b815260040160206040518083038186803b158015610bce57600080fd5b505afa158015610be2573d6000803e3d6000fd5b505050506040513d6020811015610bf857600080fd5b5051600154909150600090610c0c90610c49565b90506000610c2f600154610c1f85610ed2565b610c2a600154610c49565b610c6c565b905080821015610c3f5780610c41565b815b935050505090565b600090815260026020526040902054600160401b900467ffffffffffffffff1690565b600080610c7885610b56565b9050600081851015610c9e57600282866127100281610c9357fe5b04612710030a610cb4565b600261271083876127100281610cb057fe5b04030a5b6003549091506127106002860a61ffff92831690810282900490820390921683020201610ce081610efe565b979650505050505050565b60006103c583837f0000000000000000000000000000000000000000000000000000000000000000610f4f565b6000610d2383610ed2565b905060008113610d7a576040805162461bcd60e51b815260206004820152601960248201527f53686f756c642072657475726e2076616c696420707269636500000000000000604482015290519081900360640190fd5b6000610dac7f0000000000000000000000000000000000000000000000000000000000000000840383610c2a82610c49565b90506040518060400160405280610dc284610acc565b67ffffffffffffffff168152602001610dda83610acc565b67ffffffffffffffff908116909152600094855260026020908152604090952082518154939096015167ffffffffffffffff199093169582169590951767ffffffffffffffff60401b1916600160401b929091169190910217909255505050565b60008184841115610eca5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610e8f578181015183820152602001610e77565b50505050905090810190601f168015610ebc5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000610ac6827f00000000000000000000000000000000000000000000000000000000000000006111ae565b60006003821115610f41575080600160028204015b81811015610f3b57809150600281828581610f2a57fe5b040181610f3357fe5b049050610f13565b506103a9565b81156103a957506001919050565b600083610fbe57816001600160a01b031663668a0f026040518163ffffffff1660e01b815260040160206040518083038186803b158015610f8f57600080fd5b505afa158015610fa3573d6000803e3d6000fd5b505050506040513d6020811015610fb957600080fd5b505193505b6000826001600160a01b031663b633620c866040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561100457600080fd5b505afa158015611018573d6000803e3d6000fd5b505050506040513d602081101561102e57600080fd5b50519050838110156110715760405162461bcd60e51b815260040180806020018281038252604181526020018061124e6041913960600191505060405180910390fd5b846110b5576040805162461bcd60e51b815260206004820152600f60248201526e125b9d985b1a59081a1a5b9d081251608a1b604482015290519081900360640190fd5b60001985015b8015611160576000846001600160a01b031663b633620c836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561110757600080fd5b505afa15801561111b573d6000803e3d6000fd5b505050506040513d602081101561113157600080fd5b5051905080158015906111445750858111155b15611156575060010191506103c59050565b50600019016110bb565b506040805162461bcd60e51b815260206004820152601760248201527f4e6f2076616c696420726f756e6420494420666f756e64000000000000000000604482015290519081900360640190fd5b60005b816001600160a01b031663b5ab58dc846040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156111f557600080fd5b505afa158015611209573d6000803e3d6000fd5b505050506040513d602081101561121f57600080fd5b505190506000811380156112385750655af3107a400081125b1561124257610ac6565b6001830392506111b156fe48696e7420726f756e64206f72204c617465737420726f756e642073686f756c642062652072656769737465726564206166746572207461726765742074696d654572726f723a20496e73756666696369656e74206e756d626572206f662064617461207265676973746572656453616665436173743a2076616c756520646f65736e27742066697420696e20363420626974734572726f723a20546869732066756e6374696f6e2073686f756c6420626520616674657220696e74657276616ca26469706673582212201b70fc5adb84b9762a0f5450e340ebaebdca52dc29e1c5523011886658c2670564736f6c6343000701003348696e7420726f756e64206f72204c617465737420726f756e642073686f756c642062652072656769737465726564206166746572207461726765742074696d6553616665436173743a2076616c756520646f65736e27742066697420696e20363420626974734572726f723a20496e76616c696420696e697469616c207175616e7420616464726573734572726f723a20496e74657276616c2073686f756c64206265206d6f7265207468616e20304572726f723a20446563696d616c732073686f756c64206265206d6f7265207468616e20300000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000251c0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000516ce2f000000000000000000000000a961684a3a654fb2cca8f8991226c0cefc514d800000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419000000000000000000000000000000000000000000000000000000006017448000000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000030000000000004349

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101005760003560e01c806391b7f5ed11610097578063ea89c8c811610066578063ea89c8c814610288578063f0141d84146102ae578063f43b52cb146102cc578063f6a26384146102d457610100565b806391b7f5ed1461020257806398d5fdca1461021f578063c8f3e55514610227578063e5373d0e1461026b57610100565b80635a9b0b89116100d35780635a9b0b891461018657806365b45a33146101bd5780638bd74ebb146101f257806391ad27b4146101fa57610100565b80632133cdac146101055780632f9ae429146101345780633af2888b1461015157806348257dab14610159575b600080fd5b6101226004803603602081101561011b57600080fd5b5035610344565b60408051918252519081900360200190f35b6101226004803603602081101561014a57600080fd5b50356103ae565b6101226103cc565b6101616103db565b604051808361ffff1681526020018261ffff1681526020019250505060405180910390f35b61018e610407565b60405180836001600160a01b03168152602001826001600160a01b031681526020019250505060405180910390f35b6101de600480360360208110156101d357600080fd5b503561ffff16610439565b604080519115158252519081900360200190f35b610122610786565b6101226107b3565b6101de6004803603602081101561021857600080fd5b50356107d7565b610122610864565b61024e6004803603602081101561023d57600080fd5b503567ffffffffffffffff16610871565b6040805167ffffffffffffffff9092168252519081900360200190f35b6101226004803603602081101561028157600080fd5b5035610887565b6101de6004803603602081101561029e57600080fd5b50356001600160a01b03166108ba565b6102b66109ca565b6040805160ff9092168252519081900360200190f35b6101226109ee565b6101de600480360360208110156102ea57600080fd5b81019060208101813564010000000081111561030557600080fd5b82018360208201111561031757600080fd5b8035906020019184602083028401116401000000008311171561033957600080fd5b5090925090506109f4565b60006001600160801b037f0000000000000000000000000000000000000000000000000000000000000000167f00000000000000000000000000000000000000000000000000000000000151808061039c8584610b14565b816103a357fe5b04020190505b919050565b6000806103ba83610344565b90506103c581610b56565b9392505050565b60006103d6610b72565b905090565b60035461ffff167f00000000000000000000000000000000000000000000000000000000000000189091565b6000547f0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419906001600160a01b03169091565b600080546001600160a01b03163314610499576040805162461bcd60e51b815260206004820152601c60248201527f6f6e6c79207175616e747320616464726573732063616e2063616c6c00000000604482015290519081900360640190fd5b6123288261ffff161180156104b357506127108261ffff16105b610504576040805162461bcd60e51b815260206004820181905260248201527f6e6577206c616d626461206973206f7574206f662076616c69642072616e6765604482015290519081900360640190fd5b7f000000000000000000000000000000000000000000000000000000000000001861ffff167f00000000000000000000000000000000000000000000000000000000000151807f00000000000000000000000000000000000000000000000000000000601744806001600160801b0316600154038161057f57fe5b04116105bc5760405162461bcd60e51b815260040180806020018281038252602d81526020018061128f602d913960400191505060405180910390fd5b81600360006101000a81548161ffff021916908361ffff16021790555060007f00000000000000000000000000000000000000000000000000000000000151807f000000000000000000000000000000000000000000000000000000000000001861ffff160260015403905060006106557f00000000000000000000000000000000000000000000000000000000000151808301610b56565b9050600061066283610c49565b905060005b7f000000000000000000000000000000000000000000000000000000000000001861ffff168110156106fa5761069e848484610c6c565b91507f0000000000000000000000000000000000000000000000000000000000015180840193506106f07f00000000000000000000000000000000000000000000000000000000000151808501610b56565b9250600101610667565b5061070481610acc565b600154600090815260026020908152604091829020805467ffffffffffffffff94909416600160401b0267ffffffffffffffff60401b1990941693909317909255805161ffff8816815290517f3fa957e75488388eac4866f43f24ba3419064a952e2ffc44167109d1aa53ba36929181900390910190a1506001949350505050565b6001600160801b037f00000000000000000000000000000000000000000000000000000000601744801690565b7f000000000000000000000000000000000000000000000000000000000001518090565b600180547f000000000000000000000000000000000000000000000000000000000001518001908190556000904210156108425760405162461bcd60e51b815260040180806020018281038252602d8152602001806112e2602d913960400191505060405180910390fd5b61084e82600154610ceb565b915061085c82600154610d18565b506001919050565b60006103d6600154610b56565b60008061087c610b72565b90506103c581610acc565b60008061089383610344565b600090815260026020526040902054600160401b900467ffffffffffffffff169392505050565b600080546001600160a01b0316331461091a576040805162461bcd60e51b815260206004820152601c60248201527f6f6e6c79207175616e747320616464726573732063616e2063616c6c00000000604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b038416908117909155610989576040805162461bcd60e51b815260206004820181905260248201527f4572726f723a20496e76616c6964206e6577207175616e742061646472657373604482015290519081900360640190fd5b604080516001600160a01b038416815290517fdec341224043dcab8bced0d5eb60424f94ca517de1a336792e446eaf77c808099181900360200190a1919050565b7f000000000000000000000000000000000000000000000000000000000000000890565b60015490565b60008181610a0142610344565b9050806001541115610a445760405162461bcd60e51b815260040180806020018281038252602d8152602001806112e2602d913960400191505060405180910390fd5b817f0000000000000000000000000000000000000000000000000000000000015180600154830381610a7257fe5b041080610a7f5750600282105b15610a8f57600092505050610ac6565b60005b82811015610abe57610ab5868683818110610aa957fe5b905060200201356107d7565b50600101610a92565b506001925050505b92915050565b6000600160401b8210610b105760405162461bcd60e51b81526004018080602001828103825260268152602001806112bc6026913960400191505060405180910390fd5b5090565b60006103c583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610e3b565b60009081526002602052604090205467ffffffffffffffff1690565b6000807f0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b84196001600160a01b031663668a0f026040518163ffffffff1660e01b815260040160206040518083038186803b158015610bce57600080fd5b505afa158015610be2573d6000803e3d6000fd5b505050506040513d6020811015610bf857600080fd5b5051600154909150600090610c0c90610c49565b90506000610c2f600154610c1f85610ed2565b610c2a600154610c49565b610c6c565b905080821015610c3f5780610c41565b815b935050505090565b600090815260026020526040902054600160401b900467ffffffffffffffff1690565b600080610c7885610b56565b9050600081851015610c9e57600282866127100281610c9357fe5b04612710030a610cb4565b600261271083876127100281610cb057fe5b04030a5b6003549091506127106002860a61ffff92831690810282900490820390921683020201610ce081610efe565b979650505050505050565b60006103c583837f0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419610f4f565b6000610d2383610ed2565b905060008113610d7a576040805162461bcd60e51b815260206004820152601960248201527f53686f756c642072657475726e2076616c696420707269636500000000000000604482015290519081900360640190fd5b6000610dac7f0000000000000000000000000000000000000000000000000000000000015180840383610c2a82610c49565b90506040518060400160405280610dc284610acc565b67ffffffffffffffff168152602001610dda83610acc565b67ffffffffffffffff908116909152600094855260026020908152604090952082518154939096015167ffffffffffffffff199093169582169590951767ffffffffffffffff60401b1916600160401b929091169190910217909255505050565b60008184841115610eca5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610e8f578181015183820152602001610e77565b50505050905090810190601f168015610ebc5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000610ac6827f0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b84196111ae565b60006003821115610f41575080600160028204015b81811015610f3b57809150600281828581610f2a57fe5b040181610f3357fe5b049050610f13565b506103a9565b81156103a957506001919050565b600083610fbe57816001600160a01b031663668a0f026040518163ffffffff1660e01b815260040160206040518083038186803b158015610f8f57600080fd5b505afa158015610fa3573d6000803e3d6000fd5b505050506040513d6020811015610fb957600080fd5b505193505b6000826001600160a01b031663b633620c866040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561100457600080fd5b505afa158015611018573d6000803e3d6000fd5b505050506040513d602081101561102e57600080fd5b50519050838110156110715760405162461bcd60e51b815260040180806020018281038252604181526020018061124e6041913960600191505060405180910390fd5b846110b5576040805162461bcd60e51b815260206004820152600f60248201526e125b9d985b1a59081a1a5b9d081251608a1b604482015290519081900360640190fd5b60001985015b8015611160576000846001600160a01b031663b633620c836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561110757600080fd5b505afa15801561111b573d6000803e3d6000fd5b505050506040513d602081101561113157600080fd5b5051905080158015906111445750858111155b15611156575060010191506103c59050565b50600019016110bb565b506040805162461bcd60e51b815260206004820152601760248201527f4e6f2076616c696420726f756e6420494420666f756e64000000000000000000604482015290519081900360640190fd5b60005b816001600160a01b031663b5ab58dc846040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156111f557600080fd5b505afa158015611209573d6000803e3d6000fd5b505050506040513d602081101561121f57600080fd5b505190506000811380156112385750655af3107a400081125b1561124257610ac6565b6001830392506111b156fe48696e7420726f756e64206f72204c617465737420726f756e642073686f756c642062652072656769737465726564206166746572207461726765742074696d654572726f723a20496e73756666696369656e74206e756d626572206f662064617461207265676973746572656453616665436173743a2076616c756520646f65736e27742066697420696e20363420626974734572726f723a20546869732066756e6374696f6e2073686f756c6420626520616674657220696e74657276616ca26469706673582212201b70fc5adb84b9762a0f5450e340ebaebdca52dc29e1c5523011886658c2670564736f6c63430007010033

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

0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000251c0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000516ce2f000000000000000000000000a961684a3a654fb2cca8f8991226c0cefc514d800000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419000000000000000000000000000000000000000000000000000000006017448000000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000030000000000004349

-----Decoded View---------------
Arg [0] : decimals (uint8): 8
Arg [1] : initialLambdaE4 (uint16): 9500
Arg [2] : initialDataNum (uint16): 24
Arg [3] : initialVolE4 (uint32): 85380655
Arg [4] : quantsAddress (address): 0xA961684a3a654fb2cCA8F8991226C0CEfc514d80
Arg [5] : chainlinkOracleAddress (address): 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419
Arg [6] : startTimestamp (uint256): 1612137600
Arg [7] : interval (uint256): 86400
Arg [8] : initialRoundId (uint256): 55340232221128672073

-----Encoded View---------------
9 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000008
Arg [1] : 000000000000000000000000000000000000000000000000000000000000251c
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000018
Arg [3] : 000000000000000000000000000000000000000000000000000000000516ce2f
Arg [4] : 000000000000000000000000a961684a3a654fb2cca8f8991226c0cefc514d80
Arg [5] : 0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419
Arg [6] : 0000000000000000000000000000000000000000000000000000000060174480
Arg [7] : 0000000000000000000000000000000000000000000000000000000000015180
Arg [8] : 0000000000000000000000000000000000000000000000030000000000004349


Deployed Bytecode Sourcemap

14788:12578:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;24308:242;;;;;;;;;;;;;;;;-1:-1:-1;24308:242:0;;:::i;:::-;;;;;;;;;;;;;;;;25656:223;;;;;;;;;;;;;;;;-1:-1:-1;25656:223:0;;:::i;26609:116::-;;;:::i;25492:158::-;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;24556:172;;;:::i;:::-;;;;;-1:-1:-1;;;;;24556:172:0;;;;;;-1:-1:-1;;;;;24556:172:0;;;;;;;;;;;;;;;;19179:969;;;;;;;;;;;;;;;;-1:-1:-1;19179:969:0;;;;:::i;:::-;;;;;;;;;;;;;;;;;;25265:107;;;:::i;24933:93::-;;;:::i;17697:382::-;;;;;;;;;;;;;;;;-1:-1:-1;17697:382:0;;:::i;25378:108::-;;;:::i;26824:189::-;;;;;;;;;;;;;;;;-1:-1:-1;26824:189:0;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;27096:267;;;;;;;;;;;;;;;;-1:-1:-1;27096:267:0;;:::i;20227:281::-;;;;;;;;;;;;;;;;-1:-1:-1;20227:281:0;-1:-1:-1;;;;;20227:281:0;;:::i;24780:91::-;;;:::i;:::-;;;;;;;;;;;;;;;;;;;25092:107;;;:::i;18246:708::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;18246:708:0;;-1:-1:-1;18246:708:0;-1:-1:-1;18246:708:0;:::i;24308:242::-;24409:7;-1:-1:-1;;;;;24523:21:0;24442:102;24504:9;;24444:36;:9;24442:102;24444:13;:36::i;:::-;24443:50;;;;;;24442:71;:102;24428:116;;24308:242;;;;:::o;25656:223::-;25750:7;25769:26;25798:32;25821:8;25798:22;:32::i;:::-;25769:61;;25844:29;25854:18;25844:9;:29::i;:::-;25837:36;25656:223;-1:-1:-1;;;25656:223:0:o;26609:116::-;26666:13;26696:23;:21;:23::i;:::-;26688:31;;26609:116;:::o;25492:158::-;25625:8;;;;25635;25492:158;;:::o;24556:172::-;24627:17;24707:14;24688:16;;-1:-1:-1;;;;;24707:14:0;24556:172;;:::o;19179:969::-;19289:4;20608:14;;-1:-1:-1;;;;;20608:14:0;20594:10;:28;20586:69;;;;;-1:-1:-1;;;20586:69:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;19341:4:::1;19327:11;:18;;;:41;;;;;19363:5;19349:11;:19;;;19327:41;19311:107;;;::::0;;-1:-1:-1;;;19311:107:0;;::::1;;::::0;::::1;::::0;;;;;;;::::1;::::0;;;;;;;;;;;;;::::1;;19493:8;19441:60;;19481:9;19461:16;-1:-1:-1::0;;;;;19442:35:0::1;:16;;:35;19441:49;;;;;;:60;19425:139;;;;-1:-1:-1::0;;;19425:139:0::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;19582:11;19571:8;;:22;;;;;;;;;;;;;;;;;;19600:20;19653:9;19642:8;:20;;;19623:16;;:39;19600:62;;19669:12;19684:35;19709:9;19694:12;:24;19684:9;:35::i;:::-;19669:50;;19726:18;19747:28;19762:12;19747:14;:28::i;:::-;19726:49;;19787:9;19782:204;19806:8;19802:12;;:1;:12;19782:204;;;19843:50;19862:12;19876:4;19882:10;19843:18;:50::i;:::-;19830:63;;19918:9;19902:25;;;;19943:35;19968:9;19953:12;:24;19943:9;:35::i;:::-;19936:42:::0;-1:-1:-1;19816:3:0::1;;19782:204;;;;20057:29;:10;:27;:29::i;:::-;20020:16;::::0;19994:43:::1;::::0;;;:25:::1;:43;::::0;;;;;;;;:92;;::::1;::::0;;;::::1;-1:-1:-1::0;;;19994:92:0::1;-1:-1:-1::0;;;;19994:92:0;;::::1;::::0;;;::::1;::::0;;;20098:26;;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;::::1;-1:-1:-1::0;20138:4:0::1;::::0;19179:969;-1:-1:-1;;;;19179:969:0:o;25265:107::-;-1:-1:-1;;;;;25350:16:0;25343:23;25265:107;:::o;24933:93::-;25011:9;24933:93;:::o;17697:382::-;17770:16;:29;;17790:9;17770:29;;;;;17757:4;;17834:15;-1:-1:-1;17814:35:0;17806:93;;;;-1:-1:-1;;;17806:93:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;17969:43;17986:7;17995:16;;17969;:43::i;:::-;17959:53;;18019:36;18029:7;18038:16;;18019:9;:36::i;:::-;-1:-1:-1;18069:4:0;17697:382;;;:::o;25378:108::-;25430:7;25453:27;25463:16;;25453:9;:27::i;26824:189::-;26907:19;26938:13;26954:23;:21;:23::i;:::-;26938:39;;26991:16;:5;:14;:16::i;27096:267::-;27195:13;27220:26;27249:32;27272:8;27249:22;:32::i;:::-;27295:45;;;;:25;:45;;;;;:62;-1:-1:-1;;;27295:62:0;;;;;27096:267;-1:-1:-1;;;27096:267:0:o;20227:281::-;20337:4;20608:14;;-1:-1:-1;;;;;20608:14:0;20594:10;:28;20586:69;;;;;-1:-1:-1;;;20586:69:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;20353:14:::1;:30:::0;;-1:-1:-1;;;;;;20353:30:0::1;-1:-1:-1::0;;;;;20353:30:0;::::1;::::0;;::::1;::::0;;;20390:72:::1;;;::::0;;-1:-1:-1;;;20390:72:0;;::::1;;::::0;::::1;::::0;;;;;;;::::1;::::0;;;;;;;;;;;;;::::1;;20474:28;::::0;;-1:-1:-1;;;;;20474:28:0;::::1;::::0;;;;::::1;::::0;;;;::::1;::::0;;::::1;20227:281:::0;;;:::o;24780:91::-;24856:9;24780:91;:::o;25092:107::-;25177:16;;25092:107;:::o;18246:708::-;18346:4;18387:8;18346:4;18453:39;18476:15;18453:22;:39::i;:::-;18409:83;;18527:26;18507:16;;:46;;18499:104;;;;-1:-1:-1;;;18499:104:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;18760:14;18741:9;18721:16;;18692:26;:45;18691:59;;;;;;:83;:112;;;;18802:1;18785:14;:18;18691:112;18679:161;;;18827:5;18820:12;;;;;;18679:161;18853:9;18848:83;18872:14;18868:1;:18;18848:83;;;18902:21;18911:8;;18920:1;18911:11;;;;;;;;;;;;;18902:8;:21::i;:::-;-1:-1:-1;18888:3:0;;18848:83;;;;18944:4;18937:11;;;;18246:708;;;;;:::o;4149:179::-;4205:6;-1:-1:-1;;;4232:5:0;:13;4224:65;;;;-1:-1:-1;;;4224:65:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;4314:5:0;4149:179::o;10670:136::-;10728:7;10755:43;10759:1;10762;10755:43;;;;;;;;;;;;;;;;;:3;:43::i;20779:132::-;20839:7;20862:35;;;:25;:35;;;;;:43;;;;20779:132::o;25885:501::-;25941:13;25963:19;25985:16;-1:-1:-1;;;;;25985:28:0;;:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;25985:30:0;26064:16;;25985:30;;-1:-1:-1;26022:24:0;;26049:32;;:14;:32::i;:::-;26022:59;;26088:25;26123:152;26152:16;;26187:35;26210:11;26187:22;:35::i;:::-;26234:32;26249:16;;26234:14;:32::i;:::-;26123:18;:152::i;:::-;26088:187;;26310:17;26290:16;:37;;:90;;26363:17;26290:90;;;26337:16;26290:90;26282:98;;25885:501;;;;:::o;20974:146::-;21039:7;21062:35;;;:25;:35;;;;;:52;-1:-1:-1;;;21062:52:0;;;;;20974:146::o;21257:463::-;21382:13;21404:12;21419:23;21429:12;21419:9;:23::i;:::-;21404:38;;21449:12;21479:4;21471;:12;;:112;;21582:1;21575:4;21557;21565:5;21557:14;21556:23;;;;;;21547:5;21546:33;21545:38;21471:112;;;21532:1;21523:5;21515:4;21497;21505:5;21497:14;21496:23;;;;;;:33;21495:38;21471:112;21660:8;;21449:134;;-1:-1:-1;21652:5:0;21627:1;21617:11;;21660:8;;;;21617:22;;;21616:32;;;21652:16;;;21651:25;;;;;:33;21616:68;21699:15;21616:68;21699:5;:15::i;:::-;21691:23;21257:463;-1:-1:-1;;;;;;;21257:463:0:o;22077:218::-;22182:15;22216:73;22247:6;22255:15;22272:16;22216:30;:73::i;23122:490::-;23193:14;23210:31;23233:7;23210:22;:31::i;:::-;23193:48;;23266:1;23256:7;:11;23248:49;;;;;-1:-1:-1;;;23248:49:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;23304:24;23338:134;23379:9;23367:21;;23407:7;23426:37;23367:21;23426:14;:37::i;23338:134::-;23304:168;;23518:88;;;;;;;;23536:27;23544:7;23536:25;:27::i;:::-;23518:88;;;;;;23572:27;:16;:25;:27::i;:::-;23518:88;;;;;;;23479:36;;;;:25;:36;;;;;;;;:127;;;;;;;;;-1:-1:-1;;23479:127:0;;;;;;;;;;-1:-1:-1;;;;23479:127:0;-1:-1:-1;;;23479:127:0;;;;;;;;;;;;-1:-1:-1;;;23122:490:0:o;11109:192::-;11195:7;11231:12;11223:6;;;;11215:29;;;;-1:-1:-1;;;11215:29:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;11267:5:0;;;11109:192::o;23619:190::-;23706:14;23738:63;23775:7;23784:16;23738:36;:63::i;21824:247::-;21873:9;21900:1;21896;:5;21892:173;;;-1:-1:-1;21921:1:0;21929;21925;21921:5;;:9;21946:71;21957:1;21953;:5;21946:71;;;21975:1;21971:5;;22005:1;22000;21996;21992;:5;;;;;;:9;21991:15;;;;;;21987:19;;21946:71;;;21892:173;;;;22034:6;;22030:35;;-1:-1:-1;22056:1:0;21824:247;;;:::o;22301:815::-;22462:15;22493:11;22489:77;;22524:20;-1:-1:-1;;;;;22524:32:0;;:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;22524:34:0;;-1:-1:-1;22489:77:0;22572:25;22600:20;-1:-1:-1;;;;;22600:33:0;;22634:6;22600:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;22600:41:0;;-1:-1:-1;22664:36:0;;;;22648:135;;;;-1:-1:-1;;;22648:135:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;22798:11;22790:39;;;;;-1:-1:-1;;;22790:39:0;;;;;;;;;;;;-1:-1:-1;;;22790:39:0;;;;;;;;;;;;;;;-1:-1:-1;;22857:10:0;;22836:227;22869:9;;22836:227;;22898:17;22918:20;-1:-1:-1;;;;;22918:33:0;;22952:5;22918:40;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;22918:40:0;;-1:-1:-1;22971:14:0;;;;;:46;;;23002:15;22989:9;:28;;22971:46;22967:89;;;-1:-1:-1;23045:1:0;23037:9;;-1:-1:-1;23030:16:0;;-1:-1:-1;23030:16:0;22967:89;-1:-1:-1;;;22880:7:0;22836:227;;;-1:-1:-1;23069:41:0;;;-1:-1:-1;;;23069:41:0;;;;;;;;;;;;;;;;;;;;;;;;;;;23817:359;23960:14;23986:185;24018:20;-1:-1:-1;;;;;24018:30:0;;24049:7;24018:39;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;24018:39:0;;-1:-1:-1;24080:1:0;24070:11;;:44;;;;;15140:6;24086:7;:28;24070:44;24066:77;;;24128:5;;24066:77;24162:1;24151:12;;;;23986:185;

Swarm Source

ipfs://1b70fc5adb84b9762a0f5450e340ebaebdca52dc29e1c5523011886658c26705

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
[ 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.