false
false

Contract Address Details

0x57e709B1fbbd02652F8f883C6E6Bc0093bffBe4A

Contract Name
OrandProviderV3
Creator
0x81f6b0–105e34 at 0xa286b5–5aaf4e
Balance
0 U2U
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
39565397
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
OrandProviderV3




Optimization enabled
true
Compiler version
v0.8.19+commit.7dd6d404




Optimization runs
1000
EVM Version
default




Verified at
2024-10-07T11:14:53.709122Z

contracts/orand-v3/OrandProviderV3.sol

Sol2uml
new
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.19;

import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import '../libraries/Ownable.sol';
import '../libraries/ReentrancyGuard.sol';
import './interfaces/IOrandProviderV3.sol';
import './interfaces/IOrandECVRFV3.sol';
import './interfaces/IOrandConsumerV3.sol';
import './OrandStorageV3.sol';
import './OrandManagementV3.sol';
import './OrandECDSAV3.sol';
import '../orocle-v1/interfaces/IOrocleAggregatorV1.sol';

contract OrandProviderV3 is
  Initializable,
  Ownable,
  ReentrancyGuard,
  OrandStorageV3,
  OrandManagementV3,
  OrandECDSAV3,
  IOrandProviderV3
{
  // ECVRF verifier smart contract
  IOrandECVRFV3 private ecvrf;

  // Orocle V1
  IOrocleAggregatorV1 private oracle;

  // We allow max batching is 1000
  uint256 private maxBatching;

  // Event: Set New ECVRF Verifier
  event SetNewECVRFVerifier(address indexed actor, address indexed ecvrfAddress);

  // Event: Set the limit for batching randomness
  event SetBatchingLimit(address indexed actor, uint256 indexed maxBatching);

  // Event: set new oracle
  event SetNewOracle(address indexed actor, address indexed newOracle);

  // Event: External Error
  event ExternalError(address receiverAddress);

  // Provider V3 initialize method
  function initialize(
    uint256[2] memory publicKey,
    address operator,
    address ecvrfAddress,
    address oracleAddress,
    uint256 maxBatchingLimit
  ) public initializer {
    Ownable._initOwnable();
    ReentrancyGuard._initReentrancyGuard();
    OrandManagementV3._initOrandManagementV3(publicKey);
    OrandECDSAV3._initOrandECDSAV3(operator);
    _setNewECVRFVerifier(ecvrfAddress);
    _setNewOracle(oracleAddress);
    _setMaxBatching(maxBatchingLimit);
  }

  //=======================[  Owner  ]====================

  // Update new ECVRF verifier
  function setMaxBatching(uint256 maxBatchingLimit) external onlyOwner returns (bool) {
    _setMaxBatching(maxBatchingLimit);
    return true;
  }

  // Update new ECVRF verifier
  function setNewOracle(address oracleAddress) external onlyOwner returns (bool) {
    _setNewOracle(oracleAddress);
    return true;
  }

  // Update new ECVRF verifier
  function setNewECVRFVerifier(address ecvrfAddress) external onlyOwner returns (bool) {
    _setNewECVRFVerifier(ecvrfAddress);
    return true;
  }

  // Set new public key to verify proof
  function setPublicKey(uint256[2] memory pk) external onlyOwner returns (bool) {
    _setPublicKey(pk);
    return true;
  }

  //=======================[  Internal  ]====================

  // Update new ECVRF verifier
  function _setMaxBatching(uint256 maxBatchingLimit) internal {
    maxBatching = maxBatchingLimit;
    emit SetBatchingLimit(msg.sender, maxBatchingLimit);
  }

  // Update new ECVRF verifier
  function _setNewOracle(address oracleAddress) internal {
    oracle = IOrocleAggregatorV1(oracleAddress);
    emit SetNewOracle(msg.sender, oracleAddress);
  }

  // Update new ECVRF verifier
  function _setNewECVRFVerifier(address ecvrfAddress) internal {
    ecvrf = IOrandECVRFV3(ecvrfAddress);
    emit SetNewECVRFVerifier(msg.sender, ecvrfAddress);
  }

  // Forward call to receiver
  function _forward(address receiverAddress, uint256 result) internal {
    IOrandConsumerV3 consumerContract = IOrandConsumerV3(receiverAddress);
    bool currentProcessResponse = false;
    if (receiverAddress.code.length > 0) {
      for (uint256 i = 0; i < maxBatching; i += 1) {
        try consumerContract.consumeRandomness(result) returns (bool contractResponse) {
          currentProcessResponse = contractResponse;
        } catch {
          currentProcessResponse = false;
          emit ExternalError(receiverAddress);
        }
        if (currentProcessResponse) {
          oracle.fulfill(0, abi.encodePacked(receiverAddress));
          break;
        }
        result = uint256(keccak256(abi.encodePacked(result)));
      }
    }
  }

  //=======================[  External  ]====================

  // Start new genesis for receiver
  function genesis(bytes memory fraudProof, ECVRFProof calldata ecvrfProof) external nonReentrant returns (bool) {
    OrandECDSAProof memory ecdsaProof = _decodeFraudProof(fraudProof);
    uint256 currentEpochResult = _getCurrentEpochResult(ecdsaProof.receiverAddress);

    // Invalid genesis epoch
    if (currentEpochResult != 0 || ecdsaProof.receiverEpoch != 0) {
      revert InvalidGenesisEpoch(currentEpochResult);
    }

    // Make sure operator is valid
    if (ecdsaProof.signer != _getOperator()) {
      revert InvalidECDSAProof(ecdsaProof.signer);
    }

    // ECVRF proof digest must match
    if (
      ecdsaProof.ecvrfProofDigest !=
      uint256(
        keccak256(
          abi.encodePacked(
            _getPublicKey(),
            ecvrfProof.gamma,
            ecvrfProof.c,
            ecvrfProof.s,
            ecvrfProof.alpha,
            ecvrfProof.uWitness,
            ecvrfProof.cGammaWitness,
            ecvrfProof.sHashWitness,
            ecvrfProof.zInv
          )
        )
      )
    ) {
      revert InvalidECVRFProofDigest();
    }

    // y = keccak256(gamma.x, gamma.y)
    // uint256 y = uint256(keccak256(abi.encodePacked(ecvrfProof.gamma)));
    uint256 result = ecvrf.verifyStructECVRFProof(_getPublicKey(), ecvrfProof);

    // Add epoch to the epoch chain of Orand ECVRF
    _addEpoch(ecdsaProof.receiverAddress, result);

    // Forward proof to target contract
    _forward(ecdsaProof.receiverAddress, result);

    return true;
  }

  // Publish new epoch with Fraud Proof
  function publishFraudProof(bytes memory fraudProof, ECVRFProof calldata ecvrfProof)
    external
    nonReentrant
    returns (bool)
  {
    OrandECDSAProof memory ecdsaProof = _decodeFraudProof(fraudProof);
    uint256 currentEpochResult = _getCurrentEpochResult(ecdsaProof.receiverAddress);

    // Current alpha must be the result of previous epoch
    if (ecdsaProof.signer != _getOperator()) {
      revert InvalidProofSigner(ecdsaProof.signer);
    }

    // Current alpha must be the result of previous epoch
    if (ecvrfProof.alpha != currentEpochResult) {
      revert InvalidAlphaValue(currentEpochResult, ecvrfProof.alpha);
    }

    // ECVRF proof digest must match
    if (
      ecdsaProof.ecvrfProofDigest !=
      uint256(
        keccak256(
          abi.encodePacked(
            _getPublicKey(),
            ecvrfProof.gamma,
            ecvrfProof.c,
            ecvrfProof.s,
            ecvrfProof.alpha,
            ecvrfProof.uWitness,
            ecvrfProof.cGammaWitness,
            ecvrfProof.sHashWitness,
            ecvrfProof.zInv
          )
        )
      )
    ) {
      revert InvalidECVRFProofDigest();
    }

    // y = keccak256(gamma.x, gamma.y)
    uint256 result = uint256(keccak256(abi.encodePacked(ecvrfProof.gamma)));

    // Add epoch to the epoch chain of Orand ECVRF
    _addEpoch(ecdsaProof.receiverAddress, result);

    // Check for the existing smart contract and forward randomness to receiver
    _forward(ecdsaProof.receiverAddress, result);

    return true;
  }

  // Publish new epoch with ECDSA Proof and Fraud Proof
  function publish(address receiverAddress, ECVRFProof calldata ecvrfProof) external nonReentrant returns (bool) {
    uint256 currentEpochResult = _getCurrentEpochResult(receiverAddress);

    // Current alpha must be the result of previous epoch
    if (ecvrfProof.alpha != currentEpochResult) {
      revert InvalidAlphaValue(currentEpochResult, ecvrfProof.alpha);
    }

    // y = keccak256(gamma.x, gamma.y)
    // uint256 y = uint256(keccak256(abi.encodePacked(ecvrfProof.gamma)));
    uint256 result = ecvrf.verifyStructECVRFProof(_getPublicKey(), ecvrfProof);

    // Add epoch to the epoch chain of Orand ECVRF
    _addEpoch(receiverAddress, result);

    // Check for the existing smart contract and forward randomness to receiver
    _forward(receiverAddress, result);

    return true;
  }

  //=======================[  External View  ]====================

  // Verify a ECVRF proof epoch is valid or not
  function verifyEpoch(bytes memory fraudProof, ECVRFProof calldata ecvrfProof)
    external
    view
    returns (
      OrandECDSAProof memory ecdsaProof,
      uint96 currentEpochNumber,
      bool isEpochLinked,
      bool isValidDualProof,
      uint256 currentEpochResult,
      uint256 verifiedEpochResult
    )
  {
    ecdsaProof = _decodeFraudProof(fraudProof);

    isValidDualProof =
      ecdsaProof.ecvrfProofDigest ==
      uint256(
        keccak256(
          abi.encodePacked(
            _getPublicKey(),
            ecvrfProof.gamma,
            ecvrfProof.c,
            ecvrfProof.s,
            ecvrfProof.alpha,
            ecvrfProof.uWitness,
            ecvrfProof.cGammaWitness,
            ecvrfProof.sHashWitness,
            ecvrfProof.zInv
          )
        )
      );

    currentEpochNumber = _getCurrentEpoch(ecdsaProof.receiverAddress);
    currentEpochResult = _getCurrentEpochResult(ecdsaProof.receiverAddress);
    isEpochLinked = currentEpochResult == ecvrfProof.alpha;

    // y = keccak256(gamma.x, gamma.y)
    // uint256 y = uint256(keccak256(abi.encodePacked(ecvrfProof.gamma)));
    verifiedEpochResult = ecvrf.verifyStructECVRFProof(_getPublicKey(), ecvrfProof);
  }

  // Get address of ECVRF verifier
  function getECVRFVerifier() external view returns (address ecvrfVerifier) {
    return address(ecvrf);
  }

  // Get address of Oracle
  function getOracle() external view returns (address oracleAddress) {
    return address(oracle);
  }

  // Get maximum batching limit
  function getMaximumBatching() external view returns (uint256 maxBatchingLimit) {
    return maxBatching;
  }
}
        

