ETH Price: $3,347.87 (-0.87%)

Contract

0xD6c4986bbe09f2dDb262B4611b0BA06891be605e
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Request Deposit ...212558102024-11-24 6:27:2329 days ago1732429643IN
0xD6c4986b...891be605e
0 ETH0.0003115210.2254153

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MainchainGatewayV3

Compiler Version
v0.8.23+commit.f704f362

Optimization Enabled:
Yes with 200 runs

Other Settings:
shanghai EvmVersion
File 1 of 56 : MainchainGatewayV3.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import { IBridgeManager } from "../interfaces/bridge/IBridgeManager.sol";
import { IBridgeManagerCallback } from "../interfaces/bridge/IBridgeManagerCallback.sol";
import { HasContracts, ContractType } from "../extensions/collections/HasContracts.sol";
import "../extensions/WethUnwrapper.sol";
import "../extensions/WithdrawalLimitation.sol";
import "../libraries/Transfer.sol";
import "../interfaces/IMainchainGatewayV3.sol";

contract MainchainGatewayV3 is
  WithdrawalLimitation,
  Initializable,
  AccessControlEnumerable,
  ERC1155Holder,
  IMainchainGatewayV3,
  HasContracts,
  IBridgeManagerCallback
{
  using LibTokenInfo for TokenInfo;
  using Transfer for Transfer.Request;
  using Transfer for Transfer.Receipt;

  /// @dev Withdrawal unlocker role hash
  bytes32 public constant WITHDRAWAL_UNLOCKER_ROLE = keccak256("WITHDRAWAL_UNLOCKER_ROLE");

  /// @dev Wrapped native token address
  IWETH public wrappedNativeToken;
  /// @dev Ronin network id
  uint256 public roninChainId;
  /// @dev Total deposit
  uint256 public depositCount;
  /// @dev Domain separator
  bytes32 internal _domainSeparator;
  /// @dev Mapping from mainchain token => token address on Ronin network
  mapping(address => MappedToken) internal _roninToken;
  /// @dev Mapping from withdrawal id => withdrawal hash
  mapping(uint256 => bytes32) public withdrawalHash;
  /// @dev Mapping from withdrawal id => locked
  mapping(uint256 => bool) public withdrawalLocked;

  /// @custom:deprecated Previously `_bridgeOperatorAddedBlock` (mapping(address => uint256))
  uint256 private ______deprecatedBridgeOperatorAddedBlock;
  /// @custom:deprecated Previously `_bridgeOperators` (uint256[])
  uint256 private ______deprecatedBridgeOperators;

  uint96 private _totalOperatorWeight;
  mapping(address operator => uint96 weight) private _operatorWeight;
  /// @custom:deprecated Previously `_wethUnwrapper` (address)
  uint256 private ______deprecatedWethUnwrapper;

  constructor() {
    _disableInitializers();
  }

  fallback() external payable {
    _fallback();
  }

  receive() external payable {
    _fallback();
  }

  /**
   * @dev Initializes contract storage.
   */
  function initialize(
    address _roleSetter,
    IWETH _wrappedToken,
    uint256 _roninChainId,
    uint256 _numerator,
    uint256 _highTierVWNumerator,
    uint256 _denominator,
    // _addresses[0]: mainchainTokens
    // _addresses[1]: roninTokens
    // _addresses[2]: withdrawalUnlockers
    address[][3] calldata _addresses,
    // _thresholds[0]: highTierThreshold
    // _thresholds[1]: lockedThreshold
    // _thresholds[2]: unlockFeePercentages
    // _thresholds[3]: dailyWithdrawalLimit
    uint256[][4] calldata _thresholds,
    TokenStandard[] calldata _standards
  ) external payable virtual initializer {
    _setupRole(DEFAULT_ADMIN_ROLE, _roleSetter);
    roninChainId = _roninChainId;

    _setWrappedNativeTokenContract(_wrappedToken);
    _updateDomainSeparator();
    _setThreshold(_numerator, _denominator);
    _setHighTierVoteWeightThreshold(_highTierVWNumerator, _denominator);
    _verifyThresholds();

    if (_addresses[0].length > 0) {
      // Map mainchain tokens to ronin tokens
      _mapTokens(_addresses[0], _addresses[1], _standards);
      // Sets thresholds based on the mainchain tokens
      _setHighTierThresholds(_addresses[0], _thresholds[0]);
      _setLockedThresholds(_addresses[0], _thresholds[1]);
      _setUnlockFeePercentages(_addresses[0], _thresholds[2]);
      _setDailyWithdrawalLimits(_addresses[0], _thresholds[3]);
    }

    // Grant role for withdrawal unlocker
    for (uint256 i; i < _addresses[2].length; i++) {
      _grantRole(WITHDRAWAL_UNLOCKER_ROLE, _addresses[2][i]);
    }
  }

  function initializeV2(address bridgeManagerContract) external reinitializer(2) {
    _setContract(ContractType.BRIDGE_MANAGER, bridgeManagerContract);
  }

  function initializeV3() external reinitializer(3) {
    IBridgeManager mainchainBridgeManager = IBridgeManager(getContract(ContractType.BRIDGE_MANAGER));
    (, address[] memory operators, uint96[] memory weights) = mainchainBridgeManager.getFullBridgeOperatorInfos();

    uint96 totalWeight;
    for (uint i; i < operators.length; i++) {
      _operatorWeight[operators[i]] = weights[i];
      totalWeight += weights[i];
    }
    _totalOperatorWeight = totalWeight;
  }

  function initializeV4(address payable /* wethUnwrapper_ */) external reinitializer(4) {
    /** @deprecated
     *
     * wethUnwrapper = WethUnwrapper(wethUnwrapper_);
     */
  }

  /**
   * @dev Receives ether without doing anything. Use this function to topup native token.
   */
  function receiveEther() external payable { }

  /**
   * @inheritdoc IMainchainGatewayV3
   */
  function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {
    return _domainSeparator;
  }

  /**
   * @inheritdoc IMainchainGatewayV3
   */
  function setWrappedNativeTokenContract(IWETH _wrappedToken) external virtual onlyProxyAdmin {
    _setWrappedNativeTokenContract(_wrappedToken);
  }

  /**
   * @inheritdoc IMainchainGatewayV3
   */
  function requestDepositFor(Transfer.Request calldata _request) external payable virtual whenNotPaused {
    _requestDepositFor(_request, msg.sender);
  }

  /**
   * @inheritdoc IMainchainGatewayV3
   */
  function submitWithdrawal(Transfer.Receipt calldata _receipt, Signature[] calldata _signatures) external virtual whenNotPaused returns (bool _locked) {
    return _submitWithdrawal(_receipt, _signatures);
  }

  /**
   * @inheritdoc IMainchainGatewayV3
   */
  function unlockWithdrawal(Transfer.Receipt calldata receipt) external onlyRole(WITHDRAWAL_UNLOCKER_ROLE) {
    bytes32 _receiptHash = receipt.hash();
    if (withdrawalHash[receipt.id] != receipt.hash()) {
      revert ErrInvalidReceipt();
    }
    if (!withdrawalLocked[receipt.id]) {
      revert ErrQueryForApprovedWithdrawal();
    }
    delete withdrawalLocked[receipt.id];
    emit WithdrawalUnlocked(_receiptHash, receipt);

    address token = receipt.mainchain.tokenAddr;
    if (receipt.info.erc == TokenStandard.ERC20) {
      TokenInfo memory feeInfo = receipt.info;
      feeInfo.quantity = _computeFeePercentage(receipt.info.quantity, unlockFeePercentages[token]);
      TokenInfo memory withdrawInfo = receipt.info;
      withdrawInfo.quantity = receipt.info.quantity - feeInfo.quantity;

      feeInfo.handleAssetOut(payable(msg.sender), token, wrappedNativeToken);
      withdrawInfo.handleAssetOut(payable(receipt.mainchain.addr), token, wrappedNativeToken);
    } else {
      receipt.info.handleAssetOut(payable(receipt.mainchain.addr), token, wrappedNativeToken);
    }

    emit Withdrew(_receiptHash, receipt);
  }

  /**
   * @inheritdoc IMainchainGatewayV3
   */
  function mapTokens(address[] calldata _mainchainTokens, address[] calldata _roninTokens, TokenStandard[] calldata _standards) external virtual onlyProxyAdmin {
    if (_mainchainTokens.length == 0) revert ErrEmptyArray();
    _mapTokens(_mainchainTokens, _roninTokens, _standards);
  }

  /**
   * @inheritdoc IMainchainGatewayV3
   */
  function mapTokensAndThresholds(
    address[] calldata _mainchainTokens,
    address[] calldata _roninTokens,
    TokenStandard[] calldata _standards,
    // _thresholds[0]: highTierThreshold
    // _thresholds[1]: lockedThreshold
    // _thresholds[2]: unlockFeePercentages
    // _thresholds[3]: dailyWithdrawalLimit
    uint256[][4] calldata _thresholds
  ) external virtual onlyProxyAdmin {
    if (_mainchainTokens.length == 0) revert ErrEmptyArray();
    _mapTokens(_mainchainTokens, _roninTokens, _standards);
    _setHighTierThresholds(_mainchainTokens, _thresholds[0]);
    _setLockedThresholds(_mainchainTokens, _thresholds[1]);
    _setUnlockFeePercentages(_mainchainTokens, _thresholds[2]);
    _setDailyWithdrawalLimits(_mainchainTokens, _thresholds[3]);
  }

  /**
   * @inheritdoc IMainchainGatewayV3
   */
  function getRoninToken(address mainchainToken) public view returns (MappedToken memory token) {
    token = _roninToken[mainchainToken];
    if (token.tokenAddr == address(0)) revert ErrUnsupportedToken();
  }

  /**
   * @dev Maps mainchain tokens to Ronin network.
   *
   * Requirement:
   * - The arrays have the same length.
   *
   * Emits the `TokenMapped` event.
   *
   */
  function _mapTokens(address[] calldata mainchainTokens, address[] calldata roninTokens, TokenStandard[] calldata standards) internal virtual {
    if (!(mainchainTokens.length == roninTokens.length && mainchainTokens.length == standards.length)) revert ErrLengthMismatch(msg.sig);

    for (uint256 i; i < mainchainTokens.length; ++i) {
      _roninToken[mainchainTokens[i]].tokenAddr = roninTokens[i];
      _roninToken[mainchainTokens[i]].erc = standards[i];
    }

    emit TokenMapped(mainchainTokens, roninTokens, standards);
  }

  /**
   * @dev Submits withdrawal receipt.
   *
   * Requirements:
   * - The receipt kind is withdrawal.
   * - The receipt is to withdraw on this chain.
   * - The receipt is not used to withdraw before.
   * - The withdrawal is not reached the limit threshold.
   * - The signer weight total is larger than or equal to the minimum threshold.
   * - The signature signers are in order.
   *
   * Emits the `Withdrew` once the assets are released.
   *
   */
  function _submitWithdrawal(Transfer.Receipt calldata receipt, Signature[] memory signatures) internal virtual returns (bool locked) {
    uint256 id = receipt.id;
    uint256 quantity = receipt.info.quantity;
    address tokenAddr = receipt.mainchain.tokenAddr;

    receipt.info.validate();
    if (receipt.kind != Transfer.Kind.Withdrawal) revert ErrInvalidReceiptKind();

    if (receipt.mainchain.chainId != block.chainid) {
      revert ErrInvalidChainId(msg.sig, receipt.mainchain.chainId, block.chainid);
    }

    MappedToken memory token = getRoninToken(receipt.mainchain.tokenAddr);

    if (!(token.erc == receipt.info.erc && token.tokenAddr == receipt.ronin.tokenAddr && receipt.ronin.chainId == roninChainId)) {
      revert ErrInvalidReceipt();
    }

    if (withdrawalHash[id] != 0) revert ErrQueryForProcessedWithdrawal();

    if (!(receipt.info.erc == TokenStandard.ERC721 || !_reachedWithdrawalLimit(tokenAddr, quantity))) {
      revert ErrReachedDailyWithdrawalLimit();
    }

    bytes32 receiptHash = receipt.hash();
    bytes32 receiptDigest = Transfer.receiptDigest(_domainSeparator, receiptHash);

    uint256 minimumWeight;
    (minimumWeight, locked) = _computeMinVoteWeight(receipt.info.erc, tokenAddr, quantity);

    {
      bool passed;
      address signer;
      address lastSigner;
      Signature memory sig;
      uint256 accumWeight;
      for (uint256 i; i < signatures.length; i++) {
        sig = signatures[i];
        signer = ECDSA.recover({ hash: receiptDigest, v: sig.v, r: sig.r, s: sig.s });
        if (lastSigner >= signer) revert ErrInvalidOrder(msg.sig);

        lastSigner = signer;

        uint256 w = _getWeight(signer);
        if (w == 0) revert ErrInvalidSigner(signer, w, sig);

        accumWeight += w;
        if (accumWeight >= minimumWeight) {
          passed = true;
          break;
        }
      }

      if (!passed) revert ErrQueryForInsufficientVoteWeight();
      withdrawalHash[id] = receiptHash;
    }

    if (locked) {
      withdrawalLocked[id] = true;
      emit WithdrawalLocked(receiptHash, receipt);
      return locked;
    }

    _recordWithdrawal(tokenAddr, quantity);
    receipt.info.handleAssetOut(payable(receipt.mainchain.addr), tokenAddr, wrappedNativeToken);
    emit Withdrew(receiptHash, receipt);
  }

  /**
   * @dev Requests deposit made by `_requester` address.
   *
   * Requirements:
   * - The token info is valid.
   * - The `msg.value` is 0 while depositing ERC20 token.
   * - The `msg.value` is equal to deposit quantity while depositing native token.
   *
   * Emits the `DepositRequested` event.
   *
   */
  function _requestDepositFor(Transfer.Request memory _request, address _requester) internal virtual {
    MappedToken memory _token;
    address mainchainWeth = address(wrappedNativeToken);

    _request.info.validate();
    if (_request.tokenAddr == address(0)) {
      if (_request.info.quantity != msg.value) revert ErrInvalidRequest();

      _token = getRoninToken(mainchainWeth);
      if (_token.erc != _request.info.erc) revert ErrInvalidTokenStandard();

      _request.tokenAddr = mainchainWeth;
    } else {
      if (msg.value != 0) revert ErrInvalidRequest();

      _token = getRoninToken(_request.tokenAddr);
      if (_token.erc != _request.info.erc) revert ErrInvalidTokenStandard();

      _request.info.handleAssetIn(_requester, _request.tokenAddr);

      /**
       * Withdraw if token is WETH
       *
       * `IWETH.withdraw` only sends 2300 gas, which might be insufficient when recipient is a proxy, in this case, gateway proxy.
       * However, the storage accesses of proxy relating variables on Shanghai hardfork are warm-access, only requires additional 100*2 gas. So it should be safe,
       * no need to go via a mediator of WETH unwrapper.
       */
      if (mainchainWeth == _request.tokenAddr) {
        IWETH(mainchainWeth).withdraw(_request.info.quantity);
      }
    }

    uint256 _depositId = depositCount++;
    Transfer.Receipt memory _receipt = _request.into_deposit_receipt(_requester, _depositId, _token.tokenAddr, roninChainId);

    emit DepositRequested(_receipt.hash(), _receipt);
  }

  /**
   * @dev Returns the minimum vote weight for the token.
   */
  function _computeMinVoteWeight(TokenStandard _erc, address _token, uint256 _quantity) internal virtual returns (uint256 _weight, bool _locked) {
    uint256 _totalWeight = _getTotalWeight();
    _weight = _minimumVoteWeight(_totalWeight);
    if (_erc == TokenStandard.ERC20) {
      if (highTierThreshold[_token] <= _quantity) {
        _weight = _highTierVoteWeight(_totalWeight);
      }
      _locked = _lockedWithdrawalRequest(_token, _quantity);
    }
  }

  /**
   * @dev Update domain separator.
   */
  function _updateDomainSeparator() internal {
    /*
     * _domainSeparator = keccak256(
     *   abi.encode(
     *     keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
     *     keccak256("MainchainGatewayV2"),
     *     keccak256("2"),
     *     block.chainid,
     *     address(this)
     *   )
     * );
     */
    assembly {
      let ptr := mload(0x40)
      // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
      mstore(ptr, 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f)
      // keccak256("MainchainGatewayV2")
      mstore(add(ptr, 0x20), 0x159f52c1e3a2b6a6aad3950adf713516211484e0516dad685ea662a094b7c43b)
      // keccak256("2")
      mstore(add(ptr, 0x40), 0xad7c5bef027816a800da1736444fb58a807ef4c9603b7848673f7e3a68eb14a5)
      mstore(add(ptr, 0x60), chainid())
      mstore(add(ptr, 0x80), address())
      sstore(_domainSeparator.slot, keccak256(ptr, 0xa0))
    }
  }

  /**
   * @dev Sets the WETH contract.
   *
   * Emits the `WrappedNativeTokenContractUpdated` event.
   *
   */
  function _setWrappedNativeTokenContract(IWETH _wrappedToken) internal {
    wrappedNativeToken = _wrappedToken;
    emit WrappedNativeTokenContractUpdated(_wrappedToken);
  }

  /**
   * @dev Receives ETH from WETH or creates deposit request if sender is not WETH.
   */
  function _fallback() internal virtual {
    if (msg.sender == address(wrappedNativeToken)) {
      return;
    }

    _createDepositOnFallback();
  }

  /**
   * @dev Creates deposit request.
   */
  function _createDepositOnFallback() internal virtual whenNotPaused {
    Transfer.Request memory _request;
    _request.recipientAddr = msg.sender;
    _request.info.quantity = msg.value;
    _requestDepositFor(_request, _request.recipientAddr);
  }

  /**
   * @inheritdoc GatewayV3
   */
  function _getTotalWeight() internal view override returns (uint256 totalWeight) {
    totalWeight = _totalOperatorWeight;
    if (totalWeight == 0) revert ErrNullTotalWeightProvided(msg.sig);
  }

  /**
   * @dev Returns the weight of an address.
   */
  function _getWeight(address addr) internal view returns (uint256) {
    return _operatorWeight[addr];
  }

  ///////////////////////////////////////////////
  //                CALLBACKS
  ///////////////////////////////////////////////

  /**
   * @inheritdoc IBridgeManagerCallback
   */
  function onBridgeOperatorsAdded(
    address[] calldata operators,
    uint96[] calldata weights,
    bool[] memory addeds
  ) external onlyContract(ContractType.BRIDGE_MANAGER) returns (bytes4) {
    uint256 length = operators.length;
    if (length != addeds.length || length != weights.length) revert ErrLengthMismatch(msg.sig);
    if (length == 0) {
      return IBridgeManagerCallback.onBridgeOperatorsAdded.selector;
    }

    for (uint256 i; i < length; ++i) {
      unchecked {
        if (addeds[i]) {
          _totalOperatorWeight += weights[i];
          _operatorWeight[operators[i]] = weights[i];
        }
      }
    }

    return IBridgeManagerCallback.onBridgeOperatorsAdded.selector;
  }

  /**
   * @inheritdoc IBridgeManagerCallback
   */
  function onBridgeOperatorsRemoved(address[] calldata operators, bool[] calldata removeds) external onlyContract(ContractType.BRIDGE_MANAGER) returns (bytes4) {
    uint length = operators.length;
    if (length != removeds.length) revert ErrLengthMismatch(msg.sig);
    if (length == 0) {
      return IBridgeManagerCallback.onBridgeOperatorsRemoved.selector;
    }

    uint96 totalRemovingWeight;
    for (uint i; i < length; ++i) {
      unchecked {
        if (removeds[i]) {
          totalRemovingWeight += _operatorWeight[operators[i]];
          delete _operatorWeight[operators[i]];
        }
      }
    }

    _totalOperatorWeight -= totalRemovingWeight;

    return IBridgeManagerCallback.onBridgeOperatorsRemoved.selector;
  }

  function supportsInterface(bytes4 interfaceId) public view override(AccessControlEnumerable, IERC165, ERC1155Receiver) returns (bool) {
    return
      interfaceId == type(IMainchainGatewayV3).interfaceId || interfaceId == type(IBridgeManagerCallback).interfaceId || super.supportsInterface(interfaceId);
  }
}

File 2 of 56 : AccessControlEnumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
    using EnumerableSet for EnumerableSet.AddressSet;

    mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {_grantRole} to track enumerable memberships
     */
    function _grantRole(bytes32 role, address account) internal virtual override {
        super._grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {_revokeRole} to track enumerable memberships
     */
    function _revokeRole(bytes32 role, address account) internal virtual override {
        super._revokeRole(role, account);
        _roleMembers[role].remove(account);
    }
}

File 3 of 56 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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

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

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

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

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!Address.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.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        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.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }
}

File 4 of 56 : ERC1155Holder.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol)

pragma solidity ^0.8.0;

import "./ERC1155Receiver.sol";

/**
 * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
 *
 * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
 * stuck.
 *
 * @dev _Available since v3.1._
 */
contract ERC1155Holder is ERC1155Receiver {
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}

File 5 of 56 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (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
    }

    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");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' 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 (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // 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) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @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) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 6 of 56 : IBridgeManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { IBridgeManagerEvents } from "./events/IBridgeManagerEvents.sol";

/**
 * @title IBridgeManager
 * @dev The interface for managing bridge operators.
 */
interface IBridgeManager is IBridgeManagerEvents {
  /// @notice Error indicating that cannot find the querying operator
  error ErrOperatorNotFound(address operator);
  /// @notice Error indicating that cannot find the querying governor
  error ErrGovernorNotFound(address governor);
  /// @notice Error indicating that the msg.sender is not match the required governor
  error ErrGovernorNotMatch(address required, address sender);
  /// @notice Error indicating that the governors list will go below minimum number of required governor.
  error ErrBelowMinRequiredGovernors();
  /// @notice Common invalid input error
  error ErrInvalidInput();

  /**
   * @dev The domain separator used for computing hash digests in the contract.
   */
  function DOMAIN_SEPARATOR() external view returns (bytes32);

  /**
   * @dev Returns the total number of bridge operators.
   * @return The total number of bridge operators.
   */
  function totalBridgeOperator() external view returns (uint256);

  /**
   * @dev Checks if the given address is a bridge operator.
   * @param addr The address to check.
   * @return A boolean indicating whether the address is a bridge operator.
   */
  function isBridgeOperator(address addr) external view returns (bool);

  /**
   * @dev Retrieves the full information of all registered bridge operators.
   *
   * This external function allows external callers to obtain the full information of all the registered bridge operators.
   * The returned arrays include the addresses of governors, bridge operators, and their corresponding vote weights.
   *
   * @return governors An array of addresses representing the governors of each bridge operator.
   * @return bridgeOperators An array of addresses representing the registered bridge operators.
   * @return weights An array of uint256 values representing the vote weights of each bridge operator.
   *
   * Note: The length of each array will be the same, and the order of elements corresponds to the same bridge operator.
   *
   * Example Usage:
   * ```
   * (address[] memory governors, address[] memory bridgeOperators, uint256[] memory weights) = getFullBridgeOperatorInfos();
   * for (uint256 i = 0; i < bridgeOperators.length; i++) {
   *     // Access individual information for each bridge operator.
   *     address governor = governors[i];
   *     address bridgeOperator = bridgeOperators[i];
   *     uint256 weight = weights[i];
   *     // ... (Process or use the information as required) ...
   * }
   * ```
   *
   */
  function getFullBridgeOperatorInfos() external view returns (address[] memory governors, address[] memory bridgeOperators, uint96[] memory weights);

  /**
   * @dev Returns total weights of the governor list.
   */
  function sumGovernorsWeight(address[] calldata governors) external view returns (uint256 sum);

  /**
   * @dev Returns total weights.
   */
  function getTotalWeight() external view returns (uint256);

  /**
   * @dev Returns an array of all bridge operators.
   * @return An array containing the addresses of all bridge operators.
   */
  function getBridgeOperators() external view returns (address[] memory);

  /**
   * @dev Returns the corresponding `operator` of a `governor`.
   */
  function getOperatorOf(address governor) external view returns (address operator);

  /**
   * @dev Returns the corresponding `governor` of a `operator`.
   */
  function getGovernorOf(address operator) external view returns (address governor);

  /**
   * @dev External function to retrieve the vote weight of a specific governor.
   * @param governor The address of the governor to get the vote weight for.
   * @return voteWeight The vote weight of the specified governor.
   */
  function getGovernorWeight(address governor) external view returns (uint96);

  /**
   * @dev External function to retrieve the vote weight of a specific bridge operator.
   * @param bridgeOperator The address of the bridge operator to get the vote weight for.
   * @return weight The vote weight of the specified bridge operator.
   */
  function getBridgeOperatorWeight(address bridgeOperator) external view returns (uint96 weight);