@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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

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

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

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

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

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized != type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}
          

@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/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.8.0/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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}
          

@openzeppelin/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
          

@openzeppelin/contracts/utils/Strings.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}
          

@openzeppelin/contracts/utils/cryptography/ECDSA.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, "\x19Ethereum Signed Message:\n32")
            mstore(0x1c, hash)
            message := keccak256(0x00, 0x3c)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, "\x19\x01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            data := keccak256(ptr, 0x42)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Data with intended validator, created from a
     * `validator` and `data` according to the version 0 of EIP-191.
     *
     * See {recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x00", validator, data));
    }
}
          

@openzeppelin/contracts/utils/math/Math.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

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

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

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

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

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}
          

@openzeppelin/contracts/utils/math/SignedMath.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

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

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}
          

contracts/libraries/Bytes.sol

// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.19;

// Index is out of range
error OutOfRange(uint256 requiredLen, uint256 maxLen);

library Bytes {
  // Read address from input bytes buffer
  function readAddress(bytes memory input, uint256 offset) internal pure returns (address result) {
    if (offset + 20 > input.length) {
      revert OutOfRange(offset + 20, input.length);
    }
    assembly {
      result := shr(96, mload(add(add(input, 0x20), offset)))
    }
  }

  // Read unsafe from input bytes buffer
  function readUintUnsafe(bytes memory input, uint256 offset, uint256 bitLen) internal pure returns (uint256 result) {
    assembly {
      result := shr(sub(256, bitLen), mload(add(add(input, 0x20), offset)))
    }
  }

  // Read uint256 from input bytes buffer
  function readUint256(bytes memory input, uint256 offset) internal pure returns (uint256 result) {
    if (offset + 32 > input.length) {
      revert OutOfRange(offset + 32, input.length);
    }
    assembly {
      result := mload(add(add(input, 0x20), offset))
    }
  }

  // Read a sub bytes array from input bytes buffer
  function readBytes(bytes memory input, uint256 offset, uint256 length) internal pure returns (bytes memory) {
    if (offset + length > input.length) {
      revert OutOfRange(offset + length, input.length);
    }
    bytes memory result = new bytes(length);
    assembly {
      // Seek offset to the beginning
      let seek := add(add(input, 0x20), offset)

      // Next is size of data
      let resultOffset := add(result, 0x20)

      for {
        let i := 0
      } lt(i, length) {
        i := add(i, 0x20)
      } {
        mstore(add(resultOffset, i), mload(add(seek, i)))
      }
    }
    return result;
  }
}
          

contracts/libraries/Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import '@openzeppelin/contracts/utils/Context.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 Ownable is Context {
  address private _owner;

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

  /**
   * @dev Initializes the contract setting the deployer as the initial owner.
   */
  function _initOwnable() internal {
    _transferOwnership(_msgSender());
  }

  /**
   * @dev Throws if called by any account other than the owner.
   */
  modifier onlyOwner() {
    _checkOwner();
    _;
  }

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

  /**
   * @dev Throws if the sender is not the owner.
   */
  function _checkOwner() internal view virtual {
    require(owner() == _msgSender(), 'Ownable: caller is not the owner');
  }

  /**
   * @dev Leaves the contract without owner. It will not be possible to call
   * `onlyOwner` functions. Can only be called by the current owner.
   *
   * NOTE: Renouncing ownership will leave the contract without an owner,
   * thereby disabling 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);
  }
}
          

contracts/orand-v3/interfaces/IOrandECVRFV3.sol

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import './IOrandProviderV3.sol';

interface IOrandECVRFV3 {
  // Verify raw proof of ECVRF
  function verifyECVRFProof(
    uint256[2] memory pk,
    uint256[2] memory gamma,
    uint256 c,
    uint256 s,
    uint256 alpha,
    address uWitness,
    uint256[2] memory cGammaWitness,
    uint256[2] memory sHashWitness,
    uint256 zInv
  ) external view returns (uint256 y);

  // Verify structed proof of ECVRF
  function verifyStructECVRFProof(
    uint256[2] memory pk,
    IOrandProviderV3.ECVRFProof memory ecvrfProof
  ) external view returns (uint256 y);
}
          

contracts/libraries/ReentrancyGuard.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
contract ReentrancyGuard {
  // Booleans are more expensive than uint256 or any type that takes up a full
  // word because each write operation emits an extra SLOAD to first read the
  // slot's contents, replace the bits taken up by the boolean, and then write
  // back. This is the compiler's defense against contract upgrades and
  // pointer aliasing, and it cannot be disabled.

  // The values being non-zero value makes deployment a bit more expensive,
  // but in exchange the refund on every call to nonReentrant will be lower in
  // amount. Since refunds are capped to a percentage of the total
  // transaction's gas, it is best to keep them low in cases like this one, to
  // increase the likelihood of the full refund coming into effect.
  uint256 private constant _NOT_ENTERED = 1;
  uint256 private constant _ENTERED = 2;

  uint256 private _status;

  function _initReentrancyGuard() internal {
    _status = _NOT_ENTERED;
  }

  /**
   * @dev Prevents a contract from calling itself, directly or indirectly.
   * Calling a `nonReentrant` function from another `nonReentrant`
   * function is not supported. It is possible to prevent this from happening
   * by making the `nonReentrant` function external, and making it call a
   * `private` function that does the actual work.
   */
  modifier nonReentrant() {
    _nonReentrantBefore();
    _;
    _nonReentrantAfter();
  }

  function _nonReentrantBefore() private {
    // On the first call to nonReentrant, _status will be _NOT_ENTERED
    require(_status != _ENTERED, 'ReentrancyGuard: reentrant call');

    // Any calls to nonReentrant after this point will fail
    _status = _ENTERED;
  }

  function _nonReentrantAfter() private {
    // By storing the original value once again, a refund is triggered (see
    // https://eips.ethereum.org/EIPS/eip-2200)
    _status = _NOT_ENTERED;
  }

  /**
   * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
   * `nonReentrant` function in the call stack.
   */
  function _reentrancyGuardEntered() internal view returns (bool) {
    return _status == _ENTERED;
  }
}
          