  /**
   * @dev Returns the weights of a list of governor addresses.
   */
  function getGovernorWeights(address[] calldata governors) external view returns (uint96[] memory weights);

  /**
   * @dev Returns an array of all governors.
   * @return An array containing the addresses of all governors.
   */
  function getGovernors() external view returns (address[] memory);

  /**
   * @dev Adds multiple bridge operators.
   * @param governors An array of addresses of hot/cold wallets for bridge operator to update their node address.
   * @param bridgeOperators An array of addresses representing the bridge operators to add.
   */
  function addBridgeOperators(uint96[] calldata voteWeights, address[] calldata governors, address[] calldata bridgeOperators) external;

  /**
   * @dev Removes multiple bridge operators.
   * @param bridgeOperators An array of addresses representing the bridge operators to remove.
   */
  function removeBridgeOperators(address[] calldata bridgeOperators) external;

  /**
   * @dev Self-call to update the minimum required governor.
   * @param min The minimum number, this must not less than 3.
   */
  function setMinRequiredGovernor(uint min) external;
}

File 7 of 56 : IBridgeManagerCallback.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/**
 * @title IBridgeManagerCallback
 * @dev Interface for the callback functions to be implemented by the Bridge Manager contract.
 */
interface IBridgeManagerCallback is IERC165 {
  /**
   * @dev Handles the event when bridge operators are added.
   * @param bridgeOperators The addresses of the bridge operators.
   * @param addeds The corresponding boolean values indicating whether the operators were added or not.
   * @return selector The selector of the function being called.
   */
  function onBridgeOperatorsAdded(address[] memory bridgeOperators, uint96[] calldata weights, bool[] memory addeds) external returns (bytes4 selector);

  /**
   * @dev Handles the event when bridge operators are removed.
   * @param bridgeOperators The addresses of the bridge operators.
   * @param removeds The corresponding boolean values indicating whether the operators were removed or not.
   * @return selector The selector of the function being called.
   */
  function onBridgeOperatorsRemoved(address[] memory bridgeOperators, bool[] memory removeds) external returns (bytes4 selector);
}

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

import { HasProxyAdmin } from "./HasProxyAdmin.sol";
import "../../interfaces/collections/IHasContracts.sol";
import { IdentityGuard } from "../../utils/IdentityGuard.sol";
import { ErrUnexpectedInternalCall } from "../../utils/CommonErrors.sol";

/**
 * @title HasContracts
 * @dev A contract that provides functionality to manage multiple contracts with different roles.
 */
abstract contract HasContracts is HasProxyAdmin, IHasContracts, IdentityGuard {
  /// @dev value is equal to keccak256("@ronin.dpos.collections.HasContracts.slot") - 1
  bytes32 private constant _STORAGE_SLOT = 0xdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb;

  /**
   * @dev Modifier to restrict access to functions only to contracts with a specific role.
   * @param contractType The contract type that allowed to call
   */
  modifier onlyContract(ContractType contractType) virtual {
    _requireContract(contractType);
    _;
  }

  /**
   * @inheritdoc IHasContracts
   */
  function setContract(ContractType contractType, address addr) external virtual onlyProxyAdmin {
    _requireHasCode(addr);
    _setContract(contractType, addr);
  }

  /**
   * @inheritdoc IHasContracts
   */
  function getContract(ContractType contractType) public view returns (address contract_) {
    contract_ = _getContractMap()[uint8(contractType)];
    if (contract_ == address(0)) revert ErrContractTypeNotFound(contractType);
  }

  /**
   * @dev Internal function to set the address of a contract with a specific role.
   * @param contractType The contract type of the contract to set.
   * @param addr The address of the contract to set.
   */
  function _setContract(ContractType contractType, address addr) internal virtual {
    _getContractMap()[uint8(contractType)] = addr;
    emit ContractUpdated(contractType, addr);
  }

  /**
   * @dev Internal function to access the mapping of contract addresses with roles.
   * @return contracts_ The mapping of contract addresses with roles.
   */
  function _getContractMap() private pure returns (mapping(uint8 => address) storage contracts_) {
    assembly {
      contracts_.slot := _STORAGE_SLOT
    }
  }

  /**
   * @dev Internal function to check if the calling contract has a specific role.
   * @param contractType The contract type that the calling contract must have.
   * @dev Throws an error if the calling contract does not have the specified role.
   */
  function _requireContract(ContractType contractType) private view {
    if (msg.sender != getContract(contractType)) {
      revert ErrUnexpectedInternalCall(msg.sig, contractType, msg.sender);
    }
  }
}

File 9 of 56 : WethUnwrapper.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "../interfaces/IWETH.sol";

contract WethUnwrapper is ReentrancyGuard {
  IWETH public immutable weth;

  error ErrCannotTransferFrom();
  error ErrNotWrappedContract();
  error ErrExternalCallFailed(address sender, bytes4 sig);

  constructor(address weth_) {
    if (address(weth_).code.length == 0) revert ErrNotWrappedContract();
    weth = IWETH(weth_);
  }

  fallback() external payable {
    _fallback();
  }

  receive() external payable {
    _fallback();
  }

  function unwrap(uint256 amount) external nonReentrant {
    _deductWrappedAndWithdraw(amount);
    _sendNativeTo(payable(msg.sender), amount);
  }

  function unwrapTo(uint256 amount, address payable to) external nonReentrant {
    _deductWrappedAndWithdraw(amount);
    _sendNativeTo(payable(to), amount);
  }

  function _deductWrappedAndWithdraw(uint256 amount) internal {
    (bool success,) = address(weth).call(abi.encodeCall(IWETH.transferFrom, (msg.sender, address(this), amount)));
    if (!success) revert ErrCannotTransferFrom();

    weth.withdraw(amount);
  }

  function _sendNativeTo(address payable to, uint256 val) internal {
    (bool success,) = to.call{ value: val }("");
    if (!success) {
      revert ErrExternalCallFailed(to, msg.sig);
    }
  }

  function _fallback() internal view {
    if (msg.sender != address(weth)) revert ErrNotWrappedContract();
  }
}

File 10 of 56 : WithdrawalLimitation.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./GatewayV3.sol";

abstract contract WithdrawalLimitation is GatewayV3 {
  /// @dev Error of invalid percentage.
  error ErrInvalidPercentage();
  /// @dev Error thrown when the high-tier vote weight threshold is `0`.
  error ErrNullHighTierVoteWeightProvided(bytes4 msgSig);

  /// @dev Emitted when the high-tier vote weight threshold is updated
  event HighTierVoteWeightThresholdUpdated(
    uint256 indexed nonce, uint256 indexed numerator, uint256 indexed denominator, uint256 previousNumerator, uint256 previousDenominator
  );
  /// @dev Emitted when the thresholds for high-tier withdrawals that requires high-tier vote weights are updated
  event HighTierThresholdsUpdated(address[] tokens, uint256[] thresholds);
  /// @dev Emitted when the thresholds for locked withdrawals are updated
  event LockedThresholdsUpdated(address[] tokens, uint256[] thresholds);
  /// @dev Emitted when the fee percentages to unlock withdraw are updated
  event UnlockFeePercentagesUpdated(address[] tokens, uint256[] percentages);
  /// @dev Emitted when the daily limit thresholds are updated
  event DailyWithdrawalLimitsUpdated(address[] tokens, uint256[] limits);

  uint256 public constant _MAX_PERCENTAGE = 1_000_000;

  uint256 internal _highTierVWNum;
  uint256 internal _highTierVWDenom;

  /// @dev Mapping from mainchain token => the amount thresholds for high-tier withdrawals that requires high-tier vote weights
  mapping(address => uint256) public highTierThreshold;
  /// @dev Mapping from mainchain token => the amount thresholds to lock withdrawal
  mapping(address => uint256) public lockedThreshold;
  /// @dev Mapping from mainchain token => unlock fee percentages for unlocker
  /// @notice Values 0-1,000,000 map to 0%-100%
  mapping(address => uint256) public unlockFeePercentages;
  /// @dev Mapping from mainchain token => daily limit amount for withdrawal
  mapping(address => uint256) public dailyWithdrawalLimit;
  /// @dev Mapping from token address => today withdrawal amount
  mapping(address => uint256) public lastSyncedWithdrawal;
  /// @dev Mapping from token address => last date synced to record the `lastSyncedWithdrawal`
  mapping(address => uint256) public lastDateSynced;

  /**
   * @dev This empty reserved space is put in place to allow future versions to add new
   * variables without shifting down storage in the inheritance chain.
   */
  uint256[50] private ______gap;

  /**
   * @dev Override `GatewayV3-setThreshold`.
   *
   * Requirements:
   * - The high-tier vote weight threshold must equal to or larger than the normal threshold.
   *
   */
  function setThreshold(uint256 num, uint256 denom) external virtual override onlyProxyAdmin {
    _setThreshold(num, denom);
    _verifyThresholds();
  }

  /**
   * @dev Returns the high-tier vote weight threshold.
   */
  function getHighTierVoteWeightThreshold() external view virtual returns (uint256, uint256) {
    return (_highTierVWNum, _highTierVWDenom);
  }

  /**
   * @dev Checks whether the `_voteWeight` passes the high-tier vote weight threshold.
   */
  function checkHighTierVoteWeightThreshold(uint256 _voteWeight) external view virtual returns (bool) {
    return _voteWeight * _highTierVWDenom >= _highTierVWNum * _getTotalWeight();
  }

  /**
   * @dev Sets high-tier vote weight threshold and returns the old one.
   *
   * Requirements:
   * - The method caller is admin.
   * - The high-tier vote weight threshold must equal to or larger than the normal threshold.
   *
   * Emits the `HighTierVoteWeightThresholdUpdated` event.
   *
   */
  function setHighTierVoteWeightThreshold(
    uint256 _numerator,
    uint256 _denominator
  ) external virtual onlyProxyAdmin returns (uint256 _previousNum, uint256 _previousDenom) {
    (_previousNum, _previousDenom) = _setHighTierVoteWeightThreshold(_numerator, _denominator);
    _verifyThresholds();
  }

  /**
   * @dev Sets the thresholds for high-tier withdrawals that requires high-tier vote weights.
   *
   * Requirements:
   * - The method caller is admin.
   * - The arrays have the same length and its length larger than 0.
   *
   * Emits the `HighTierThresholdsUpdated` event.
   *
   */
  function setHighTierThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) external virtual onlyProxyAdmin {
    if (_tokens.length == 0) revert ErrEmptyArray();
    _setHighTierThresholds(_tokens, _thresholds);
  }

  /**
   * @dev Sets the amount thresholds to lock withdrawal.
   *
   * Requirements:
   * - The method caller is admin.
   * - The arrays have the same length and its length larger than 0.
   *
   * Emits the `LockedThresholdsUpdated` event.
   *
   */
  function setLockedThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) external virtual onlyProxyAdmin {
    if (_tokens.length == 0) revert ErrEmptyArray();
    _setLockedThresholds(_tokens, _thresholds);
  }

  /**
   * @dev Sets fee percentages to unlock withdrawal.
   *
   * Requirements:
   * - The method caller is admin.
   * - The arrays have the same length and its length larger than 0.
   *
   * Emits the `UnlockFeePercentagesUpdated` event.
   *
   */
  function setUnlockFeePercentages(address[] calldata _tokens, uint256[] calldata _percentages) external virtual onlyProxyAdmin {
    if (_tokens.length == 0) revert ErrEmptyArray();
    _setUnlockFeePercentages(_tokens, _percentages);
  }

  /**
   * @dev Sets daily limit amounts for the withdrawals.
   *
   * Requirements:
   * - The method caller is admin.
   * - The arrays have the same length and its length larger than 0.
   *
   * Emits the `DailyWithdrawalLimitsUpdated` event.
   *
   */
  function setDailyWithdrawalLimits(address[] calldata _tokens, uint256[] calldata _limits) external virtual onlyProxyAdmin {
    if (_tokens.length == 0) revert ErrEmptyArray();
    _setDailyWithdrawalLimits(_tokens, _limits);
  }

  /**
   * @dev Checks whether the withdrawal reaches the limitation.
   */
  function reachedWithdrawalLimit(address _token, uint256 _quantity) external view virtual returns (bool) {
    return _reachedWithdrawalLimit(_token, _quantity);
  }

  /**
   * @dev Sets high-tier vote weight threshold and returns the old one.
   *
   * Emits the `HighTierVoteWeightThresholdUpdated` event.
   *
   */
  function _setHighTierVoteWeightThreshold(uint256 _numerator, uint256 _denominator) internal returns (uint256 _previousNum, uint256 _previousDenom) {
    if (_numerator > _denominator || _numerator == 0 || _denominator == 0) revert ErrInvalidThreshold(msg.sig);

    _previousNum = _highTierVWNum;
    _previousDenom = _highTierVWDenom;
    _highTierVWNum = _numerator;
    _highTierVWDenom = _denominator;

    unchecked {
      emit HighTierVoteWeightThresholdUpdated(nonce++, _numerator, _denominator, _previousNum, _previousDenom);
    }
  }

  /**
   * @dev Sets the thresholds for high-tier withdrawals that requires high-tier vote weights.
   *
   * Requirements:
   * - The array lengths are equal.
   *
   * Emits the `HighTierThresholdsUpdated` event.
   *
   */
  function _setHighTierThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) internal virtual {
    if (_tokens.length != _thresholds.length) revert ErrLengthMismatch(msg.sig);

    for (uint256 _i; _i < _tokens.length;) {
      highTierThreshold[_tokens[_i]] = _thresholds[_i];

      unchecked {
        ++_i;
      }
    }
    emit HighTierThresholdsUpdated(_tokens, _thresholds);
  }

  /**
   * @dev Sets the amount thresholds to lock withdrawal.
   *
   * Requirements:
   * - The array lengths are equal.
   *
   * Emits the `LockedThresholdsUpdated` event.
   *
   */
  function _setLockedThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) internal virtual {
    if (_tokens.length != _thresholds.length) revert ErrLengthMismatch(msg.sig);

    for (uint256 _i; _i < _tokens.length;) {
      lockedThreshold[_tokens[_i]] = _thresholds[_i];

      unchecked {
        ++_i;
      }
    }
    emit LockedThresholdsUpdated(_tokens, _thresholds);
  }

  /**
   * @dev Sets fee percentages to unlock withdrawal.
   *
   * Requirements:
   * - The array lengths are equal.
   * - The percentage is equal to or less than 100_000.
   *
   * Emits the `UnlockFeePercentagesUpdated` event.
   *
   */
  function _setUnlockFeePercentages(address[] calldata _tokens, uint256[] calldata _percentages) internal virtual {
    if (_tokens.length != _percentages.length) revert ErrLengthMismatch(msg.sig);

    for (uint256 _i; _i < _tokens.length;) {
      if (_percentages[_i] > _MAX_PERCENTAGE) revert ErrInvalidPercentage();

      unlockFeePercentages[_tokens[_i]] = _percentages[_i];

      unchecked {
        ++_i;
      }
    }
    emit UnlockFeePercentagesUpdated(_tokens, _percentages);
  }

  /**
   * @dev Sets daily limit amounts for the withdrawals.
   *
   * Requirements:
   * - The array lengths are equal.
   *
   * Emits the `DailyWithdrawalLimitsUpdated` event.
   *
   */
  function _setDailyWithdrawalLimits(address[] calldata _tokens, uint256[] calldata _limits) internal virtual {
    if (_tokens.length != _limits.length) revert ErrLengthMismatch(msg.sig);

    for (uint256 _i; _i < _tokens.length;) {
      dailyWithdrawalLimit[_tokens[_i]] = _limits[_i];

      unchecked {
        ++_i;
      }
    }
    emit DailyWithdrawalLimitsUpdated(_tokens, _limits);
  }

  /**
   * @dev Checks whether the withdrawal reaches the daily limitation.
   *
   * Requirements:
   * - The daily withdrawal threshold should not apply for locked withdrawals.
   *
   */
  function _reachedWithdrawalLimit(address _token, uint256 _quantity) internal view virtual returns (bool) {
    if (_lockedWithdrawalRequest(_token, _quantity)) {
      return false;
    }

    uint256 _currentDate = block.timestamp / 1 days;
    if (_currentDate > lastDateSynced[_token]) {
      return dailyWithdrawalLimit[_token] <= _quantity;
    } else {
      return dailyWithdrawalLimit[_token] <= lastSyncedWithdrawal[_token] + _quantity;
    }
  }

  /**
   * @dev Record withdrawal token.
   */
  function _recordWithdrawal(address _token, uint256 _quantity) internal virtual {
    uint256 _currentDate = block.timestamp / 1 days;
    if (_currentDate > lastDateSynced[_token]) {
      lastDateSynced[_token] = _currentDate;
      lastSyncedWithdrawal[_token] = _quantity;
    } else {
      lastSyncedWithdrawal[_token] += _quantity;
    }
  }

  /**
   * @dev Returns whether the withdrawal request is locked or not.
   */
  function _lockedWithdrawalRequest(address _token, uint256 _quantity) internal view virtual returns (bool) {
    return lockedThreshold[_token] <= _quantity;
  }

  /**
   * @dev Computes fee percentage.
   */
  function _computeFeePercentage(uint256 _amount, uint256 _percentage) internal view virtual returns (uint256) {
    return (_amount * _percentage) / _MAX_PERCENTAGE;
  }

  /**
   * @dev Returns high-tier vote weight.
   */
  function _highTierVoteWeight(uint256 _totalWeight) internal view virtual returns (uint256 highTierVW) {
    highTierVW = (_highTierVWNum * _totalWeight + _highTierVWDenom - 1) / _highTierVWDenom;
    if (highTierVW == 0) revert ErrNullHighTierVoteWeightProvided(msg.sig);
  }

  /**
   * @dev Validates whether the high-tier vote weight threshold is larger than the normal threshold.
   */
  function _verifyThresholds() internal view {
    if (_num * _highTierVWDenom > _highTierVWNum * _denom) revert ErrInvalidThreshold(msg.sig);
  }
}

File 11 of 56 : Transfer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./LibTokenInfo.sol";
import "./LibTokenOwner.sol";

library Transfer {
  using ECDSA for bytes32;
  using LibTokenOwner for TokenOwner;
  using LibTokenInfo for TokenInfo;

  enum Kind {
    Deposit,
    Withdrawal
  }

  struct Request {
    // For deposit request: Recipient address on Ronin network
    // For withdrawal request: Recipient address on mainchain network
    address recipientAddr;
    // Token address to deposit/withdraw
    // Value 0: native token
    address tokenAddr;
    TokenInfo info;
  }

  /**
   * @dev Converts the transfer request into the deposit receipt.
   */
  function into_deposit_receipt(
    Request memory _request,
    address _requester,
    uint256 _id,
    address _roninTokenAddr,
    uint256 _roninChainId
  ) internal view returns (Receipt memory _receipt) {
    _receipt.id = _id;
    _receipt.kind = Kind.Deposit;
    _receipt.mainchain.addr = _requester;
    _receipt.mainchain.tokenAddr = _request.tokenAddr;
    _receipt.mainchain.chainId = block.chainid;
    _receipt.ronin.addr = _request.recipientAddr;
    _receipt.ronin.tokenAddr = _roninTokenAddr;
    _receipt.ronin.chainId = _roninChainId;
    _receipt.info = _request.info;
  }

  /**
   * @dev Converts the transfer request into the withdrawal receipt.
   */
  function into_withdrawal_receipt(
    Request memory _request,
    address _requester,
    uint256 _id,
    address _mainchainTokenAddr,
    uint256 _mainchainId
  ) internal view returns (Receipt memory _receipt) {
    _receipt.id = _id;
    _receipt.kind = Kind.Withdrawal;
    _receipt.ronin.addr = _requester;
    _receipt.ronin.tokenAddr = _request.tokenAddr;
    _receipt.ronin.chainId = block.chainid;
    _receipt.mainchain.addr = _request.recipientAddr;
    _receipt.mainchain.tokenAddr = _mainchainTokenAddr;
    _receipt.mainchain.chainId = _mainchainId;
    _receipt.info = _request.info;
  }

  struct Receipt {
    uint256 id;
    Kind kind;
    TokenOwner mainchain;
    TokenOwner ronin;
    TokenInfo info;
  }

  // keccak256("Receipt(uint256 id,uint8 kind,TokenOwner mainchain,TokenOwner ronin,TokenInfo info)TokenInfo(uint8 erc,uint256 id,uint256 quantity)TokenOwner(address addr,address tokenAddr,uint256 chainId)");
  bytes32 public constant TYPE_HASH = 0xb9d1fe7c9deeec5dc90a2f47ff1684239519f2545b2228d3d91fb27df3189eea;

  /**
   * @dev Returns token info struct hash.
   */
  function hash(Receipt memory _receipt) internal pure returns (bytes32 digest) {
    bytes32 hashedReceiptMainchain = _receipt.mainchain.hash();
    bytes32 hashedReceiptRonin = _receipt.ronin.hash();
    bytes32 hashedReceiptInfo = _receipt.info.hash();

    /*
     * return
     *   keccak256(
     *     abi.encode(
     *       TYPE_HASH,
     *       _receipt.id,
     *       _receipt.kind,
     *       Token.hash(_receipt.mainchain),
     *       Token.hash(_receipt.ronin),
     *       Token.hash(_receipt.info)
     *     )
     *   );
     */
    assembly {
      let ptr := mload(0x40)
      mstore(ptr, TYPE_HASH)
      mstore(add(ptr, 0x20), mload(_receipt)) // _receipt.id
      mstore(add(ptr, 0x40), mload(add(_receipt, 0x20))) // _receipt.kind
      mstore(add(ptr, 0x60), hashedReceiptMainchain)
      mstore(add(ptr, 0x80), hashedReceiptRonin)
      mstore(add(ptr, 0xa0), hashedReceiptInfo)
      digest := keccak256(ptr, 0xc0)
    }
  }

  /**
   * @dev Returns the receipt digest.
   */
  function receiptDigest(bytes32 _domainSeparator, bytes32 _receiptHash) internal pure returns (bytes32) {
    return _domainSeparator.toTypedDataHash(_receiptHash);
  }
}

File 12 of 56 : IMainchainGatewayV3.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IWETH.sol";
import "./consumers/SignatureConsumer.sol";
import "./consumers/MappedTokenConsumer.sol";
import "../libraries/Transfer.sol";

interface IMainchainGatewayV3 is SignatureConsumer, MappedTokenConsumer {
  /**
   * @dev Error indicating that a query was made for an approved withdrawal.
   */
  error ErrQueryForApprovedWithdrawal();

  /**
   * @dev Error indicating that the daily withdrawal limit has been reached.
   */
  error ErrReachedDailyWithdrawalLimit();

  /**
   * @dev Error indicating that a query was made for a processed withdrawal.
   */
  error ErrQueryForProcessedWithdrawal();

  /**
   * @dev Error indicating that a query was made for insufficient vote weight.
   */
  error ErrQueryForInsufficientVoteWeight();

  /**
   * @dev Error indicating that the recovered signer from the signature has invalid vote weight.
   */
  error ErrInvalidSigner(address signer, uint256 weight, Signature sig);

  /**
   * @dev Error indicating that the total weight provided is null.
   */
  error ErrNullTotalWeightProvided(bytes4 msgSig);

  /// @dev Emitted when the deposit is requested
  event DepositRequested(bytes32 receiptHash, Transfer.Receipt receipt);
  /// @dev Emitted when the assets are withdrawn
  event Withdrew(bytes32 receiptHash, Transfer.Receipt receipt);
  /// @dev Emitted when the tokens are mapped
  event TokenMapped(address[] mainchainTokens, address[] roninTokens, TokenStandard[] standards);
  /// @dev Emitted when the wrapped native token contract is updated
  event WrappedNativeTokenContractUpdated(IWETH weth);
  /// @dev Emitted when the withdrawal is locked
  event WithdrawalLocked(bytes32 receiptHash, Transfer.Receipt receipt);
  /// @dev Emitted when the withdrawal is unlocked
  event WithdrawalUnlocked(bytes32 receiptHash, Transfer.Receipt receipt);

  /**
   * @dev Returns the WETH address.
   */
  function wrappedNativeToken() external view returns (IWETH);

  /**
   * @dev Returns the domain separator.
   */
  function DOMAIN_SEPARATOR() external view returns (bytes32);

  /**
   * @dev Returns deposit count.
   */
  function depositCount() external view returns (uint256);

  /**
   * @dev Sets the wrapped native token contract.
   *
   * Requirements:
   * - The method caller is admin.
   *
   * Emits the `WrappedNativeTokenContractUpdated` event.
   *
   */
  function setWrappedNativeTokenContract(IWETH _wrappedToken) external;

  /**
   * @dev Returns whether the withdrawal is locked.
   */
  function withdrawalLocked(uint256 withdrawalId) external view returns (bool);

  /**
   * @dev Returns the withdrawal hash.
   */
  function withdrawalHash(uint256 withdrawalId) external view returns (bytes32);

  /**
   * @dev Locks the assets and request deposit.
   */
  function requestDepositFor(Transfer.Request calldata _request) external payable;

  /**
   * @dev Withdraws based on the receipt and the validator signatures.
   * Returns whether the withdrawal is locked.
   *
   * Emits the `Withdrew` once the assets are released.
   *
   */
  function submitWithdrawal(Transfer.Receipt memory _receipt, Signature[] memory _signatures) external returns (bool _locked);

  /**
   * @dev Approves a specific withdrawal.
   *
   * Requirements:
   * - The method caller is a validator.
   *
   * Emits the `Withdrew` once the assets are released.
   *
   */
  function unlockWithdrawal(Transfer.Receipt calldata _receipt) external;

  /**
   * @dev Maps mainchain tokens to Ronin network.
   *
   * Requirement:
   * - The method caller is admin.
   * - The arrays have the same length and its length larger than 0.
   *
   * Emits the `TokenMapped` event.
   *
   */
  function mapTokens(address[] calldata _mainchainTokens, address[] calldata _roninTokens, TokenStandard[] calldata _standards) external;

  /**
   * @dev Maps mainchain tokens to Ronin network and sets thresholds.
   *
   * Requirement:
   * - The method caller is admin.
   * - The arrays have the same length and its length larger than 0.
   *
   * Emits the `TokenMapped` event.
   *
   */
  function mapTokensAndThresholds(
    address[] calldata _mainchainTokens,
    address[] calldata _roninTokens,
    TokenStandard[] calldata _standards,
    uint256[][4] calldata _thresholds
  ) external;

  /**
   * @dev Returns token address on Ronin network.
   * Note: Reverts for unsupported token.
   */
  function getRoninToken(address _mainchainToken) external view returns (MappedToken memory _token);
}

File 13 of 56 : IAccessControlEnumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerable is IAccessControl {
    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

File 14 of 56 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 15 of 56 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 *  Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
 *  See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 *  In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 16 of 56 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 17 of 56 : ERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../IERC1155Receiver.sol";
import "../../../utils/introspection/ERC165.sol";

/**
 * @dev _Available since v3.1._
 */
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
    }
}

File 18 of 56 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_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) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @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] = _HEX_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);
    }
}

File 19 of 56 : IBridgeManagerEvents.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IBridgeManagerEvents {
  /**
   * @dev Emitted when new bridge operators are added.
   */
  event BridgeOperatorsAdded(bool[] statuses, uint96[] voteWeights, address[] governors, address[] bridgeOperators);

  /**
   * @dev Emitted when a bridge operator is failed to add.
   */
  event BridgeOperatorAddingFailed(address indexed operator);

  /**
   * @dev Emitted when bridge operators are removed.
   */
  event BridgeOperatorsRemoved(bool[] statuses, address[] bridgeOperators);

  /**
   * @dev Emitted when a bridge operator is failed to remove.
   */
  event BridgeOperatorRemovingFailed(address indexed operator);

  /**
   * @dev Emitted when a bridge operator is updated.
   */
  event BridgeOperatorUpdated(address indexed governor, address indexed fromBridgeOperator, address indexed toBridgeOperator);

  /**
   * @dev Emitted when the minimum number of required governors is updated.
   */
  event MinRequiredGovernorUpdated(uint min);
}

File 20 of 56 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

File 21 of 56 : HasProxyAdmin.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/StorageSlot.sol";
import "../../utils/CommonErrors.sol";

abstract contract HasProxyAdmin {
  // bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
  bytes32 private constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

  modifier onlyProxyAdmin() {
    _requireProxyAdmin();
    _;
  }

  /**
   * @dev Returns proxy admin.
   */
  function _getProxyAdmin() internal view virtual returns (address) {
    return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
  }

  function _requireProxyAdmin() internal view {
    if (msg.sender != _getProxyAdmin()) revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);
  }
}

File 22 of 56 : IHasContracts.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.9;

import { ContractType } from "../../utils/ContractType.sol";

interface IHasContracts {
  /// @dev Error of invalid role.
  error ErrContractTypeNotFound(ContractType contractType);

  /// @dev Emitted when a contract is updated.
  event ContractUpdated(ContractType indexed contractType, address indexed addr);

  /**
   * @dev Returns the address of a contract with a specific role.
   * Throws an error if no contract is set for the specified role.
   *
   * @param contractType The role of the contract to retrieve.
   * @return contract_ The address of the contract with the specified role.
   */
  function getContract(ContractType contractType) external view returns (address contract_);

  /**
   * @dev Sets the address of a contract with a specific role.
   * Emits the event {ContractUpdated}.
   * @param contractType The role of the contract to set.
   * @param addr The address of the contract to set.
   */
  function setContract(ContractType contractType, address addr) external;
}

File 23 of 56 : IdentityGuard.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { AddressArrayUtils } from "../libraries/AddressArrayUtils.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import { TransparentUpgradeableProxyV2 } from "../extensions/TransparentUpgradeableProxyV2.sol";
import { ErrAddressIsNotCreatedEOA, ErrZeroAddress, ErrOnlySelfCall, ErrZeroCodeContract, ErrUnsupportedInterface } from "./CommonErrors.sol";

abstract contract IdentityGuard {
  using AddressArrayUtils for address[];

  /// @dev value is equal to keccak256(abi.encode())
  /// @dev see: https://eips.ethereum.org/EIPS/eip-1052
  bytes32 internal constant CREATED_ACCOUNT_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;

  /**
   * @dev Modifier to restrict functions to only be called by this contract.
   * @dev Reverts if the caller is not this contract.
   */
  modifier onlySelfCall() virtual {
    _requireSelfCall();
    _;
  }

  /**
   * @dev Modifier to ensure that the elements in the `arr` array are non-duplicates.
   * It calls the internal `_checkDuplicate` function to perform the duplicate check.
   *
   * Requirements:
   * - The elements in the `arr` array must not contain any duplicates.
   */
  modifier nonDuplicate(address[] memory arr) virtual {
    _requireNonDuplicate(arr);
    _;
  }

  /**
   * @dev Internal method to check the method caller.
   * @dev Reverts if the method caller is not this contract.
   */
  function _requireSelfCall() internal view virtual {
    if (msg.sender != address(this)) revert ErrOnlySelfCall(msg.sig);
  }

  /**
   * @dev Internal function to check if a contract address has code.
   * @param addr The address of the contract to check.
   * @dev Throws an error if the contract address has no code.
   */
  function _requireHasCode(address addr) internal view {
    if (addr.code.length == 0) revert ErrZeroCodeContract(addr);
  }

  /**
   * @dev Checks if an address is zero and reverts if it is.
   * @param addr The address to check.
   */
  function _requireNonZeroAddress(address addr) internal pure {
    if (addr == address(0)) revert ErrZeroAddress(msg.sig);
  }

  /**
   * @dev Check if arr is empty and revert if it is.
   * Checks if an array contains any duplicate addresses and reverts if duplicates are found.
   * @param arr The array of addresses to check.
   */
  function _requireNonDuplicate(address[] memory arr) internal pure {
    if (arr.hasDuplicate()) revert AddressArrayUtils.ErrDuplicated(msg.sig);
  }

  /**
   * @dev Internal function to require that the provided address is a created externally owned account (EOA).
   * This internal function is used to ensure that the provided address is a valid externally owned account (EOA).
   * It checks the codehash of the address against a predefined constant to confirm that the address is a created EOA.
   * @notice This method only works with non-state EOA accounts
   */
  function _requireCreatedEOA(address addr) internal view {
    _requireNonZeroAddress(addr);
    bytes32 codehash = addr.codehash;
    if (codehash != CREATED_ACCOUNT_HASH) revert ErrAddressIsNotCreatedEOA(addr, codehash);
  }

  /**
   * @dev Internal function to require that the specified contract supports the given interface. This method handle in
   * both case that the callee is either or not the proxy admin of the caller. If the contract does not support the
   * interface `interfaceId` or EIP165, a revert with the corresponding error message is triggered.
   *
   * @param contractAddr The address of the contract to check for interface support.
   * @param interfaceId The interface ID to check for support.
   */
  function _requireSupportsInterface(address contractAddr, bytes4 interfaceId) internal view {
    bytes memory supportsInterfaceParams = abi.encodeCall(IERC165.supportsInterface, (interfaceId));
    (bool success, bytes memory returnOrRevertData) = contractAddr.staticcall(supportsInterfaceParams);
    if (!success) {
      (success, returnOrRevertData) = contractAddr.staticcall(abi.encodeCall(TransparentUpgradeableProxyV2.functionDelegateCall, (supportsInterfaceParams)));
      if (!success) revert ErrUnsupportedInterface(interfaceId, contractAddr);
    }
    if (!abi.decode(returnOrRevertData, (bool))) revert ErrUnsupportedInterface(interfaceId, contractAddr);
  }
}

File 24 of 56 : CommonErrors.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { ContractType } from "./ContractType.sol";
import { RoleAccess } from "./RoleAccess.sol";

error ErrSyncTooFarPeriod(uint256 period, uint256 latestRewardedPeriod);
/**
 * @dev Error thrown when an address is expected to be an already created externally owned account (EOA).
 * This error indicates that the provided address is invalid for certain contract operations that require already created EOA.
 */
error ErrAddressIsNotCreatedEOA(address addr, bytes32 codehash);
/**
 * @dev Error raised when a bridge operator update operation fails.
 * @param bridgeOperator The address of the bridge operator that failed to update.
 */
error ErrBridgeOperatorUpdateFailed(address bridgeOperator);
/**
 * @dev Error thrown when attempting to add a bridge operator that already exists in the contract.
 * This error indicates that the provided bridge operator address is already registered as a bridge operator in the contract.
 */
error ErrBridgeOperatorAlreadyExisted(address bridgeOperator);
/**
 * @dev The error indicating an unsupported interface.
 * @param interfaceId The bytes4 interface identifier that is not supported.
 * @param addr The address where the unsupported interface was encountered.
 */
error ErrUnsupportedInterface(bytes4 interfaceId, address addr);
/**
 * @dev Error thrown when the return data from a callback function is invalid.
 * @param callbackFnSig The signature of the callback function that returned invalid data.
 * @param register The address of the register where the callback function was invoked.
 * @param returnData The invalid return data received from the callback function.
 */
error ErrInvalidReturnData(bytes4 callbackFnSig, address register, bytes returnData);
/**
 * @dev Error of set to non-contract.
 */
error ErrZeroCodeContract(address addr);
/**
 * @dev Error indicating that arguments are invalid.
 */
error ErrInvalidArguments(bytes4 msgSig);
/**
 * @dev Error indicating that given address is null when it should not.
 */
error ErrZeroAddress(bytes4 msgSig);
/**
 * @dev Error indicating that the provided threshold is invalid for a specific function signature.
 * @param msgSig The function signature (bytes4) that the invalid threshold applies to.
 */
error ErrInvalidThreshold(bytes4 msgSig);

/**
 * @dev Error indicating that a function can only be called by the contract itself.
 * @param msgSig The function signature (bytes4) that can only be called by the contract itself.
 */
error ErrOnlySelfCall(bytes4 msgSig);

/**
 * @dev Error indicating that the caller is unauthorized to perform a specific function.
 * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.
 * @param expectedRole The role required to perform the function.
 */
error ErrUnauthorized(bytes4 msgSig, RoleAccess expectedRole);

/**
 * @dev Error indicating that the caller is unauthorized to perform a specific function.
 * @param msgSig The function signature (bytes4) that the caller is unauthorized to perform.
 */
error ErrUnauthorizedCall(bytes4 msgSig);

/**
 * @dev Error indicating that the caller is unauthorized to perform a specific function.
 * @param msgSig The function signature (bytes4).
 * @param expectedContractType The contract type required to perform the function.
 * @param actual The actual address that called to the function.
 */
error ErrUnexpectedInternalCall(bytes4 msgSig, ContractType expectedContractType, address actual);

/**
 * @dev Error indicating that an array is empty when it should contain elements.
 */
error ErrEmptyArray();

/**
 * @dev Error indicating a mismatch in the length of input parameters or arrays for a specific function.
 * @param msgSig The function signature (bytes4) that has a length mismatch.
 */
error ErrLengthMismatch(bytes4 msgSig);

/**
 * @dev Error indicating that a proxy call to an external contract has failed.
 * @param msgSig The function signature (bytes4) of the proxy call that failed.
 * @param extCallSig The function signature (bytes4) of the external contract call that failed.
 */
error ErrProxyCallFailed(bytes4 msgSig, bytes4 extCallSig);

/**
 * @dev Error indicating that a function tried to call a precompiled contract that is not allowed.
 * @param msgSig The function signature (bytes4) that attempted to call a precompiled contract.
 */
error ErrCallPrecompiled(bytes4 msgSig);

/**
 * @dev Error indicating that a native token transfer has failed.
 * @param msgSig The function signature (bytes4) of the token transfer that failed.
 */
error ErrNativeTransferFailed(bytes4 msgSig);

/**
 * @dev Error indicating that an order is invalid.
 * @param msgSig The function signature (bytes4) of the operation that encountered an invalid order.
 */
error ErrInvalidOrder(bytes4 msgSig);

/**
 * @dev Error indicating that the chain ID is invalid.
 * @param msgSig The function signature (bytes4) of the operation that encountered an invalid chain ID.
 * @param actual Current chain ID that executing function.
 * @param expected Expected chain ID required for the tx to success.
 */
error ErrInvalidChainId(bytes4 msgSig, uint256 actual, uint256 expected);

/**
 * @dev Error indicating that a vote type is not supported.
 * @param msgSig The function signature (bytes4) of the operation that encountered an unsupported vote type.
 */
error ErrUnsupportedVoteType(bytes4 msgSig);

/**
 * @dev Error indicating that the proposal nonce is invalid.
 * @param msgSig The function signature (bytes4) of the operation that encountered an invalid proposal nonce.
 */
error ErrInvalidProposalNonce(bytes4 msgSig);

/**
 * @dev Error indicating that a voter has already voted.
 * @param voter The address of the voter who has already voted.
 */
error ErrAlreadyVoted(address voter);

/**
 * @dev Error indicating that a signature is invalid for a specific function signature.
 * @param msgSig The function signature (bytes4) that encountered an invalid signature.
 */
error ErrInvalidSignatures(bytes4 msgSig);

/**
 * @dev Error indicating that a relay call has failed.
 * @param msgSig The function signature (bytes4) of the relay call that failed.
 */
error ErrRelayFailed(bytes4 msgSig);
/**
 * @dev Error indicating that a vote weight is invalid for a specific function signature.
 * @param msgSig The function signature (bytes4) that encountered an invalid vote weight.
 */
error ErrInvalidVoteWeight(bytes4 msgSig);

/**
 * @dev Error indicating that a query was made for an outdated bridge operator set.
 */
error ErrQueryForOutdatedBridgeOperatorSet();

/**
 * @dev Error indicating that a request is invalid.
 */
error ErrInvalidRequest();

/**
 * @dev Error indicating that a token standard is invalid.
 */
error ErrInvalidTokenStandard();

/**
 * @dev Error indicating that a token is not supported.
 */
error ErrUnsupportedToken();

/**
 * @dev Error indicating that a receipt kind is invalid.
 */
error ErrInvalidReceiptKind();

/**
 * @dev Error indicating that a receipt is invalid.
 */
error ErrInvalidReceipt();

/**
 * @dev Error indicating that an address is not payable.
 */
error ErrNonpayableAddress(address);

/**
 * @dev Error indicating that the period is already processed, i.e. scattered reward.
 */
error ErrPeriodAlreadyProcessed(uint256 requestingPeriod, uint256 latestPeriod);

/**
 * @dev Error thrown when an invalid vote hash is provided.
 */
error ErrInvalidVoteHash();

/**
 * @dev Error thrown when querying for an empty vote.
 */
error ErrQueryForEmptyVote();

/**
 * @dev Error thrown when querying for an expired vote.
 */
error ErrQueryForExpiredVote();

/**
 * @dev Error thrown when querying for a non-existent vote.
 */
error ErrQueryForNonExistentVote();

/**
 * @dev Error indicating that the method is only called once per block.
 */
error ErrOncePerBlock();

/**
 * @dev Error of method caller must be coinbase
 */
error ErrCallerMustBeCoinbase();

/**
 * @dev Error thrown when an invalid proposal is encountered.
 * @param actual The actual value of the proposal.
 * @param expected The expected value of the proposal.
 */
error ErrInvalidProposal(bytes32 actual, bytes32 expected);

/**
 * @dev Error of proposal is not approved for executing.
 */
error ErrProposalNotApproved();

/**
 * @dev Error of the caller is not the specified executor.
 */
error ErrInvalidExecutor();

/**
 * @dev Error of the `caller` to relay is not the specified `executor`.
 */
error ErrNonExecutorCannotRelay(address executor, address caller);

File 25 of 56 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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].
 */
abstract 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;

    constructor() {
        _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() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 26 of 56 : IWETH.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IWETH {
  event Transfer(address indexed src, address indexed dst, uint wad);

  function deposit() external payable;

  function transfer(address dst, uint wad) external returns (bool);

  function approve(address guy, uint wad) external returns (bool);

  function transferFrom(address src, address dst, uint wad) external returns (bool);

  function withdraw(uint256 _wad) external;

  function balanceOf(address) external view returns (uint256);
}

File 27 of 56 : GatewayV3.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/security/Pausable.sol";
import "../interfaces/IQuorum.sol";
import "./collections/HasProxyAdmin.sol";

abstract contract GatewayV3 is HasProxyAdmin, Pausable, IQuorum {
  /**
   * @dev Error indicating that `_minimumVoteWeight` is returning 0.
   */
  error ErrNullMinVoteWeightProvided(bytes4 msgSig);

  uint256 internal _num;
  uint256 internal _denom;

  address private ______deprecated;
  uint256 public nonce;

  address public emergencyPauser;

  /**
   * @dev This empty reserved space is put in place to allow future versions to add new
   * variables without shifting down storage in the inheritance chain.
   */
  uint256[49] private ______gap;

  /**
   * @dev Grant emergency pauser role for `_addr`.
   */
  function setEmergencyPauser(address _addr) external onlyProxyAdmin {
    emergencyPauser = _addr;
  }

  /**
   * @inheritdoc IQuorum
   */
  function getThreshold() external view virtual returns (uint256 num_, uint256 denom_) {
    return (_num, _denom);
  }

  /**
   * @inheritdoc IQuorum
   */
  function checkThreshold(uint256 _voteWeight) external view virtual returns (bool) {
    return _voteWeight * _denom >= _num * _getTotalWeight();
  }

  /**
   * @inheritdoc IQuorum
   */
  function setThreshold(uint256 _numerator, uint256 _denominator) external virtual onlyProxyAdmin {
    return _setThreshold(_numerator, _denominator);
  }

  /**
   * @dev Triggers paused state.
   */
  function pause() external {
    _requireAuth();
    _pause();
  }

  /**
   * @dev Triggers unpaused state.
   */
  function unpause() external {
    _requireAuth();
    _unpause();
  }

  /**
   * @inheritdoc IQuorum
   */
  function minimumVoteWeight() public view virtual returns (uint256) {
    return _minimumVoteWeight(_getTotalWeight());
  }

  /**
   * @dev Sets threshold and returns the old one.
   *
   * Emits the `ThresholdUpdated` event.
   *
   */
  function _setThreshold(uint256 num, uint256 denom) internal virtual {
    if (num > denom || denom == 0 || num == 0) revert ErrInvalidThreshold(msg.sig);

    uint256 prevNum = _num;
    uint256 prevDenom = _denom;

    _num = num;
    _denom = denom;

    unchecked {
      emit ThresholdUpdated(nonce++, num, denom, prevNum, prevDenom);
    }
  }

  /**
   * @dev Returns minimum vote weight.
   */
  function _minimumVoteWeight(uint256 _totalWeight) internal view virtual returns (uint256 minVoteWeight) {
    minVoteWeight = (_num * _totalWeight + _denom - 1) / _denom;
    if (minVoteWeight == 0) revert ErrNullMinVoteWeightProvided(msg.sig);
  }

  /**
   * @dev Internal method to check method caller.
   *
   * Requirements:
   *
   * - The method caller must be admin or pauser.
   *
   */
  function _requireAuth() private view {
    if (!(msg.sender == _getProxyAdmin() || msg.sender == emergencyPauser)) {
      revert ErrUnauthorized(msg.sig, RoleAccess.ADMIN);
    }
  }

  /**
   * @dev Returns the total weight.
   */
  function _getTotalWeight() internal view virtual returns (uint256);
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 29 of 56 : LibTokenInfo.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC1155/presets/ERC1155PresetMinterPauser.sol";
import "../interfaces/IWETH.sol";

enum TokenStandard {
  ERC20,
  ERC721,
  ERC1155
}

struct TokenInfo {
  TokenStandard erc;
  // For ERC20:  the id must be 0 and the quantity is larger than 0.
  // For ERC721: the quantity must be 0.
  uint256 id;
  uint256 quantity;
}

/**
 * @dev Error indicating that the `transfer` has failed.
 * @param tokenInfo Info of the token including ERC standard, id or quantity.
 * @param to Receiver of the token value.
 * @param token Address of the token.
 */
error ErrTokenCouldNotTransfer(TokenInfo tokenInfo, address to, address token);

/**
 * @dev Error indicating that the `handleAssetIn` has failed.
 * @param tokenInfo Info of the token including ERC standard, id or quantity.
 * @param from Owner of the token value.
 * @param to Receiver of the token value.
 * @param token Address of the token.
 */
error ErrTokenCouldNotTransferFrom(TokenInfo tokenInfo, address from, address to, address token);

/// @dev Error indicating that the provided information is invalid.
error ErrInvalidInfo();

/// @dev Error indicating that the minting of ERC20 tokens has failed.
error ErrERC20MintingFailed();

/// @dev Error indicating that the minting of ERC721 tokens has failed.
error ErrERC721MintingFailed();

/// @dev Error indicating that the transfer of ERC1155 tokens has failed.
error ErrERC1155TransferFailed();

/// @dev Error indicating that the mint of ERC1155 tokens has failed.
error ErrERC1155MintingFailed();

/// @dev Error indicating that an unsupported standard is encountered.
error ErrUnsupportedStandard();

library LibTokenInfo {
  /**
   *
   *        HASH
   *
   */

  // keccak256("TokenInfo(uint8 erc,uint256 id,uint256 quantity)");
  bytes32 public constant INFO_TYPE_HASH_SINGLE = 0x1e2b74b2a792d5c0f0b6e59b037fa9d43d84fbb759337f0112fcc15ca414fc8d;

  /**
   * @dev Returns token info struct hash.
   */
  function hash(TokenInfo memory self) internal pure returns (bytes32 digest) {
    // keccak256(abi.encode(INFO_TYPE_HASH_SINGLE, info.erc, info.id, info.quantity))
    assembly ("memory-safe") {
      let ptr := mload(0x40)
      mstore(ptr, INFO_TYPE_HASH_SINGLE)
      mstore(add(ptr, 0x20), mload(self)) // info.erc
      mstore(add(ptr, 0x40), mload(add(self, 0x20))) // info.id
      mstore(add(ptr, 0x60), mload(add(self, 0x40))) // info.quantity
      digest := keccak256(ptr, 0x80)
    }
  }

  /**
   *
   *         VALIDATE
   *
   */

  /**
   * @dev Validates the token info.
   */
  function validate(TokenInfo memory self) internal pure {
    if (!(_checkERC20(self) || _checkERC721(self) || _checkERC1155(self))) {
      revert ErrInvalidInfo();
    }
  }

  function _checkERC20(TokenInfo memory self) private pure returns (bool) {
    return (self.erc == TokenStandard.ERC20 && self.quantity > 0 && self.id == 0);
  }

  function _checkERC721(TokenInfo memory self) private pure returns (bool) {
    return (self.erc == TokenStandard.ERC721 && self.quantity == 0);
  }

  function _checkERC1155(TokenInfo memory self) private pure returns (bool res) {
    // Only validate the quantity, because id of ERC-1155 can be 0.
    return (self.erc == TokenStandard.ERC1155 && self.quantity > 0);
  }

  /**
   *
   *       TRANSFER IN/OUT METHOD
   *
   */

  /**
   * @dev Transfer asset in.
   *
   * Requirements:
   * - The `_from` address must approve for the contract using this library.
   *
   */
  function handleAssetIn(TokenInfo memory self, address from, address token) internal {
    bool success;
    bytes memory data;
    if (self.erc == TokenStandard.ERC20) {
      (success, data) = token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, address(this), self.quantity));
      success = success && (data.length == 0 || abi.decode(data, (bool)));
    } else if (self.erc == TokenStandard.ERC721) {
      success = _tryTransferFromERC721(token, from, address(this), self.id);
    } else if (self.erc == TokenStandard.ERC1155) {
      success = _tryTransferFromERC1155(token, from, address(this), self.id, self.quantity);
    } else {
      revert ErrUnsupportedStandard();
    }

    if (!success) revert ErrTokenCouldNotTransferFrom(self, from, address(this), token);
  }

  /**
   * @dev Tries transfer assets out, or mint the assets if cannot transfer.
   *
   * @notice Prioritizes transfer native token if the token is wrapped.
   *
   */
  function handleAssetOut(TokenInfo memory self, address payable to, address token, IWETH wrappedNativeToken) internal {
    if (token == address(wrappedNativeToken)) {
      // Try sending the native token before transferring the wrapped token
      if (!to.send(self.quantity)) {
        wrappedNativeToken.deposit{ value: self.quantity }();
        _transferTokenOut(self, to, token);
      }

      return;
    }

    if (self.erc == TokenStandard.ERC20) {
      uint256 balance = IERC20(token).balanceOf(address(this));
      if (balance < self.quantity) {
        if (!_tryMintERC20(token, address(this), self.quantity - balance)) revert ErrERC20MintingFailed();
      }

      _transferTokenOut(self, to, token);
      return;
    }

    if (self.erc == TokenStandard.ERC721) {
      if (!_tryTransferOutOrMintERC721(token, to, self.id)) {
        revert ErrERC721MintingFailed();
      }
      return;
    }

    if (self.erc == TokenStandard.ERC1155) {
      if (!_tryTransferOutOrMintERC1155(token, to, self.id, self.quantity)) {
        revert ErrERC1155MintingFailed();
      }
      return;
    }

    revert ErrUnsupportedStandard();
  }

  /**
   *
   *      TRANSFER HELPERS
   *
   */

  /**
   * @dev Transfer assets from current address to `_to` address.
   */
  function _transferTokenOut(TokenInfo memory self, address to, address token) private {
    bool success;
    if (self.erc == TokenStandard.ERC20) {
      success = _tryTransferERC20(token, to, self.quantity);
    } else if (self.erc == TokenStandard.ERC721) {
      success = _tryTransferFromERC721(token, address(this), to, self.id);
    } else {
      revert ErrUnsupportedStandard();
    }

    if (!success) revert ErrTokenCouldNotTransfer(self, to, token);
  }

  /**
   *      TRANSFER ERC-20
   */

  /**
   * @dev Transfers ERC20 token and returns the result.
   */
  function _tryTransferERC20(address token, address to, uint256 quantity) private returns (bool success) {
    bytes memory data;
    (success, data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, quantity));
    success = success && (data.length == 0 || abi.decode(data, (bool)));
  }

  /**
   * @dev Mints ERC20 token and returns the result.
   */
  function _tryMintERC20(address token, address to, uint256 quantity) private returns (bool success) {
    // bytes4(keccak256("mint(address,uint256)"))
    (success,) = token.call(abi.encodeWithSelector(0x40c10f19, to, quantity));
  }

  /**
   *      TRANSFER ERC-721
   */

  /**
   * @dev Transfers the ERC721 token out. If the transfer failed, mints the ERC721.
   * @return success Returns `false` if both transfer and mint are failed.
   */
  function _tryTransferOutOrMintERC721(address token, address to, uint256 id) private returns (bool success) {
    success = _tryTransferFromERC721(token, address(this), to, id);
    if (!success) {
      return _tryMintERC721(token, to, id);
    }
  }

  /**
   * @dev Transfers ERC721 token and returns the result.
   */
  function _tryTransferFromERC721(address token, address from, address to, uint256 id) private returns (bool success) {
    (success,) = token.call(abi.encodeWithSelector(IERC721.transferFrom.selector, from, to, id));
  }

  /**
   * @dev Mints ERC721 token and returns the result.
   */
  function _tryMintERC721(address token, address to, uint256 id) private returns (bool success) {
    // bytes4(keccak256("mint(address,uint256)"))
    (success,) = token.call(abi.encodeWithSelector(0x40c10f19, to, id));
  }

  /**
   *      TRANSFER ERC-1155
   */

  /**
   * @dev Transfers the ERC1155 token out. If the transfer failed, mints the ERC11555.
   * @return success Returns `false` if both transfer and mint are failed.
   */
  function _tryTransferOutOrMintERC1155(address token, address to, uint256 id, uint256 amount) private returns (bool success) {
    success = _tryTransferFromERC1155(token, address(this), to, id, amount);
    if (!success) {
      return _tryMintERC1155(token, to, id, amount);
    }
  }

  /**
   * @dev Transfers ERC1155 token and returns the result.
   */
  function _tryTransferFromERC1155(address token, address from, address to, uint256 id, uint256 amount) private returns (bool success) {
    (success,) = token.call(abi.encodeCall(IERC1155.safeTransferFrom, (from, to, id, amount, new bytes(0))));
  }

  /**
   * @dev Mints ERC1155 token and returns the result.
   */
  function _tryMintERC1155(address token, address to, uint256 id, uint256 amount) private returns (bool success) {
    (success,) = token.call(abi.encodeCall(ERC1155PresetMinterPauser.mint, (to, id, amount, new bytes(0))));
  }
}