contracts/orand-v3/OrandECDSAV3.sol

// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.19;

import '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';
import '../libraries/Bytes.sol';
import './interfaces/IOrandECDSAV3.sol';

contract OrandECDSAV3 is IOrandECDSAV3 {
  // Event: Set New Operator
  event SetNewOperator(address indexed oldOperator, address indexed newOperator);

  // Orand operator address
  address private operator;

  // Byte manipulation
  using Bytes for bytes;

  // Verifiy digital signature
  using ECDSA for bytes;
  using ECDSA for bytes32;

  // Set operator at constructing time
  function _initOrandECDSAV3(address operatorAddress) internal {
    _setOperator(operatorAddress);
  }

  //=======================[  Internal  ]====================

  // Set proof operator
  function _setOperator(address operatorAddress) internal {
    emit SetNewOperator(operator, operatorAddress);
    operator = operatorAddress;
  }

  //=======================[  Internal View  ]====================

  // Get operator address
  function _getOperator() internal view returns (address operatorAddress) {
    return operator;
  }

  // Verify proof of operator
  // 0 - 65: secp256k1 Signature
  // 65 - 77: Epoch
  // 77 - 97: Receiver address
  // 97 - 129: Y result of VRF
  function _decodeFraudProof(bytes memory fraudProof) internal pure returns (OrandECDSAProof memory ecdsaProof) {
    if (fraudProof.length != 129) {
      revert InvalidECDSAProofLength(fraudProof.length);
    }
    bytes memory signature = fraudProof.readBytes(0, 65);
    bytes memory message = fraudProof.readBytes(65, fraudProof.length - 65);
    uint256 proofUint = message.readUint256(0);
    ecdsaProof.receiverEpoch = uint96(proofUint >> 160);
    ecdsaProof.receiverAddress = address(uint160(proofUint));
    ecdsaProof.ecvrfProofDigest = message.readUint256(32);
    ecdsaProof.signer = message.toEthSignedMessageHash().recover(signature);
    return ecdsaProof;
  }

  //=======================[  External View  ]====================

  // Decompose a valid proof
  function decomposeProof(bytes memory proof) external pure returns (OrandECDSAProof memory ecdsaProof) {
    return _decodeFraudProof(proof);
  }

  // Get operator
  function getOperator() external view returns (address operatorAddress) {
    return _getOperator();
  }
}
          

contracts/orand-v3/OrandManagementV3.sol

// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.19;

import '../libraries/Bytes.sol';
import './interfaces/IOrandManagementV3.sol';

contract OrandManagementV3 is IOrandManagementV3 {
  // Public key that will be use to
  uint256[2] private publicKey;

  // Event Set New Public Key
  event SetNewPublicKey(address indexed actor, uint256 indexed pkx, uint256 indexed pky);

  // Set public key of Orand at the constructing time

  function _initOrandManagementV3(uint256[2] memory publickey) internal {
    _setPublicKey(publickey);
  }

  //=======================[  Internal  ]====================

  // Set new public key by XY to verify ECVRF proof
  function _setPublicKey(uint256[2] memory publickey) internal {
    publicKey = publickey;
    emit SetNewPublicKey(msg.sender, publickey[0], publickey[1]);
  }

  //=======================[  Internal view ]====================

  // Get public key
  function _getPublicKey() internal view returns (uint256[2] memory pubKey) {
    return publicKey;
  }

  // Get public key digest
  function _getPublicKeyDigest() internal view returns (bytes32 pubKeyDigest) {
    return keccak256(abi.encodePacked(publicKey));
  }

  //=======================[  External view  ]====================

  // Get public key
  function getPublicKey() external view returns (uint256[2] memory pubKey) {
    return _getPublicKey();
  }

  // Get digest of corresponding public key
  function getPublicKeyDigest() external view returns (bytes32 operator) {
    return _getPublicKeyDigest();
  }
}
          

contracts/orand-v3/OrandStorageV3.sol

// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.19;

import './interfaces/IOrandStorageV3.sol';
import '../libraries/Bytes.sol';

contract OrandStorageV3 is IOrandStorageV3 {
  using Bytes for bytes;

  // Event: New Epoch
  event NewEpoch(address indexed receiverAddress, uint96 indexed receiverEpoch, uint256 indexed randomness);

  // Storage of recent epoch's result
  // Map epoch ++ receiver  -> alpha
  mapping(uint256 => uint256) private epochResult;

  // Map receiver -> total epoch
  mapping(address => uint256) private epochMax;

  //=======================[  Internal  ]====================

  // Add validity epoch
  function _addEpoch(address receiver, uint256 result) internal {
    uint96 epoch = uint96(epochMax[receiver]);
    // Add epoch to storage
    // epoch != 0 => able to sue == true
    epochResult[_packing(epoch, receiver)] = result;
    // If add new epoch we increase the epoch max 1
    epochMax[receiver] = epoch + 1;
    // Emit event to outside of EVM
    emit NewEpoch(receiver, epoch, result);
  }

  //=======================[  Internal pure ]====================

  // Packing adderss and uint96 to a single bytes32
  // 96 bits a ++ 160 bits b
  function _packing(uint96 a, address b) internal pure returns (uint256 packed) {
    assembly {
      packed := or(shl(160, a), b)
    }
  }

  //=======================[  Internal View  ]====================

  // Get result of current epoch
  function _getCurrentEpoch(address receiver) internal view returns (uint96 epoch) {
    epoch = uint96(epochMax[receiver]);
    return (epoch > 0) ? epoch - 1 : epoch;
  }

  // Get total number of epoch for a given receiver
  function _getTotalEpoch(address receiver) internal view returns (uint96 epoch) {
    return uint96(epochMax[receiver]);
  }

  // Get result of current epoch
  function _getCurrentEpochResult(address receiver) internal view returns (uint256 result) {
    return epochResult[_packing(_getCurrentEpoch(receiver), receiver)];
  }

  //=======================[  External View  ]====================

  // Get a given epoch result for a given receiver
  function getEpochResult(address receiver, uint96 epoch) external view returns (uint256 result) {
    return epochResult[_packing(epoch, receiver)];
  }

  // Get current epoch of a given receiver
  function getCurrentEpochResult(address receiver) external view returns (uint256 result) {
    return _getCurrentEpochResult(receiver);
  }

  // Get total number of epochs for a given receiver
  function getTotalEpoch(address receiver) external view returns (uint96 epoch) {
    return _getTotalEpoch(receiver);
  }

  // Get current epoch of a given receiver
  function getCurrentEpoch(address receiver) external view returns (uint96 epoch) {
    return _getCurrentEpoch(receiver);
  }
}
          

contracts/orand-v3/interfaces/IOrandConsumerV3.sol

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

error InvalidProvider();

/**
* @dev IOrandConsumerV3 must be implemented for all service that use Orand
*/
interface IOrandConsumerV3 {
  /**
  * Consume the verifiable randomness from Orand provider
  * @param randomness Randomness value
  * @return return false if you want to stop batching otherwise return true
  */
  function consumeRandomness(uint256 randomness) external returns (bool);
  /**
  * Check the fulfill status of randomness batching
  * @return true if all requests are fulfilled otherwise return false
  */
  function isFulfilled() external returns (bool);
}
          

contracts/orand-v3/interfaces/IOrandECDSAV3.sol

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

// Error
error InvalidECDSAProofLength(uint256 proofLength);
error InvalidProofSigner(address proofSigner);

interface IOrandECDSAV3 {
  // Struct Orand ECDSA proof
  struct OrandECDSAProof {
    address signer;
    address receiverAddress;
    uint96 receiverEpoch;
    uint256 ecvrfProofDigest;
  }

  // Get signer address from a valid proof
  function decomposeProof(bytes memory proof) external pure returns (OrandECDSAProof memory ecdsaProof);

  // Get operator
  function getOperator() external view returns (address operatorAddress);
}
          

contracts/orand-v3/interfaces/IOrandManagementV3.sol

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

interface IOrandManagementV3 {
  // Get public key
  function getPublicKey() external view returns (uint256[2] memory pubKey);

  // Get digest of corresponding public key
  function getPublicKeyDigest() external view returns (bytes32 operator);
}
          

contracts/orand-v3/interfaces/IOrandProviderV3.sol

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import './IOrandECDSAV3.sol';