File 30 of 56 : LibTokenOwner.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

struct TokenOwner {
  address addr;
  address tokenAddr;
  uint256 chainId;
}

library LibTokenOwner {
  // keccak256("TokenOwner(address addr,address tokenAddr,uint256 chainId)");
  bytes32 public constant OWNER_TYPE_HASH = 0x353bdd8d69b9e3185b3972e08b03845c0c14a21a390215302776a7a34b0e8764;

  /**
   * @dev Returns ownership struct hash.
   */
  function hash(TokenOwner memory owner) internal pure returns (bytes32 digest) {
    // keccak256(abi.encode(OWNER_TYPE_HASH, owner.addr, owner.tokenAddr, owner.chainId))
    assembly ("memory-safe") {
      let ptr := mload(0x40)
      mstore(ptr, OWNER_TYPE_HASH)
      mstore(add(ptr, 0x20), mload(owner)) // owner.addr
      mstore(add(ptr, 0x40), mload(add(owner, 0x20))) // owner.tokenAddr
      mstore(add(ptr, 0x60), mload(add(owner, 0x40))) // owner.chainId
      digest := keccak256(ptr, 0x80)
    }
  }
}

File 31 of 56 : SignatureConsumer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface SignatureConsumer {
  struct Signature {
    uint8 v;
    bytes32 r;
    bytes32 s;
  }
}

File 32 of 56 : MappedTokenConsumer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../../libraries/LibTokenInfo.sol";

interface MappedTokenConsumer {
  struct MappedToken {
    TokenStandard erc;
    address tokenAddr;
  }
}

File 33 of 56 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

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

pragma solidity ^0.8.0;

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

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

File 35 of 56 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

File 36 of 56 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

File 37 of 56 : StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }
}

File 38 of 56 : ContractType.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

enum ContractType {
  UNKNOWN, // 0
  PAUSE_ENFORCER, // 1
  BRIDGE, // 2
  BRIDGE_TRACKING, // 3
  GOVERNANCE_ADMIN, // 4
  MAINTENANCE, // 5
  SLASH_INDICATOR, // 6
  STAKING_VESTING, // 7
  VALIDATOR, // 8
  STAKING, // 9
  RONIN_TRUSTED_ORGANIZATION, // 10
  BRIDGE_MANAGER, // 11
  BRIDGE_SLASH, // 12
  BRIDGE_REWARD, // 13
  FAST_FINALITY_TRACKING, // 14
  PROFILE // 15

}

File 39 of 56 : AddressArrayUtils.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.0;

library AddressArrayUtils {
  /**
   * @dev Error thrown when a duplicated element is detected in an array.
   * @param msgSig The function signature that invoke the error.
   */
  error ErrDuplicated(bytes4 msgSig);

  /**
   * @dev Returns whether or not there's a duplicate. Runs in O(n^2).
   * @param A Array to search
   * @return Returns true if duplicate, false otherwise
   */
  function hasDuplicate(address[] memory A) internal pure returns (bool) {
    if (A.length == 0) {
      return false;
    }
    unchecked {
      for (uint256 i = 0; i < A.length - 1; i++) {
        for (uint256 j = i + 1; j < A.length; j++) {
          if (A[i] == A[j]) {
            return true;
          }
        }
      }
    }
    return false;
  }

  /**
   * @dev Returns whether two arrays of addresses are equal or not.
   */
  function isEqual(address[] memory _this, address[] memory _other) internal pure returns (bool yes_) {
    // Hashing two arrays and compare their hash
    assembly {
      let _thisHash := keccak256(add(_this, 32), mul(mload(_this), 32))
      let _otherHash := keccak256(add(_other, 32), mul(mload(_other), 32))
      yes_ := eq(_thisHash, _otherHash)
    }
  }

  /**
   * @dev Return the concatenated array from a and b.
   */
  function extend(address[] memory a, address[] memory b) internal pure returns (address[] memory c) {
    uint256 lengthA = a.length;
    uint256 lengthB = b.length;
    unchecked {
      c = new address[](lengthA + lengthB);
    }
    uint256 i;
    for (; i < lengthA;) {
      c[i] = a[i];
      unchecked {
        ++i;
      }
    }
    for (uint256 j; j < lengthB;) {
      c[i] = b[j];
      unchecked {
        ++i;
        ++j;
      }
    }
  }
}

File 40 of 56 : TransparentUpgradeableProxyV2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

contract TransparentUpgradeableProxyV2 is TransparentUpgradeableProxy {
  constructor(address _logic, address admin_, bytes memory _data) payable TransparentUpgradeableProxy(_logic, admin_, _data) { }

  /**
   * @dev Calls a function from the current implementation as specified by `_data`, which should be an encoded function call.
   *
   * Requirements:
   * - Only the admin can call this function.
   *
   * Note: The proxy admin is not allowed to interact with the proxy logic through the fallback function to avoid
   * triggering some unexpected logic. This is to allow the administrator to explicitly call the proxy, please consider
   * reviewing the encoded data `_data` and the method which is called before using this.
   *
   */
  function functionDelegateCall(bytes memory _data) public payable ifAdmin {
    address _addr = _implementation();
    assembly {
      let _result := delegatecall(gas(), _addr, add(_data, 32), mload(_data), 0, 0)
      returndatacopy(0, 0, returndatasize())
      switch _result
      case 0 { revert(0, returndatasize()) }
      default { return(0, returndatasize()) }
    }
  }
}

File 41 of 56 : RoleAccess.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

enum RoleAccess {
  UNKNOWN, // 0
  ADMIN, // 1
  COINBASE, // 2
  GOVERNOR, // 3
  CANDIDATE_ADMIN, // 4
  WITHDRAWAL_MIGRATOR, // 5
  __DEPRECATED_BRIDGE_OPERATOR, // 6
  BLOCK_PRODUCER, // 7
  VALIDATOR_CANDIDATE, // 8
  CONSENSUS, // 9
  TREASURY // 10

}

File 42 of 56 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

File 43 of 56 : IQuorum.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IQuorum {
  /// @dev Emitted when the threshold is updated
  event ThresholdUpdated(uint256 indexed nonce, uint256 indexed numerator, uint256 indexed denominator, uint256 previousNumerator, uint256 previousDenominator);

  /**
   * @dev Returns the threshold.
   */
  function getThreshold() external view returns (uint256 _num, uint256 _denom);

  /**
   * @dev Checks whether the `_voteWeight` passes the threshold.
   */
  function checkThreshold(uint256 _voteWeight) external view returns (bool);

  /**
   * @dev Returns the minimum vote weight to pass the threshold.
   */
  function minimumVoteWeight() external view returns (uint256);

  /**
   * @dev Sets the threshold.
   *
   * Requirements:
   * - The method caller is admin.
   *
   * Emits the `ThresholdUpdated` event.
   *
   */
  function setThreshold(uint256 numerator, uint256 denominator) external;
}

File 44 of 56 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 45 of 56 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

File 46 of 56 : ERC1155PresetMinterPauser.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/presets/ERC1155PresetMinterPauser.sol)

pragma solidity ^0.8.0;

import "../ERC1155.sol";
import "../extensions/ERC1155Burnable.sol";
import "../extensions/ERC1155Pausable.sol";
import "../../../access/AccessControlEnumerable.sol";
import "../../../utils/Context.sol";

/**
 * @dev {ERC1155} token, including:
 *
 *  - ability for holders to burn (destroy) their tokens
 *  - a minter role that allows for token minting (creation)
 *  - a pauser role that allows to stop all token transfers
 *
 * This contract uses {AccessControl} to lock permissioned functions using the
 * different roles - head to its documentation for details.
 *
 * The account that deploys the contract will be granted the minter and pauser
 * roles, as well as the default admin role, which will let it grant both minter
 * and pauser roles to other accounts.
 *
 * _Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard]._
 */
contract ERC1155PresetMinterPauser is Context, AccessControlEnumerable, ERC1155Burnable, ERC1155Pausable {
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

    /**
     * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE`, and `PAUSER_ROLE` to the account that
     * deploys the contract.
     */
    constructor(string memory uri) ERC1155(uri) {
        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());

        _setupRole(MINTER_ROLE, _msgSender());
        _setupRole(PAUSER_ROLE, _msgSender());
    }

    /**
     * @dev Creates `amount` new tokens for `to`, of token type `id`.
     *
     * See {ERC1155-_mint}.
     *
     * Requirements:
     *
     * - the caller must have the `MINTER_ROLE`.
     */
    function mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual {
        require(hasRole(MINTER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have minter role to mint");

        _mint(to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] variant of {mint}.
     */
    function mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual {
        require(hasRole(MINTER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have minter role to mint");

        _mintBatch(to, ids, amounts, data);
    }

    /**
     * @dev Pauses all token transfers.
     *
     * See {ERC1155Pausable} and {Pausable-_pause}.
     *
     * Requirements:
     *
     * - the caller must have the `PAUSER_ROLE`.
     */
    function pause() public virtual {
        require(hasRole(PAUSER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have pauser role to pause");
        _pause();
    }

    /**
     * @dev Unpauses all token transfers.
     *
     * See {ERC1155Pausable} and {Pausable-_unpause}.
     *
     * Requirements:
     *
     * - the caller must have the `PAUSER_ROLE`.
     */
    function unpause() public virtual {
        require(hasRole(PAUSER_ROLE, _msgSender()), "ERC1155PresetMinterPauser: must have pauser role to unpause");
        _unpause();
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(AccessControlEnumerable, ERC1155)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }

    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual override(ERC1155, ERC1155Pausable) {
        super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
    }
}

File 47 of 56 : TransparentUpgradeableProxy.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)

pragma solidity ^0.8.0;

import "../ERC1967/ERC1967Proxy.sol";

/**
 * @dev This contract implements a proxy that is upgradeable by an admin.
 *
 * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
 * clashing], which can potentially be used in an attack, this contract uses the
 * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
 * things that go hand in hand:
 *
 * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
 * that call matches one of the admin functions exposed by the proxy itself.
 * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
 * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
 * "admin cannot fallback to proxy target".
 *
 * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
 * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
 * to sudden errors when trying to call a function from the proxy implementation.
 *
 * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
 * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
 */
contract TransparentUpgradeableProxy is ERC1967Proxy {
    /**
     * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
     * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
     */
    constructor(
        address _logic,
        address admin_,
        bytes memory _data
    ) payable ERC1967Proxy(_logic, _data) {
        _changeAdmin(admin_);
    }

    /**
     * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
     */
    modifier ifAdmin() {
        if (msg.sender == _getAdmin()) {
            _;
        } else {
            _fallback();
        }
    }

    /**
     * @dev Returns the current admin.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
     * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
     */
    function admin() external ifAdmin returns (address admin_) {
        admin_ = _getAdmin();
    }

    /**
     * @dev Returns the current implementation.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
     * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
     */
    function implementation() external ifAdmin returns (address implementation_) {
        implementation_ = _implementation();
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
     */
    function changeAdmin(address newAdmin) external virtual ifAdmin {
        _changeAdmin(newAdmin);
    }

    /**
     * @dev Upgrade the implementation of the proxy.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
     */
    function upgradeTo(address newImplementation) external ifAdmin {
        _upgradeToAndCall(newImplementation, bytes(""), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
     * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
     * proxied contract.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
     */
    function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
        _upgradeToAndCall(newImplementation, data, true);
    }

    /**
     * @dev Returns the current admin.
     */
    function _admin() internal view virtual returns (address) {
        return _getAdmin();
    }

    /**
     * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
     */
    function _beforeFallback() internal virtual override {
        require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
        super._beforeFallback();
    }
}

File 48 of 56 : ERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.0;

import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of the basic standard multi-token.
 * See https://eips.ethereum.org/EIPS/eip-1155
 * Originally based on code by Enjin: https://github.com/enjin/erc-1155
 *
 * _Available since v3.1._
 */
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
    using Address for address;

    // Mapping from token ID to account balances
    mapping(uint256 => mapping(address => uint256)) private _balances;

    // Mapping from account to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
    string private _uri;

    /**
     * @dev See {_setURI}.
     */
    constructor(string memory uri_) {
        _setURI(uri_);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC1155).interfaceId ||
            interfaceId == type(IERC1155MetadataURI).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC1155MetadataURI-uri}.
     *
     * This implementation returns the same URI for *all* token types. It relies
     * on the token type ID substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * Clients calling this function must replace the `\{id\}` substring with the
     * actual token type ID.
     */
    function uri(uint256) public view virtual override returns (string memory) {
        return _uri;
    }

    /**
     * @dev See {IERC1155-balanceOf}.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
        require(account != address(0), "ERC1155: address zero is not a valid owner");
        return _balances[id][account];
    }

    /**
     * @dev See {IERC1155-balanceOfBatch}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
        public
        view
        virtual
        override
        returns (uint256[] memory)
    {
        require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");

        uint256[] memory batchBalances = new uint256[](accounts.length);

        for (uint256 i = 0; i < accounts.length; ++i) {
            batchBalances[i] = balanceOf(accounts[i], ids[i]);
        }

        return batchBalances;
    }

    /**
     * @dev See {IERC1155-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC1155-isApprovedForAll}.
     */
    function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[account][operator];
    }

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner nor approved"
        );
        _safeTransferFrom(from, to, id, amount, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner nor approved"
        );
        _safeBatchTransferFrom(from, to, ids, amounts, data);
    }

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }
        _balances[id][to] += amount;

        emit TransferSingle(operator, from, to, id, amount);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
            _balances[id][to] += amount;
        }

        emit TransferBatch(operator, from, to, ids, amounts);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
    }

    /**
     * @dev Sets a new URI for all token types, by relying on the token type ID
     * substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * By this mechanism, any occurrence of the `\{id\}` substring in either the
     * URI or any of the amounts in the JSON file at said URI will be replaced by
     * clients with the token type ID.
     *
     * For example, the `https://token-cdn-domain/\{id\}.json` URI would be
     * interpreted by clients as
     * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
     * for token type ID 0x4cce0.
     *
     * See {uri}.
     *
     * Because these URIs cannot be meaningfully represented by the {URI} event,
     * this function emits no events.
     */
    function _setURI(string memory newuri) internal virtual {
        _uri = newuri;
    }

    /**
     * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        _balances[id][to] += amount;
        emit TransferSingle(operator, address(0), to, id, amount);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; i++) {
            _balances[ids[i]][to] += amounts[i];
        }

        emit TransferBatch(operator, address(0), to, ids, amounts);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
    }

    /**
     * @dev Destroys `amount` tokens of token type `id` from `from`
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `amount` tokens of token type `id`.
     */
    function _burn(
        address from,
        uint256 id,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }

        emit TransferSingle(operator, from, address(0), id, amount);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     */
    function _burnBatch(
        address from,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        for (uint256 i = 0; i < ids.length; i++) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
        }

        emit TransferBatch(operator, from, address(0), ids, amounts);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC1155: setting approval status for self");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `ids` and `amounts` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    /**
     * @dev Hook that is called after any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `id` and `amount` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
                if (response != IERC1155Receiver.onERC1155Received.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
        uint256[] memory array = new uint256[](1);
        array[0] = element;

        return array;
    }
}

File 49 of 56 : ERC1155Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/extensions/ERC1155Burnable.sol)

pragma solidity ^0.8.0;

import "../ERC1155.sol";

/**
 * @dev Extension of {ERC1155} that allows token holders to destroy both their
 * own tokens and those that they have been approved to use.
 *
 * _Available since v3.1._
 */
abstract contract ERC1155Burnable is ERC1155 {
    function burn(
        address account,
        uint256 id,
        uint256 value
    ) public virtual {
        require(
            account == _msgSender() || isApprovedForAll(account, _msgSender()),
            "ERC1155: caller is not token owner nor approved"
        );

        _burn(account, id, value);
    }

    function burnBatch(
        address account,
        uint256[] memory ids,
        uint256[] memory values
    ) public virtual {
        require(
            account == _msgSender() || isApprovedForAll(account, _msgSender()),
            "ERC1155: caller is not token owner nor approved"
        );

        _burnBatch(account, ids, values);
    }
}

File 50 of 56 : ERC1155Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/ERC1155Pausable.sol)

pragma solidity ^0.8.0;

import "../ERC1155.sol";
import "../../../security/Pausable.sol";

/**
 * @dev ERC1155 token with pausable token transfers, minting and burning.
 *
 * Useful for scenarios such as preventing trades until the end of an evaluation
 * period, or having an emergency switch for freezing all token transfers in the
 * event of a large bug.
 *
 * _Available since v3.1._
 */
abstract contract ERC1155Pausable is ERC1155, Pausable {
    /**
     * @dev See {ERC1155-_beforeTokenTransfer}.
     *
     * Requirements:
     *
     * - the contract must not be paused.
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual override {
        super._beforeTokenTransfer(operator, from, to, ids, amounts, data);

        require(!paused(), "ERC1155Pausable: token transfer while paused");
    }
}

File 51 of 56 : ERC1967Proxy.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)

pragma solidity ^0.8.0;

import "../Proxy.sol";
import "./ERC1967Upgrade.sol";

/**
 * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
 * implementation address that can be changed. This address is stored in storage in the location specified by
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
 * implementation behind the proxy.
 */
contract ERC1967Proxy is Proxy, ERC1967Upgrade {
    /**
     * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
     *
     * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
     * function call, and allows initializing the storage of the proxy like a Solidity constructor.
     */
    constructor(address _logic, bytes memory _data) payable {
        _upgradeToAndCall(_logic, _data, false);
    }

    /**
     * @dev Returns the current implementation address.
     */
    function _implementation() internal view virtual override returns (address impl) {
        return ERC1967Upgrade._getImplementation();
    }
}

File 52 of 56 : IERC1155MetadataURI.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.0;

import "../IERC1155.sol";

/**
 * @dev Interface of the optional ERC1155MetadataExtension interface, as defined
 * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155MetadataURI is IERC1155 {
    /**
     * @dev Returns the URI for token type `id`.
     *
     * If the `\{id\}` substring is present in the URI, it must be replaced by
     * clients with the actual token type ID.
     */
    function uri(uint256 id) external view returns (string memory);
}

File 53 of 56 : Proxy.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)

pragma solidity ^0.8.0;

/**
 * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
 * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
 * be specified by overriding the virtual {_implementation} function.
 *
 * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
 * different contract through the {_delegate} function.
 *
 * The success and return data of the delegated call will be returned back to the caller of the proxy.
 */
abstract contract Proxy {
    /**
     * @dev Delegates the current call to `implementation`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _delegate(address implementation) internal virtual {
        assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
            // delegatecall returns 0 on error.
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }

    /**
     * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
     * and {_fallback} should delegate.
     */
    function _implementation() internal view virtual returns (address);

    /**
     * @dev Delegates the current call to the address returned by `_implementation()`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _fallback() internal virtual {
        _beforeFallback();
        _delegate(_implementation());
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
     * function in the contract matches the call data.
     */
    fallback() external payable virtual {
        _fallback();
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
     * is empty.
     */
    receive() external payable virtual {
        _fallback();
    }

    /**
     * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
     * call, or as part of the Solidity `fallback` or `receive` functions.
     *
     * If overridden should call `super._beforeFallback()`.
     */
    function _beforeFallback() internal virtual {}
}

File 54 of 56 : ERC1967Upgrade.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeacon.sol";
import "../../interfaces/draft-IERC1822.sol";
import "../../utils/Address.sol";
import "../../utils/StorageSlot.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967Upgrade {
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            Address.isContract(IBeacon(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
        }
    }
}

File 55 of 56 : IBeacon.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeacon {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

File 56 of 56 : draft-IERC1822.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822Proxiable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

Settings
{
  "remappings": [
    "forge-std/=dependencies/@fdk-0.3.1-beta/dependencies/@forge-std-1.9.1/src/",
    "@openzeppelin/=dependencies/@openzeppelin-4.7.3/",
    "hardhat/=node_modules/hardhat/",
    "@ronin/contracts/=src/",
    "@ronin/test/=test/",
    "solady/=dependencies/@fdk-0.3.1-beta/dependencies/@solady-0.0.228/src/",
    "@fdk/=dependencies/@fdk-0.3.1-beta/script/",
    "@prb/math/=lib/prb-math/",
    "@prb/test/=dependencies/@prb-test-0.6.5/src/",
    "ds-test/=lib/prb-math/lib/forge-std/lib/ds-test/src/",
    "hardhat-deploy/=node_modules/hardhat-deploy/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "prb-math/=lib/prb-math/src/",
    "prb-test/=lib/prb-test/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": true,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "shanghai",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"enum ContractType","name":"contractType","type":"uint8"}],"name":"ErrContractTypeNotFound","type":"error"},{"inputs":[],"name":"ErrERC1155MintingFailed","type":"error"},{"inputs":[],"name":"ErrERC20MintingFailed","type":"error"},{"inputs":[],"name":"ErrERC721MintingFailed","type":"error"},{"inputs":[],"name":"ErrEmptyArray","type":"error"},{"inputs":[{"internalType":"bytes4","name":"msgSig","type":"bytes4"},{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"expected","type":"uint256"}],"name":"ErrInvalidChainId","type":"error"},{"inputs":[],"name":"ErrInvalidInfo","type":"error"},{"inputs":[{"internalType":"bytes4","name":"msgSig","type":"bytes4"}],"name":"ErrInvalidOrder","type":"error"},{"inputs":[],"name":"ErrInvalidPercentage","type":"error"},{"inputs":[],"name":"ErrInvalidReceipt","type":"error"},{"inputs":[],"name":"ErrInvalidReceiptKind","type":"error"},{"inputs":[],"name":"ErrInvalidRequest","type":"error"},{"inputs":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"uint256","name":"weight","type":"uint256"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct SignatureConsumer.Signature","name":"sig","type":"tuple"}],"name":"ErrInvalidSigner","type":"error"},{"inputs":[{"internalType":"bytes4","name":"msgSig","type":"bytes4"}],"name":"ErrInvalidThreshold","type":"error"},{"inputs":[],"name":"ErrInvalidTokenStandard","type":"error"},{"inputs":[{"internalType":"bytes4","name":"msgSig","type":"bytes4"}],"name":"ErrLengthMismatch","type":"error"},{"inputs":[{"internalType":"bytes4","name":"msgSig","type":"bytes4"}],"name":"ErrNullHighTierVoteWeightProvided","type":"error"},{"inputs":[{"internalType":"bytes4","name":"msgSig","type":"bytes4"}],"name":"ErrNullMinVoteWeightProvided","type":"error"},{"inputs":[{"internalType":"bytes4","name":"msgSig","type":"bytes4"}],"name":"ErrNullTotalWeightProvided","type":"error"},{"inputs":[],"name":"ErrQueryForApprovedWithdrawal","type":"error"},{"inputs":[],"name":"ErrQueryForInsufficientVoteWeight","type":"error"},{"inputs":[],"name":"ErrQueryForProcessedWithdrawal","type":"error"},{"inputs":[],"name":"ErrReachedDailyWithdrawalLimit","type":"error"},{"inputs":[{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"tokenInfo","type":"tuple"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"ErrTokenCouldNotTransfer","type":"error"},{"inputs":[{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"tokenInfo","type":"tuple"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"ErrTokenCouldNotTransferFrom","type":"error"},{"inputs":[{"internalType":"bytes4","name":"msgSig","type":"bytes4"},{"internalType":"enum RoleAccess","name":"expectedRole","type":"uint8"}],"name":"ErrUnauthorized","type":"error"},{"inputs":[{"internalType":"bytes4","name":"msgSig","type":"bytes4"},{"internalType":"enum ContractType","name":"expectedContractType","type":"uint8"},{"internalType":"address","name":"actual","type":"address"}],"name":"ErrUnexpectedInternalCall","type":"error"},{"inputs":[],"name":"ErrUnsupportedStandard","type":"error"},{"inputs":[],"name":"ErrUnsupportedToken","type":"error"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"ErrZeroCodeContract","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"enum ContractType","name":"contractType","type":"uint8"},{"indexed":true,"internalType":"address","name":"addr","type":"address"}],"name":"ContractUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"limits","type":"uint256[]"}],"name":"DailyWithdrawalLimitsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"receiptHash","type":"bytes32"},{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"enum Transfer.Kind","name":"kind","type":"uint8"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"mainchain","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"ronin","type":"tuple"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"indexed":false,"internalType":"struct Transfer.Receipt","name":"receipt","type":"tuple"}],"name":"DepositRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"thresholds","type":"uint256[]"}],"name":"HighTierThresholdsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"numerator","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"denominator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"previousNumerator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"previousDenominator","type":"uint256"}],"name":"HighTierVoteWeightThresholdUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"thresholds","type":"uint256[]"}],"name":"LockedThresholdsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"numerator","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"denominator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"previousNumerator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"previousDenominator","type":"uint256"}],"name":"ThresholdUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"mainchainTokens","type":"address[]"},{"indexed":false,"internalType":"address[]","name":"roninTokens","type":"address[]"},{"indexed":false,"internalType":"enum TokenStandard[]","name":"standards","type":"uint8[]"}],"name":"TokenMapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"percentages","type":"uint256[]"}],"name":"UnlockFeePercentagesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"receiptHash","type":"bytes32"},{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"enum Transfer.Kind","name":"kind","type":"uint8"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"mainchain","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"ronin","type":"tuple"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"indexed":false,"internalType":"struct Transfer.Receipt","name":"receipt","type":"tuple"}],"name":"WithdrawalLocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"receiptHash","type":"bytes32"},{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"enum Transfer.Kind","name":"kind","type":"uint8"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"mainchain","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"ronin","type":"tuple"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"indexed":false,"internalType":"struct Transfer.Receipt","name":"receipt","type":"tuple"}],"name":"WithdrawalUnlocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"receiptHash","type":"bytes32"},{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"enum Transfer.Kind","name":"kind","type":"uint8"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"mainchain","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"ronin","type":"tuple"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"indexed":false,"internalType":"struct Transfer.Receipt","name":"receipt","type":"tuple"}],"name":"Withdrew","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IWETH","name":"weth","type":"address"}],"name":"WrappedNativeTokenContractUpdated","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAWAL_UNLOCKER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_MAX_PERCENTAGE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_voteWeight","type":"uint256"}],"name":"checkHighTierVoteWeightThreshold","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_voteWeight","type":"uint256"}],"name":"checkThreshold","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"dailyWithdrawalLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyPauser","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum ContractType","name":"contractType","type":"uint8"}],"name":"getContract","outputs":[{"internalType":"address","name":"contract_","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getHighTierVoteWeightThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"mainchainToken","type":"address"}],"name":"getRoninToken","outputs":[{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"address","name":"tokenAddr","type":"address"}],"internalType":"struct MappedTokenConsumer.MappedToken","name":"token","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getThreshold","outputs":[{"internalType":"uint256","name":"num_","type":"uint256"},{"internalType":"uint256","name":"denom_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"highTierThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_roleSetter","type":"address"},{"internalType":"contract IWETH","name":"_wrappedToken","type":"address"},{"internalType":"uint256","name":"_roninChainId","type":"uint256"},{"internalType":"uint256","name":"_numerator","type":"uint256"},{"internalType":"uint256","name":"_highTierVWNumerator","type":"uint256"},{"internalType":"uint256","name":"_denominator","type":"uint256"},{"internalType":"address[][3]","name":"_addresses","type":"address[][3]"},{"internalType":"uint256[][4]","name":"_thresholds","type":"uint256[][4]"},{"internalType":"enum TokenStandard[]","name":"_standards","type":"uint8[]"}],"name":"initialize","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"bridgeManagerContract","type":"address"}],"name":"initializeV2","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initializeV3","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"","type":"address"}],"name":"initializeV4","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastDateSynced","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastSyncedWithdrawal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lockedThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_mainchainTokens","type":"address[]"},{"internalType":"address[]","name":"_roninTokens","type":"address[]"},{"internalType":"enum TokenStandard[]","name":"_standards","type":"uint8[]"}],"name":"mapTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_mainchainTokens","type":"address[]"},{"internalType":"address[]","name":"_roninTokens","type":"address[]"},{"internalType":"enum TokenStandard[]","name":"_standards","type":"uint8[]"},{"internalType":"uint256[][4]","name":"_thresholds","type":"uint256[][4]"}],"name":"mapTokensAndThresholds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minimumVoteWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"operators","type":"address[]"},{"internalType":"uint96[]","name":"weights","type":"uint96[]"},{"internalType":"bool[]","name":"addeds","type":"bool[]"}],"name":"onBridgeOperatorsAdded","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"operators","type":"address[]"},{"internalType":"bool[]","name":"removeds","type":"bool[]"}],"name":"onBridgeOperatorsRemoved","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_quantity","type":"uint256"}],"name":"reachedWithdrawalLimit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"receiveEther","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"recipientAddr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"internalType":"struct Transfer.Request","name":"_request","type":"tuple"}],"name":"requestDepositFor","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"roninChainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum ContractType","name":"contractType","type":"uint8"},{"internalType":"address","name":"addr","type":"address"}],"name":"setContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_limits","type":"uint256[]"}],"name":"setDailyWithdrawalLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"setEmergencyPauser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_thresholds","type":"uint256[]"}],"name":"setHighTierThresholds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numerator","type":"uint256"},{"internalType":"uint256","name":"_denominator","type":"uint256"}],"name":"setHighTierVoteWeightThreshold","outputs":[{"internalType":"uint256","name":"_previousNum","type":"uint256"},{"internalType":"uint256","name":"_previousDenom","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_thresholds","type":"uint256[]"}],"name":"setLockedThresholds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"num","type":"uint256"},{"internalType":"uint256","name":"denom","type":"uint256"}],"name":"setThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_percentages","type":"uint256[]"}],"name":"setUnlockFeePercentages","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IWETH","name":"_wrappedToken","type":"address"}],"name":"setWrappedNativeTokenContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"enum Transfer.Kind","name":"kind","type":"uint8"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"mainchain","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"ronin","type":"tuple"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"internalType":"struct Transfer.Receipt","name":"_receipt","type":"tuple"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct SignatureConsumer.Signature[]","name":"_signatures","type":"tuple[]"}],"name":"submitWithdrawal","outputs":[{"internalType":"bool","name":"_locked","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"unlockFeePercentages","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"enum Transfer.Kind","name":"kind","type":"uint8"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"mainchain","type":"tuple"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct TokenOwner","name":"ronin","type":"tuple"},{"components":[{"internalType":"enum TokenStandard","name":"erc","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct TokenInfo","name":"info","type":"tuple"}],"internalType":"struct Transfer.Receipt","name":"receipt","type":"tuple"}],"name":"unlockWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"withdrawalHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"withdrawalLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wrappedNativeToken","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801562000010575f80fd5b505f805460ff19169055620000246200002a565b620000ec565b607154610100900460ff1615620000975760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60715460ff9081161015620000ea576071805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61561480620000fa5f395ff3fe60806040526004361061038f575f3560e01c80638f34e347116101db578063b9c3620911610101578063d55ed1031161009f578063dff525e11161006e578063dff525e114610a99578063e400327c14610ab8578063e75235b814610ad7578063f23a6e6114610aee5761039e565b8063d55ed10314610a11578063d64af2a614610a3c578063dafae40814610a5b578063de981f1b14610a7a5761039e565b8063ca15c873116100db578063ca15c87314610991578063cdb67444146109b0578063d19773d2146109c7578063d547741f146109f25761039e565b8063b9c3620914610928578063bc197c8114610947578063c48549de146109725761039e565b8063a217fddf11610179578063affed0e011610148578063affed0e01461089d578063b1a2567e146108b2578063b1d08a03146108d1578063b2975794146108fc5761039e565b8063a217fddf14610840578063a3912ec81461039c578063ab79656614610853578063ac78dfe81461087e5761039e565b80639157921c116101b55780639157921c146107af57806391d14854146107ce57806393c5678f146107ed5780639dcc4da31461080c5761039e565b80638f34e347146107315780638f851d8a146107645780639010d07c146107905761039e565b806336568abe116102c0578063504af48c1161025e5780636c1ce6701161022d5780636c1ce670146106cb5780637de5dedd146106ea5780638456cb59146106fe578063865e6fd3146107125761039e565b8063504af48c1461064c57806359122f6b1461065f5780635c975abb1461068a5780636932be98146106a05761039e565b80633f4ba83a1161029a5780633f4ba83a146105d85780634b14557e146105ec5780634d0d6673146105ff5780634d493f4e1461061e5761039e565b806336568abe1461058657806338e454b1146105a55780633e70838b146105b95761039e565b80631d4a72101161032d5780632dfdf0b5116103075780632dfdf0b5146105285780632f2ff15d1461053d578063302d12db1461055c5780633644e515146105725761039e565b80631d4a7210146104b0578063248a9ca3146104db57806329b6eca9146105095761039e565b806317ce2dd41161036957806317ce2dd41461043057806317fcb39b146104535780631a8e55b0146104725780631b6e7594146104915761039e565b806301ffc9a7146103a6578063065b3adf146103da578063110a8308146104115761039e565b3661039e5761039c610b19565b005b61039c610b19565b3480156103b1575f80fd5b506103c56103c03660046142cf565b610b37565b60405190151581526020015b60405180910390f35b3480156103e5575f80fd5b506005546103f9906001600160a01b031681565b6040516001600160a01b0390911681526020016103d1565b34801561041c575f80fd5b5061039c61042b36600461430a565b610b7c565b34801561043b575f80fd5b5061044560755481565b6040519081526020016103d1565b34801561045e575f80fd5b506074546103f9906001600160a01b031681565b34801561047d575f80fd5b5061039c61048c366004614365565b610c04565b34801561049c575f80fd5b5061039c6104ab3660046143cb565b610c3f565b3480156104bb575f80fd5b506104456104ca36600461430a565b603e6020525f908152604090205481565b3480156104e6575f80fd5b506104456104f5366004614468565b5f9081526072602052604090206001015490565b348015610514575f80fd5b5061039c61052336600461430a565b610c7e565b348015610533575f80fd5b5061044560765481565b348015610548575f80fd5b5061039c61055736600461447f565b610d06565b348015610567575f80fd5b50610445620f424081565b34801561057d575f80fd5b50607754610445565b348015610591575f80fd5b5061039c6105a036600461447f565b610d2f565b3480156105b0575f80fd5b5061039c610dad565b3480156105c4575f80fd5b5061039c6105d336600461430a565b610f7f565b3480156105e3575f80fd5b5061039c610fa9565b61039c6105fa3660046144ad565b610fb9565b34801561060a575f80fd5b506103c56106193660046144d4565b610fdc565b348015610629575f80fd5b506103c5610638366004614468565b607a6020525f908152604090205460ff1681565b61039c61065a366004614575565b61104a565b34801561066a575f80fd5b5061044561067936600461430a565b603a6020525f908152604090205481565b348015610695575f80fd5b505f5460ff166103c5565b3480156106ab575f80fd5b506104456106ba366004614468565b60796020525f908152604090205481565b3480156106d6575f80fd5b506103c56106e5366004614646565b61130b565b3480156106f5575f80fd5b50610445611316565b348015610709575f80fd5b5061039c61132c565b34801561071d575f80fd5b5061039c61072c36600461467e565b61133c565b34801561073c575f80fd5b506104457f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e481565b34801561076f575f80fd5b5061078361077e366004614743565b611357565b6040516103d19190614831565b34801561079b575f80fd5b506103f96107aa366004614846565b6114d3565b3480156107ba575f80fd5b5061039c6107c9366004614866565b6114ea565b3480156107d9575f80fd5b506103c56107e836600461447f565b611765565b3480156107f8575f80fd5b5061039c610807366004614365565b61178f565b348015610817575f80fd5b5061082b610826366004614846565b6117c4565b604080519283526020830191909152016103d1565b34801561084b575f80fd5b506104455f81565b34801561085e575f80fd5b5061044561086d36600461430a565b603c6020525f908152604090205481565b348015610889575f80fd5b506103c5610898366004614468565b6117ec565b3480156108a8575f80fd5b5061044560045481565b3480156108bd575f80fd5b5061039c6108cc366004614365565b611817565b3480156108dc575f80fd5b506104456108eb36600461430a565b60396020525f908152604090205481565b348015610907575f80fd5b5061091b61091636600461430a565b61184c565b6040516103d191906148a9565b348015610933575f80fd5b5061039c610942366004614846565b6118ed565b348015610952575f80fd5b506107836109613660046149a4565b63bc197c8160e01b95945050505050565b34801561097d575f80fd5b5061078361098c366004614365565b611907565b34801561099c575f80fd5b506104456109ab366004614468565b611a93565b3480156109bb575f80fd5b5060375460385461082b565b3480156109d2575f80fd5b506104456109e136600461430a565b603b6020525f908152604090205481565b3480156109fd575f80fd5b5061039c610a0c36600461447f565b611aa9565b348015610a1c575f80fd5b50610445610a2b36600461430a565b603d6020525f908152604090205481565b348015610a47575f80fd5b5061039c610a5636600461430a565b611acd565b348015610a66575f80fd5b506103c5610a75366004614468565b611ade565b348015610a85575f80fd5b506103f9610a94366004614a4a565b611b01565b348015610aa4575f80fd5b5061039c610ab3366004614a63565b611b74565b348015610ac3575f80fd5b5061039c610ad2366004614365565b611be7565b348015610ae2575f80fd5b5060015460025461082b565b348015610af9575f80fd5b50610783610b08366004614b17565b63f23a6e6160e01b95945050505050565b6074546001600160a01b03163303610b2d57565b610b35611c1c565b565b5f6001600160e01b03198216631f3673bb60e01b1480610b6757506001600160e01b031982166312c0151560e21b145b80610b765750610b7682611c46565b92915050565b607154600490610100900460ff16158015610b9e575060715460ff8083169116105b610bc35760405162461bcd60e51b8152600401610bba90614b7a565b60405180910390fd5b6071805461ffff191660ff83169081176101001761ff0019169091556040519081525f805160206155bf833981519152906020015b60405180910390a15050565b610c0c611c6a565b5f839003610c2d576040516316ee9d3b60e11b815260040160405180910390fd5b610c3984848484611cc3565b50505050565b610c47611c6a565b5f859003610c68576040516316ee9d3b60e11b815260040160405180910390fd5b610c76868686868686611d94565b505050505050565b607154600290610100900460ff16158015610ca0575060715460ff8083169116105b610cbc5760405162461bcd60e51b8152600401610bba90614b7a565b6071805461ffff191660ff831617610100179055610cdb600b83611f36565b6071805461ff001916905560405160ff821681525f805160206155bf83398151915290602001610bf8565b5f82815260726020526040902060010154610d2081611fd7565b610d2a8383611fe1565b505050565b6001600160a01b0381163314610d9f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610bba565b610da98282612002565b5050565b607154600390610100900460ff16158015610dcf575060715460ff8083169116105b610deb5760405162461bcd60e51b8152600401610bba90614b7a565b6071805461ffff191660ff8316176101001790555f610e0a600b611b01565b90505f80826001600160a01b031663c441c4a86040518163ffffffff1660e01b81526004015f60405180830381865afa158015610e49573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610e709190810190614c41565b92509250505f805b8351811015610f2957828181518110610e9357610e93614d1f565b6020026020010151607e5f868481518110610eb057610eb0614d1f565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f205f6101000a8154816001600160601b0302191690836001600160601b03160217905550828181518110610f0c57610f0c614d1f565b602002602001015182610f1f9190614d47565b9150600101610e78565b50607d80546001600160601b0319166001600160601b039290921691909117905550506071805461ff00191690555060405160ff821681525f805160206155bf833981519152906020015b60405180910390a150565b610f87611c6a565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b610fb1612023565b610b35612091565b610fc16120e2565b610fd9610fd336839003830183614db4565b33612127565b50565b5f610fe56120e2565b611040848484808060200260200160405190810160405280939291908181526020015f905b828210156110365761102760608302860136819003810190614e05565b8152602001906001019061100a565b505050505061236e565b90505b9392505050565b607154610100900460ff161580801561106a5750607154600160ff909116105b806110845750303b158015611084575060715460ff166001145b6110a05760405162461bcd60e51b8152600401610bba90614b7a565b6071805460ff1916600117905580156110c3576071805461ff0019166101001790555b6110cd5f8c6127fa565b60758990556110db8a612804565b6111666040517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81527f159f52c1e3a2b6a6aad3950adf713516211484e0516dad685ea662a094b7c43b60208201527fad7c5bef027816a800da1736444fb58a807ef4c9603b7848673f7e3a68eb14a5604082015246606082015230608082015260a0812060775550565b6111708887612852565b61117a87876128f3565b505061118461299a565b5f61118f8680614e4c565b9050111561124f576111b86111a48680614e4c565b6111b16020890189614e4c565b8787611d94565b6111dd6111c58680614e4c565b865f5b6020028101906111d89190614e4c565b6129e6565b6112036111ea8680614e4c565b8660015b6020028101906111fe9190614e4c565b611cc3565b6112296112108680614e4c565b8660025b6020028101906112249190614e4c565b612ab7565b61124f6112368680614e4c565b8660035b60200281019061124a9190614e4c565b612bc4565b5f5b61125e6040870187614e4c565b90508110156112ca576112c27f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e46112986040890189614e4c565b848181106112a8576112a8614d1f565b90506020020160208101906112bd919061430a565b611fe1565b600101611251565b5080156112fe576071805461ff0019169055604051600181525f805160206155bf8339815191529060200160405180910390a15b5050505050505050505050565b5f6110438383612c95565b5f611327611322612d59565b612d96565b905090565b611334612023565b610b35612dfa565b611344611c6a565b61134d81612e36565b610da98282611f36565b5f600b61136381612e6b565b82518690811415806113755750808514155b156113a0575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b805f036113b757506347c28ec560e11b91506114c9565b5f5b818110156114bc578481815181106113d3576113d3614d1f565b6020026020010151156114b4578686828181106113f2576113f2614d1f565b90506020020160208101906114079190614e91565b607d80546001600160601b031981166001600160601b03918216939093011691909117905586868281811061143e5761143e614d1f565b90506020020160208101906114539190614e91565b607e5f8b8b8581811061146857611468614d1f565b905060200201602081019061147d919061430a565b6001600160a01b0316815260208101919091526040015f2080546001600160601b0319166001600160601b03929092169190911790555b6001016113b9565b506347c28ec560e11b9250505b5095945050505050565b5f8281526073602052604081206110439083612eb6565b7f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e461151481611fd7565b5f61152c61152736859003850185614f06565b612ec1565b905061154061152736859003850185614f06565b83355f908152607960205260409020541461156e5760405163f4b8742f60e01b815260040160405180910390fd5b82355f908152607a602052604090205460ff1661159e5760405163147bfe0760e01b815260040160405180910390fd5b82355f908152607a602052604090819020805460ff19169055517fd639511b37b3b002cca6cfe6bca0d833945a5af5a045578a0627fc43b79b2630906115e79083908690614fd7565b60405180910390a15f611600608085016060860161430a565b90505f6116156101208601610100870161505c565b600281111561162657611626614881565b036116ea575f61163f3686900386016101008701615075565b6001600160a01b0383165f908152603b602052604090205490915061166a9061014087013590612f88565b60408201525f6116833687900387016101008801615075565b604083015190915061169a9061014088013561508f565b60408201526074546116ba908390339086906001600160a01b0316612fa1565b6116e36116cd606088016040890161430a565b60745483919086906001600160a01b0316612fa1565b5050611726565b6117266116fd606086016040870161430a565b60745483906001600160a01b031661171e3689900389016101008a01615075565b929190612fa1565b7f21e88e956aa3e086f6388e899965cef814688f99ad8bb29b08d396571016372d8285604051611757929190614fd7565b60405180910390a150505050565b5f9182526072602090815260408084206001600160a01b0393909316845291905290205460ff1690565b611797611c6a565b5f8390036117b8576040516316ee9d3b60e11b815260040160405180910390fd5b610c39848484846129e6565b5f806117ce611c6a565b6117d884846128f3565b90925090506117e561299a565b9250929050565b5f6117f5612d59565b60375461180291906150a2565b60385461180f90846150a2565b101592915050565b61181f611c6a565b5f839003611840576040516316ee9d3b60e11b815260040160405180910390fd5b610c3984848484612ab7565b604080518082019091525f80825260208201526001600160a01b0382165f908152607860205260409081902081518083019092528054829060ff16600281111561189857611898614881565b60028111156118a9576118a9614881565b815290546001600160a01b03610100909104811660209283015290820151919250166118e857604051631b79f53b60e21b815260040160405180910390fd5b919050565b6118f5611c6a565b6118ff8282612852565b610da961299a565b5f600b61191381612e6b565b84838114611941575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b805f036119585750636242a4ef60e11b9150611a8a565b5f805b82811015611a3b5786868281811061197557611975614d1f565b905060200201602081019061198a91906150b9565b15611a3357607e5f8a8a848181106119a4576119a4614d1f565b90506020020160208101906119b9919061430a565b6001600160a01b0316815260208101919091526040015f908120546001600160601b03169290920191607e908a8a848181106119f7576119f7614d1f565b9050602002016020810190611a0c919061430a565b6001600160a01b0316815260208101919091526040015f2080546001600160601b03191690555b60010161195b565b50607d80548291905f90611a599084906001600160601b03166150d4565b92506101000a8154816001600160601b0302191690836001600160601b0316021790555063c48549de60e01b935050505b50949350505050565b5f818152607360205260408120610b76906131ca565b5f82815260726020526040902060010154611ac381611fd7565b610d2a8383612002565b611ad5611c6a565b610fd981612804565b5f611ae7612d59565b600154611af491906150a2565b60025461180f90846150a2565b5f7fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb5f83600f811115611b3657611b36614881565b60ff16815260208101919091526040015f20546001600160a01b03169050806118e8578160405163409140df60e11b8152600401610bba9190615104565b611b7c611c6a565b5f869003611b9d576040516316ee9d3b60e11b815260040160405180910390fd5b611bab878787878787611d94565b611bb78787835f6111c8565b611bc487878360016111ee565b611bd18787836002611214565b611bde878783600361123a565b50505050505050565b611bef611c6a565b5f839003611c10576040516316ee9d3b60e11b815260040160405180910390fd5b610c3984848484612bc4565b611c246120e2565b611c2c614292565b338152604080820151349101528051610fd9908290612127565b5f6001600160e01b03198216630271189760e51b1480610b765750610b76826131d3565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314610b35575f356001600160e01b0319166001604051620f948f60ea1b8152600401610bba929190615112565b828114611cf0575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b5f5b83811015611d5e57828282818110611d0c57611d0c614d1f565b90506020020135603a5f878785818110611d2857611d28614d1f565b9050602002016020810190611d3d919061430a565b6001600160a01b0316815260208101919091526040015f2055600101611cf2565b507f64557254143204d91ba2d95acb9fda1e5fea55f77efd028685765bc1e94dd4b5848484846040516117579493929190615187565b8483148015611da257508481145b611dcc575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b5f5b85811015611eec57848482818110611de857611de8614d1f565b9050602002016020810190611dfd919061430a565b60785f898985818110611e1257611e12614d1f565b9050602002016020810190611e27919061430a565b6001600160a01b03908116825260208201929092526040015f208054610100600160a81b0319166101009390921692909202179055828282818110611e6e57611e6e614d1f565b9050602002016020810190611e83919061505c565b60785f898985818110611e9857611e98614d1f565b9050602002016020810190611ead919061430a565b6001600160a01b0316815260208101919091526040015f20805460ff19166001836002811115611edf57611edf614881565b0217905550600101611dce565b507fa4f03cc9c0e0aeb5b71b4ec800702753f65748c2cf3064695ba8e8b46be70444868686868686604051611f26969594939291906151d1565b60405180910390a1505050505050565b807fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb5f84600f811115611f6b57611f6b614881565b60ff16815260208101919091526040015f2080546001600160a01b0319166001600160a01b03928316179055811682600f811115611fab57611fab614881565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c59905f90a35050565b610fd981336131f7565b611feb828261325b565b5f828152607360205260409020610d2a90826132e0565b61200c82826132f4565b5f828152607360205260409020610d2a908261335a565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031633148061206557506005546001600160a01b031633145b610b35575f356001600160e01b0319166001604051620f948f60ea1b8152600401610bba929190615112565b61209961336e565b5f805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b5f5460ff1615610b355760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610bba565b6040805180820182525f80825260208201526074549184015190916001600160a01b031690612155906133b6565b60208401516001600160a01b03166121f657348460400151604001511461218f5760405163129c2ce160e31b815260040160405180910390fd5b6121988161184c565b60408501515190925060028111156121b2576121b2614881565b825160028111156121c5576121c5614881565b146121e25760405162035e2b60ea1b815260040160405180910390fd5b6001600160a01b03811660208501526122fd565b34156122155760405163129c2ce160e31b815260040160405180910390fd5b612222846020015161184c565b604085015151909250600281111561223c5761223c614881565b8251600281111561224f5761224f614881565b1461226c5760405162035e2b60ea1b815260040160405180910390fd5b602084015160408501516122819185906133fa565b83602001516001600160a01b0316816001600160a01b0316036122fd576040848101518101519051632e1a7d4d60e01b815260048101919091526001600160a01b03821690632e1a7d4d906024015f604051808303815f87803b1580156122e6575f80fd5b505af11580156122f8573d5f803e3d5ffd5b505050505b607680545f918261230d83615240565b9190505590505f612333858386602001516075548a61356e90949392919063ffffffff16565b90507fd7b25068d9dc8d00765254cfb7f5070f98d263c8d68931d937c7362fa738048b61235f82612ec1565b82604051611f26929190615278565b5f823561014084013582612388608087016060880161430a565b90506123a56123a03688900388016101008901615075565b6133b6565b60016123b76040880160208901615313565b60018111156123c8576123c8614881565b146123e65760405163182f3d8760e11b815260040160405180910390fd5b608086013546146124275760405163092048d160e11b81525f356001600160e01b031916600482015260808701356024820152466044820152606401610bba565b5f61243b6109166080890160608a0161430a565b905061244f6101208801610100890161505c565b600281111561246057612460614881565b8151600281111561247357612473614881565b1480156124a4575061248b60e0880160c0890161430a565b6001600160a01b031681602001516001600160a01b0316145b80156124b5575060755460e0880135145b6124d25760405163f4b8742f60e01b815260040160405180910390fd5b5f84815260796020526040902054156124fe57604051634f13df6160e01b815260040160405180910390fd5b600161251261012089016101008a0161505c565b600281111561252357612523614881565b148061253657506125348284612c95565b155b6125535760405163c51297b760e01b815260040160405180910390fd5b5f612566611527368a90038a018a614f06565b90505f61257560775483613641565b90505f61259461258d6101208c016101008d0161505c565b8688613681565b604080516060810182525f80825260208201819052918101829052919a50919250819081905f805b8e518110156126d4578e81815181106125d7576125d7614d1f565b602002602001015192506125f888845f015185602001518660400151613702565b9450846001600160a01b0316846001600160a01b031610612639575f356001600160e01b031916604051635d3dcd3160e01b8152600401610bba9190614831565b6001600160a01b0385165f908152607e60205260408120548695506001600160601b0316908190036126ae5760408051634e97700760e01b81526001600160a01b038816600482015260248101839052855160ff1660448201526020860151606482015290850151608482015260a401610bba565b6126b8818461532c565b92508783106126cb5760019650506126d4565b506001016125bc565b50846126f357604051639e8f5f6360e01b815260040160405180910390fd5b5050505f8981526079602052604090208590555050871561276c575f878152607a602052604090819020805460ff19166001179055517f89e52969465b1f1866fc5d46fd62de953962e9cb33552443cd999eba05bd20dc906127589085908d90614fd7565b60405180910390a150505050505050610b76565b612776858761372a565b6127b461278960608c0160408d0161430a565b8660745f9054906101000a90046001600160a01b03168d6101000180360381019061171e9190615075565b7f21e88e956aa3e086f6388e899965cef814688f99ad8bb29b08d396571016372d838b6040516127e5929190614fd7565b60405180910390a15050505050505092915050565b610da98282611fe1565b607480546001600160a01b0319166001600160a01b0383169081179091556040519081527f9d2334c23be647e994f27a72c5eee42a43d5bdcfe15bb88e939103c2b114cbaf90602001610f74565b8082118061285e575080155b80612867575081155b15612892575f356001600160e01b0319166040516387f6f09560e01b8152600401610bba9190614831565b6001805460028054858455908490556004805493840190556040805183815260208101839052929391928592879290917f976f8a9c5bdf8248dec172376d6e2b80a8e3df2f0328e381c6db8e1cf138c0f8910160405180910390a450505050565b5f8082841180612901575083155b8061290a575082155b15612935575f356001600160e01b0319166040516387f6f09560e01b8152600401610bba9190614831565b5050603780546038805492859055839055600480546001810190915560408051838152602081018590529293928592879290917f31312c97b89cc751b832d98fd459b967a2c3eef3b49757d1cf5ebaa12bb6eee1910160405180910390a49250929050565b6002546037546129aa91906150a2565b6038546001546129ba91906150a2565b1115610b35575f356001600160e01b0319166040516387f6f09560e01b8152600401610bba9190614831565b828114612a13575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b5f5b83811015612a8157828282818110612a2f57612a2f614d1f565b9050602002013560395f878785818110612a4b57612a4b614d1f565b9050602002016020810190612a60919061430a565b6001600160a01b0316815260208101919091526040015f2055600101612a15565b507f80bc635c452ae67f12f9b6f12ad4daa6dbbc04eeb9ebb87d354ce10c0e210dc0848484846040516117579493929190615187565b828114612ae4575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b5f5b83811015612b8e57620f4240838383818110612b0457612b04614d1f565b905060200201351115612b2a5760405163572d3bd360e11b815260040160405180910390fd5b828282818110612b3c57612b3c614d1f565b90506020020135603b5f878785818110612b5857612b58614d1f565b9050602002016020810190612b6d919061430a565b6001600160a01b0316815260208101919091526040015f2055600101612ae6565b507fb05f5de88ae0294ebb6f67c5af2fcbbd593cc6bdfe543e2869794a4c8ce3ea50848484846040516117579493929190615187565b828114612bf1575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b5f5b83811015612c5f57828282818110612c0d57612c0d614d1f565b90506020020135603c5f878785818110612c2957612c29614d1f565b9050602002016020810190612c3e919061430a565b6001600160a01b0316815260208101919091526040015f2055600101612bf3565b507fb5d2963614d72181b4df1f993d45b83edf42fa19710f0204217ba1b3e183bb73848484846040516117579493929190615187565b6001600160a01b0382165f908152603a60205260408120548210612cba57505f610b76565b5f612cc8620151804261533f565b6001600160a01b0385165f908152603e6020526040902054909150811115612d0c5750506001600160a01b0382165f908152603c6020526040902054811015610b76565b6001600160a01b0384165f908152603d6020526040902054612d2f90849061532c565b6001600160a01b0385165f908152603c602052604090205411159150610b769050565b5092915050565b607d546001600160601b03165f819003612d93575f356001600160e01b031916604051631103b51560e31b8152600401610bba9190614831565b90565b5f600254600160025484600154612dad91906150a2565b612db7919061532c565b612dc1919061508f565b612dcb919061533f565b9050805f036118e8575f356001600160e01b03191660405163267b1b9160e01b8152600401610bba9190614831565b612e026120e2565b5f805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586120c53390565b806001600160a01b03163b5f03610fd957604051630bfc64a360e21b81526001600160a01b0382166004820152602401610bba565b612e7481611b01565b6001600160a01b0316336001600160a01b031614610fd9575f356001600160e01b03191681336040516320e0f98d60e21b8152600401610bba9392919061535e565b5f61104383836137b6565b5f80612ed083604001516137dc565b90505f612ee084606001516137dc565b90505f612f338560800151604080517f1e2b74b2a792d5c0f0b6e59b037fa9d43d84fbb759337f0112fcc15ca414fc8d815282516020808301919091528301518183015291015160608201526080902090565b604080517fb9d1fe7c9deeec5dc90a2f47ff1684239519f2545b2228d3d91fb27df3189eea815287516020808301919091529097015190870152606086019390935250608084015260a08301525060c0902090565b5f620f4240612f9783856150a2565b611043919061533f565b806001600160a01b0316826001600160a01b0316036130495760408085015190516001600160a01b0385169180156108fc02915f818181858888f1935050505061304457806001600160a01b031663d0e30db085604001516040518263ffffffff1660e01b81526004015f604051808303818588803b158015613022575f80fd5b505af1158015613034573d5f803e3d5ffd5b5050505050613044848484613824565b610c39565b5f8451600281111561305d5761305d614881565b03613120576040516370a0823160e01b81523060048201525f906001600160a01b038416906370a0823190602401602060405180830381865afa1580156130a6573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906130ca9190615395565b9050846040015181101561310f576130f283308388604001516130ed919061508f565b6138a2565b61310f57604051632f739fff60e11b815260040160405180910390fd5b61311a858585613824565b50610c39565b60018451600281111561313557613135614881565b036131665761314982848660200151613942565b6130445760405163c8e3a09f60e01b815260040160405180910390fd5b60028451600281111561317b5761317b614881565b036131b157613194828486602001518760400151613968565b613044576040516334b471a760e21b815260040160405180910390fd5b6040516361e411a760e11b815260040160405180910390fd5b5f610b76825490565b5f6001600160e01b03198216635a05180f60e01b1480610b765750610b7682613990565b6132018282611765565b610da957613219816001600160a01b031660146139c4565b6132248360206139c4565b6040516020016132359291906153ce565b60408051601f198184030181529082905262461bcd60e51b8252610bba9160040161546d565b6132658282611765565b610da9575f8281526072602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561329c3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f611043836001600160a01b038416613b59565b6132fe8282611765565b15610da9575f8281526072602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b5f611043836001600160a01b038416613ba5565b5f5460ff16610b355760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610bba565b6133bf81613c88565b806133ce57506133ce81613cbd565b806133dd57506133dd81613ce4565b610fd95760405163034992a760e51b815260040160405180910390fd5b5f6060818551600281111561341157613411614881565b036134e85760408581015181516001600160a01b03878116602483015230604483015260648083019390935283518083039093018352608490910183526020820180516001600160e01b03166323b872dd60e01b179052915191851691613478919061547f565b5f604051808303815f865af19150503d805f81146134b1576040519150601f19603f3d011682016040523d82523d5f602084013e6134b6565b606091505b5090925090508180156134e15750805115806134e15750808060200190518101906134e1919061549a565b9150613541565b6001855160028111156134fd576134fd614881565b03613512576134e18385308860200151613d0c565b60028551600281111561352757613527614881565b036131b1576134e183853088602001518960400151613db5565b816135675784843085604051639d2e4c6760e01b8152600401610bba94939291906154b5565b5050505050565b6135dd6040805160a0810182525f8082526020808301829052835160608082018652838252818301849052818601849052848601919091528451808201865283815280830184905280860184905281850152845190810185528281529081018290529283015290608082015290565b8381525f6020820181905250604080820180516001600160a01b039788169052602080890151825190891690820152905146908301528751606084018051918916909152805195909716940193909352935182015292909201516080820152919050565b6040805161190160f01b60208083019190915260228201859052604280830185905283518084039091018152606290920190925280519101205f90611043565b5f805f61368c612d59565b905061369781612d96565b92505f8660028111156136ac576136ac614881565b036136f9576001600160a01b0385165f9081526039602052604090205484106136db576136d881613e64565b92505b6001600160a01b0385165f908152603a602052604090205484101591505b50935093915050565b5f805f61371187878787613ec8565b9150915061371e81613fad565b5090505b949350505050565b5f613738620151804261533f565b6001600160a01b0384165f908152603e6020526040902054909150811115613785576001600160a01b03929092165f908152603e6020908152604080832094909455603d90529190912055565b6001600160a01b0383165f908152603d6020526040812080548492906137ac90849061532c565b9091555050505050565b5f825f0182815481106137cb576137cb614d1f565b905f5260205f200154905092915050565b604080517f353bdd8d69b9e3185b3972e08b03845c0c14a21a390215302776a7a34b0e8764815282516020808301919091528301518183015291015160608201526080902090565b5f808451600281111561383957613839614881565b036138545761384d82848660400151614162565b905061387e565b60018451600281111561386957613869614881565b036131b15761384d8230858760200151613d0c565b80610c39578383836040516341bd7d9160e11b8152600401610bba939291906154eb565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b03166340c10f1960e01b17905291515f928616916138f99161547f565b5f604051808303815f865af19150503d805f8114613932576040519150601f19603f3d011682016040523d82523d5f602084013e613937565b606091505b509095945050505050565b5f61394f84308585613d0c565b905080611043576139618484846138a2565b9050611043565b5f6139768530868686613db5565b9050806137225761398985858585614230565b9050613722565b5f6001600160e01b03198216637965db0b60e01b1480610b7657506301ffc9a760e01b6001600160e01b0319831614610b76565b60605f6139d28360026150a2565b6139dd90600261532c565b6001600160401b038111156139f4576139f46146a8565b6040519080825280601f01601f191660200182016040528015613a1e576020820181803683370190505b509050600360fc1b815f81518110613a3857613a38614d1f565b60200101906001600160f81b03191690815f1a905350600f60fb1b81600181518110613a6657613a66614d1f565b60200101906001600160f81b03191690815f1a9053505f613a888460026150a2565b613a9390600161532c565b90505b6001811115613b0a576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613ac757613ac7614d1f565b1a60f81b828281518110613add57613add614d1f565b60200101906001600160f81b03191690815f1a90535060049490941c93613b038161551b565b9050613a96565b5083156110435760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610bba565b5f818152600183016020526040812054613b9e57508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610b76565b505f610b76565b5f8181526001830160205260408120548015613c7f575f613bc760018361508f565b85549091505f90613bda9060019061508f565b9050818114613c39575f865f018281548110613bf857613bf8614d1f565b905f5260205f200154905080875f018481548110613c1857613c18614d1f565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080613c4a57613c4a615530565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610b76565b5f915050610b76565b5f8082516002811115613c9d57613c9d614881565b148015613cad57505f8260400151115b8015610b76575050602001511590565b5f600182516002811115613cd357613cd3614881565b148015610b76575050604001511590565b5f600282516002811115613cfa57613cfa614881565b148015610b7657505060400151151590565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291515f92871691613d6b9161547f565b5f604051808303815f865af19150503d805f8114613da4576040519150601f19603f3d011682016040523d82523d5f602084013e613da9565b606091505b50909695505050505050565b604080515f808252602082019092526001600160a01b03871690613de490879087908790879060448101615544565b60408051601f198184030181529181526020820180516001600160e01b0316637921219560e11b17905251613e19919061547f565b5f604051808303815f865af19150503d805f8114613e52576040519150601f19603f3d011682016040523d82523d5f602084013e613e57565b606091505b5090979650505050505050565b5f603854600160385484603754613e7b91906150a2565b613e85919061532c565b613e8f919061508f565b613e99919061533f565b9050805f036118e8575f356001600160e01b031916604051639b974b0f60e01b8152600401610bba9190614831565b5f807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613efd57505f90506003613fa4565b8460ff16601b14158015613f1557508460ff16601c14155b15613f2557505f90506004613fa4565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613f76573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b038116613f9e575f60019250925050613fa4565b91505f90505b94509492505050565b5f816004811115613fc057613fc0614881565b03613fc85750565b6001816004811115613fdc57613fdc614881565b036140295760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610bba565b600281600481111561403d5761403d614881565b0361408a5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610bba565b600381600481111561409e5761409e614881565b036140f65760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610bba565b600481600481111561410a5761410a614881565b03610fd95760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610bba565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291515f92606092908716916141be919061547f565b5f604051808303815f865af19150503d805f81146141f7576040519150601f19603f3d011682016040523d82523d5f602084013e6141fc565b606091505b509092509050818015614227575080511580614227575080806020019051810190614227919061549a565b95945050505050565b604080515f808252602082019092526001600160a01b0386169061425d9086908690869060448101615588565b60408051601f198184030181529181526020820180516001600160e01b031663731133e960e01b17905251613d6b919061547f565b604080516060810182525f80825260208201529081016142ca6040805160608101909152805f81526020015f81526020015f81525090565b905290565b5f602082840312156142df575f80fd5b81356001600160e01b031981168114611043575f80fd5b6001600160a01b0381168114610fd9575f80fd5b5f6020828403121561431a575f80fd5b8135611043816142f6565b5f8083601f840112614335575f80fd5b5081356001600160401b0381111561434b575f80fd5b6020830191508360208260051b85010111156117e5575f80fd5b5f805f8060408587031215614378575f80fd5b84356001600160401b038082111561438e575f80fd5b61439a88838901614325565b909650945060208701359150808211156143b2575f80fd5b506143bf87828801614325565b95989497509550505050565b5f805f805f80606087890312156143e0575f80fd5b86356001600160401b03808211156143f6575f80fd5b6144028a838b01614325565b9098509650602089013591508082111561441a575f80fd5b6144268a838b01614325565b9096509450604089013591508082111561443e575f80fd5b5061444b89828a01614325565b979a9699509497509295939492505050565b80356118e8816142f6565b5f60208284031215614478575f80fd5b5035919050565b5f8060408385031215614490575f80fd5b8235915060208301356144a2816142f6565b809150509250929050565b5f60a082840312156144bd575f80fd5b50919050565b5f61016082840312156144bd575f80fd5b5f805f61018084860312156144e7575f80fd5b6144f185856144c3565b92506101608401356001600160401b038082111561450d575f80fd5b818601915086601f830112614520575f80fd5b81358181111561452e575f80fd5b876020606083028501011115614542575f80fd5b6020830194508093505050509250925092565b8060608101831015610b76575f80fd5b8060808101831015610b76575f80fd5b5f805f805f805f805f806101208b8d03121561458f575f80fd5b6145988b61445d565b99506145a660208c0161445d565b985060408b0135975060608b0135965060808b0135955060a08b0135945060c08b01356001600160401b03808211156145dd575f80fd5b6145e98e838f01614555565b955060e08d01359150808211156145fe575f80fd5b61460a8e838f01614565565b94506101008d0135915080821115614620575f80fd5b5061462d8d828e01614325565b915080935050809150509295989b9194979a5092959850565b5f8060408385031215614657575f80fd5b8235614662816142f6565b946020939093013593505050565b8035601081106118e8575f80fd5b5f806040838503121561468f575f80fd5b61469883614670565b915060208301356144a2816142f6565b634e487b7160e01b5f52604160045260245ffd5b604051606081016001600160401b03811182821017156146de576146de6146a8565b60405290565b604051601f8201601f191681016001600160401b038111828210171561470c5761470c6146a8565b604052919050565b5f6001600160401b0382111561472c5761472c6146a8565b5060051b60200190565b8015158114610fd9575f80fd5b5f805f805f60608688031215614757575f80fd5b85356001600160401b038082111561476d575f80fd5b61477989838a01614325565b9097509550602091508782013581811115614792575f80fd5b61479e8a828b01614325565b9096509450506040880135818111156147b5575f80fd5b88019050601f810189136147c7575f80fd5b80356147da6147d582614714565b6146e4565b81815260059190911b8201830190838101908b8311156147f8575f80fd5b928401925b8284101561481f57833561481081614736565b825292840192908401906147fd565b80955050505050509295509295909350565b6001600160e01b031991909116815260200190565b5f8060408385031215614857575f80fd5b50508035926020909101359150565b5f6101608284031215614877575f80fd5b61104383836144c3565b634e487b7160e01b5f52602160045260245ffd5b600381106148a5576148a5614881565b9052565b5f6040820190506148bb828451614895565b6020928301516001600160a01b0316919092015290565b5f82601f8301126148e1575f80fd5b813560206148f16147d583614714565b8083825260208201915060208460051b870101935086841115614912575f80fd5b602086015b8481101561492e5780358352918301918301614917565b509695505050505050565b5f82601f830112614948575f80fd5b81356001600160401b03811115614961576149616146a8565b614974601f8201601f19166020016146e4565b818152846020838601011115614988575f80fd5b816020850160208301375f918101602001919091529392505050565b5f805f805f60a086880312156149b8575f80fd5b85356149c3816142f6565b945060208601356149d3816142f6565b935060408601356001600160401b03808211156149ee575f80fd5b6149fa89838a016148d2565b94506060880135915080821115614a0f575f80fd5b614a1b89838a016148d2565b93506080880135915080821115614a30575f80fd5b50614a3d88828901614939565b9150509295509295909350565b5f60208284031215614a5a575f80fd5b61104382614670565b5f805f805f805f6080888a031215614a79575f80fd5b87356001600160401b0380821115614a8f575f80fd5b614a9b8b838c01614325565b909950975060208a0135915080821115614ab3575f80fd5b614abf8b838c01614325565b909750955060408a0135915080821115614ad7575f80fd5b614ae38b838c01614325565b909550935060608a0135915080821115614afb575f80fd5b50614b088a828b01614565565b91505092959891949750929550565b5f805f805f60a08688031215614b2b575f80fd5b8535614b36816142f6565b94506020860135614b46816142f6565b9350604086013592506060860135915060808601356001600160401b03811115614b6e575f80fd5b614a3d88828901614939565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b5f82601f830112614bd7575f80fd5b81516020614be76147d583614714565b8083825260208201915060208460051b870101935086841115614c08575f80fd5b602086015b8481101561492e578051614c20816142f6565b8352918301918301614c0d565b6001600160601b0381168114610fd9575f80fd5b5f805f60608486031215614c53575f80fd5b83516001600160401b0380821115614c69575f80fd5b614c7587838801614bc8565b9450602091508186015181811115614c8b575f80fd5b614c9788828901614bc8565b945050604086015181811115614cab575f80fd5b86019050601f81018713614cbd575f80fd5b8051614ccb6147d582614714565b81815260059190911b82018301908381019089831115614ce9575f80fd5b928401925b82841015614d10578351614d0181614c2d565b82529284019290840190614cee565b80955050505050509250925092565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b6001600160601b03818116838216019080821115612d5257612d52614d33565b8035600381106118e8575f80fd5b5f60608284031215614d85575f80fd5b614d8d6146bc565b9050614d9882614d67565b8152602082013560208201526040820135604082015292915050565b5f60a08284031215614dc4575f80fd5b614dcc6146bc565b8235614dd7816142f6565b81526020830135614de7816142f6565b6020820152614df98460408501614d75565b60408201529392505050565b5f60608284031215614e15575f80fd5b614e1d6146bc565b823560ff81168114614e2d575f80fd5b8152602083810135908201526040928301359281019290925250919050565b5f808335601e19843603018112614e61575f80fd5b8301803591506001600160401b03821115614e7a575f80fd5b6020019150600581901b36038213156117e5575f80fd5b5f60208284031215614ea1575f80fd5b813561104381614c2d565b8035600281106118e8575f80fd5b5f60608284031215614eca575f80fd5b614ed26146bc565b90508135614edf816142f6565b81526020820135614eef816142f6565b806020830152506040820135604082015292915050565b5f6101608284031215614f17575f80fd5b60405160a081018181106001600160401b0382111715614f3957614f396146a8565b60405282358152614f4c60208401614eac565b6020820152614f5e8460408501614eba565b6040820152614f708460a08501614eba565b6060820152614f83846101008501614d75565b60808201529392505050565b600281106148a5576148a5614881565b8035614faa816142f6565b6001600160a01b039081168352602082013590614fc6826142f6565b166020830152604090810135910152565b5f6101808201905083825282356020830152614ff560208401614eac565b6150026040840182614f8f565b506150136060830160408501614f9f565b61502360c0830160a08501614f9f565b61012061503e8184016150396101008701614d67565b614895565b61014081850135818501528085013561016085015250509392505050565b5f6020828403121561506c575f80fd5b61104382614d67565b5f60608284031215615085575f80fd5b6110438383614d75565b81810381811115610b7657610b76614d33565b8082028115828204841417610b7657610b76614d33565b5f602082840312156150c9575f80fd5b813561104381614736565b6001600160601b03828116828216039080821115612d5257612d52614d33565b601081106148a5576148a5614881565b60208101610b7682846150f4565b6001600160e01b03198316815260408101600b831061513357615133614881565b8260208301529392505050565b8183525f60208085019450825f5b8581101561517c578135615161816142f6565b6001600160a01b03168752958201959082019060010161514e565b509495945050505050565b604081525f61519a604083018688615140565b82810360208401528381526001600160fb1b038411156151b8575f80fd5b8360051b80866020840137016020019695505050505050565b606081525f6151e460608301888a615140565b602083820360208501526151f982888a615140565b84810360408601528581528692506020015f5b86811015615231576152218261503986614d67565b928201929082019060010161520c565b509a9950505050505050505050565b5f6001820161525157615251614d33565b5060010190565b615263828251614895565b60208181015190830152604090810151910152565b5f6101808201905083825282516020830152602083015161529c6040840182614f8f565b5060408381015180516001600160a01b03908116606086015260208201511660808501529081015160a084015250606083015180516001600160a01b0390811660c085015260208201511660e0840152604081015161010084015250608083015161530b610120840182615258565b509392505050565b5f60208284031215615323575f80fd5b61104382614eac565b80820180821115610b7657610b76614d33565b5f8261535957634e487b7160e01b5f52601260045260245ffd5b500490565b6001600160e01b0319841681526060810161537c60208301856150f4565b6001600160a01b03929092166040919091015292915050565b5f602082840312156153a5575f80fd5b5051919050565b5f5b838110156153c65781810151838201526020016153ae565b50505f910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f83516154058160178501602088016153ac565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516154368160288401602088016153ac565b01602801949350505050565b5f81518084526154598160208601602086016153ac565b601f01601f19169290920160200192915050565b602081525f6110436020830184615442565b5f82516154908184602087016153ac565b9190910192915050565b5f602082840312156154aa575f80fd5b815161104381614736565b60c081016154c38287615258565b6001600160a01b0394851660608301529284166080820152921660a090920191909152919050565b60a081016154f98286615258565b6001600160a01b03938416606083015291909216608090920191909152919050565b5f8161552957615529614d33565b505f190190565b634e487b7160e01b5f52603160045260245ffd5b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190525f9061557d90830184615442565b979650505050505050565b60018060a01b0385168152836020820152826040820152608060608201525f6155b46080830184615442565b969550505050505056fe7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498a2646970667358221220827c27eb9c0e782e11cbede65a649bc4e28189cba6c89b3275f6ddb6d70f18bc64736f6c63430008170033