error UnableToForwardRandomness(address receiver, uint256 y);
error InvalidAlphaValue(uint256 expectedAlpha, uint256 givenAlpha);
error InvalidGenesisEpoch(uint256 currentEpoch);
error InvalidECVRFProofDigest();
error InvalidECDSAProof(address signerAddress);

interface IOrandProviderV3 is IOrandECDSAV3 {
  // ECVRF struct
  struct ECVRFProof {
    uint256[2] gamma;
    uint256 c;
    uint256 s;
    uint256 alpha;
    address uWitness;
    uint256[2] cGammaWitness;
    uint256[2] sHashWitness;
    uint256 zInv;
  }

  // Start new genesis for receiver
  function genesis(bytes memory fraudProof, ECVRFProof calldata ecvrfProof) external returns (bool);

  // Publish new epoch with Fraud Proof
  function publishFraudProof(bytes memory fraudProof, ECVRFProof calldata ecvrfProof) external returns (bool);

  // Publish new epoch with ECDSA Proof and Fraud Proof
  function publish(address receiver, ECVRFProof calldata ecvrfProof) external returns (bool);

  // Verify a ECVRF proof epoch is valid or not
  function verifyEpoch(
    bytes memory fraudProof,
    ECVRFProof calldata ecvrfProof
  )
    external
    view
    returns (
      OrandECDSAProof memory ecdsaProof,
      uint96 currentEpochNumber,
      bool isEpochLinked,
      bool isValidDualProof,
      uint256 currentEpochResult,
      uint256 verifiedEpochResult
    );

  // Get address of ECVRF verifier
  function getECVRFVerifier() external view returns (address ecvrfVerifier);
}
          

contracts/orand-v3/interfaces/IOrandStorageV3.sol

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

interface IOrandStorageV3 {
  // Get a given epoch result for a given receiver
  function getEpochResult(address receiver, uint96 epoch) external view returns (uint256 result);

  // Get total number of epochs for a given receiver
  function getTotalEpoch(address receiver) external view returns (uint96 epoch);

  // Get current epoch of a given receiver
  function getCurrentEpoch(address receiver) external view returns (uint96 epoch);

  // Get current epoch of a given receiver
  function getCurrentEpochResult(address receiver) external view returns (uint256 result);
}
          

contracts/orocle-v1/interfaces/IOrocleAggregatorV1.sol

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

error ExistedApplication(uint32 appId);
error InvalidApplication(uint32 appId);
error InvalidApplicationName(bytes24 appName);
error InvalidRoundNumber(uint64 round, uint64 requiredRound);
error UndefinedRound(uint64 round);
error InvalidDataLength(uint256 length);
error UnableToPublishData(bytes data);
error DeactivatedUser(address user);

interface IOrocleAggregatorV1 {
  /**
   * Emit event when a new request is created
   * @param identifier Data identifier
   * @param data Data
   */
  function request(uint256 identifier, bytes calldata data) external returns (bool);

  /**
   * Fulfill request
   * @param identifier Data identifier
   * @param data Data
   */
  function fulfill(uint256 identifier, bytes calldata data) external returns (bool);

  /**
   * Check if user is deactivated
   * @param user User address
   * @return status
   */
  function isDeactivated(address user) external view returns (bool);

  /**
   * Get round of a given application
   * @param appId Application ID
   * @return round
   */
  function getMetadata(uint32 appId, bytes20 identifier) external view returns (uint64 round, uint64 lastUpdate);

  /**
   * Get data of an application
   * @param appId Application ID
   * @param round Round number
   * @param identifier Data identifier
   * @return data Data
   */
  function getData(uint32 appId, uint64 round, bytes20 identifier) external view returns (bytes32 data);

  /**
   * Get latest data of an application
   * @param appId Application ID
   * @param identifier Data identifier
   * @return data
   */
  function getLatestData(uint32 appId, bytes20 identifier) external view returns (bytes32 data);

  /**
   * Get latest data of an application
   * @param appId Application ID
   * @param identifier Data identifier
   * @return round lastUpdate data
   */
  function getLatestRound(
    uint32 appId,
    bytes20 identifier
  ) external view returns (uint64 round, uint64 lastUpdate, bytes32 data);
}
          

Compiler Settings

{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata","storageLayout"],"":["ast"]}},"optimizer":{"runs":1000,"enabled":true},"libraries":{}}
              

Contract ABI

[{"type":"error","name":"InvalidAlphaValue","inputs":[{"type":"uint256","name":"expectedAlpha","internalType":"uint256"},{"type":"uint256","name":"givenAlpha","internalType":"uint256"}]},{"type":"error","name":"InvalidECDSAProof","inputs":[{"type":"address","name":"signerAddress","internalType":"address"}]},{"type":"error","name":"InvalidECDSAProofLength","inputs":[{"type":"uint256","name":"proofLength","internalType":"uint256"}]},{"type":"error","name":"InvalidECVRFProofDigest","inputs":[]},{"type":"error","name":"InvalidGenesisEpoch","inputs":[{"type":"uint256","name":"currentEpoch","internalType":"uint256"}]},{"type":"error","name":"InvalidProofSigner","inputs":[{"type":"address","name":"proofSigner","internalType":"address"}]},{"type":"error","name":"OutOfRange","inputs":[{"type":"uint256","name":"requiredLen","internalType":"uint256"},{"type":"uint256","name":"maxLen","internalType":"uint256"}]},{"type":"event","name":"ExternalError","inputs":[{"type":"address","name":"receiverAddress","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"NewEpoch","inputs":[{"type":"address","name":"receiverAddress","internalType":"address","indexed":true},{"type":"uint96","name":"receiverEpoch","internalType":"uint96","indexed":true},{"type":"uint256","name":"randomness","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SetBatchingLimit","inputs":[{"type":"address","name":"actor","internalType":"address","indexed":true},{"type":"uint256","name":"maxBatching","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"SetNewECVRFVerifier","inputs":[{"type":"address","name":"actor","internalType":"address","indexed":true},{"type":"address","name":"ecvrfAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SetNewOperator","inputs":[{"type":"address","name":"oldOperator","internalType":"address","indexed":true},{"type":"address","name":"newOperator","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SetNewOracle","inputs":[{"type":"address","name":"actor","internalType":"address","indexed":true},{"type":"address","name":"newOracle","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SetNewPublicKey","inputs":[{"type":"address","name":"actor","internalType":"address","indexed":true},{"type":"uint256","name":"pkx","internalType":"uint256","indexed":true},{"type":"uint256","name":"pky","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"pure","outputs":[{"type":"tuple","name":"ecdsaProof","internalType":"struct IOrandECDSAV3.OrandECDSAProof","components":[{"type":"address","name":"signer","internalType":"address"},{"type":"address","name":"receiverAddress","internalType":"address"},{"type":"uint96","name":"receiverEpoch","internalType":"uint96"},{"type":"uint256","name":"ecvrfProofDigest","internalType":"uint256"}]}],"name":"decomposeProof","inputs":[{"type":"bytes","name":"proof","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"genesis","inputs":[{"type":"bytes","name":"fraudProof","internalType":"bytes"},{"type":"tuple","name":"ecvrfProof","internalType":"struct IOrandProviderV3.ECVRFProof","components":[{"type":"uint256[2]","name":"gamma","internalType":"uint256[2]"},{"type":"uint256","name":"c","internalType":"uint256"},{"type":"uint256","name":"s","internalType":"uint256"},{"type":"uint256","name":"alpha","internalType":"uint256"},{"type":"address","name":"uWitness","internalType":"address"},{"type":"uint256[2]","name":"cGammaWitness","internalType":"uint256[2]"},{"type":"uint256[2]","name":"sHashWitness","internalType":"uint256[2]"},{"type":"uint256","name":"zInv","internalType":"uint256"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint96","name":"epoch","internalType":"uint96"}],"name":"getCurrentEpoch","inputs":[{"type":"address","name":"receiver","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"result","internalType":"uint256"}],"name":"getCurrentEpochResult","inputs":[{"type":"address","name":"receiver","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"ecvrfVerifier","internalType":"address"}],"name":"getECVRFVerifier","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"result","internalType":"uint256"}],"name":"getEpochResult","inputs":[{"type":"address","name":"receiver","internalType":"address"},{"type":"uint96","name":"epoch","internalType":"uint96"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"maxBatchingLimit","internalType":"uint256"}],"name":"getMaximumBatching","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"operatorAddress","internalType":"address"}],"name":"getOperator","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"oracleAddress","internalType":"address"}],"name":"getOracle","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[2]","name":"pubKey","internalType":"uint256[2]"}],"name":"getPublicKey","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"operator","internalType":"bytes32"}],"name":"getPublicKeyDigest","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint96","name":"epoch","internalType":"uint96"}],"name":"getTotalEpoch","inputs":[{"type":"address","name":"receiver","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"uint256[2]","name":"publicKey","internalType":"uint256[2]"},{"type":"address","name":"operator","internalType":"address"},{"type":"address","name":"ecvrfAddress","internalType":"address"},{"type":"address","name":"oracleAddress","internalType":"address"},{"type":"uint256","name":"maxBatchingLimit","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"publish","inputs":[{"type":"address","name":"receiverAddress","internalType":"address"},{"type":"tuple","name":"ecvrfProof","internalType":"struct IOrandProviderV3.ECVRFProof","components":[{"type":"uint256[2]","name":"gamma","internalType":"uint256[2]"},{"type":"uint256","name":"c","internalType":"uint256"},{"type":"uint256","name":"s","internalType":"uint256"},{"type":"uint256","name":"alpha","internalType":"uint256"},{"type":"address","name":"uWitness","internalType":"address"},{"type":"uint256[2]","name":"cGammaWitness","internalType":"uint256[2]"},{"type":"uint256[2]","name":"sHashWitness","internalType":"uint256[2]"},{"type":"uint256","name":"zInv","internalType":"uint256"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"publishFraudProof","inputs":[{"type":"bytes","name":"fraudProof","internalType":"bytes"},{"type":"tuple","name":"ecvrfProof","internalType":"struct IOrandProviderV3.ECVRFProof","components":[{"type":"uint256[2]","name":"gamma","internalType":"uint256[2]"},{"type":"uint256","name":"c","internalType":"uint256"},{"type":"uint256","name":"s","internalType":"uint256"},{"type":"uint256","name":"alpha","internalType":"uint256"},{"type":"address","name":"uWitness","internalType":"address"},{"type":"uint256[2]","name":"cGammaWitness","internalType":"uint256[2]"},{"type":"uint256[2]","name":"sHashWitness","internalType":"uint256[2]"},{"type":"uint256","name":"zInv","internalType":"uint256"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"setMaxBatching","inputs":[{"type":"uint256","name":"maxBatchingLimit","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"setNewECVRFVerifier","inputs":[{"type":"address","name":"ecvrfAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"setNewOracle","inputs":[{"type":"address","name":"oracleAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"setPublicKey","inputs":[{"type":"uint256[2]","name":"pk","internalType":"uint256[2]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"ecdsaProof","internalType":"struct IOrandECDSAV3.OrandECDSAProof","components":[{"type":"address","name":"signer","internalType":"address"},{"type":"address","name":"receiverAddress","internalType":"address"},{"type":"uint96","name":"receiverEpoch","internalType":"uint96"},{"type":"uint256","name":"ecvrfProofDigest","internalType":"uint256"}]},{"type":"uint96","name":"currentEpochNumber","internalType":"uint96"},{"type":"bool","name":"isEpochLinked","internalType":"bool"},{"type":"bool","name":"isValidDualProof","internalType":"bool"},{"type":"uint256","name":"currentEpochResult","internalType":"uint256"},{"type":"uint256","name":"verifiedEpochResult","internalType":"uint256"}],"name":"verifyEpoch","inputs":[{"type":"bytes","name":"fraudProof","internalType":"bytes"},{"type":"tuple","name":"ecvrfProof","internalType":"struct IOrandProviderV3.ECVRFProof","components":[{"type":"uint256[2]","name":"gamma","internalType":"uint256[2]"},{"type":"uint256","name":"c","internalType":"uint256"},{"type":"uint256","name":"s","internalType":"uint256"},{"type":"uint256","name":"alpha","internalType":"uint256"},{"type":"address","name":"uWitness","internalType":"address"},{"type":"uint256[2]","name":"cGammaWitness","internalType":"uint256[2]"},{"type":"uint256[2]","name":"sHashWitness","internalType":"uint256[2]"},{"type":"uint256","name":"zInv","internalType":"uint256"}]}]}]
              

Contract Creation Code

Verify & Publish
0x608060405234801561001057600080fd5b50612068806100206000396000f3fe608060405234801561001057600080fd5b506004361061018d5760003560e01c8063833b1fce116100e3578063cfa51d9a1161008c578063e7f43c6811610066578063e7f43c6814610371578063f2fde38b14610379578063f4de72311461038c57600080fd5b8063cfa51d9a14610324578063e02bc3c814610349578063e5114f6c1461035157600080fd5b8063b0ab7dac116100bd578063b0ab7dac146102dc578063bf776ba414610300578063c0f948d21461031357600080fd5b8063833b1fce1461028d5780638da5cb5b146102b25780639a336be1146102c957600080fd5b806372ceb2de116101455780637fcde1c21161011f5780637fcde1c214610255578063803ab8db14610268578063804d45961461027b57600080fd5b806372ceb2de1461021c578063769862a71461022f5780637dbfe9f51461024257600080fd5b80633d6a3664116101765780633d6a3664146101dc5780634d3223a5146101ff578063715018a61461021257600080fd5b8063243904d4146101925780632e334452146101c7575b600080fd5b6101a56101a0366004611969565b61039f565b6040516bffffffffffffffffffffffff90911681526020015b60405180910390f35b6101cf6103bf565b6040516101be91906119ae565b6101ef6101ea366004611969565b6103d4565b60405190151581526020016101be565b6101a561020d366004611969565b6103f0565b61021a6103fb565b005b6101ef61022a366004611969565b61040f565b61021a61023d366004611a42565b610422565b6101ef610250366004611a9f565b610582565b6101ef610263366004611ad1565b610595565b6101ef610276366004611b06565b61067d565b6009545b6040519081526020016101be565b6008546001600160a01b03165b6040516001600160a01b0390911681526020016101be565b6000546201000090046001600160a01b031661029a565b6101ef6102d7366004611baf565b610690565b61027f6102ea366004611bf6565b60a01b1760009081526002602052604090205490565b6101ef61030e366004611baf565b61089c565b6007546001600160a01b031661029a565b610337610332366004611baf565b610a2b565b6040516101be96959493929190611c3e565b61027f610b7a565b61036461035f366004611cc0565b610b84565b6040516101be9190611cfd565b61029a610bb1565b61021a610387366004611969565b610bc5565b61027f61039a366004611969565b610c55565b6001600160a01b0381166000908152600360205260408120545b92915050565b6103c76118e1565b6103cf610c60565b905090565b60006103de610c9a565b6103e782610cfb565b5060015b919050565b60006103b982610d54565b610403610c9a565b61040d6000610d91565b565b6000610419610c9a565b6103e782610e02565b600054610100900460ff16158080156104425750600054600160ff909116105b8061045c5750303b15801561045c575060005460ff166001145b6104d35760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b6000805460ff1916600117905580156104f6576000805461ff0019166101001790555b6104fe610e5b565b61050760018055565b61051086610e64565b61051985610e6d565b61052284610e02565b61052b83610cfb565b61053482610e76565b801561057a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050565b600061058c610c9a565b6103e782610e76565b600061059f610eab565b60006105aa84610f04565b9050808360800135146105dd576040516338e5849560e11b815260048101829052608084013560248201526044016104ca565b6007546000906001600160a01b03166331ff34cf6105f9610c60565b866040518363ffffffff1660e01b8152600401610617929190611d50565b602060405180830381865afa158015610634573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106589190611dcb565b90506106648582610f34565b61066e8582610fc9565b6001925050506103b960018055565b6000610687610c9a565b6103e7826111b8565b600061069a610eab565b60006106a5846111fb565b905060006106b68260200151610f04565b9050801515806106d7575060408201516bffffffffffffffffffffffff1615155b15610711576040517f2c364f1c000000000000000000000000000000000000000000000000000000008152600481018290526024016104ca565b60065482516001600160a01b039081169116146107685781516040517f0f7070840000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201526024016104ca565b610770610c60565b8460408101356060820135608083013561079060c0850160a08601611969565b8960c0018a610100018b61014001356040516020016107b799989796959493929190611de4565b6040516020818303038152906040528051906020012060001c8260600151146107f3576040516305b604d760e01b815260040160405180910390fd5b6007546000906001600160a01b03166331ff34cf61080f610c60565b876040518363ffffffff1660e01b815260040161082d929190611d50565b602060405180830381865afa15801561084a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086e9190611dcb565b905061087e836020015182610f34565b61088c836020015182610fc9565b600193505050506103b960018055565b60006108a6610eab565b60006108b1846111fb565b905060006108c28260200151610f04565b90506108d66006546001600160a01b031690565b6001600160a01b031682600001516001600160a01b0316146109325781516040517fd90fe8e10000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201526024016104ca565b80846080013514610963576040516338e5849560e11b815260048101829052608085013560248201526044016104ca565b61096b610c60565b8460408101356060820135608083013561098b60c0850160a08601611969565b8960c0018a610100018b61014001356040516020016109b299989796959493929190611de4565b6040516020818303038152906040528051906020012060001c8260600151146109ee576040516305b604d760e01b815260040160405180910390fd5b604051600090610a02908690602001611e73565b6040516020818303038152906040528051906020012060001c905061087e836020015182610f34565b60408051608081018252600080825260208201819052918101829052606081018290529080808080610a5c886111fb565b9550610a66610c60565b87604081013560608201356080830135610a8660c0850160a08601611969565b8c60c0018d610100018e6101400135604051602001610aad99989796959493929190611de4565b6040516020818303038152906040528051906020012060001c8660600151149250610adb8660200151610d54565b9450610aea8660200151610f04565b6007546080890135821495509092506001600160a01b03166331ff34cf610b0f610c60565b896040518363ffffffff1660e01b8152600401610b2d929190611d50565b602060405180830381865afa158015610b4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6e9190611dcb565b90509295509295509295565b60006103cf6112f0565b6040805160808101825260008082526020820181905291810182905260608101919091526103b9826111fb565b60006103cf6006546001600160a01b031690565b610bcd610c9a565b6001600160a01b038116610c495760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104ca565b610c5281610d91565b50565b60006103b982610f04565b610c686118e1565b60408051808201918290529060049060029082845b815481526020019060010190808311610c7d575050505050905090565b6000546001600160a01b036201000090910416331461040d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104ca565b6008805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03831690811790915560405133907fd85f66a2d033a785734c4777d12d2526304b1727ddd6774582a4ddb3474dac9790600090a350565b6001600160a01b0381166000908152600360205260409020546bffffffffffffffffffffffff8116610d8657806103b9565b6103b9600182611e96565b600080546001600160a01b03838116620100008181027fffffffffffffffffffff0000000000000000000000000000000000000000ffff851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b6007805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03831690811790915560405133907f5f710a9b3681930bf1343b51da6fa8f2476a09903e0831f661f36bd63892931a90600090a350565b61040d33610d91565b610c52816111b8565b610c528161131f565b6009819055604051819033907fe71d538682fa7ee72ed8c324fac011fe5a8d0f5ceb54d49f35c82099889a957c90600090a350565b600260015403610efd5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104ca565b6002600155565b600060026000610f1e610f1685610d54565b60a01b851790565b8152602001908152602001600020549050919050565b6001600160a01b03821660009081526003602090815260408083205460a081901b861784526002909252909120829055610f6f816001611ec2565b6001600160a01b0384166000818152600360205260408082206bffffffffffffffffffffffff9485169055518593851692917f50524705e17603fd96db3d4cbd148655f75d19bf9ab86067ef587134b7919e8091a4505050565b8160006001600160a01b0382163b156111b25760005b6009548110156111b0576040517f2f4a1ff5000000000000000000000000000000000000000000000000000000008152600481018590526001600160a01b03841690632f4a1ff5906024016020604051808303816000875af1925050508015611065575060408051601f3d908101601f1916820190925261106291810190611ee7565b60015b6110ae576040516001600160a01b0386168152600092507f2db09d5006d15c5b3a0a9520cdb57ecb6381b7e9f478edcf029d11cfcf7dc5ad9060200160405180910390a16110b1565b91505b81156111785760085460408051606088901b6bffffffffffffffffffffffff191660208201528151601481830301815260348201928390527f0d9577c6000000000000000000000000000000000000000000000000000000009092526001600160a01b0390921691630d9577c69161112f9160009190603801611f2d565b6020604051808303816000875af115801561114e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111729190611ee7565b506111b0565b60408051602081018690520160408051601f19818403018152919052805160209091012093506111a9600182611f67565b9050610fdf565b505b50505050565b6111c560048260026118ff565b506020810151815160405133907fbfa225acb3bdc1bbe3faa03e81a000c6399a94d8db72b0c434dd5828b7083f5690600090a450565b604080516080810182526000808252602082018190529181018290526060810191909152815160811461125f5781516040517f0786993c0000000000000000000000000000000000000000000000000000000081526004016104ca91815260200190565b600061126d83826041611388565b9050600061128b60418086516112839190611f7a565b869190611388565b905060006112998282611444565b60a081901c60408601526001600160a01b0381166020808701919091529091506112c4908390611444565b60608501526112dc836112d684611492565b906114cd565b6001600160a01b0316845250919392505050565b600060046040516020016113049190611f8d565b60405160208183030381529060405280519060200120905090565b6006546040516001600160a01b038084169216907f82d04c58d23161f2b0d3c01082dae861326f4703555a22090a04f971dc00d4e790600090a36006805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b82516060906113978385611f67565b11156113cb576113a78284611f67565b845160405163abe5c32f60e01b8152600481019290925260248201526044016104ca565b60008267ffffffffffffffff8111156113e6576113e66119bc565b6040519080825280601f01601f191660200182016040528015611410576020820181803683370190505b5090508360208601016020820160005b85811015611438578281015182820152602001611420565b50919695505050505050565b8151600090611454836020611f67565b111561148957611465826020611f67565b835160405163abe5c32f60e01b8152600481019290925260248201526044016104ca565b50016020015190565b600061149e82516114f1565b826040516020016114b0929190611fc1565b604051602081830303815290604052805190602001209050919050565b60008060006114dc8585611591565b915091506114e9816115d6565b509392505050565b606060006114fe8361173b565b600101905060008167ffffffffffffffff81111561151e5761151e6119bc565b6040519080825280601f01601f191660200182016040528015611548576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461155257509392505050565b60008082516041036115c75760208301516040840151606085015160001a6115bb8782858561181d565b945094505050506115cf565b506000905060025b9250929050565b60008160048111156115ea576115ea61201c565b036115f25750565b60018160048111156116065761160661201c565b036116535760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016104ca565b60028160048111156116675761166761201c565b036116b45760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016104ca565b60038160048111156116c8576116c861201c565b03610c525760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f756500000000000000000000000000000000000000000000000000000000000060648201526084016104ca565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310611784577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef810000000083106117b0576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106117ce57662386f26fc10000830492506010015b6305f5e10083106117e6576305f5e100830492506008015b61271083106117fa57612710830492506004015b6064831061180c576064830492506002015b600a83106103b95760010192915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561185457506000905060036118d8565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156118a8573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166118d1576000600192509250506118d8565b9150600090505b94509492505050565b60405180604001604052806002906020820280368337509192915050565b826002810192821561192d579160200282015b8281111561192d578251825591602001919060010190611912565b5061193992915061193d565b5090565b5b80821115611939576000815560010161193e565b80356001600160a01b03811681146103eb57600080fd5b60006020828403121561197b57600080fd5b61198482611952565b9392505050565b8060005b60028110156111b257815184526020938401939091019060010161198f565b604081016103b9828461198b565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126119e357600080fd5b6040516040810181811067ffffffffffffffff82111715611a0657611a066119bc565b8060405250806040840185811115611a1d57600080fd5b845b81811015611a37578035835260209283019201611a1f565b509195945050505050565b600080600080600060c08688031215611a5a57600080fd5b611a6487876119d2565b9450611a7260408701611952565b9350611a8060608701611952565b9250611a8e60808701611952565b9497939650919460a0013592915050565b600060208284031215611ab157600080fd5b5035919050565b60006101608284031215611acb57600080fd5b50919050565b6000806101808385031215611ae557600080fd5b611aee83611952565b9150611afd8460208501611ab8565b90509250929050565b600060408284031215611b1857600080fd5b61198483836119d2565b600082601f830112611b3357600080fd5b813567ffffffffffffffff80821115611b4e57611b4e6119bc565b604051601f8301601f19908116603f01168101908282118183101715611b7657611b766119bc565b81604052838152866020858801011115611b8f57600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806101808385031215611bc357600080fd5b823567ffffffffffffffff811115611bda57600080fd5b611be685828601611b22565b925050611afd8460208501611ab8565b60008060408385031215611c0957600080fd5b611c1283611952565b915060208301356bffffffffffffffffffffffff81168114611c3357600080fd5b809150509250929050565b6101208101611c8982896001600160a01b03808251168352806020830151166020840152506bffffffffffffffffffffffff6040820151166040830152606081015160608301525050565b6bffffffffffffffffffffffff96909616608082015293151560a085015291151560c084015260e083015261010090910152919050565b600060208284031215611cd257600080fd5b813567ffffffffffffffff811115611ce957600080fd5b611cf584828501611b22565b949350505050565b608081016103b982846001600160a01b03808251168352806020830151166020840152506bffffffffffffffffffffffff6040820151166040830152606081015160608301525050565b60408183375050565b6101a08101611d5f828561198b565b604083604084013760408301356080830152606083013560a0830152608083013560c08301526001600160a01b03611d9960a08501611952565b1660e0830152610100604060c08501828501376101406040828601828601378085013561018085015250509392505050565b600060208284031215611ddd57600080fd5b5051919050565b6000818b825b6002811015611e09578151835260209283019290910190600101611dea565b50505060408a60408401378860808301528760a08301528660c08301526bffffffffffffffffffffffff198660601b1660e0830152611e4b60f4830186611d47565b611e59610134830185611d47565b506101748101919091526101940198975050505050505050565b6040828237604001919050565b634e487b7160e01b600052601160045260246000fd5b6bffffffffffffffffffffffff828116828216039080821115611ebb57611ebb611e80565b5092915050565b6bffffffffffffffffffffffff818116838216019080821115611ebb57611ebb611e80565b600060208284031215611ef957600080fd5b8151801515811461198457600080fd5b60005b83811015611f24578181015183820152602001611f0c565b50506000910152565b8281526040602082015260008251806040840152611f52816060850160208701611f09565b601f01601f1916919091016060019392505050565b808201808211156103b9576103b9611e80565b818103818111156103b9576103b9611e80565b60008183825b6002811015611fb2578154835260209092019160019182019101611f93565b50505060408201905092915050565b7f19457468657265756d205369676e6564204d6573736167653a0a000000000000815260008351611ff981601a850160208801611f09565b83519083019061201081601a840160208801611f09565b01601a01949350505050565b634e487b7160e01b600052602160045260246000fdfea264697066735822122067c7b495d597b680b9706e498e1788efea65ea59c9cf7576d9c03f2d783dd3e264736f6c63430008130033

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061018d5760003560e01c8063833b1fce116100e3578063cfa51d9a1161008c578063e7f43c6811610066578063e7f43c6814610371578063f2fde38b14610379578063f4de72311461038c57600080fd5b8063cfa51d9a14610324578063e02bc3c814610349578063e5114f6c1461035157600080fd5b8063b0ab7dac116100bd578063b0ab7dac146102dc578063bf776ba414610300578063c0f948d21461031357600080fd5b8063833b1fce1461028d5780638da5cb5b146102b25780639a336be1146102c957600080fd5b806372ceb2de116101455780637fcde1c21161011f5780637fcde1c214610255578063803ab8db14610268578063804d45961461027b57600080fd5b806372ceb2de1461021c578063769862a71461022f5780637dbfe9f51461024257600080fd5b80633d6a3664116101765780633d6a3664146101dc5780634d3223a5146101ff578063715018a61461021257600080fd5b8063243904d4146101925780632e334452146101c7575b600080fd5b6101a56101a0366004611969565b61039f565b6040516bffffffffffffffffffffffff90911681526020015b60405180910390f35b6101cf6103bf565b6040516101be91906119ae565b6101ef6101ea366004611969565b6103d4565b60405190151581526020016101be565b6101a561020d366004611969565b6103f0565b61021a6103fb565b005b6101ef61022a366004611969565b61040f565b61021a61023d366004611a42565b610422565b6101ef610250366004611a9f565b610582565b6101ef610263366004611ad1565b610595565b6101ef610276366004611b06565b61067d565b6009545b6040519081526020016101be565b6008546001600160a01b03165b6040516001600160a01b0390911681526020016101be565b6000546201000090046001600160a01b031661029a565b6101ef6102d7366004611baf565b610690565b61027f6102ea366004611bf6565b60a01b1760009081526002602052604090205490565b6101ef61030e366004611baf565b61089c565b6007546001600160a01b031661029a565b610337610332366004611baf565b610a2b565b6040516101be96959493929190611c3e565b61027f610b7a565b61036461035f366004611cc0565b610b84565b6040516101be9190611cfd565b61029a610bb1565b61021a610387366004611969565b610bc5565b61027f61039a366004611969565b610c55565b6001600160a01b0381166000908152600360205260408120545b92915050565b6103c76118e1565b6103cf610c60565b905090565b60006103de610c9a565b6103e782610cfb565b5060015b919050565b60006103b982610d54565b610403610c9a565b61040d6000610d91565b565b6000610419610c9a565b6103e782610e02565b600054610100900460ff16158080156104425750600054600160ff909116105b8061045c5750303b15801561045c575060005460ff166001145b6104d35760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b6000805460ff1916600117905580156104f6576000805461ff0019166101001790555b6104fe610e5b565b61050760018055565b61051086610e64565b61051985610e6d565b61052284610e02565b61052b83610cfb565b61053482610e76565b801561057a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050565b600061058c610c9a565b6103e782610e76565b600061059f610eab565b60006105aa84610f04565b9050808360800135146105dd576040516338e5849560e11b815260048101829052608084013560248201526044016104ca565b6007546000906001600160a01b03166331ff34cf6105f9610c60565b866040518363ffffffff1660e01b8152600401610617929190611d50565b602060405180830381865afa158015610634573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106589190611dcb565b90506106648582610f34565b61066e8582610fc9565b6001925050506103b960018055565b6000610687610c9a565b6103e7826111b8565b600061069a610eab565b60006106a5846111fb565b905060006106b68260200151610f04565b9050801515806106d7575060408201516bffffffffffffffffffffffff1615155b15610711576040517f2c364f1c000000000000000000000000000000000000000000000000000000008152600481018290526024016104ca565b60065482516001600160a01b039081169116146107685781516040517f0f7070840000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201526024016104ca565b610770610c60565b8460408101356060820135608083013561079060c0850160a08601611969565b8960c0018a610100018b61014001356040516020016107b799989796959493929190611de4565b6040516020818303038152906040528051906020012060001c8260600151146107f3576040516305b604d760e01b815260040160405180910390fd5b6007546000906001600160a01b03166331ff34cf61080f610c60565b876040518363ffffffff1660e01b815260040161082d929190611d50565b602060405180830381865afa15801561084a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086e9190611dcb565b905061087e836020015182610f34565b61088c836020015182610fc9565b600193505050506103b960018055565b60006108a6610eab565b60006108b1846111fb565b905060006108c28260200151610f04565b90506108d66006546001600160a01b031690565b6001600160a01b031682600001516001600160a01b0316146109325781516040517fd90fe8e10000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201526024016104ca565b80846080013514610963576040516338e5849560e11b815260048101829052608085013560248201526044016104ca565b61096b610c60565b8460408101356060820135608083013561098b60c0850160a08601611969565b8960c0018a610100018b61014001356040516020016109b299989796959493929190611de4565b6040516020818303038152906040528051906020012060001c8260600151146109ee576040516305b604d760e01b815260040160405180910390fd5b604051600090610a02908690602001611e73565b6040516020818303038152906040528051906020012060001c905061087e836020015182610f34565b60408051608081018252600080825260208201819052918101829052606081018290529080808080610a5c886111fb565b9550610a66610c60565b87604081013560608201356080830135610a8660c0850160a08601611969565b8c60c0018d610100018e6101400135604051602001610aad99989796959493929190611de4565b6040516020818303038152906040528051906020012060001c8660600151149250610adb8660200151610d54565b9450610aea8660200151610f04565b6007546080890135821495509092506001600160a01b03166331ff34cf610b0f610c60565b896040518363ffffffff1660e01b8152600401610b2d929190611d50565b602060405180830381865afa158015610b4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6e9190611dcb565b90509295509295509295565b60006103cf6112f0565b6040805160808101825260008082526020820181905291810182905260608101919091526103b9826111fb565b60006103cf6006546001600160a01b031690565b610bcd610c9a565b6001600160a01b038116610c495760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104ca565b610c5281610d91565b50565b60006103b982610f04565b610c686118e1565b60408051808201918290529060049060029082845b815481526020019060010190808311610c7d575050505050905090565b6000546001600160a01b036201000090910416331461040d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104ca565b6008805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03831690811790915560405133907fd85f66a2d033a785734c4777d12d2526304b1727ddd6774582a4ddb3474dac9790600090a350565b6001600160a01b0381166000908152600360205260409020546bffffffffffffffffffffffff8116610d8657806103b9565b6103b9600182611e96565b600080546001600160a01b03838116620100008181027fffffffffffffffffffff0000000000000000000000000000000000000000ffff851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b6007805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03831690811790915560405133907f5f710a9b3681930bf1343b51da6fa8f2476a09903e0831f661f36bd63892931a90600090a350565b61040d33610d91565b610c52816111b8565b610c528161131f565b6009819055604051819033907fe71d538682fa7ee72ed8c324fac011fe5a8d0f5ceb54d49f35c82099889a957c90600090a350565b600260015403610efd5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104ca565b6002600155565b600060026000610f1e610f1685610d54565b60a01b851790565b8152602001908152602001600020549050919050565b6001600160a01b03821660009081526003602090815260408083205460a081901b861784526002909252909120829055610f6f816001611ec2565b6001600160a01b0384166000818152600360205260408082206bffffffffffffffffffffffff9485169055518593851692917f50524705e17603fd96db3d4cbd148655f75d19bf9ab86067ef587134b7919e8091a4505050565b8160006001600160a01b0382163b156111b25760005b6009548110156111b0576040517f2f4a1ff5000000000000000000000000000000000000000000000000000000008152600481018590526001600160a01b03841690632f4a1ff5906024016020604051808303816000875af1925050508015611065575060408051601f3d908101601f1916820190925261106291810190611ee7565b60015b6110ae576040516001600160a01b0386168152600092507f2db09d5006d15c5b3a0a9520cdb57ecb6381b7e9f478edcf029d11cfcf7dc5ad9060200160405180910390a16110b1565b91505b81156111785760085460408051606088901b6bffffffffffffffffffffffff191660208201528151601481830301815260348201928390527f0d9577c6000000000000000000000000000000000000000000000000000000009092526001600160a01b0390921691630d9577c69161112f9160009190603801611f2d565b6020604051808303816000875af115801561114e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111729190611ee7565b506111b0565b60408051602081018690520160408051601f19818403018152919052805160209091012093506111a9600182611f67565b9050610fdf565b505b50505050565b6111c560048260026118ff565b506020810151815160405133907fbfa225acb3bdc1bbe3faa03e81a000c6399a94d8db72b0c434dd5828b7083f5690600090a450565b604080516080810182526000808252602082018190529181018290526060810191909152815160811461125f5781516040517f0786993c0000000000000000000000000000000000000000000000000000000081526004016104ca91815260200190565b600061126d83826041611388565b9050600061128b60418086516112839190611f7a565b869190611388565b905060006112998282611444565b60a081901c60408601526001600160a01b0381166020808701919091529091506112c4908390611444565b60608501526112dc836112d684611492565b906114cd565b6001600160a01b0316845250919392505050565b600060046040516020016113049190611f8d565b60405160208183030381529060405280519060200120905090565b6006546040516001600160a01b038084169216907f82d04c58d23161f2b0d3c01082dae861326f4703555a22090a04f971dc00d4e790600090a36006805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b82516060906113978385611f67565b11156113cb576113a78284611f67565b845160405163abe5c32f60e01b8152600481019290925260248201526044016104ca565b60008267ffffffffffffffff8111156113e6576113e66119bc565b6040519080825280601f01601f191660200182016040528015611410576020820181803683370190505b5090508360208601016020820160005b85811015611438578281015182820152602001611420565b50919695505050505050565b8151600090611454836020611f67565b111561148957611465826020611f67565b835160405163abe5c32f60e01b8152600481019290925260248201526044016104ca565b50016020015190565b600061149e82516114f1565b826040516020016114b0929190611fc1565b604051602081830303815290604052805190602001209050919050565b60008060006114dc8585611591565b915091506114e9816115d6565b509392505050565b606060006114fe8361173b565b600101905060008167ffffffffffffffff81111561151e5761151e6119bc565b6040519080825280601f01601f191660200182016040528015611548576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461155257509392505050565b60008082516041036115c75760208301516040840151606085015160001a6115bb8782858561181d565b945094505050506115cf565b506000905060025b9250929050565b60008160048111156115ea576115ea61201c565b036115f25750565b60018160048111156116065761160661201c565b036116535760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016104ca565b60028160048111156116675761166761201c565b036116b45760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016104ca565b60038160048111156116c8576116c861201c565b03610c525760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f756500000000000000000000000000000000000000000000000000000000000060648201526084016104ca565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310611784577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef810000000083106117b0576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106117ce57662386f26fc10000830492506010015b6305f5e10083106117e6576305f5e100830492506008015b61271083106117fa57612710830492506004015b6064831061180c576064830492506002015b600a83106103b95760010192915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561185457506000905060036118d8565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156118a8573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166118d1576000600192509250506118d8565b9150600090505b94509492505050565b60405180604001604052806002906020820280368337509192915050565b826002810192821561192d579160200282015b8281111561192d578251825591602001919060010190611912565b5061193992915061193d565b5090565b5b80821115611939576000815560010161193e565b80356001600160a01b03811681146103eb57600080fd5b60006020828403121561197b57600080fd5b61198482611952565b9392505050565b8060005b60028110156111b257815184526020938401939091019060010161198f565b604081016103b9828461198b565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126119e357600080fd5b6040516040810181811067ffffffffffffffff82111715611a0657611a066119bc565b8060405250806040840185811115611a1d57600080fd5b845b81811015611a37578035835260209283019201611a1f565b509195945050505050565b600080600080600060c08688031215611a5a57600080fd5b611a6487876119d2565b9450611a7260408701611952565b9350611a8060608701611952565b9250611a8e60808701611952565b9497939650919460a0013592915050565b600060208284031215611ab157600080fd5b5035919050565b60006101608284031215611acb57600080fd5b50919050565b6000806101808385031215611ae557600080fd5b611aee83611952565b9150611afd8460208501611ab8565b90509250929050565b600060408284031215611b1857600080fd5b61198483836119d2565b600082601f830112611b3357600080fd5b813567ffffffffffffffff80821115611b4e57611b4e6119bc565b604051601f8301601f19908116603f01168101908282118183101715611b7657611b766119bc565b81604052838152866020858801011115611b8f57600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806101808385031215611bc357600080fd5b823567ffffffffffffffff811115611bda57600080fd5b611be685828601611b22565b925050611afd8460208501611ab8565b60008060408385031215611c0957600080fd5b611c1283611952565b915060208301356bffffffffffffffffffffffff81168114611c3357600080fd5b809150509250929050565b6101208101611c8982896001600160a01b03808251168352806020830151166020840152506bffffffffffffffffffffffff6040820151166040830152606081015160608301525050565b6bffffffffffffffffffffffff96909616608082015293151560a085015291151560c084015260e083015261010090910152919050565b600060208284031215611cd257600080fd5b813567ffffffffffffffff811115611ce957600080fd5b611cf584828501611b22565b949350505050565b608081016103b982846001600160a01b03808251168352806020830151166020840152506bffffffffffffffffffffffff6040820151166040830152606081015160608301525050565b60408183375050565b6101a08101611d5f828561198b565b604083604084013760408301356080830152606083013560a0830152608083013560c08301526001600160a01b03611d9960a08501611952565b1660e0830152610100604060c08501828501376101406040828601828601378085013561018085015250509392505050565b600060208284031215611ddd57600080fd5b5051919050565b6000818b825b6002811015611e09578151835260209283019290910190600101611dea565b50505060408a60408401378860808301528760a08301528660c08301526bffffffffffffffffffffffff198660601b1660e0830152611e4b60f4830186611d47565b611e59610134830185611d47565b506101748101919091526101940198975050505050505050565b6040828237604001919050565b634e487b7160e01b600052601160045260246000fd5b6bffffffffffffffffffffffff828116828216039080821115611ebb57611ebb611e80565b5092915050565b6bffffffffffffffffffffffff818116838216019080821115611ebb57611ebb611e80565b600060208284031215611ef957600080fd5b8151801515811461198457600080fd5b60005b83811015611f24578181015183820152602001611f0c565b50506000910152565b8281526040602082015260008251806040840152611f52816060850160208701611f09565b601f01601f1916919091016060019392505050565b808201808211156103b9576103b9611e80565b818103818111156103b9576103b9611e80565b60008183825b6002811015611fb2578154835260209092019160019182019101611f93565b50505060408201905092915050565b7f19457468657265756d205369676e6564204d6573736167653a0a000000000000815260008351611ff981601a850160208801611f09565b83519083019061201081601a840160208801611f09565b01601a01949350505050565b634e487b7160e01b600052602160045260246000fdfea264697066735822122067c7b495d597b680b9706e498e1788efea65ea59c9cf7576d9c03f2d783dd3e264736f6c63430008130033