Deployed Bytecode

0x60806040526004361061038f575f3560e01c80638f34e347116101db578063b9c3620911610101578063d55ed1031161009f578063dff525e11161006e578063dff525e114610a99578063e400327c14610ab8578063e75235b814610ad7578063f23a6e6114610aee5761039e565b8063d55ed10314610a11578063d64af2a614610a3c578063dafae40814610a5b578063de981f1b14610a7a5761039e565b8063ca15c873116100db578063ca15c87314610991578063cdb67444146109b0578063d19773d2146109c7578063d547741f146109f25761039e565b8063b9c3620914610928578063bc197c8114610947578063c48549de146109725761039e565b8063a217fddf11610179578063affed0e011610148578063affed0e01461089d578063b1a2567e146108b2578063b1d08a03146108d1578063b2975794146108fc5761039e565b8063a217fddf14610840578063a3912ec81461039c578063ab79656614610853578063ac78dfe81461087e5761039e565b80639157921c116101b55780639157921c146107af57806391d14854146107ce57806393c5678f146107ed5780639dcc4da31461080c5761039e565b80638f34e347146107315780638f851d8a146107645780639010d07c146107905761039e565b806336568abe116102c0578063504af48c1161025e5780636c1ce6701161022d5780636c1ce670146106cb5780637de5dedd146106ea5780638456cb59146106fe578063865e6fd3146107125761039e565b8063504af48c1461064c57806359122f6b1461065f5780635c975abb1461068a5780636932be98146106a05761039e565b80633f4ba83a1161029a5780633f4ba83a146105d85780634b14557e146105ec5780634d0d6673146105ff5780634d493f4e1461061e5761039e565b806336568abe1461058657806338e454b1146105a55780633e70838b146105b95761039e565b80631d4a72101161032d5780632dfdf0b5116103075780632dfdf0b5146105285780632f2ff15d1461053d578063302d12db1461055c5780633644e515146105725761039e565b80631d4a7210146104b0578063248a9ca3146104db57806329b6eca9146105095761039e565b806317ce2dd41161036957806317ce2dd41461043057806317fcb39b146104535780631a8e55b0146104725780631b6e7594146104915761039e565b806301ffc9a7146103a6578063065b3adf146103da578063110a8308146104115761039e565b3661039e5761039c610b19565b005b61039c610b19565b3480156103b1575f80fd5b506103c56103c03660046142cf565b610b37565b60405190151581526020015b60405180910390f35b3480156103e5575f80fd5b506005546103f9906001600160a01b031681565b6040516001600160a01b0390911681526020016103d1565b34801561041c575f80fd5b5061039c61042b36600461430a565b610b7c565b34801561043b575f80fd5b5061044560755481565b6040519081526020016103d1565b34801561045e575f80fd5b506074546103f9906001600160a01b031681565b34801561047d575f80fd5b5061039c61048c366004614365565b610c04565b34801561049c575f80fd5b5061039c6104ab3660046143cb565b610c3f565b3480156104bb575f80fd5b506104456104ca36600461430a565b603e6020525f908152604090205481565b3480156104e6575f80fd5b506104456104f5366004614468565b5f9081526072602052604090206001015490565b348015610514575f80fd5b5061039c61052336600461430a565b610c7e565b348015610533575f80fd5b5061044560765481565b348015610548575f80fd5b5061039c61055736600461447f565b610d06565b348015610567575f80fd5b50610445620f424081565b34801561057d575f80fd5b50607754610445565b348015610591575f80fd5b5061039c6105a036600461447f565b610d2f565b3480156105b0575f80fd5b5061039c610dad565b3480156105c4575f80fd5b5061039c6105d336600461430a565b610f7f565b3480156105e3575f80fd5b5061039c610fa9565b61039c6105fa3660046144ad565b610fb9565b34801561060a575f80fd5b506103c56106193660046144d4565b610fdc565b348015610629575f80fd5b506103c5610638366004614468565b607a6020525f908152604090205460ff1681565b61039c61065a366004614575565b61104a565b34801561066a575f80fd5b5061044561067936600461430a565b603a6020525f908152604090205481565b348015610695575f80fd5b505f5460ff166103c5565b3480156106ab575f80fd5b506104456106ba366004614468565b60796020525f908152604090205481565b3480156106d6575f80fd5b506103c56106e5366004614646565b61130b565b3480156106f5575f80fd5b50610445611316565b348015610709575f80fd5b5061039c61132c565b34801561071d575f80fd5b5061039c61072c36600461467e565b61133c565b34801561073c575f80fd5b506104457f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e481565b34801561076f575f80fd5b5061078361077e366004614743565b611357565b6040516103d19190614831565b34801561079b575f80fd5b506103f96107aa366004614846565b6114d3565b3480156107ba575f80fd5b5061039c6107c9366004614866565b6114ea565b3480156107d9575f80fd5b506103c56107e836600461447f565b611765565b3480156107f8575f80fd5b5061039c610807366004614365565b61178f565b348015610817575f80fd5b5061082b610826366004614846565b6117c4565b604080519283526020830191909152016103d1565b34801561084b575f80fd5b506104455f81565b34801561085e575f80fd5b5061044561086d36600461430a565b603c6020525f908152604090205481565b348015610889575f80fd5b506103c5610898366004614468565b6117ec565b3480156108a8575f80fd5b5061044560045481565b3480156108bd575f80fd5b5061039c6108cc366004614365565b611817565b3480156108dc575f80fd5b506104456108eb36600461430a565b60396020525f908152604090205481565b348015610907575f80fd5b5061091b61091636600461430a565b61184c565b6040516103d191906148a9565b348015610933575f80fd5b5061039c610942366004614846565b6118ed565b348015610952575f80fd5b506107836109613660046149a4565b63bc197c8160e01b95945050505050565b34801561097d575f80fd5b5061078361098c366004614365565b611907565b34801561099c575f80fd5b506104456109ab366004614468565b611a93565b3480156109bb575f80fd5b5060375460385461082b565b3480156109d2575f80fd5b506104456109e136600461430a565b603b6020525f908152604090205481565b3480156109fd575f80fd5b5061039c610a0c36600461447f565b611aa9565b348015610a1c575f80fd5b50610445610a2b36600461430a565b603d6020525f908152604090205481565b348015610a47575f80fd5b5061039c610a5636600461430a565b611acd565b348015610a66575f80fd5b506103c5610a75366004614468565b611ade565b348015610a85575f80fd5b506103f9610a94366004614a4a565b611b01565b348015610aa4575f80fd5b5061039c610ab3366004614a63565b611b74565b348015610ac3575f80fd5b5061039c610ad2366004614365565b611be7565b348015610ae2575f80fd5b5060015460025461082b565b348015610af9575f80fd5b50610783610b08366004614b17565b63f23a6e6160e01b95945050505050565b6074546001600160a01b03163303610b2d57565b610b35611c1c565b565b5f6001600160e01b03198216631f3673bb60e01b1480610b6757506001600160e01b031982166312c0151560e21b145b80610b765750610b7682611c46565b92915050565b607154600490610100900460ff16158015610b9e575060715460ff8083169116105b610bc35760405162461bcd60e51b8152600401610bba90614b7a565b60405180910390fd5b6071805461ffff191660ff83169081176101001761ff0019169091556040519081525f805160206155bf833981519152906020015b60405180910390a15050565b610c0c611c6a565b5f839003610c2d576040516316ee9d3b60e11b815260040160405180910390fd5b610c3984848484611cc3565b50505050565b610c47611c6a565b5f859003610c68576040516316ee9d3b60e11b815260040160405180910390fd5b610c76868686868686611d94565b505050505050565b607154600290610100900460ff16158015610ca0575060715460ff8083169116105b610cbc5760405162461bcd60e51b8152600401610bba90614b7a565b6071805461ffff191660ff831617610100179055610cdb600b83611f36565b6071805461ff001916905560405160ff821681525f805160206155bf83398151915290602001610bf8565b5f82815260726020526040902060010154610d2081611fd7565b610d2a8383611fe1565b505050565b6001600160a01b0381163314610d9f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610bba565b610da98282612002565b5050565b607154600390610100900460ff16158015610dcf575060715460ff8083169116105b610deb5760405162461bcd60e51b8152600401610bba90614b7a565b6071805461ffff191660ff8316176101001790555f610e0a600b611b01565b90505f80826001600160a01b031663c441c4a86040518163ffffffff1660e01b81526004015f60405180830381865afa158015610e49573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052610e709190810190614c41565b92509250505f805b8351811015610f2957828181518110610e9357610e93614d1f565b6020026020010151607e5f868481518110610eb057610eb0614d1f565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f205f6101000a8154816001600160601b0302191690836001600160601b03160217905550828181518110610f0c57610f0c614d1f565b602002602001015182610f1f9190614d47565b9150600101610e78565b50607d80546001600160601b0319166001600160601b039290921691909117905550506071805461ff00191690555060405160ff821681525f805160206155bf833981519152906020015b60405180910390a150565b610f87611c6a565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b610fb1612023565b610b35612091565b610fc16120e2565b610fd9610fd336839003830183614db4565b33612127565b50565b5f610fe56120e2565b611040848484808060200260200160405190810160405280939291908181526020015f905b828210156110365761102760608302860136819003810190614e05565b8152602001906001019061100a565b505050505061236e565b90505b9392505050565b607154610100900460ff161580801561106a5750607154600160ff909116105b806110845750303b158015611084575060715460ff166001145b6110a05760405162461bcd60e51b8152600401610bba90614b7a565b6071805460ff1916600117905580156110c3576071805461ff0019166101001790555b6110cd5f8c6127fa565b60758990556110db8a612804565b6111666040517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81527f159f52c1e3a2b6a6aad3950adf713516211484e0516dad685ea662a094b7c43b60208201527fad7c5bef027816a800da1736444fb58a807ef4c9603b7848673f7e3a68eb14a5604082015246606082015230608082015260a0812060775550565b6111708887612852565b61117a87876128f3565b505061118461299a565b5f61118f8680614e4c565b9050111561124f576111b86111a48680614e4c565b6111b16020890189614e4c565b8787611d94565b6111dd6111c58680614e4c565b865f5b6020028101906111d89190614e4c565b6129e6565b6112036111ea8680614e4c565b8660015b6020028101906111fe9190614e4c565b611cc3565b6112296112108680614e4c565b8660025b6020028101906112249190614e4c565b612ab7565b61124f6112368680614e4c565b8660035b60200281019061124a9190614e4c565b612bc4565b5f5b61125e6040870187614e4c565b90508110156112ca576112c27f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e46112986040890189614e4c565b848181106112a8576112a8614d1f565b90506020020160208101906112bd919061430a565b611fe1565b600101611251565b5080156112fe576071805461ff0019169055604051600181525f805160206155bf8339815191529060200160405180910390a15b5050505050505050505050565b5f6110438383612c95565b5f611327611322612d59565b612d96565b905090565b611334612023565b610b35612dfa565b611344611c6a565b61134d81612e36565b610da98282611f36565b5f600b61136381612e6b565b82518690811415806113755750808514155b156113a0575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b805f036113b757506347c28ec560e11b91506114c9565b5f5b818110156114bc578481815181106113d3576113d3614d1f565b6020026020010151156114b4578686828181106113f2576113f2614d1f565b90506020020160208101906114079190614e91565b607d80546001600160601b031981166001600160601b03918216939093011691909117905586868281811061143e5761143e614d1f565b90506020020160208101906114539190614e91565b607e5f8b8b8581811061146857611468614d1f565b905060200201602081019061147d919061430a565b6001600160a01b0316815260208101919091526040015f2080546001600160601b0319166001600160601b03929092169190911790555b6001016113b9565b506347c28ec560e11b9250505b5095945050505050565b5f8281526073602052604081206110439083612eb6565b7f5e5712e902fff5e704bc4d506ad976718319e019e9d2a872528a01a85db433e461151481611fd7565b5f61152c61152736859003850185614f06565b612ec1565b905061154061152736859003850185614f06565b83355f908152607960205260409020541461156e5760405163f4b8742f60e01b815260040160405180910390fd5b82355f908152607a602052604090205460ff1661159e5760405163147bfe0760e01b815260040160405180910390fd5b82355f908152607a602052604090819020805460ff19169055517fd639511b37b3b002cca6cfe6bca0d833945a5af5a045578a0627fc43b79b2630906115e79083908690614fd7565b60405180910390a15f611600608085016060860161430a565b90505f6116156101208601610100870161505c565b600281111561162657611626614881565b036116ea575f61163f3686900386016101008701615075565b6001600160a01b0383165f908152603b602052604090205490915061166a9061014087013590612f88565b60408201525f6116833687900387016101008801615075565b604083015190915061169a9061014088013561508f565b60408201526074546116ba908390339086906001600160a01b0316612fa1565b6116e36116cd606088016040890161430a565b60745483919086906001600160a01b0316612fa1565b5050611726565b6117266116fd606086016040870161430a565b60745483906001600160a01b031661171e3689900389016101008a01615075565b929190612fa1565b7f21e88e956aa3e086f6388e899965cef814688f99ad8bb29b08d396571016372d8285604051611757929190614fd7565b60405180910390a150505050565b5f9182526072602090815260408084206001600160a01b0393909316845291905290205460ff1690565b611797611c6a565b5f8390036117b8576040516316ee9d3b60e11b815260040160405180910390fd5b610c39848484846129e6565b5f806117ce611c6a565b6117d884846128f3565b90925090506117e561299a565b9250929050565b5f6117f5612d59565b60375461180291906150a2565b60385461180f90846150a2565b101592915050565b61181f611c6a565b5f839003611840576040516316ee9d3b60e11b815260040160405180910390fd5b610c3984848484612ab7565b604080518082019091525f80825260208201526001600160a01b0382165f908152607860205260409081902081518083019092528054829060ff16600281111561189857611898614881565b60028111156118a9576118a9614881565b815290546001600160a01b03610100909104811660209283015290820151919250166118e857604051631b79f53b60e21b815260040160405180910390fd5b919050565b6118f5611c6a565b6118ff8282612852565b610da961299a565b5f600b61191381612e6b565b84838114611941575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b805f036119585750636242a4ef60e11b9150611a8a565b5f805b82811015611a3b5786868281811061197557611975614d1f565b905060200201602081019061198a91906150b9565b15611a3357607e5f8a8a848181106119a4576119a4614d1f565b90506020020160208101906119b9919061430a565b6001600160a01b0316815260208101919091526040015f908120546001600160601b03169290920191607e908a8a848181106119f7576119f7614d1f565b9050602002016020810190611a0c919061430a565b6001600160a01b0316815260208101919091526040015f2080546001600160601b03191690555b60010161195b565b50607d80548291905f90611a599084906001600160601b03166150d4565b92506101000a8154816001600160601b0302191690836001600160601b0316021790555063c48549de60e01b935050505b50949350505050565b5f818152607360205260408120610b76906131ca565b5f82815260726020526040902060010154611ac381611fd7565b610d2a8383612002565b611ad5611c6a565b610fd981612804565b5f611ae7612d59565b600154611af491906150a2565b60025461180f90846150a2565b5f7fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb5f83600f811115611b3657611b36614881565b60ff16815260208101919091526040015f20546001600160a01b03169050806118e8578160405163409140df60e11b8152600401610bba9190615104565b611b7c611c6a565b5f869003611b9d576040516316ee9d3b60e11b815260040160405180910390fd5b611bab878787878787611d94565b611bb78787835f6111c8565b611bc487878360016111ee565b611bd18787836002611214565b611bde878783600361123a565b50505050505050565b611bef611c6a565b5f839003611c10576040516316ee9d3b60e11b815260040160405180910390fd5b610c3984848484612bc4565b611c246120e2565b611c2c614292565b338152604080820151349101528051610fd9908290612127565b5f6001600160e01b03198216630271189760e51b1480610b765750610b76826131d3565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b03163314610b35575f356001600160e01b0319166001604051620f948f60ea1b8152600401610bba929190615112565b828114611cf0575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b5f5b83811015611d5e57828282818110611d0c57611d0c614d1f565b90506020020135603a5f878785818110611d2857611d28614d1f565b9050602002016020810190611d3d919061430a565b6001600160a01b0316815260208101919091526040015f2055600101611cf2565b507f64557254143204d91ba2d95acb9fda1e5fea55f77efd028685765bc1e94dd4b5848484846040516117579493929190615187565b8483148015611da257508481145b611dcc575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b5f5b85811015611eec57848482818110611de857611de8614d1f565b9050602002016020810190611dfd919061430a565b60785f898985818110611e1257611e12614d1f565b9050602002016020810190611e27919061430a565b6001600160a01b03908116825260208201929092526040015f208054610100600160a81b0319166101009390921692909202179055828282818110611e6e57611e6e614d1f565b9050602002016020810190611e83919061505c565b60785f898985818110611e9857611e98614d1f565b9050602002016020810190611ead919061430a565b6001600160a01b0316815260208101919091526040015f20805460ff19166001836002811115611edf57611edf614881565b0217905550600101611dce565b507fa4f03cc9c0e0aeb5b71b4ec800702753f65748c2cf3064695ba8e8b46be70444868686868686604051611f26969594939291906151d1565b60405180910390a1505050505050565b807fdea3103d22025c269050bea94c0c84688877f12fa22b7e6d2d5d78a9a49aa1cb5f84600f811115611f6b57611f6b614881565b60ff16815260208101919091526040015f2080546001600160a01b0319166001600160a01b03928316179055811682600f811115611fab57611fab614881565b6040517f865d1c228a8ea13709cfe61f346f7ff67f1bbd4a18ff31ad3e7147350d317c59905f90a35050565b610fd981336131f7565b611feb828261325b565b5f828152607360205260409020610d2a90826132e0565b61200c82826132f4565b5f828152607360205260409020610d2a908261335a565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103546001600160a01b031633148061206557506005546001600160a01b031633145b610b35575f356001600160e01b0319166001604051620f948f60ea1b8152600401610bba929190615112565b61209961336e565b5f805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b5f5460ff1615610b355760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610bba565b6040805180820182525f80825260208201526074549184015190916001600160a01b031690612155906133b6565b60208401516001600160a01b03166121f657348460400151604001511461218f5760405163129c2ce160e31b815260040160405180910390fd5b6121988161184c565b60408501515190925060028111156121b2576121b2614881565b825160028111156121c5576121c5614881565b146121e25760405162035e2b60ea1b815260040160405180910390fd5b6001600160a01b03811660208501526122fd565b34156122155760405163129c2ce160e31b815260040160405180910390fd5b612222846020015161184c565b604085015151909250600281111561223c5761223c614881565b8251600281111561224f5761224f614881565b1461226c5760405162035e2b60ea1b815260040160405180910390fd5b602084015160408501516122819185906133fa565b83602001516001600160a01b0316816001600160a01b0316036122fd576040848101518101519051632e1a7d4d60e01b815260048101919091526001600160a01b03821690632e1a7d4d906024015f604051808303815f87803b1580156122e6575f80fd5b505af11580156122f8573d5f803e3d5ffd5b505050505b607680545f918261230d83615240565b9190505590505f612333858386602001516075548a61356e90949392919063ffffffff16565b90507fd7b25068d9dc8d00765254cfb7f5070f98d263c8d68931d937c7362fa738048b61235f82612ec1565b82604051611f26929190615278565b5f823561014084013582612388608087016060880161430a565b90506123a56123a03688900388016101008901615075565b6133b6565b60016123b76040880160208901615313565b60018111156123c8576123c8614881565b146123e65760405163182f3d8760e11b815260040160405180910390fd5b608086013546146124275760405163092048d160e11b81525f356001600160e01b031916600482015260808701356024820152466044820152606401610bba565b5f61243b6109166080890160608a0161430a565b905061244f6101208801610100890161505c565b600281111561246057612460614881565b8151600281111561247357612473614881565b1480156124a4575061248b60e0880160c0890161430a565b6001600160a01b031681602001516001600160a01b0316145b80156124b5575060755460e0880135145b6124d25760405163f4b8742f60e01b815260040160405180910390fd5b5f84815260796020526040902054156124fe57604051634f13df6160e01b815260040160405180910390fd5b600161251261012089016101008a0161505c565b600281111561252357612523614881565b148061253657506125348284612c95565b155b6125535760405163c51297b760e01b815260040160405180910390fd5b5f612566611527368a90038a018a614f06565b90505f61257560775483613641565b90505f61259461258d6101208c016101008d0161505c565b8688613681565b604080516060810182525f80825260208201819052918101829052919a50919250819081905f805b8e518110156126d4578e81815181106125d7576125d7614d1f565b602002602001015192506125f888845f015185602001518660400151613702565b9450846001600160a01b0316846001600160a01b031610612639575f356001600160e01b031916604051635d3dcd3160e01b8152600401610bba9190614831565b6001600160a01b0385165f908152607e60205260408120548695506001600160601b0316908190036126ae5760408051634e97700760e01b81526001600160a01b038816600482015260248101839052855160ff1660448201526020860151606482015290850151608482015260a401610bba565b6126b8818461532c565b92508783106126cb5760019650506126d4565b506001016125bc565b50846126f357604051639e8f5f6360e01b815260040160405180910390fd5b5050505f8981526079602052604090208590555050871561276c575f878152607a602052604090819020805460ff19166001179055517f89e52969465b1f1866fc5d46fd62de953962e9cb33552443cd999eba05bd20dc906127589085908d90614fd7565b60405180910390a150505050505050610b76565b612776858761372a565b6127b461278960608c0160408d0161430a565b8660745f9054906101000a90046001600160a01b03168d6101000180360381019061171e9190615075565b7f21e88e956aa3e086f6388e899965cef814688f99ad8bb29b08d396571016372d838b6040516127e5929190614fd7565b60405180910390a15050505050505092915050565b610da98282611fe1565b607480546001600160a01b0319166001600160a01b0383169081179091556040519081527f9d2334c23be647e994f27a72c5eee42a43d5bdcfe15bb88e939103c2b114cbaf90602001610f74565b8082118061285e575080155b80612867575081155b15612892575f356001600160e01b0319166040516387f6f09560e01b8152600401610bba9190614831565b6001805460028054858455908490556004805493840190556040805183815260208101839052929391928592879290917f976f8a9c5bdf8248dec172376d6e2b80a8e3df2f0328e381c6db8e1cf138c0f8910160405180910390a450505050565b5f8082841180612901575083155b8061290a575082155b15612935575f356001600160e01b0319166040516387f6f09560e01b8152600401610bba9190614831565b5050603780546038805492859055839055600480546001810190915560408051838152602081018590529293928592879290917f31312c97b89cc751b832d98fd459b967a2c3eef3b49757d1cf5ebaa12bb6eee1910160405180910390a49250929050565b6002546037546129aa91906150a2565b6038546001546129ba91906150a2565b1115610b35575f356001600160e01b0319166040516387f6f09560e01b8152600401610bba9190614831565b828114612a13575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b5f5b83811015612a8157828282818110612a2f57612a2f614d1f565b9050602002013560395f878785818110612a4b57612a4b614d1f565b9050602002016020810190612a60919061430a565b6001600160a01b0316815260208101919091526040015f2055600101612a15565b507f80bc635c452ae67f12f9b6f12ad4daa6dbbc04eeb9ebb87d354ce10c0e210dc0848484846040516117579493929190615187565b828114612ae4575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b5f5b83811015612b8e57620f4240838383818110612b0457612b04614d1f565b905060200201351115612b2a5760405163572d3bd360e11b815260040160405180910390fd5b828282818110612b3c57612b3c614d1f565b90506020020135603b5f878785818110612b5857612b58614d1f565b9050602002016020810190612b6d919061430a565b6001600160a01b0316815260208101919091526040015f2055600101612ae6565b507fb05f5de88ae0294ebb6f67c5af2fcbbd593cc6bdfe543e2869794a4c8ce3ea50848484846040516117579493929190615187565b828114612bf1575f356001600160e01b0319166040516306b5667560e21b8152600401610bba9190614831565b5f5b83811015612c5f57828282818110612c0d57612c0d614d1f565b90506020020135603c5f878785818110612c2957612c29614d1f565b9050602002016020810190612c3e919061430a565b6001600160a01b0316815260208101919091526040015f2055600101612bf3565b507fb5d2963614d72181b4df1f993d45b83edf42fa19710f0204217ba1b3e183bb73848484846040516117579493929190615187565b6001600160a01b0382165f908152603a60205260408120548210612cba57505f610b76565b5f612cc8620151804261533f565b6001600160a01b0385165f908152603e6020526040902054909150811115612d0c5750506001600160a01b0382165f908152603c6020526040902054811015610b76565b6001600160a01b0384165f908152603d6020526040902054612d2f90849061532c565b6001600160a01b0385165f908152603c602052604090205411159150610b769050565b5092915050565b607d546001600160601b03165f819003612d93575f356001600160e01b031916604051631103b51560e31b8152600401610bba9190614831565b90565b5f600254600160025484600154612dad91906150a2565b612db7919061532c565b612dc1919061508f565b612dcb919061533f565b9050805f036118e8575f356001600160e01b03191660405163267b1b9160e01b8152600401610bba9190614831565b612e026120e2565b5f805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586120c53390565b806001600160a01b03163b5f03610fd957604051630bfc64a360e21b81526001600160a01b0382166004820152602401610bba565b612e7481611b01565b6001600160a01b0316336001600160a01b031614610fd9575f356001600160e01b03191681336040516320e0f98d60e21b8152600401610bba9392919061535e565b5f61104383836137b6565b5f80612ed083604001516137dc565b90505f612ee084606001516137dc565b90505f612f338560800151604080517f1e2b74b2a792d5c0f0b6e59b037fa9d43d84fbb759337f0112fcc15ca414fc8d815282516020808301919091528301518183015291015160608201526080902090565b604080517fb9d1fe7c9deeec5dc90a2f47ff1684239519f2545b2228d3d91fb27df3189eea815287516020808301919091529097015190870152606086019390935250608084015260a08301525060c0902090565b5f620f4240612f9783856150a2565b611043919061533f565b806001600160a01b0316826001600160a01b0316036130495760408085015190516001600160a01b0385169180156108fc02915f818181858888f1935050505061304457806001600160a01b031663d0e30db085604001516040518263ffffffff1660e01b81526004015f604051808303818588803b158015613022575f80fd5b505af1158015613034573d5f803e3d5ffd5b5050505050613044848484613824565b610c39565b5f8451600281111561305d5761305d614881565b03613120576040516370a0823160e01b81523060048201525f906001600160a01b038416906370a0823190602401602060405180830381865afa1580156130a6573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906130ca9190615395565b9050846040015181101561310f576130f283308388604001516130ed919061508f565b6138a2565b61310f57604051632f739fff60e11b815260040160405180910390fd5b61311a858585613824565b50610c39565b60018451600281111561313557613135614881565b036131665761314982848660200151613942565b6130445760405163c8e3a09f60e01b815260040160405180910390fd5b60028451600281111561317b5761317b614881565b036131b157613194828486602001518760400151613968565b613044576040516334b471a760e21b815260040160405180910390fd5b6040516361e411a760e11b815260040160405180910390fd5b5f610b76825490565b5f6001600160e01b03198216635a05180f60e01b1480610b765750610b7682613990565b6132018282611765565b610da957613219816001600160a01b031660146139c4565b6132248360206139c4565b6040516020016132359291906153ce565b60408051601f198184030181529082905262461bcd60e51b8252610bba9160040161546d565b6132658282611765565b610da9575f8281526072602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561329c3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f611043836001600160a01b038416613b59565b6132fe8282611765565b15610da9575f8281526072602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b5f611043836001600160a01b038416613ba5565b5f5460ff16610b355760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610bba565b6133bf81613c88565b806133ce57506133ce81613cbd565b806133dd57506133dd81613ce4565b610fd95760405163034992a760e51b815260040160405180910390fd5b5f6060818551600281111561341157613411614881565b036134e85760408581015181516001600160a01b03878116602483015230604483015260648083019390935283518083039093018352608490910183526020820180516001600160e01b03166323b872dd60e01b179052915191851691613478919061547f565b5f604051808303815f865af19150503d805f81146134b1576040519150601f19603f3d011682016040523d82523d5f602084013e6134b6565b606091505b5090925090508180156134e15750805115806134e15750808060200190518101906134e1919061549a565b9150613541565b6001855160028111156134fd576134fd614881565b03613512576134e18385308860200151613d0c565b60028551600281111561352757613527614881565b036131b1576134e183853088602001518960400151613db5565b816135675784843085604051639d2e4c6760e01b8152600401610bba94939291906154b5565b5050505050565b6135dd6040805160a0810182525f8082526020808301829052835160608082018652838252818301849052818601849052848601919091528451808201865283815280830184905280860184905281850152845190810185528281529081018290529283015290608082015290565b8381525f6020820181905250604080820180516001600160a01b039788169052602080890151825190891690820152905146908301528751606084018051918916909152805195909716940193909352935182015292909201516080820152919050565b6040805161190160f01b60208083019190915260228201859052604280830185905283518084039091018152606290920190925280519101205f90611043565b5f805f61368c612d59565b905061369781612d96565b92505f8660028111156136ac576136ac614881565b036136f9576001600160a01b0385165f9081526039602052604090205484106136db576136d881613e64565b92505b6001600160a01b0385165f908152603a602052604090205484101591505b50935093915050565b5f805f61371187878787613ec8565b9150915061371e81613fad565b5090505b949350505050565b5f613738620151804261533f565b6001600160a01b0384165f908152603e6020526040902054909150811115613785576001600160a01b03929092165f908152603e6020908152604080832094909455603d90529190912055565b6001600160a01b0383165f908152603d6020526040812080548492906137ac90849061532c565b9091555050505050565b5f825f0182815481106137cb576137cb614d1f565b905f5260205f200154905092915050565b604080517f353bdd8d69b9e3185b3972e08b03845c0c14a21a390215302776a7a34b0e8764815282516020808301919091528301518183015291015160608201526080902090565b5f808451600281111561383957613839614881565b036138545761384d82848660400151614162565b905061387e565b60018451600281111561386957613869614881565b036131b15761384d8230858760200151613d0c565b80610c39578383836040516341bd7d9160e11b8152600401610bba939291906154eb565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b03166340c10f1960e01b17905291515f928616916138f99161547f565b5f604051808303815f865af19150503d805f8114613932576040519150601f19603f3d011682016040523d82523d5f602084013e613937565b606091505b509095945050505050565b5f61394f84308585613d0c565b905080611043576139618484846138a2565b9050611043565b5f6139768530868686613db5565b9050806137225761398985858585614230565b9050613722565b5f6001600160e01b03198216637965db0b60e01b1480610b7657506301ffc9a760e01b6001600160e01b0319831614610b76565b60605f6139d28360026150a2565b6139dd90600261532c565b6001600160401b038111156139f4576139f46146a8565b6040519080825280601f01601f191660200182016040528015613a1e576020820181803683370190505b509050600360fc1b815f81518110613a3857613a38614d1f565b60200101906001600160f81b03191690815f1a905350600f60fb1b81600181518110613a6657613a66614d1f565b60200101906001600160f81b03191690815f1a9053505f613a888460026150a2565b613a9390600161532c565b90505b6001811115613b0a576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613ac757613ac7614d1f565b1a60f81b828281518110613add57613add614d1f565b60200101906001600160f81b03191690815f1a90535060049490941c93613b038161551b565b9050613a96565b5083156110435760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610bba565b5f818152600183016020526040812054613b9e57508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610b76565b505f610b76565b5f8181526001830160205260408120548015613c7f575f613bc760018361508f565b85549091505f90613bda9060019061508f565b9050818114613c39575f865f018281548110613bf857613bf8614d1f565b905f5260205f200154905080875f018481548110613c1857613c18614d1f565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080613c4a57613c4a615530565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610b76565b5f915050610b76565b5f8082516002811115613c9d57613c9d614881565b148015613cad57505f8260400151115b8015610b76575050602001511590565b5f600182516002811115613cd357613cd3614881565b148015610b76575050604001511590565b5f600282516002811115613cfa57613cfa614881565b148015610b7657505060400151151590565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291515f92871691613d6b9161547f565b5f604051808303815f865af19150503d805f8114613da4576040519150601f19603f3d011682016040523d82523d5f602084013e613da9565b606091505b50909695505050505050565b604080515f808252602082019092526001600160a01b03871690613de490879087908790879060448101615544565b60408051601f198184030181529181526020820180516001600160e01b0316637921219560e11b17905251613e19919061547f565b5f604051808303815f865af19150503d805f8114613e52576040519150601f19603f3d011682016040523d82523d5f602084013e613e57565b606091505b5090979650505050505050565b5f603854600160385484603754613e7b91906150a2565b613e85919061532c565b613e8f919061508f565b613e99919061533f565b9050805f036118e8575f356001600160e01b031916604051639b974b0f60e01b8152600401610bba9190614831565b5f807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613efd57505f90506003613fa4565b8460ff16601b14158015613f1557508460ff16601c14155b15613f2557505f90506004613fa4565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613f76573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b038116613f9e575f60019250925050613fa4565b91505f90505b94509492505050565b5f816004811115613fc057613fc0614881565b03613fc85750565b6001816004811115613fdc57613fdc614881565b036140295760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610bba565b600281600481111561403d5761403d614881565b0361408a5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610bba565b600381600481111561409e5761409e614881565b036140f65760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610bba565b600481600481111561410a5761410a614881565b03610fd95760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610bba565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291515f92606092908716916141be919061547f565b5f604051808303815f865af19150503d805f81146141f7576040519150601f19603f3d011682016040523d82523d5f602084013e6141fc565b606091505b509092509050818015614227575080511580614227575080806020019051810190614227919061549a565b95945050505050565b604080515f808252602082019092526001600160a01b0386169061425d9086908690869060448101615588565b60408051601f198184030181529181526020820180516001600160e01b031663731133e960e01b17905251613d6b919061547f565b604080516060810182525f80825260208201529081016142ca6040805160608101909152805f81526020015f81526020015f81525090565b905290565b5f602082840312156142df575f80fd5b81356001600160e01b031981168114611043575f80fd5b6001600160a01b0381168114610fd9575f80fd5b5f6020828403121561431a575f80fd5b8135611043816142f6565b5f8083601f840112614335575f80fd5b5081356001600160401b0381111561434b575f80fd5b6020830191508360208260051b85010111156117e5575f80fd5b5f805f8060408587031215614378575f80fd5b84356001600160401b038082111561438e575f80fd5b61439a88838901614325565b909650945060208701359150808211156143b2575f80fd5b506143bf87828801614325565b95989497509550505050565b5f805f805f80606087890312156143e0575f80fd5b86356001600160401b03808211156143f6575f80fd5b6144028a838b01614325565b9098509650602089013591508082111561441a575f80fd5b6144268a838b01614325565b9096509450604089013591508082111561443e575f80fd5b5061444b89828a01614325565b979a9699509497509295939492505050565b80356118e8816142f6565b5f60208284031215614478575f80fd5b5035919050565b5f8060408385031215614490575f80fd5b8235915060208301356144a2816142f6565b809150509250929050565b5f60a082840312156144bd575f80fd5b50919050565b5f61016082840312156144bd575f80fd5b5f805f61018084860312156144e7575f80fd5b6144f185856144c3565b92506101608401356001600160401b038082111561450d575f80fd5b818601915086601f830112614520575f80fd5b81358181111561452e575f80fd5b876020606083028501011115614542575f80fd5b6020830194508093505050509250925092565b8060608101831015610b76575f80fd5b8060808101831015610b76575f80fd5b5f805f805f805f805f806101208b8d03121561458f575f80fd5b6145988b61445d565b99506145a660208c0161445d565b985060408b0135975060608b0135965060808b0135955060a08b0135945060c08b01356001600160401b03808211156145dd575f80fd5b6145e98e838f01614555565b955060e08d01359150808211156145fe575f80fd5b61460a8e838f01614565565b94506101008d0135915080821115614620575f80fd5b5061462d8d828e01614325565b915080935050809150509295989b9194979a5092959850565b5f8060408385031215614657575f80fd5b8235614662816142f6565b946020939093013593505050565b8035601081106118e8575f80fd5b5f806040838503121561468f575f80fd5b61469883614670565b915060208301356144a2816142f6565b634e487b7160e01b5f52604160045260245ffd5b604051606081016001600160401b03811182821017156146de576146de6146a8565b60405290565b604051601f8201601f191681016001600160401b038111828210171561470c5761470c6146a8565b604052919050565b5f6001600160401b0382111561472c5761472c6146a8565b5060051b60200190565b8015158114610fd9575f80fd5b5f805f805f60608688031215614757575f80fd5b85356001600160401b038082111561476d575f80fd5b61477989838a01614325565b9097509550602091508782013581811115614792575f80fd5b61479e8a828b01614325565b9096509450506040880135818111156147b5575f80fd5b88019050601f810189136147c7575f80fd5b80356147da6147d582614714565b6146e4565b81815260059190911b8201830190838101908b8311156147f8575f80fd5b928401925b8284101561481f57833561481081614736565b825292840192908401906147fd565b80955050505050509295509295909350565b6001600160e01b031991909116815260200190565b5f8060408385031215614857575f80fd5b50508035926020909101359150565b5f6101608284031215614877575f80fd5b61104383836144c3565b634e487b7160e01b5f52602160045260245ffd5b600381106148a5576148a5614881565b9052565b5f6040820190506148bb828451614895565b6020928301516001600160a01b0316919092015290565b5f82601f8301126148e1575f80fd5b813560206148f16147d583614714565b8083825260208201915060208460051b870101935086841115614912575f80fd5b602086015b8481101561492e5780358352918301918301614917565b509695505050505050565b5f82601f830112614948575f80fd5b81356001600160401b03811115614961576149616146a8565b614974601f8201601f19166020016146e4565b818152846020838601011115614988575f80fd5b816020850160208301375f918101602001919091529392505050565b5f805f805f60a086880312156149b8575f80fd5b85356149c3816142f6565b945060208601356149d3816142f6565b935060408601356001600160401b03808211156149ee575f80fd5b6149fa89838a016148d2565b94506060880135915080821115614a0f575f80fd5b614a1b89838a016148d2565b93506080880135915080821115614a30575f80fd5b50614a3d88828901614939565b9150509295509295909350565b5f60208284031215614a5a575f80fd5b61104382614670565b5f805f805f805f6080888a031215614a79575f80fd5b87356001600160401b0380821115614a8f575f80fd5b614a9b8b838c01614325565b909950975060208a0135915080821115614ab3575f80fd5b614abf8b838c01614325565b909750955060408a0135915080821115614ad7575f80fd5b614ae38b838c01614325565b909550935060608a0135915080821115614afb575f80fd5b50614b088a828b01614565565b91505092959891949750929550565b5f805f805f60a08688031215614b2b575f80fd5b8535614b36816142f6565b94506020860135614b46816142f6565b9350604086013592506060860135915060808601356001600160401b03811115614b6e575f80fd5b614a3d88828901614939565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b5f82601f830112614bd7575f80fd5b81516020614be76147d583614714565b8083825260208201915060208460051b870101935086841115614c08575f80fd5b602086015b8481101561492e578051614c20816142f6565b8352918301918301614c0d565b6001600160601b0381168114610fd9575f80fd5b5f805f60608486031215614c53575f80fd5b83516001600160401b0380821115614c69575f80fd5b614c7587838801614bc8565b9450602091508186015181811115614c8b575f80fd5b614c9788828901614bc8565b945050604086015181811115614cab575f80fd5b86019050601f81018713614cbd575f80fd5b8051614ccb6147d582614714565b81815260059190911b82018301908381019089831115614ce9575f80fd5b928401925b82841015614d10578351614d0181614c2d565b82529284019290840190614cee565b80955050505050509250925092565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b6001600160601b03818116838216019080821115612d5257612d52614d33565b8035600381106118e8575f80fd5b5f60608284031215614d85575f80fd5b614d8d6146bc565b9050614d9882614d67565b8152602082013560208201526040820135604082015292915050565b5f60a08284031215614dc4575f80fd5b614dcc6146bc565b8235614dd7816142f6565b81526020830135614de7816142f6565b6020820152614df98460408501614d75565b60408201529392505050565b5f60608284031215614e15575f80fd5b614e1d6146bc565b823560ff81168114614e2d575f80fd5b8152602083810135908201526040928301359281019290925250919050565b5f808335601e19843603018112614e61575f80fd5b8301803591506001600160401b03821115614e7a575f80fd5b6020019150600581901b36038213156117e5575f80fd5b5f60208284031215614ea1575f80fd5b813561104381614c2d565b8035600281106118e8575f80fd5b5f60608284031215614eca575f80fd5b614ed26146bc565b90508135614edf816142f6565b81526020820135614eef816142f6565b806020830152506040820135604082015292915050565b5f6101608284031215614f17575f80fd5b60405160a081018181106001600160401b0382111715614f3957614f396146a8565b60405282358152614f4c60208401614eac565b6020820152614f5e8460408501614eba565b6040820152614f708460a08501614eba565b6060820152614f83846101008501614d75565b60808201529392505050565b600281106148a5576148a5614881565b8035614faa816142f6565b6001600160a01b039081168352602082013590614fc6826142f6565b166020830152604090810135910152565b5f6101808201905083825282356020830152614ff560208401614eac565b6150026040840182614f8f565b506150136060830160408501614f9f565b61502360c0830160a08501614f9f565b61012061503e8184016150396101008701614d67565b614895565b61014081850135818501528085013561016085015250509392505050565b5f6020828403121561506c575f80fd5b61104382614d67565b5f60608284031215615085575f80fd5b6110438383614d75565b81810381811115610b7657610b76614d33565b8082028115828204841417610b7657610b76614d33565b5f602082840312156150c9575f80fd5b813561104381614736565b6001600160601b03828116828216039080821115612d5257612d52614d33565b601081106148a5576148a5614881565b60208101610b7682846150f4565b6001600160e01b03198316815260408101600b831061513357615133614881565b8260208301529392505050565b8183525f60208085019450825f5b8581101561517c578135615161816142f6565b6001600160a01b03168752958201959082019060010161514e565b509495945050505050565b604081525f61519a604083018688615140565b82810360208401528381526001600160fb1b038411156151b8575f80fd5b8360051b80866020840137016020019695505050505050565b606081525f6151e460608301888a615140565b602083820360208501526151f982888a615140565b84810360408601528581528692506020015f5b86811015615231576152218261503986614d67565b928201929082019060010161520c565b509a9950505050505050505050565b5f6001820161525157615251614d33565b5060010190565b615263828251614895565b60208181015190830152604090810151910152565b5f6101808201905083825282516020830152602083015161529c6040840182614f8f565b5060408381015180516001600160a01b03908116606086015260208201511660808501529081015160a084015250606083015180516001600160a01b0390811660c085015260208201511660e0840152604081015161010084015250608083015161530b610120840182615258565b509392505050565b5f60208284031215615323575f80fd5b61104382614eac565b80820180821115610b7657610b76614d33565b5f8261535957634e487b7160e01b5f52601260045260245ffd5b500490565b6001600160e01b0319841681526060810161537c60208301856150f4565b6001600160a01b03929092166040919091015292915050565b5f602082840312156153a5575f80fd5b5051919050565b5f5b838110156153c65781810151838201526020016153ae565b50505f910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f83516154058160178501602088016153ac565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516154368160288401602088016153ac565b01602801949350505050565b5f81518084526154598160208601602086016153ac565b601f01601f19169290920160200192915050565b602081525f6110436020830184615442565b5f82516154908184602087016153ac565b9190910192915050565b5f602082840312156154aa575f80fd5b815161104381614736565b60c081016154c38287615258565b6001600160a01b0394851660608301529284166080820152921660a090920191909152919050565b60a081016154f98286615258565b6001600160a01b03938416606083015291909216608090920191909152919050565b5f8161552957615529614d33565b505f190190565b634e487b7160e01b5f52603160045260245ffd5b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190525f9061557d90830184615442565b979650505050505050565b60018060a01b0385168152836020820152826040820152608060608201525f6155b46080830184615442565b969550505050505056fe7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498a2646970667358221220827c27eb9c0e782e11cbede65a649bc4e28189cba6c89b3275f6ddb6d70f18bc64736f6c63430008170033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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