Arbitrum Sepolia Testnet

Contract

0xb6279106b9789938Aa1A4a6aC8507459CC4c9565

Overview

ETH Balance

0 ETH

More Info

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Amount

There are no matching entries

1 Internal Transaction found.

Latest 1 internal transaction

Parent Transaction Hash Block From To Amount
1485223952025-05-01 21:37:30190 days ago1746135450
0xb6279106...9CC4c9565
 Contract Creation0 ETH

Loading...
Loading

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

Contract Name:
FundsManagerLogic

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 10000 runs

Other Settings:
paris EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 36 : FundsManagerLogic.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright 2023 Immersve

pragma solidity ^0.8.28;

import { IFundsAdmin } from "./interfaces/IFundsAdmin.sol";
import { IFundsStorage } from "./interfaces/IFundsStorage.sol";
import { FundsStorageLogic } from "./FundsStorageLogic.sol";
import { BeaconProxy } from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
import { UpgradeableBeacon } from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
import { ERC1967Utils } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol";
import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract FundsManagerLogic is AccessControlUpgradeable, UUPSUpgradeable, PausableUpgradeable, IFundsAdmin {

  /**
   * The FundsStorageLogic beacon.
   */
  UpgradeableBeacon internal _fundsStorageBeacon;

  /**
   * The FundsStorageLogic implementation contract.
   * This storage slot will NOT be initialized on a proxy.
   */
  address internal _storageLogicAddress;

  /**
   * The FundsAdminLogic implementation contract.
   * This storage slot will NOT be initialized on a proxy.
   */
  /// @custom:oz-renamed-from _adminLogicAddress
  address internal _masterLogicAddress;

  /**
    * A build number supplied when (re)initializing.
    */
  string internal _buildNumber;

  /**
    * A VCS commit id supplied when (re)initializing.
    */
  string internal _commitId;

  struct FundStorageConfig {
    bool isInstance;
  }

  /**
   * Addresses of FundsStorage beacon proxies that have been created by this factory.
   */
  mapping (address => FundStorageConfig) internal _fundsStorageInstances;

  /// @inheritdoc IFundsAdmin
  bytes32 public constant WITHDRAWAL_SIGNER_ROLE = keccak256("WITHDRAWAL_AUTHORIZER_ROLE");

  /// @inheritdoc IFundsAdmin
  bytes32 public constant SETTLER_ROLE = keccak256("SETTLER_ROLE");

  /**
    * Mapping of token address to funds settlement address. The settlement
    * address is the only address to which funds storage instance token deposits
    * can be transfered as part of the settlement process. When a settlement
    * address is not set (ie. `address(0)`) then the token is NOT supported.
    */
  mapping(address => address) internal _tokenSettlementAddress;

  /**
    * Mapping of funds storage address to settlement nonce.
    */
  mapping(address => uint256) internal _fundsStorageSettlementNonce;

  /**
   * @notice This field is DEPRECATED. Refunder address will be dynamic
   * from now on. We are not removing this field from the contract to keep
   * storage layout compatibility
   */
  address internal _refunderAddress;

  /**
   * Indicates if Direct Spend funding mode is enabled
   */
  bool internal _directSpendEnabled;

  /**
   * @dev indicates the amount of seconds after which a
   * direct spend transaction is expired in case a reversal
   * is being executed against it
   */
  uint256 internal _directSpendReversalCutoffSeconds;

  /// @custom:oz-upgrades-unsafe-allow constructor
  constructor() {
    // invoked in the context of the contract being deployed
    _disableInitializers();
    _storageLogicAddress = address(new FundsStorageLogic());
    _masterLogicAddress = address(this);
  }

  /**
   * @dev This initializer will be run after every upgrade.
   * @param commitId A reference to the VCS commit that this contract is initialized from.
   * @param buildNumber A reference to the build number for this contract initialization.
   */
  function initialize(string calldata commitId, string calldata buildNumber) public onlyProxy onlyRole(DEFAULT_ADMIN_ROLE) {
    /*
     * Warning: this initializer must guard against reinitialization!
     *
     * The initializer acts like a constructor for initializing state on a
     * delegating proxy. Normally the "initializer" modifier is used to prevent
     * it being invoked multiple times. We have removed the guard in order to
     * simplify our contract upgrade process; we always call "initialize" when
     * performing a proxy upgrade.
     *
     * It is the duty of this initializer to do nothing when the proxy state is
     * already initialized.
     */
    bool _proxiesInitialized = address(_fundsStorageBeacon) != address(0);
    if(!_proxiesInitialized) {
      _initialize();
    }
    _buildNumber = buildNumber;
    _commitId = commitId;
  }

  function _initialize() internal reinitializer(2) onlyProxy {
    address implAddress = ERC1967Utils.getImplementation();
    FundsManagerLogic impl = FundsManagerLogic(implAddress);
    _fundsStorageBeacon = new UpgradeableBeacon(impl.getStorageLogicAddress(), address(this));
    PausableUpgradeable.__Pausable_init();
    _directSpendEnabled = false; // defaults to disabled
    _directSpendReversalCutoffSeconds = 7 days;
  }

  /// @inheritdoc IFundsAdmin
  function getStorageBeaconAddress() public view returns(address) {
    return address(_fundsStorageBeacon);
  }

  function getStorageLogicAddress() public view returns(address) {
    return _storageLogicAddress;
  }

  /// @inheritdoc IFundsAdmin
  function getMasterAddress() public view returns(address) {
    return address(this);
  }

  function getMasterLogicAddress() public view returns(address) {
    return _masterLogicAddress;
  }

  function _authorizeUpgrade(address newImplementation) internal view override onlyRole(DEFAULT_ADMIN_ROLE) {
  }

  /// @inheritdoc UUPSUpgradeable
  function upgradeToAndCall(address newImplAddress, bytes memory data) public payable override onlyProxy {
    super.upgradeToAndCall(newImplAddress, data);
    FundsManagerLogic newImpl = FundsManagerLogic(newImplAddress);
    _fundsStorageBeacon.upgradeTo(newImpl.getStorageLogicAddress());
  }

  /// @inheritdoc IFundsAdmin
  function getVersion() external pure returns(uint256) {
    return 1;
  }

  /// @inheritdoc IFundsAdmin
  function getCommitId() external view returns(string memory) {
    return _commitId;
  }

  /// @inheritdoc IFundsAdmin
  function getBuildNumber() external view returns(string memory) {
    return _buildNumber;
  }

  /// @inheritdoc IFundsAdmin
  function createFundsStorage(address token, string calldata name, FundingMode fundingMode) external onlyProxy whenNotPaused returns(address) {
    _requireTokenSupported(token);
    /*
     * Salt for create2 will be sender address padded with first 96 bits of hash(name)
     * Bitmask is equal to: ethers.toBeHex(((1n << 96n) - 1n) << 160n)
     */
    uint256 bitmask = 0xffffffffffffffffffffffff0000000000000000000000000000000000000000;
    uint256 nameHash = uint256(keccak256(bytes(name)));
    uint256 salt = (nameHash & bitmask) + uint160(msg.sender);
    /*
     * Beacon proxy is created without providing encoded initializer data,
     * making constructor bytes always the same. This simplifies counterfactual address
     * calculation.
     */
    BeaconProxy proxy = new BeaconProxy{ salt: bytes32(salt) }( address(_fundsStorageBeacon), new bytes(0));
    FundsStorageLogic(address(proxy)).initialize(address(this), token, name, fundingMode);
    _fundsStorageInstances[address(proxy)].isInstance = true;
    emit FundsStorageCreated(token, address(proxy), name);
    return address(proxy);
  }

  /// @inheritdoc IFundsAdmin
  function isFundsStorage(address addr) public view returns(bool) {
    return _fundsStorageInstances[addr].isInstance;
  }

  /// @inheritdoc IFundsAdmin
  function getSettlementNonce(address fundsStorage) public view returns(uint256) {
    return _fundsStorageSettlementNonce[fundsStorage];
  }

  /// @inheritdoc IFundsAdmin
  function settle(
    address from,
    uint256 amount,
    uint256 nonce,
    bytes32 merkleRoot
  ) external onlyProxy onlyRole(SETTLER_ROLE) whenNotPaused {
    /*
     * The bytes32(0) is required for forwards compatibility. In future, when
     * merkle withdraw is implemented, the bytes32(0) merkle root will be
     * disallowed.
     */
    if(merkleRoot != bytes32(0)) revert MerkleRootInvalid();
    IFundsStorage fundsStorage = _requireFundsStorage(from);
    if(nonce != _fundsStorageSettlementNonce[from] + 1) revert NonceOutOfSequence();
    fundsStorage.transferToSettlementAddress(amount);
    _fundsStorageSettlementNonce[from] = nonce;
    emit Settlement(from, amount, nonce);
  }

  /// @inheritdoc IFundsAdmin
  function addStorageLiquidity(
    address refundee,
    address sourceAddress,
    uint256 amount,
    uint256 nonce,
    bytes32 merkleRoot
  ) external onlyProxy onlyRole(SETTLER_ROLE) whenNotPaused {
    if(merkleRoot != bytes32(0)) revert MerkleRootInvalid();
    if(nonce != _fundsStorageSettlementNonce[refundee] + 1) revert NonceOutOfSequence();
    IFundsStorage fundsStorage = _requireFundsStorage(refundee);
    address tokenAddress = fundsStorage.getToken();
    _requireTokenSupported(tokenAddress);
    fundsStorage.addStorageLiquidity(sourceAddress, amount);
    _fundsStorageSettlementNonce[refundee] = nonce;
    emit StorageLiquidityAdded(refundee, sourceAddress, amount, nonce);
  }

  /// @inheritdoc IFundsAdmin
  function directSpendDebit(
    address storageAddress,
    address spender,
    uint256 amount,
    bytes32 idempotencyKey
  ) external onlyProxy onlyRole(SETTLER_ROLE) whenNotPaused {
    _requireDirectSpendEnabled();
    IFundsStorage fundsStorage = _requireFundsStorage(storageAddress);
    fundsStorage.directSpendDebit(spender, amount, idempotencyKey);
  }

  /// @inheritdoc IFundsAdmin
  function directSpendGetTransaction(address storageAddress, bytes32 idempotencyKey) external onlyProxy view returns(DirectSpendTransaction memory) {
    IFundsStorage fundsStorage = _requireFundsStorage(storageAddress);
    return fundsStorage.directSpendGetTransaction(idempotencyKey);
  }

    /// @inheritdoc IFundsAdmin
  function directSpendRefund(
    address storageAddress,
    address destinationAddress,
    address sourceAddress,
    uint256 amount,
    bytes32 idempotencyKey
  ) external onlyProxy onlyRole(SETTLER_ROLE) whenNotPaused {
    _requireDirectSpendEnabled();
    IFundsStorage fundsStorage = _requireFundsStorage(storageAddress);
    fundsStorage.directSpendRefund(destinationAddress, sourceAddress, amount, idempotencyKey);
    IERC20 erc20 = IERC20(fundsStorage.getToken());
    SafeERC20.safeTransferFrom(erc20, sourceAddress, destinationAddress, amount);
  }

  /// @inheritdoc IFundsAdmin
  function directSpendReverse(
    address storageAddress,
    bytes32 originalIdempotencyKey,
    uint256 amount,
    bytes32 idempotencyKey
  ) external onlyProxy onlyRole(SETTLER_ROLE) whenNotPaused {
    _requireDirectSpendEnabled();
    IFundsStorage fundsStorage = _requireFundsStorage(storageAddress);
    fundsStorage.directSpendReverse(originalIdempotencyKey, amount, idempotencyKey);
  }

  /**
   * @notice Verifies that the token is supported by the admin contract.
   *  To be able to support a token, it's settlement address needs to be set
   *  by {setSettlementAddress}
   * @param token The ERC-20 token to verify
   */
  function _requireTokenSupported(address token) internal view {
    if (_tokenSettlementAddress[token] == address(0)) revert TokenNotSupported({ token: token });
  }

  function _requireDirectSpendEnabled() internal view {
    if (!_directSpendEnabled) revert DirectSpendDisabled();
  }

  function _requireFundsStorage(address storageAddress) internal view returns (IFundsStorage) {
    if(!isFundsStorage(storageAddress)) revert StorageAccountInvalid(storageAddress);
    return IFundsStorage(storageAddress);
  }

  /// @inheritdoc IFundsAdmin
  function setSettlementAddress(address token, address settlementAddress) external onlyProxy onlyRole(DEFAULT_ADMIN_ROLE) {
    _tokenSettlementAddress[token] = settlementAddress;
  }

  /// @inheritdoc IFundsAdmin
  function getSettlementAddress(address token) external view returns(address) {
    return _tokenSettlementAddress[token];
  }

  /// @inheritdoc IFundsAdmin
  function transferDefaultAdminRole(address adminAccount) external onlyProxy onlyRole(DEFAULT_ADMIN_ROLE) {
    _grantRole(DEFAULT_ADMIN_ROLE, adminAccount);
    _revokeRole(DEFAULT_ADMIN_ROLE, msg.sender);
  }

  /**
   * @dev Prevents direct role assignment. Use specific grant functions instead
   */
  function grantRole(bytes32 /*role*/, address /*account*/) public pure override(AccessControlUpgradeable, IAccessControl) {
    revert OperationUnsupported();
  }

  /**
   * @dev Prevents direct role revocation. Use specific revoke functions instead
   */
  function revokeRole(bytes32 /*role*/, address /*account*/) public pure override(AccessControlUpgradeable, IAccessControl) {
    revert OperationUnsupported();
  }

  /// @inheritdoc IFundsAdmin
  function grantWithdrawalSignerRole(address withdrawalSigner) external onlyProxy onlyRole(DEFAULT_ADMIN_ROLE) {
    _grantRole(WITHDRAWAL_SIGNER_ROLE, withdrawalSigner);
  }

  /// @inheritdoc IFundsAdmin
  function revokeWithdrawalSignerRole(address withdrawalSigner) external onlyProxy onlyRole(DEFAULT_ADMIN_ROLE) {
    _revokeRole(WITHDRAWAL_SIGNER_ROLE, withdrawalSigner);
  }

  /// @inheritdoc IFundsAdmin
  function grantSettlerRole(address settlerAddress) external onlyProxy onlyRole(DEFAULT_ADMIN_ROLE) {
    _grantRole(SETTLER_ROLE, settlerAddress);
  }

  /// @inheritdoc IFundsAdmin
  function revokeSettlerRole(address settlerAddress) external onlyProxy onlyRole(DEFAULT_ADMIN_ROLE) {
    _revokeRole(SETTLER_ROLE, settlerAddress);
  }

  /// @inheritdoc IFundsAdmin
  // solhint-disable-next-line private-vars-leading-underscore
  function _requireWithdrawalSignerAuthorized(address signerAuthorizer) external onlyProxy view  whenNotPaused {
    if (!hasRole(WITHDRAWAL_SIGNER_ROLE, signerAuthorizer)) revert SignatureUnauthorized();
  }

  /// @inheritdoc IFundsAdmin
  // solhint-disable-next-line private-vars-leading-underscore
  function _requireMasterNotPaused() external onlyProxy view {
    _requireNotPaused(); // from PausableUpgradeable
  }

  /// @inheritdoc IFundsAdmin
  function pause() external onlyProxy onlyRole(DEFAULT_ADMIN_ROLE) {
    _pause();
  }

  /// @inheritdoc IFundsAdmin
  function unpause() external onlyProxy onlyRole(DEFAULT_ADMIN_ROLE) {
    _unpause();
  }

  /// @inheritdoc IFundsAdmin
  function enableDirectSpend() external onlyProxy onlyRole(DEFAULT_ADMIN_ROLE) {
    _directSpendEnabled = true;
  }

  /// @inheritdoc IFundsAdmin
  function disableDirectSpend() external onlyProxy onlyRole(DEFAULT_ADMIN_ROLE) {
    _directSpendEnabled = false;
  }

  function setDirectSpendReversalCutoffSeconds(uint256 expiry) external onlyProxy onlyRole(DEFAULT_ADMIN_ROLE) {
    if (expiry > 365 days) {
      // we don't allow expirations higher to a year to keep a low risk
      // of reversing already cleared operations
      revert OperationUnsupported();
    }
    _directSpendReversalCutoffSeconds = expiry;
  }

  function getDirectSpendReversalCutoffSeconds() external onlyProxy view returns(uint256) {
    return _directSpendReversalCutoffSeconds;
  }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.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:
 *
 * ```solidity
 * 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}:
 *
 * ```solidity
 * 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. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;


    /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
    struct AccessControlStorage {
        mapping(bytes32 role => RoleData) _roles;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;

    function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
        assembly {
            $.slot := AccessControlStorageLocation
        }
    }

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    function __AccessControl_init() internal onlyInitializing {
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    /**
     * @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 returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        return $._roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @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 returns (bytes32) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        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 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 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 `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

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

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        if (!hasRole(role, account)) {
            $._roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        if (hasRole(role, account)) {
            $._roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}

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

pragma solidity ^0.8.20;

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

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

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

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reininitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._initialized = 1;
        if (isTopLevelCall) {
            $._initializing = true;
        }
        _;
        if (isTopLevelCall) {
            $._initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._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() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

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

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

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        assembly {
            $.slot := INITIALIZABLE_STORAGE
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.20;

import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    address private immutable __self = address(this);

    /**
     * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
     * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
     * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
     * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
     * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
     * during an upgrade.
     */
    string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";

    /**
     * @dev The call is from an unauthorized context.
     */
    error UUPSUnauthorizedCallContext();

    /**
     * @dev The storage `slot` is unsupported as a UUID.
     */
    error UUPSUnsupportedProxiableUUID(bytes32 slot);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        _checkProxy();
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        _checkNotDelegated();
        _;
    }

    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * 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. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual notDelegated returns (bytes32) {
        return ERC1967Utils.IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data);
    }

    /**
     * @dev Reverts if the execution is not performed via delegatecall or the execution
     * context is not of a proxy with an ERC1967-compliant implementation pointing to self.
     * See {_onlyProxy}.
     */
    function _checkProxy() internal view virtual {
        if (
            address(this) == __self || // Must be called through delegatecall
            ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
        ) {
            revert UUPSUnauthorizedCallContext();
        }
    }

    /**
     * @dev Reverts if the execution is performed via delegatecall.
     * See {notDelegated}.
     */
    function _checkNotDelegated() internal view virtual {
        if (address(this) != __self) {
            // Must not be called through delegatecall
            revert UUPSUnauthorizedCallContext();
        }
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
     *
     * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
     * is expected to be the implementation slot in ERC1967.
     *
     * Emits an {IERC1967-Upgraded} event.
     */
    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
        try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
            if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
                revert UUPSUnsupportedProxiableUUID(slot);
            }
            ERC1967Utils.upgradeToAndCall(newImplementation, data);
        } catch {
            // The implementation is not UUPS
            revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
        }
    }
}

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

pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)

pragma solidity ^0.8.20;

import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {IERC5267} from "@openzeppelin/contracts/interfaces/IERC5267.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose
 * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract
 * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to
 * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
 * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the
 * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
 */
abstract contract EIP712Upgradeable is Initializable, IERC5267 {
    bytes32 private constant TYPE_HASH =
        keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    /// @custom:storage-location erc7201:openzeppelin.storage.EIP712
    struct EIP712Storage {
        /// @custom:oz-renamed-from _HASHED_NAME
        bytes32 _hashedName;
        /// @custom:oz-renamed-from _HASHED_VERSION
        bytes32 _hashedVersion;

        string _name;
        string _version;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.EIP712")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant EIP712StorageLocation = 0xa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100;

    function _getEIP712Storage() private pure returns (EIP712Storage storage $) {
        assembly {
            $.slot := EIP712StorageLocation
        }
    }

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    function __EIP712_init(string memory name, string memory version) internal onlyInitializing {
        __EIP712_init_unchained(name, version);
    }

    function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {
        EIP712Storage storage $ = _getEIP712Storage();
        $._name = name;
        $._version = version;

        // Reset prior values in storage if upgrading
        $._hashedName = 0;
        $._hashedVersion = 0;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        return _buildDomainSeparator();
    }

    function _buildDomainSeparator() private view returns (bytes32) {
        return keccak256(abi.encode(TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);
    }

    /**
     * @dev See {IERC-5267}.
     */
    function eip712Domain()
        public
        view
        virtual
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        )
    {
        EIP712Storage storage $ = _getEIP712Storage();
        // If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized
        // and the EIP712 domain is not reliable, as it will be missing name and version.
        require($._hashedName == 0 && $._hashedVersion == 0, "EIP712: Uninitialized");

        return (
            hex"0f", // 01111
            _EIP712Name(),
            _EIP712Version(),
            block.chainid,
            address(this),
            bytes32(0),
            new uint256[](0)
        );
    }

    /**
     * @dev The name parameter for the EIP712 domain.
     *
     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
     * are a concern.
     */
    function _EIP712Name() internal view virtual returns (string memory) {
        EIP712Storage storage $ = _getEIP712Storage();
        return $._name;
    }

    /**
     * @dev The version parameter for the EIP712 domain.
     *
     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
     * are a concern.
     */
    function _EIP712Version() internal view virtual returns (string memory) {
        EIP712Storage storage $ = _getEIP712Storage();
        return $._version;
    }

    /**
     * @dev The hash of the name parameter for the EIP712 domain.
     *
     * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead.
     */
    function _EIP712NameHash() internal view returns (bytes32) {
        EIP712Storage storage $ = _getEIP712Storage();
        string memory name = _EIP712Name();
        if (bytes(name).length > 0) {
            return keccak256(bytes(name));
        } else {
            // If the name is empty, the contract may have been upgraded without initializing the new storage.
            // We return the name hash in storage if non-zero, otherwise we assume the name is empty by design.
            bytes32 hashedName = $._hashedName;
            if (hashedName != 0) {
                return hashedName;
            } else {
                return keccak256("");
            }
        }
    }

    /**
     * @dev The hash of the version parameter for the EIP712 domain.
     *
     * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead.
     */
    function _EIP712VersionHash() internal view returns (bytes32) {
        EIP712Storage storage $ = _getEIP712Storage();
        string memory version = _EIP712Version();
        if (bytes(version).length > 0) {
            return keccak256(bytes(version));
        } else {
            // If the version is empty, the contract may have been upgraded without initializing the new storage.
            // We return the version hash in storage if non-zero, otherwise we assume the version is empty by design.
            bytes32 hashedVersion = $._hashedVersion;
            if (hashedVersion != 0) {
                return hashedVersion;
            } else {
                return keccak256("");
            }
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../proxy/utils/Initializable.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);
 * }
 * ```
 */
abstract contract ERC165Upgradeable is Initializable, IERC165 {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {
    /// @custom:storage-location erc7201:openzeppelin.storage.Pausable
    struct PausableStorage {
        bool _paused;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;

    function _getPausableStorage() private pure returns (PausableStorage storage $) {
        assembly {
            $.slot := PausableStorageLocation
        }
    }

    /**
     * @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);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        PausableStorage storage $ = _getPausableStorage();
        $._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) {
        PausableStorage storage $ = _getPausableStorage();
        return $._paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @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 ReentrancyGuardUpgradeable is Initializable {
    // 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;

    /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
    struct ReentrancyGuardStorage {
        uint256 _status;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;

    function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
        assembly {
            $.slot := ReentrancyGuardStorageLocation
        }
    }

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        $._status = NOT_ENTERED;
    }

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

    function _nonReentrantBefore() private {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if ($._status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        $._status = ENTERED;
    }

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @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.
     */
    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 `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

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

pragma solidity ^0.8.20;

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

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

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

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

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

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

File 12 of 36 : draft-IERC1822.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.20;

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

File 13 of 36 : IERC5267.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)

pragma solidity ^0.8.20;

interface IERC5267 {
    /**
     * @dev MAY be emitted to signal that the domain could have changed.
     */
    event EIP712DomainChanged();

    /**
     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
     * signature.
     */
    function eip712Domain()
        external
        view
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        );
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/BeaconProxy.sol)

pragma solidity ^0.8.20;

import {IBeacon} from "./IBeacon.sol";
import {Proxy} from "../Proxy.sol";
import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol";

/**
 * @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.
 *
 * The beacon address can only be set once during construction, and cannot be changed afterwards. It is stored in an
 * immutable variable to avoid unnecessary storage reads, and also in the beacon storage slot specified by
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] so that it can be accessed externally.
 *
 * CAUTION: Since the beacon address can never be changed, you must ensure that you either control the beacon, or trust
 * the beacon to not upgrade the implementation maliciously.
 *
 * IMPORTANT: Do not use the implementation logic to modify the beacon storage slot. Doing so would leave the proxy in
 * an inconsistent state where the beacon storage slot does not match the beacon address.
 */
contract BeaconProxy is Proxy {
    // An immutable address for the beacon to avoid unnecessary SLOADs before each delegate call.
    address private immutable _beacon;

    /**
     * @dev Initializes the proxy with `beacon`.
     *
     * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This
     * will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity
     * constructor.
     *
     * Requirements:
     *
     * - `beacon` must be a contract with the interface {IBeacon}.
     * - If `data` is empty, `msg.value` must be zero.
     */
    constructor(address beacon, bytes memory data) payable {
        ERC1967Utils.upgradeBeaconToAndCall(beacon, data);
        _beacon = beacon;
    }

    /**
     * @dev Returns the current implementation address of the associated beacon.
     */
    function _implementation() internal view virtual override returns (address) {
        return IBeacon(_getBeacon()).implementation();
    }

    /**
     * @dev Returns the beacon.
     */
    function _getBeacon() internal view virtual returns (address) {
        return _beacon;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.20;

/**
 * @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.
     *
     * {UpgradeableBeacon} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/UpgradeableBeacon.sol)

pragma solidity ^0.8.20;

import {IBeacon} from "./IBeacon.sol";
import {Ownable} from "../../access/Ownable.sol";

/**
 * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their
 * implementation contract, which is where they will delegate all function calls.
 *
 * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.
 */
contract UpgradeableBeacon is IBeacon, Ownable {
    address private _implementation;

    /**
     * @dev The `implementation` of the beacon is invalid.
     */
    error BeaconInvalidImplementation(address implementation);

    /**
     * @dev Emitted when the implementation returned by the beacon is changed.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Sets the address of the initial implementation, and the initial owner who can upgrade the beacon.
     */
    constructor(address implementation_, address initialOwner) Ownable(initialOwner) {
        _setImplementation(implementation_);
    }

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

    /**
     * @dev Upgrades the beacon to a new implementation.
     *
     * Emits an {Upgraded} event.
     *
     * Requirements:
     *
     * - msg.sender must be the owner of the contract.
     * - `newImplementation` must be a contract.
     */
    function upgradeTo(address newImplementation) public virtual onlyOwner {
        _setImplementation(newImplementation);
    }

    /**
     * @dev Sets the implementation contract address for this beacon
     *
     * Requirements:
     *
     * - `newImplementation` must be a contract.
     */
    function _setImplementation(address newImplementation) private {
        if (newImplementation.code.length == 0) {
            revert BeaconInvalidImplementation(newImplementation);
        }
        _implementation = newImplementation;
        emit Upgraded(newImplementation);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Proxy.sol)

pragma solidity ^0.8.20;

import {Proxy} from "../Proxy.sol";
import {ERC1967Utils} from "./ERC1967Utils.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 {
    /**
     * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation`.
     *
     * If `_data` is nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
     * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
     *
     * Requirements:
     *
     * - If `data` is empty, `msg.value` must be zero.
     */
    constructor(address implementation, bytes memory _data) payable {
        ERC1967Utils.upgradeToAndCall(implementation, _data);
    }

    /**
     * @dev Returns the current implementation address.
     *
     * 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() internal view virtual override returns (address) {
        return ERC1967Utils.getImplementation();
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)

pragma solidity ^0.8.20;

import {IBeacon} from "../beacon/IBeacon.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 */
library ERC1967Utils {
    // We re-declare ERC-1967 events here because they can't be used directly from IERC1967.
    // This will be fixed in Solidity 0.8.21. At that point we should remove these events.
    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

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

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

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev The `implementation` of the proxy is invalid.
     */
    error ERC1967InvalidImplementation(address implementation);

    /**
     * @dev The `admin` of the proxy is invalid.
     */
    error ERC1967InvalidAdmin(address admin);

    /**
     * @dev The `beacon` of the proxy is invalid.
     */
    error ERC1967InvalidBeacon(address beacon);

    /**
     * @dev An upgrade function sees `msg.value > 0` that may be lost.
     */
    error ERC1967NonPayable();

    /**
     * @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 {
        if (newImplementation.code.length == 0) {
            revert ERC1967InvalidImplementation(newImplementation);
        }
        StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Performs implementation upgrade with additional setup call if data is nonempty.
     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
     * to avoid stuck value in the contract.
     *
     * Emits an {IERC1967-Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);

        if (data.length > 0) {
            Address.functionDelegateCall(newImplementation, data);
        } else {
            _checkNonPayable();
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Returns the current admin.
     *
     * 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 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 {
        if (newAdmin == address(0)) {
            revert ERC1967InvalidAdmin(address(0));
        }
        StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {IERC1967-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 the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @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 {
        if (newBeacon.code.length == 0) {
            revert ERC1967InvalidBeacon(newBeacon);
        }

        StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;

        address beaconImplementation = IBeacon(newBeacon).implementation();
        if (beaconImplementation.code.length == 0) {
            revert ERC1967InvalidImplementation(beaconImplementation);
        }
    }

    /**
     * @dev Change the beacon and trigger a setup call if data is nonempty.
     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
     * to avoid stuck value in the contract.
     *
     * Emits an {IERC1967-BeaconUpgraded} event.
     *
     * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
     * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
     * efficiency.
     */
    function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);

        if (data.length > 0) {
            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
        } else {
            _checkNonPayable();
        }
    }

    /**
     * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
     * if an upgrade doesn't perform an initialization call.
     */
    function _checkNonPayable() private {
        if (msg.value > 0) {
            revert ERC1967NonPayable();
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/Proxy.sol)

pragma solidity ^0.8.20;

/**
 * @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 {
        _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();
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

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

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

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

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}

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

pragma solidity ^0.8.20;

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

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

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

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

pragma solidity ^0.8.20;

/**
 * @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
    }

    /**
     * @dev The signature derives the `address(0)`.
     */
    error ECDSAInvalidSignature();

    /**
     * @dev The signature has an invalid length.
     */
    error ECDSAInvalidSignatureLength(uint256 length);

    /**
     * @dev The signature has an S value that is in the upper half order.
     */
    error ECDSAInvalidSignatureS(bytes32 s);

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
     * return address(0) without also returning an error description. Errors are documented using an enum (error type)
     * and a bytes32 providing additional information about the error.
     *
     * If no error is returned, then the address can be used for verification purposes.
     *
     * The `ecrecover` EVM precompile 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 {MessageHashUtils-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]
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {
        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, bytes32(signature.length));
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM precompile 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 {MessageHashUtils-toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
        _throwError(error, errorArg);
        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]
     */
    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {
        unchecked {
            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
            // We do not check for an overflow here since the shift operation results in 0 or 1.
            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.
     */
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError, bytes32) {
        // 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, s);
        }

        // 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, bytes32(0));
        }

        return (signer, RecoverError.NoError, bytes32(0));
    }

    /**
     * @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, bytes32 errorArg) = tryRecover(hash, v, r, s);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
     */
    function _throwError(RecoverError error, bytes32 errorArg) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert ECDSAInvalidSignature();
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert ECDSAInvalidSignatureLength(uint256(errorArg));
        } else if (error == RecoverError.InvalidSignatureS) {
            revert ECDSAInvalidSignatureS(errorArg);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)

pragma solidity ^0.8.20;

import {Strings} from "../Strings.sol";

/**
 * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
 *
 * The library provides methods for generating a hash of a message that conforms to the
 * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
 * specifications.
 */
library MessageHashUtils {
    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing a bytes32 `messageHash` with
     * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
     * keccak256, although any bytes32 value can be safely used because the final digest will
     * be re-hashed.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
            mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
            digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
        }
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing an arbitrary `message` with
     * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
        return
            keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x00` (data with intended validator).
     *
     * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
     * `validator` address. Then hashing the result.
     *
     * See {ECDSA-recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked(hex"19_00", validator, data));
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).
     *
     * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
     * `\x19\x01` and hashing the result. It corresponds to the hash signed by the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
     *
     * See {ECDSA-recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, hex"19_01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            digest := keccak256(ptr, 0x42)
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

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

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

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

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

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

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

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

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

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

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

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

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

pragma solidity ^0.8.20;

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

/**
 * @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:
 * ```solidity
 * 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(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes 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
        }
    }

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

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

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

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

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

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";

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

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

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

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

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

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        uint256 localValue = value;
        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_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        return string(buffer);
    }

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

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

// SPDX-License-Identifier: UNLICENSED
// Copyright 2023 Immersve

pragma solidity ^0.8.28;

import { IFundsStorage } from "./interfaces/IFundsStorage.sol";
import { IFundsAdmin } from "./interfaces/IFundsAdmin.sol";
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import { EIP712Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract FundsStorageLogic is IFundsStorage, ReentrancyGuardUpgradeable, EIP712Upgradeable {

  /**
    * The FundsAdmin proxy which provides configurations for any FundsStorage
    * operations.
    */
  IFundsAdmin internal _fundsAdmin;

  /**
    * The user-supplied name of the FundsStorage, useful for aiding with
    * auditing deployed contracts.
    */
  string internal _name;

  /**
    * The token supported by this FundsStorage. Token transfers into this
    * contract which are not from this token are not able to be withdrawn and
    * will be trapped forever.
    */
  IERC20 internal _token;

  /**
    * Mapping of depositor address to withdrawal nonce.
    */
  mapping(address => uint256) internal _usedNonces;

  /**
   * @dev Keep track of already used idempotency keys for debit and refund operations
   */
  mapping(bytes32 => DirectSpendTransaction) internal _directSpendTransactions;

  FundingMode internal _fundingMode;

  /**
    * @dev This initializer will be invoked once for each BeaconProxy created by
    *   the FundsStorageFactory.
    * @param adminAddress The address of the FundsAdmin which supplies
    *   configurations to this FundsStorage.
    * @param token The ERC-20 token to be supported by this funds storage.
    * @param name The name of the funds storage.
    */
  function initialize(address adminAddress, address token, string calldata name, FundingMode fundingMode) public initializer {
    _fundsAdmin = IFundsAdmin(adminAddress);
    _token = IERC20(token);
    _name = name;
    _fundingMode = fundingMode;
    /*
     * Initialize the EIP-712 domain separator used when verifying withdraw signatures.
     */
    __EIP712_init("Immersve.FundsStorageLogic", "1");
    __ReentrancyGuard_init();
  }

  /// @inheritdoc IFundsStorage
  function getName() external view returns(string memory name) {
    return _name;
  }

  /// @inheritdoc IFundsStorage
  function getToken() external view returns(address) {
    return address(_token);
  }

  /// @inheritdoc IFundsStorage
  function getWithdrawalNonce(address depositor) public view returns(uint256) {
    return _usedNonces[depositor];
  }

  /// @inheritdoc IFundsStorage
  function getFundingMode() external view returns(FundingMode) {
    return _fundingMode;
  }

  /// @inheritdoc IFundsStorage
  function withdraw(
      uint256 amount,
      uint256 expiryDate,
      uint256 nonce,
      bytes memory _signature
  ) external nonReentrant {
      _requireMasterNotPaused();
      _requireFundingMode(FundingMode.DEPOSIT);
      if(block.timestamp > expiryDate) revert ExpiryDatePassed();
      // check if the funds were already withdrawn with this nonce
      if(nonce != _usedNonces[msg.sender] + 1) revert NonceOutOfSequence();
      bytes32 digest = _hashTypedDataV4(
          keccak256(abi.encode(keccak256("WithdrawalIntent(address depositorAddress,uint256 amount,uint256 expiryDate,uint256 nonce)"), msg.sender, amount, expiryDate, nonce))
      );
      _verifySignature(digest, _signature);
      _usedNonces[msg.sender] = nonce;
      if (amount > 0) {
        SafeERC20.safeTransfer(_token, msg.sender, amount);
      }
      emit Withdrawal(msg.sender, amount, expiryDate, nonce, WithdrawalType.ONLINE_SIGNATURE);
  }

  /**
   * @dev Verify that the hash has been signed by an account with WITHDRAWAL_AUTHORIZER role
   **/
  function _verifySignature(bytes32 digest, bytes memory signature) internal view {
      address signer = ECDSA.recover(digest, signature);
      _fundsAdmin._requireWithdrawalSignerAuthorized(signer);
  }

  /// @inheritdoc IFundsStorage
  function transferToSettlementAddress(uint256 amount) external {
    _requireMasterNotPaused();
    _requireFundsAdmin(msg.sender);
    address settlementAddress = _fundsAdmin.getSettlementAddress(address(_token));
    if(settlementAddress == address(0)) revert TokenNotSupported({ token: address(_token) });
    SafeERC20.safeTransfer(_token, settlementAddress, amount);
  }

  /// @inheritdoc IFundsStorage
  function directSpendDebit(address spender, uint256 amount, bytes32 idempotencyKey) external {
    _requireMasterNotPaused();
    _requireFundingMode(FundingMode.APPROVAL);
    _requireFundsAdmin(msg.sender);
    _requireUniqueDirectSpendIdempotencyKey(idempotencyKey);
    SafeERC20.safeTransferFrom(_token, spender, address(this), amount);
    _directSpendTransactions[idempotencyKey] = DirectSpendTransaction(
      amount,
      block.timestamp,
      spender,
      DirectSpendOperationType.DEBIT, // operation
      true, // exists?
      0
    );
    emit DirectSpendDebit(spender, amount, idempotencyKey);
  }

  /// @inheritdoc IFundsStorage
  function directSpendGetTransaction(bytes32 idempotencyKey) external view returns(DirectSpendTransaction memory) {
    return _directSpendTransactions[idempotencyKey];
  }

  /// @inheritdoc IFundsStorage
  function directSpendRefund(
    address destinationAddress,
    address sourceAddress,
    uint256 amount,
    bytes32 idempotencyKey
  ) external {
    _requireMasterNotPaused();
    _requireFundingMode(FundingMode.APPROVAL);
    _requireFundsAdmin(msg.sender);
    _requireUniqueDirectSpendIdempotencyKey(idempotencyKey);
    _directSpendTransactions[idempotencyKey] = DirectSpendTransaction(
      amount,
      block.timestamp,
      destinationAddress,
      DirectSpendOperationType.REFUND, // operation
      true, // exists?
      0
    );
    emit DirectSpendRefund(destinationAddress, sourceAddress, amount, idempotencyKey);
  }

  /// @inheritdoc IFundsStorage
  function directSpendReverse(
    bytes32 originalIdempotencyKey,
    uint256 amount,
    bytes32 idempotencyKey
  ) external {
    _requireMasterNotPaused();
    _requireFundingMode(FundingMode.APPROVAL);
    _requireFundsAdmin(msg.sender);
    _requireUniqueDirectSpendIdempotencyKey(idempotencyKey);
    DirectSpendTransaction memory directSpendTransaction = _directSpendTransactions[originalIdempotencyKey];
    if(!directSpendTransaction.exists) revert DirectSpendTransactionNotFound();
    if(directSpendTransaction.operationType != DirectSpendOperationType.DEBIT) revert OperationUnsupported();
    _requireUnexpiredDirectSpendTransaction(directSpendTransaction);
    uint256 availableReversalAmount = directSpendTransaction.amount - directSpendTransaction.reversedAmount;
    if(amount > availableReversalAmount) revert DirectSpendReversalInsufficientFunds();
    address destinationAddress = directSpendTransaction.fundingAddress;
    SafeERC20.safeTransfer(_token, destinationAddress, amount);
    _directSpendTransactions[originalIdempotencyKey].reversedAmount = directSpendTransaction.reversedAmount + amount;
    _directSpendTransactions[idempotencyKey] = DirectSpendTransaction(
      amount,
      block.timestamp,
      destinationAddress,
      DirectSpendOperationType.REVERSAL, // operation
      true, // exists?
      amount
    );
    emit DirectSpendReversal(originalIdempotencyKey, destinationAddress, amount, idempotencyKey);
  }

  /// @inheritdoc IFundsStorage
  function addStorageLiquidity(
    address sourceAddress,
    uint256 amount
  ) external {
    _requireMasterNotPaused();
    _requireFundsAdmin(msg.sender);
    IERC20 token = IERC20(_token);
    SafeERC20.safeTransferFrom(token, sourceAddress, address(this), amount);
  }

  function _requireFundingMode(FundingMode expectedFundingMode) internal view {
    FundingMode currentFundingMode = _fundingMode;
    if(currentFundingMode != expectedFundingMode) revert FundingModeInvalid(currentFundingMode, expectedFundingMode);
  }

  function _requireFundsAdmin(address sender) internal view {
    if(address(_fundsAdmin) != sender) revert SenderAccountNotAuthorized(sender);
  }

  function _requireUniqueDirectSpendIdempotencyKey(bytes32 idempotencyKey) internal view {
    DirectSpendTransaction memory directSpendTransaction = _directSpendTransactions[idempotencyKey];
    if(directSpendTransaction.exists) revert IdempotencyKeyAlreadyUsed();
  }

  function _requireUnexpiredDirectSpendTransaction(DirectSpendTransaction memory transaction) internal {
    uint256 transactionExpiryDate = transaction.timestamp + _fundsAdmin.getDirectSpendReversalCutoffSeconds();
    if(block.timestamp > transactionExpiryDate) revert DirectSpendTransactionExpired();
  }

  function _requireMasterNotPaused() internal view {
    _fundsAdmin._requireMasterNotPaused();
  }
}

File 33 of 36 : IErrors.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright 2023 Immersve

pragma solidity ^0.8.28;

import { ITypes } from "./ITypes.sol";

interface IErrors is ITypes {

  /**
   * @notice Operation needs to be processed in a specific order.
   * Nonce makes sure that the order is correct. Otherwise the
   * nonce is out of sequence and there is a problem with the order
   * of this operation
   */
  error NonceOutOfSequence();

  /**
   * @notice In order to execute this operation, a specific signature
   * is required, and the provided signature is not valid
   */
  error SignatureUnauthorized();

  /**
   * @notice Provided Merkle Root has an invalid value or format
   */
  error MerkleRootInvalid();

  /**
   * @notice Tokens are enabled at the FundsManagerLogic level.
   * Operations trying to use unsupported tokens will fail unless
   * token is manually enabled for support
   */
  error TokenNotSupported(address token);

  /**
   * @notice Operations requires to be ran before the expiry date
   */
  error ExpiryDatePassed();

  /**
   * @notice The sender of the transaction is not authorized
   * to perform this action
   */
  error SenderAccountNotAuthorized(address account);

  /**
   * @notice The provided account address is not an Storage contract
   */
  error StorageAccountInvalid(address source);

  /**
   * @notice The executed operation is not supported by this version
   * of the protocol
   */
  error OperationUnsupported();

  /**
   * @notice Operations are idempotent. If the key is already used it
   * means that the operation was already executed
   */
  error IdempotencyKeyAlreadyUsed();

  /**
   * @notice There is no record of a DirectSpendTransaction for the
   * provided params
   */
  error DirectSpendTransactionNotFound();

  /**
   * @notice Direct Spend is disabled at the FundsManagerLogic level.
   * This feature is disabled by default and must be manually enabled.
   * Direct spend feature should only be enabled for fast EVM chains
   * like ARB or BASE
   */
  error DirectSpendDisabled();

  /**
   * @notice Reversal operation failed because there is not enough
   * liquidity on the storage contract
   */
  error DirectSpendReversalInsufficientFunds();

  /**
   * @notice The Direct Spend Transaction is already expired
   */
  error DirectSpendTransactionExpired();
  /**
   * @notice Operation requires a specific FundingMode. Storage instance
   * funding mode differs from the expected mode for the current operation
   */
  error FundingModeInvalid(FundingMode current, FundingMode expected);
}

// SPDX-License-Identifier: UNLICENSED
// Copyright 2023 Immersve

pragma solidity ^0.8.28;

import { IErrors } from "./IErrors.sol";
import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol";

/**
  * @notice Administrative management for funds storage.
  */
interface IFundsAdmin is IErrors, IAccessControl {

  /**
    * Role for authorizing withdrawal signatures.
    */
  //solhint-disable-next-line func-name-mixedcase
  function WITHDRAWAL_SIGNER_ROLE() external pure returns(bytes32);

  /**
    * Role for authorizing settlement and refund.
    */
  //solhint-disable-next-line func-name-mixedcase
  function SETTLER_ROLE() external pure returns(bytes32);

  /**
    * @notice Event logged when a settlement is executed.
    * @param from The address of the FundsStorage that is settling.
    * @param amount The amount being settled.
    * @param nonce The settlement nonce.
    */
  event Settlement(address from, uint256 amount, uint256 nonce);

  /**
    * @notice Event logged when a refund is executed.
    * @param refundee The address of the FundsStorage receiving the refund.
    * @param sourceAddress The address of the FundsStorage receiving the refund.
    * @param amount The amount being refunded.
    * @param nonce The settlement nonce.
    */
  event StorageLiquidityAdded(address refundee, address sourceAddress, uint256 amount, uint256 nonce);

  /**
    * @notice Event logged when a new FundsStorage is created.
    * @param token The token used by the FundsStorage.
    * @param addr The address of the created FundsStorage.
    * @param name The name of the created FundsStorage.
    */
  event FundsStorageCreated(address token, address addr, string name);

  /**
    * @notice Get the deployed factory logic version.
    */
  function getVersion() external pure returns(uint256);

  /**
    * @notice Get the deployed factory commit id.
    */
  function getCommitId() external view returns(string memory);

  /**
    * @notice Get the deployed factory build number.
    */
  function getBuildNumber() external view returns(string memory);

  /**
    * @notice Get the address of the beacon used for FundsStorage instances
    * created by this factory.
    */
  function getStorageBeaconAddress() external view returns(address);

  /**
    * @notice Get the address of the FundsAdmin used to configure FundsStorage
  * instances created by this factory.
    */
  function getMasterAddress() external view returns(address);

  /**
   * @notice Create a new FundsStorage. The address of the deployed contract is
   *   determined by the sender address and the name. Deployment will fail if the
   *   a name has already been used from the same message sender.
   * @param token The token supported by the funds storage.
   * @param name The name of the funds storage.
   */
  function createFundsStorage(address token, string calldata name, FundingMode fundingMode) external returns(address);

  /**
    * @notice Check if an address is for a FundsStorage created by this factory.
    * @param addr the address to check.
    */
  function isFundsStorage(address addr) external view returns(bool);

  /**
    * @notice Get the current withdrawal nonce for a FundsStorage. The next
    *   settlement or refund transaction for the FundsStorage must be one more
    *   than this value.
    * @param fundsStorage A FundsStorage address.
    */
  function getSettlementNonce(address fundsStorage) external view returns(uint256);

  /**
    * @notice Settle cleared funds by triggering a token transfer. Only the
    *   settler role can settle.
    * @param from The FundsStorage address to settle from.
    * @param amount The amount to settle.
    * @param nonce The Funds Storage's settlement nonce. The settlement nonce
    *   must be one more than the Funds Storage's current settlement nonce.
    */
  function settle(
    address from,
    uint256 amount,
    uint256 nonce,
    bytes32 merkleRoot
  ) external;

  /**
    * @notice Add storage liquidity to a FundsStorage address. A token tranfer
    *   will be issued from the sourceAddress. Only the settler
    *   role can do this.
    * @param refundee The FundsStorage address to refund to
    * @param sourceAddress The source of funds for the liquidity addition
    * @param amount The liquidity amount to add.
    * @param nonce The settlement nonce. The settlement nonce must be one more than
    *   the Funds Storage's current settlement nonce.
    */
  function addStorageLiquidity(
    address refundee,
    address sourceAddress,
    uint256 amount,
    uint256 nonce,
    bytes32 merkleRoot
  ) external;

  /**
   * @notice Trigger a debit function call to the FundsStorage contract.
   * Storage contract will check for available balance and allowance to try
   * or reject the actual transfer
   *
   * @param storageAddress The Funds Storage address
   * @param spender The account spending assets with Immersve
   * @param amount The amount being spent by the spender
   * @param idempotencyKey An idempotent key to avoid doing the same operation twice
   */
  function directSpendDebit(
    address storageAddress,
    address spender,
    uint256 amount,
    bytes32 idempotencyKey
  ) external;

  /**
   * @notice Trigger a directSpendRefund function call to the FundsStorage contract.
   * Storage contract will trigger an erc-20 transfer from the source address into
   * the destinationAddress
   *
   * @param storageAddress The Funds Storage address
   * @param destinationAddress The account receiving the refund
   * @param sourceAddress The account providing liquidity for the refund
   * @param amount The amount being spent by the spender
   * @param idempotencyKey An idempotent key to avoid doing the same operation twice
   */
  function directSpendRefund(
    address storageAddress,
    address destinationAddress,
    address sourceAddress,
    uint256 amount,
    bytes32 idempotencyKey
  ) external;

  /**
   * @notice Trigger a directSpendReverse function call to the FundsStorage contract.
   * Executes a payment reversal. Reversals are always linked to existing payments
   * and cannot be higher than the original amount
   *
   * @param storageAddress The Funds Storage address
   * @param originalIdempotencyKey The idempotency key of the original direct spend transaction
   * @param amount The amount being reversed to the destination address
   * @param idempotencyKey An idempotent key to avoid doing the same operation twice
   */
  function directSpendReverse(
    address storageAddress,
    bytes32 originalIdempotencyKey,
    uint256 amount,
    bytes32 idempotencyKey
  ) external;

  /**
   * @notice Retrieves a direct spend transaction from a storage
   * contract by it's idempotency key
   *
   * @param storageAddress The Partner FundsStorage contract address
   * @param idempotencyKey The unique idempotency key
   */
  function directSpendGetTransaction(
    address storageAddress,
    bytes32 idempotencyKey
  ) external view returns(DirectSpendTransaction memory);

  /**
    * @notice Update settlement addresses to include the given settlementAddress.
    * @param token The token address to configure.
    * @param settlementAddress The settlement address to allow. Setting settlementAddress
    *    to zero means that the token is not supported anymore.
    */
  function setSettlementAddress(address token, address settlementAddress) external;

  /**
    * @notice Get the settlement address for the specified token.
    * @param token The token for which to get the settlement address.
    */
  function getSettlementAddress(address token) external view returns(address);

  /**
    * @notice Transfer the DEFAULT_ADMIN_ROLE to a new account/
    * @param adminAccount The new account that can invoke all admin functions.
    */
  function transferDefaultAdminRole(address adminAccount) external;
  /**
    * @notice Grant the WITHDRAWAL_SIGNER_ROLE.
    * @param withdrawalSigner The address that can authorize withdrawals.
    */
  function grantWithdrawalSignerRole(address withdrawalSigner) external;

  /**
    * @notice Revoke the WITHDRAWAL_SIGNER_ROLE.
    * @param withdrawalSigner The address that can authorize withdrawals.
    */
  function revokeWithdrawalSignerRole(address withdrawalSigner) external;

  /**
    * @notice Grant the SETTLER_ROLE.
    * @param settlerAddress The address that can perform settle and refund.
    */
  function grantSettlerRole(address settlerAddress) external;

  /**
    * @notice Revoke the SETTLER_ROLE.
    * @param settlerAddress The address that can perform settle and refund.
    */
  function revokeSettlerRole(address settlerAddress) external;

  /**
    * @notice Check if the provided address is authorized to do withdrawals
    * @param signerAuthorizer The address to verify.
    */
  // solhint-disable-next-line private-vars-leading-underscore
  function _requireWithdrawalSignerAuthorized(address signerAuthorizer) external view;

  /**
   * @notice Requires master contract to be unpaused. Otherwise, an error is thrown
   */
  // solhint-disable-next-line private-vars-leading-underscore
  function _requireMasterNotPaused() external view;
  /**
   * @notice Pause all token transfer operations
   */
  function pause() external;

  /**
   * @notice Resume all token transfer operations
   */
  function unpause() external;

  /**
   * @notice Enables direct spend funding mode
   */
  function enableDirectSpend() external;

  /**
   * @notice Disable direct spend funding mode
   */
  function disableDirectSpend() external;

  function setDirectSpendReversalCutoffSeconds(uint256 expiry) external;

  function getDirectSpendReversalCutoffSeconds() external returns(uint256);
}

// SPDX-License-Identifier: UNLICENSED
// Copyright 2023 Immersve

pragma solidity ^0.8.28;

import { IErrors } from "./IErrors.sol";

/**
  * @notice Holder of deposits for an Immersve Funding Channel. Deposits are
  *   made via ERC-20 transfer. Withdrawals are made by getting a signed message
  *   from Immersve Funding Source APIs. To guarantee correct deposit addresses are
  *   used, the Immersve Funding Source APIs can be used to generate the required
  *   deposit transaction parameters.
  *   Approvals are made via ERC-20 approval transactions.
  */
interface IFundsStorage is IErrors {

  /**
    * Type indicator for a withdrawal event.
    */
  enum WithdrawalType{ ONLINE_SIGNATURE, MERKLE_PROOF }

  /**
    * @notice Event logged when a withdrawal is executed.
    * @param depositor The address of the depositor that is withdrawing.
    * @param amount The amount withdrawn.
    * @param expiryDate The withdrawal expiry timestamp.
    * @param nonce The withdrawal nonce.
    * @param withdrawalType The WithdrawalType that was performed.
    */
  event Withdrawal(address depositor, uint256 amount, uint256 expiryDate, uint256 nonce, WithdrawalType withdrawalType);

  /**
   * @notice Event logged when a direct spend debit operation is executed.
   *    This will be called when funding source associated to the funding address
   *    is authorized to spend with an associated Immersve card.
   *
   * @param fundingAddress The address to take funds from
   * @param amount The amount being debited from the funding address
   * @param idempotencyKey A unique key to make operation idempotent
   */
  event DirectSpendDebit(address fundingAddress, uint256 amount, bytes32 idempotencyKey);

  /**
   * @notice Event logged when a direct spend refund operation is executed.
   *    This will be called when a payment is refunded by the card network
   *
   * @param fundingAddress The address to transfer the refund to
   * @param sourceAddress The address of the refund pool
   * @param amount The amount being refunded to the funding address
   * @param idempotencyKey A unique key to make operation idempotent
   */
  event DirectSpendRefund(address fundingAddress, address sourceAddress, uint256 amount, bytes32 idempotencyKey);

  /**
   * @notice Event logged when a direct spend reversal operation is executed.
   *    This will be called when a payment is reversed by the card network
   *
   * @param originalIdempotencyKey The idempotency key of the original direct spend transaction
   * @param fundingAddress The address to transfer the reversal to
   * @param amount The amount being reversed to the funding address
   * @param idempotencyKey A unique key to make operation idempotent
   */
  event DirectSpendReversal(bytes32 originalIdempotencyKey, address fundingAddress, uint256 amount, bytes32 idempotencyKey);

  /**
    * @notice Get the name of the funds storage.
    */
  function getName() external view returns(string memory name);

  /**
    * @notice Get the token supported by the funds storage. The supported token
    *   is defined when the FundsStorage is deployed and cannot change. Token
    *   deposits into a FundsStorage from other tokens cannot be withdrawn and will
    *   be stuck forever.
    */
  function getToken() external view returns(address);

  /**
    * @notice Get the current withdrawal nonce for a depositor. The next
    *   withdrawal transaction must be one more that this value.
    * @param depositor The depositor address.
    */
  function getWithdrawalNonce(address depositor) external view returns(uint256);

  /**
    * @notice Withdraw funds using a signed withdrawal approval. The withdrawal
    *   approval is issued by Immersve Funding Source APIs. The message sender
    *   must be the same address connected to the Immersve Funding Source which
    *   the signed withdrawal approval relates to. A zero-amount withdrawal may
    *   be used to invalidate signed withdrawal approvals without triggering a
    *   token transfer.
    * @param amount The amount being withdrawn.
    * @param expiryDate The timestamp when the signature expires.
    * @param nonce The withdrawal nonce. The withdrawal nonce must be one more
    *   than the the depositor's current withdrawal nonce.
    * @param signature The signed withdrawal appoval.
    */
  function withdraw(
    uint256 amount,
    uint256 expiryDate,
    uint256 nonce,
    bytes memory signature
  ) external;

  /**
    * @notice Perform a settlement transfer. Settlement can only be initiated
    *   by the FundsAdmin contract.
    * @param amount The amount being settled.
    */
  function transferToSettlementAddress(uint256 amount) external;

  /**
   * @notice Perform a debit directly from the spender wallet. Wallet must have
   * granted the approval amount beforehand to the FundsStorage address
   *
   * @param spender The account spending assets with Immersve
   * @param amount The amount being spent by the spender
   * @param idempotencyKey An idempotent key to avoid doing the same operation twice
   */
  function directSpendDebit(address spender, uint256 amount, bytes32 idempotencyKey) external;

  /**
   * @notice Retrieves a direct spend transaction from it's idempotency key
   * @param idempotencyKey The idempotency key of an existing transaction
   */
  function directSpendGetTransaction(bytes32 idempotencyKey) external view returns(DirectSpendTransaction memory);

  /**
   * @notice Storage contract will trigger an erc-20 transfer from the source address into
   * the refundAddress
   *
   * @param destinationAddress The account receiving the refund
   * @param sourceAddress The account providing liquidity for the refund
   * @param amount The amount being refund to the destination address
   * @param idempotencyKey An idempotent key to avoid doing the same operation twice
   */
  function directSpendRefund(
    address destinationAddress,
    address sourceAddress,
    uint256 amount,
    bytes32 idempotencyKey
  ) external;

  /**
   * @notice Executes a payment reversal. Reversals are always linked to
   * existing payments and cannot be higher than the original amount
   *
   * @param originalIdempotencyKey The idempotency key of the original direct spend transaction
   * @param amount The amount being reversed to the destination address
   * @param idempotencyKey An idempotent key to avoid doing the same operation twice
   */
  function directSpendReverse(
    bytes32 originalIdempotencyKey,
    uint256 amount,
    bytes32 idempotencyKey
  ) external;

  /**
   * @notice Executes a transfer from the sourceAddress into the storage address
   * to add liquidity for reversal operations and withdrawals
   *
   * @param sourceAddress The origin of funds to add liquidity from
   * @param amount The amount of funds being added to the storage contract
   */
  function addStorageLiquidity(
    address sourceAddress,
    uint256 amount
  ) external;

  /**
   * @notice Gets the FundingMode configured for the FundsStorage instance
   */
  function getFundingMode() external view returns(FundingMode);
}

File 36 of 36 : ITypes.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright 2025 Immersve

pragma solidity ^0.8.28;


/**
 * @notice Interface containing common direct spend types
 */
interface ITypes {

  /**
   * @notice Direct Spend operation
   * - DEBIT: Transfer assets from funding address into storage contract
   * - REFUND: Transfer assets from refund pool into funding address
   * - REVERSAL: Transfer assets from storage contract into funding address
   */
  enum DirectSpendOperationType{ DEBIT, REFUND, REVERSAL }

  /**
   * @notice Funding Mode
   * - DEPOSIT: Funding address is required to do a deposit on the storage
   * contract via ERC-20 transfer. Balance, debits and refunds are kept
   * fully off-chain.
   * - APPROVAL: Funding address is required to approve ERC-20 approval to
   * the storage contract. Debits are executed during payments and refunds
   * are executed when funds become available in the refund pool
   *
   * See: https://docs.immersve.com/guides/funding-protocols/#protocol-variants
   */
  enum FundingMode{ DEPOSIT, APPROVAL }

  /** @dev The details of a Direct Spend transaction */
  struct DirectSpendTransaction {
    uint256 amount;
    uint256 timestamp; // epoch
    address fundingAddress;
    DirectSpendOperationType operationType;
    bool exists;
    uint256 reversedAmount;
  }
}

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

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"DirectSpendDisabled","type":"error"},{"inputs":[],"name":"DirectSpendReversalInsufficientFunds","type":"error"},{"inputs":[],"name":"DirectSpendTransactionExpired","type":"error"},{"inputs":[],"name":"DirectSpendTransactionNotFound","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"ExpiryDatePassed","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"enum ITypes.FundingMode","name":"current","type":"uint8"},{"internalType":"enum ITypes.FundingMode","name":"expected","type":"uint8"}],"name":"FundingModeInvalid","type":"error"},{"inputs":[],"name":"IdempotencyKeyAlreadyUsed","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"MerkleRootInvalid","type":"error"},{"inputs":[],"name":"NonceOutOfSequence","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"OperationUnsupported","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"SenderAccountNotAuthorized","type":"error"},{"inputs":[],"name":"SignatureUnauthorized","type":"error"},{"inputs":[{"internalType":"address","name":"source","type":"address"}],"name":"StorageAccountInvalid","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"TokenNotSupported","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"FundsStorageCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","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":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"Settlement","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"refundee","type":"address"},{"indexed":false,"internalType":"address","name":"sourceAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"StorageLiquidityAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SETTLER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAWAL_SIGNER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_requireMasterNotPaused","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"signerAuthorizer","type":"address"}],"name":"_requireWithdrawalSignerAuthorized","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"refundee","type":"address"},{"internalType":"address","name":"sourceAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"name":"addStorageLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"enum ITypes.FundingMode","name":"fundingMode","type":"uint8"}],"name":"createFundsStorage","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"storageAddress","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"idempotencyKey","type":"bytes32"}],"name":"directSpendDebit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"storageAddress","type":"address"},{"internalType":"bytes32","name":"idempotencyKey","type":"bytes32"}],"name":"directSpendGetTransaction","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"address","name":"fundingAddress","type":"address"},{"internalType":"enum ITypes.DirectSpendOperationType","name":"operationType","type":"uint8"},{"internalType":"bool","name":"exists","type":"bool"},{"internalType":"uint256","name":"reversedAmount","type":"uint256"}],"internalType":"struct ITypes.DirectSpendTransaction","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"storageAddress","type":"address"},{"internalType":"address","name":"destinationAddress","type":"address"},{"internalType":"address","name":"sourceAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"idempotencyKey","type":"bytes32"}],"name":"directSpendRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"storageAddress","type":"address"},{"internalType":"bytes32","name":"originalIdempotencyKey","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"idempotencyKey","type":"bytes32"}],"name":"directSpendReverse","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disableDirectSpend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableDirectSpend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBuildNumber","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCommitId","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDirectSpendReversalCutoffSeconds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMasterAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMasterLogicAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"address","name":"token","type":"address"}],"name":"getSettlementAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"fundsStorage","type":"address"}],"name":"getSettlementNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStorageBeaconAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStorageLogicAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"settlerAddress","type":"address"}],"name":"grantSettlerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"withdrawalSigner","type":"address"}],"name":"grantWithdrawalSignerRole","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":"string","name":"commitId","type":"string"},{"internalType":"string","name":"buildNumber","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"isFundsStorage","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"settlerAddress","type":"address"}],"name":"revokeSettlerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"withdrawalSigner","type":"address"}],"name":"revokeWithdrawalSignerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"expiry","type":"uint256"}],"name":"setDirectSpendReversalCutoffSeconds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"settlementAddress","type":"address"}],"name":"setSettlementAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"name":"settle","outputs":[],"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":"adminAccount","type":"address"}],"name":"transferDefaultAdminRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplAddress","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]

0x60a06040523060805234801561001457600080fd5b5061001d610075565b60405161002990610127565b604051809103906000f080158015610045573d6000803e3d6000fd5b50600180546001600160a01b03929092166001600160a01b03199283161790556002805490911630179055610134565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100c55760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146101245780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b61294e80613da783390190565b608051613c4a61015d600039600081816119260152818161194f0152611e860152613c4a6000f3fe6080604052600436106102f25760003560e01c806372241f1f1161018f5780639eff927d116100e1578063ca0eab921161008a578063e0c5b96411610064578063e0c5b964146108fd578063e0e956611461091b578063f135d06f1461093057600080fd5b8063ca0eab92146108c8578063d547741f14610454578063daa68a01146108e857600080fd5b8063a77280a4116100bb578063a77280a41461083f578063ad3cb1cc1461085f578063ad738079146108a857600080fd5b80639eff927d146107d4578063a14ec1c8146107f4578063a217fddf1461082a57600080fd5b8063882d25d4116101435780639d766e601161011d5780639d766e60146107605780639dc68d27146107805780639ed27e72146107b457600080fd5b8063882d25d4146106bb5780638986dc92146106db57806391d14854146106fb57600080fd5b80637eda3065116101745780637eda30651461066f57806383999e86146106915780638456cb59146106a657600080fd5b806372241f1f1461060e5780637445e85c1461063b57600080fd5b806339abfe67116102485780635bb08bcd116101fc578063641ef0b0116101d6578063641ef0b0146105bb5780636c30da72146105d957806371c62948146105f957600080fd5b80635bb08bcd146105445780635c975abb146105645780636211773e1461059b57600080fd5b80634cd88b761161022d5780634cd88b76146104fc5780634f1ef2861461051c57806352d1902d1461052f57600080fd5b806339abfe67146104c95780633f4ba83a146104e757600080fd5b806320f47f27116102aa578063356b73a711610284578063356b73a71461047457806336568abe1461048957806336e89453146104a957600080fd5b806320f47f27146103cc578063248a9ca3146104055780632f2ff15d1461045457600080fd5b80630d8e6e2c116102db5780630d8e6e2c146103535780630e04e445146103715780631526e087146103aa57600080fd5b806301ffc9a7146102f75780630d25a1411461032c575b600080fd5b34801561030357600080fd5b5061031761031236600461279a565b610950565b60405190151581526020015b60405180910390f35b34801561033857600080fd5b50305b6040516001600160a01b039091168152602001610323565b34801561035f57600080fd5b5060015b604051908152602001610323565b34801561037d57600080fd5b5061031761038c3660046127f1565b6001600160a01b031660009081526005602052604090205460ff1690565b3480156103b657600080fd5b506103ca6103c53660046127f1565b6109e9565b005b3480156103d857600080fd5b5061033b6103e73660046127f1565b6001600160a01b039081166000908152600660205260409020541690565b34801561041157600080fd5b5061036361042036600461280e565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b34801561046057600080fd5b506103ca61046f366004612827565b610a18565b34801561048057600080fd5b506103ca610a4a565b34801561049557600080fd5b506103ca6104a4366004612827565b610a9f565b3480156104b557600080fd5b506103ca6104c4366004612857565b610aeb565b3480156104d557600080fd5b506002546001600160a01b031661033b565b3480156104f357600080fd5b506103ca610b45565b34801561050857600080fd5b506103ca6105173660046128ce565b610b63565b6103ca61052a3660046129c8565b610bb5565b34801561053b57600080fd5b50610363610cbd565b34801561055057600080fd5b506103ca61055f3660046127f1565b610cec565b34801561057057600080fd5b507fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16610317565b3480156105a757600080fd5b506103ca6105b6366004612a75565b610d29565b3480156105c757600080fd5b506001546001600160a01b031661033b565b3480156105e557600080fd5b506103ca6105f43660046127f1565b610e05565b34801561060557600080fd5b506103ca610e86565b34801561061a57600080fd5b5061062e610629366004612abb565b610e98565b6040516103239190612b16565b34801561064757600080fd5b506103637f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f81565b34801561067b57600080fd5b50610684610f6a565b6040516103239190612bc7565b34801561069d57600080fd5b506103ca610ffc565b3480156106b257600080fd5b506103ca61103a565b3480156106c757600080fd5b506103ca6106d63660046127f1565b611055565b3480156106e757600080fd5b506103ca6106f636600461280e565b611092565b34801561070757600080fd5b50610317610716366004612827565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561076c57600080fd5b506103ca61077b3660046127f1565b6110e9565b34801561078c57600080fd5b506103637f4824dd03b57de4bb122dd97fb0eac61746a2848a58aaec225ff6798314b82e2b81565b3480156107c057600080fd5b506103ca6107cf3660046127f1565b611126565b3480156107e057600080fd5b506103ca6107ef366004612bda565b611163565b34801561080057600080fd5b5061036361080f3660046127f1565b6001600160a01b031660009081526007602052604090205490565b34801561083657600080fd5b50610363600081565b34801561084b57600080fd5b506103ca61085a366004612c15565b611207565b34801561086b57600080fd5b506106846040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b3480156108b457600080fd5b506103ca6108c3366004612bda565b61143f565b3480156108d457600080fd5b5061033b6108e3366004612c66565b6115f1565b3480156108f457600080fd5b506106846117a4565b34801561090957600080fd5b506000546001600160a01b031661033b565b34801561092757600080fd5b506103636117b3565b34801561093c57600080fd5b506103ca61094b366004612cd2565b6117c4565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806109e357507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b6109f161191b565b60006109fc816119eb565b610a076000836119f5565b50610a13600033611ac4565b505050565b6040517fc357622d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a5261191b565b6000610a5d816119eb565b50600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b6001600160a01b0381163314610ae1576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a138282611ac4565b610af361191b565b6000610afe816119eb565b506001600160a01b03918216600090815260066020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001691909216179055565b610b4d61191b565b6000610b58816119eb565b610b60611b6a565b50565b610b6b61191b565b6000610b76816119eb565b6000546001600160a01b0316151580610b9157610b91611bdc565b6003610b9e848683612dce565b506004610bac868883612dce565b50505050505050565b610bbd61191b565b610bc78282611e5c565b600082905060008054906101000a90046001600160a01b03166001600160a01b0316633659cfe6826001600160a01b031663641ef0b06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c509190612eca565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401600060405180830381600087803b158015610ca957600080fd5b505af1158015610bac573d6000803e3d6000fd5b6000610cc7611e7b565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b610cf461191b565b6000610cff816119eb565b610a137f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f836119f5565b610d3161191b565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f610d5b816119eb565b610d63611edd565b610d6b611f39565b6000610d7686611f8d565b6040517f08b1c8050000000000000000000000000000000000000000000000000000000081526001600160a01b0387811660048301526024820187905260448201869052919250908216906308b1c805906064015b600060405180830381600087803b158015610de557600080fd5b505af1158015610df9573d6000803e3d6000fd5b50505050505050505050565b610e0d61191b565b610e15611edd565b6001600160a01b03811660009081527f30fdd05c961c3b53fafbb4bb42e92ecd0d99e9875668e3f346965af1473a07fb602052604090205460ff16610b60576040517f2b1fcd6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e8e61191b565b610e96611edd565b565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a0810191909152610ed261191b565b6000610edd84611f8d565b6040517f77989e77000000000000000000000000000000000000000000000000000000008152600481018590529091506001600160a01b038216906377989e779060240160c060405180830381865afa158015610f3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f629190612efc565b949350505050565b606060038054610f7990612d2d565b80601f0160208091040260200160405190810160405280929190818152602001828054610fa590612d2d565b8015610ff25780601f10610fc757610100808354040283529160200191610ff2565b820191906000526020600020905b815481529060010190602001808311610fd557829003601f168201915b5050505050905090565b61100461191b565b600061100f816119eb565b50600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b61104261191b565b600061104d816119eb565b610b60611ff3565b61105d61191b565b6000611068816119eb565b610a137f4824dd03b57de4bb122dd97fb0eac61746a2848a58aaec225ff6798314b82e2b836119f5565b61109a61191b565b60006110a5816119eb565b6301e133808211156110e3576040517fc357622d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600955565b6110f161191b565b60006110fc816119eb565b610a137f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f83611ac4565b61112e61191b565b6000611139816119eb565b610a137f4824dd03b57de4bb122dd97fb0eac61746a2848a58aaec225ff6798314b82e2b83611ac4565b61116b61191b565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f611195816119eb565b61119d611edd565b6111a5611f39565b60006111b086611f8d565b6040517f0e02015a0000000000000000000000000000000000000000000000000000000081526004810187905260248101869052604481018590529091506001600160a01b03821690630e02015a90606401610dcb565b61120f61191b565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f611239816119eb565b611241611edd565b8115611279576040517faa6905cc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03861660009081526007602052604090205461129d906001612f77565b83146112d5576040517f5e3312b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006112e087611f8d565b90506000816001600160a01b03166321df0da76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611322573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113469190612eca565b90506113518161204e565b6040517f6c535be70000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015260248201889052831690636c535be790604401600060405180830381600087803b1580156113b457600080fd5b505af11580156113c8573d6000803e3d6000fd5b505050506001600160a01b038881166000818152600760209081526040918290208990558151928352928a1692820192909252908101879052606081018690527fcd7c65ed8cfeb9a0e64513e51c9a506b7f49a353fc48b42affd6993c2af80eb49060800160405180910390a15050505050505050565b61144761191b565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f611471816119eb565b611479611edd565b81156114b1576040517faa6905cc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006114bc86611f8d565b6001600160a01b0387166000908152600760205260409020549091506114e3906001612f77565b841461151b576040517f5e3312b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdfeaa4b3000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b0382169063dfeaa4b390602401600060405180830381600087803b15801561157657600080fd5b505af115801561158a573d6000803e3d6000fd5b505050506001600160a01b0386166000818152600760209081526040918290208790558151928352820187905281018590527f93744be23632b71c15fda59d4fcb485fc80f35677969b2262f752f3c26a12a829060600160405180910390a1505050505050565b60006115fb61191b565b611603611edd565b61160c8561204e565b6040517fffffffffffffffffffffffff0000000000000000000000000000000000000000906000906116419087908790612fb1565b6040519081900390209050600061165a33848416612f77565b600080546040805183815260208101909152929350909183916001600160a01b03169060405161168990612780565b611694929190612fc1565b8190604051809103906000f59050801580156116b4573d6000803e3d6000fd5b506040517f125a02370000000000000000000000000000000000000000000000000000000081529091506001600160a01b0382169063125a0237906117059030908d908d908d908d9060040161300e565b600060405180830381600087803b15801561171f57600080fd5b505af1158015611733573d6000803e3d6000fd5b5050506001600160a01b03821660009081526005602052604090819020805460ff19166001179055517f52eb04d640c7a602488455e1c58ec60f4aca2ba18be6496ca4d8f719ca3c91259150611790908b9084908c908c90613062565b60405180910390a198975050505050505050565b606060048054610f7990612d2d565b60006117bd61191b565b5060095490565b6117cc61191b565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f6117f6816119eb565b6117fe611edd565b611806611f39565b600061181187611f8d565b6040517fc3ef90da0000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152878116602483015260448201879052606482018690529192509082169063c3ef90da90608401600060405180830381600087803b15801561188757600080fd5b505af115801561189b573d6000803e3d6000fd5b505050506000816001600160a01b03166321df0da76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119039190612eca565b9050611911818789886120aa565b5050505050505050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614806119b457507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166119a87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614155b15610e96576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610b608133612138565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff16611aba576000848152602082815260408083206001600160a01b03871684529091529020805460ff19166001179055611a703390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506109e3565b60009150506109e3565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff1615611aba576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506109e3565b611b726121c5565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0080546002919068010000000000000000900460ff1680611c2b5750805467ffffffffffffffff808416911610155b15611c62576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000001667ffffffffffffffff83161768010000000000000000178155611ca761191b565b6000611cda7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b90506000819050806001600160a01b031663641ef0b06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d439190612eca565b30604051611d509061278d565b6001600160a01b03928316815291166020820152604001604051809103906000f080158015611d83573d6000803e3d6000fd5b50600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055611dc4612220565b5050600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16905562093a8060095580547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16815560405167ffffffffffffffff831681527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050565b611e6461191b565b611e6d82612230565b611e77828261223b565b5050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610e96576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1615610e96576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60085474010000000000000000000000000000000000000000900460ff16610e96576040517f03b395ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03811660009081526005602052604081205460ff16611fef576040517fe22117bd0000000000000000000000000000000000000000000000000000000081526001600160a01b03831660048201526024015b60405180910390fd5b5090565b611ffb611edd565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833611bbe565b6001600160a01b0381811660009081526006602052604090205416610b60576040517f06439c6b0000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611fe6565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905261213290859061233c565b50505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408083206001600160a01b038516845290915290205460ff16611e77576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401611fe6565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16610e96576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6122286123b8565b610e9661241f565b6000611e77816119eb565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612295575060408051601f3d908101601f1916820190925261229291810190613094565b60015b6122d6576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401611fe6565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114612332576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401611fe6565b610a138383612452565b60006123516001600160a01b038416836124a8565b9050805160001415801561237657508080602001905181019061237491906130ad565b155b15610a13576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401611fe6565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16610e96576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6124276123b8565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300805460ff19169055565b61245b826124bd565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a28051156124a057610a138282612565565b611e776125db565b60606124b683836000612613565b9392505050565b806001600160a01b03163b60000361250c576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611fe6565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6060600080846001600160a01b03168460405161258291906130c8565b600060405180830381855af49150503d80600081146125bd576040519150601f19603f3d011682016040523d82523d6000602084013e6125c2565b606091505b50915091506125d28583836126c9565b95945050505050565b3415610e96576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081471015612651576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401611fe6565b600080856001600160a01b0316848660405161266d91906130c8565b60006040518083038185875af1925050503d80600081146126aa576040519150601f19603f3d011682016040523d82523d6000602084013e6126af565b606091505b50915091506126bf8683836126c9565b9695505050505050565b6060826126de576126d98261273e565b6124b6565b81511580156126f557506001600160a01b0384163b155b15612737576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401611fe6565b50806124b6565b80511561274e5780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6105eb806130e583390190565b610545806136d083390190565b6000602082840312156127ac57600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146124b657600080fd5b6001600160a01b0381168114610b6057600080fd5b60006020828403121561280357600080fd5b81356124b6816127dc565b60006020828403121561282057600080fd5b5035919050565b6000806040838503121561283a57600080fd5b82359150602083013561284c816127dc565b809150509250929050565b6000806040838503121561286a57600080fd5b8235612875816127dc565b9150602083013561284c816127dc565b60008083601f84011261289757600080fd5b50813567ffffffffffffffff8111156128af57600080fd5b6020830191508360208285010111156128c757600080fd5b9250929050565b600080600080604085870312156128e457600080fd5b843567ffffffffffffffff8111156128fb57600080fd5b61290787828801612885565b909550935050602085013567ffffffffffffffff81111561292757600080fd5b61293387828801612885565b95989497509550505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160c0810167ffffffffffffffff811182821017156129915761299161293f565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156129c0576129c061293f565b604052919050565b600080604083850312156129db57600080fd5b82356129e6816127dc565b9150602083013567ffffffffffffffff811115612a0257600080fd5b8301601f81018513612a1357600080fd5b803567ffffffffffffffff811115612a2d57612a2d61293f565b612a406020601f19601f84011601612997565b818152866020838501011115612a5557600080fd5b816020840160208301376000602083830101528093505050509250929050565b60008060008060808587031215612a8b57600080fd5b8435612a96816127dc565b93506020850135612aa6816127dc565b93969395505050506040820135916060013590565b60008060408385031215612ace57600080fd5b8235612ad9816127dc565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600060c08201905082518252602083015160208301526001600160a01b036040840151166040830152606083015160038110612b5457612b54612ae7565b8060608401525060808301511515608083015260a083015160a083015292915050565b60005b83811015612b92578181015183820152602001612b7a565b50506000910152565b60008151808452612bb3816020860160208601612b77565b601f01601f19169290920160200192915050565b6020815260006124b66020830184612b9b565b60008060008060808587031215612bf057600080fd5b8435612bfb816127dc565b966020860135965060408601359560600135945092505050565b600080600080600060a08688031215612c2d57600080fd5b8535612c38816127dc565b94506020860135612c48816127dc565b94979496505050506040830135926060810135926080909101359150565b60008060008060608587031215612c7c57600080fd5b8435612c87816127dc565b9350602085013567ffffffffffffffff811115612ca357600080fd5b612caf87828801612885565b909450925050604085013560028110612cc757600080fd5b939692955090935050565b600080600080600060a08688031215612cea57600080fd5b8535612cf5816127dc565b94506020860135612d05816127dc565b93506040860135612d15816127dc565b94979396509394606081013594506080013592915050565b600181811c90821680612d4157607f821691505b602082108103612d7a577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b601f821115610a1357806000526020600020601f840160051c81016020851015612da75750805b601f840160051c820191505b81811015612dc75760008155600101612db3565b5050505050565b67ffffffffffffffff831115612de657612de661293f565b612dfa83612df48354612d2d565b83612d80565b6000601f841160018114612e4c5760008515612e165750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355612dc7565b600083815260209020601f19861690835b82811015612e7d5786850135825560209485019460019092019101612e5d565b5086821015612eb8577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555050505050565b600060208284031215612edc57600080fd5b81516124b6816127dc565b80518015158114612ef757600080fd5b919050565b600060c0828403128015612f0f57600080fd5b506000612f1a61296e565b83518152602080850151908201526040840151612f36816127dc565b6040820152606084015160038110612f4c578283fd5b6060820152612f5d60808501612ee7565b608082015260a09384015193810193909352509092915050565b808201808211156109e3577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8183823760009101908152919050565b6001600160a01b0383168152604060208201526000610f626040830184612b9b565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b6001600160a01b03861681526001600160a01b0385166020820152608060408201526000613040608083018587612fe3565b90506002831061305257613052612ae7565b8260608301529695505050505050565b6001600160a01b03851681526001600160a01b03841660208201526060604082015260006126bf606083018486612fe3565b6000602082840312156130a657600080fd5b5051919050565b6000602082840312156130bf57600080fd5b6124b682612ee7565b600082516130da818460208701612b77565b919091019291505056fe60a06040526040516105eb3803806105eb83398101604081905261002291610387565b61002c828261003e565b506001600160a01b0316608052610484565b610047826100fe565b6040516001600160a01b038316907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a28051156100f2576100ed826001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e7919061044d565b82610211565b505050565b6100fa610288565b5050565b806001600160a01b03163b60000361013957604051631933b43b60e21b81526001600160a01b03821660048201526024015b60405180910390fd5b807fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5080546001600160a01b0319166001600160a01b0392831617905560408051635c60da1b60e01b81529051600092841691635c60da1b9160048083019260209291908290030181865afa1580156101b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d9919061044d565b9050806001600160a01b03163b6000036100fa57604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610130565b6060600080846001600160a01b03168460405161022e9190610468565b600060405180830381855af49150503d8060008114610269576040519150601f19603f3d011682016040523d82523d6000602084013e61026e565b606091505b50909250905061027f8583836102a9565b95945050505050565b34156102a75760405163b398979f60e01b815260040160405180910390fd5b565b6060826102be576102b982610308565b610301565b81511580156102d557506001600160a01b0384163b155b156102fe57604051639996b31560e01b81526001600160a01b0385166004820152602401610130565b50805b9392505050565b8051156103185780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80516001600160a01b038116811461034857600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561037e578181015183820152602001610366565b50506000910152565b6000806040838503121561039a57600080fd5b6103a383610331565b60208401519092506001600160401b038111156103bf57600080fd5b8301601f810185136103d057600080fd5b80516001600160401b038111156103e9576103e961034d565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104175761041761034d565b60405281815282820160200187101561042f57600080fd5b610440826020830160208601610363565b8093505050509250929050565b60006020828403121561045f57600080fd5b61030182610331565b6000825161047a818460208701610363565b9190910192915050565b60805161014d61049e60003960006024015261014d6000f3fe608060405261000c61000e565b005b61001e610019610020565b6100b6565b565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561008d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100b191906100da565b905090565b3660008037600080366000845af43d6000803e8080156100d5573d6000f35b3d6000fd5b6000602082840312156100ec57600080fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811461011057600080fd5b939250505056fea2646970667358221220847da51342687254596c326192e2f3d8105e3ef1bf337cd24124316a6711d7ad64736f6c634300081c0033608060405234801561001057600080fd5b5060405161054538038061054583398101604081905261002f91610165565b806001600160a01b03811661005f57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61006881610079565b50610072826100c9565b5050610198565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b806001600160a01b03163b6000036100ff5760405163211eb15960e21b81526001600160a01b0382166004820152602401610056565b600180546001600160a01b0319166001600160a01b0383169081179091556040517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b80516001600160a01b038116811461016057600080fd5b919050565b6000806040838503121561017857600080fd5b61018183610149565b915061018f60208401610149565b90509250929050565b61039e806101a76000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c8063715018a611610050578063715018a6146100c45780638da5cb5b146100cc578063f2fde38b146100ea57600080fd5b80633659cfe61461006c5780635c60da1b14610081575b600080fd5b61007f61007a36600461032b565b6100fd565b005b60015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61007f610111565b60005473ffffffffffffffffffffffffffffffffffffffff1661009b565b61007f6100f836600461032b565b610125565b61010561018b565b61010e816101de565b50565b61011961018b565b61012360006102b6565b565b61012d61018b565b73ffffffffffffffffffffffffffffffffffffffff8116610182576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b61010e816102b6565b60005473ffffffffffffffffffffffffffffffffffffffff163314610123576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610179565b8073ffffffffffffffffffffffffffffffffffffffff163b600003610247576040517f847ac56400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401610179565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561033d57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461036157600080fd5b939250505056fea2646970667358221220e240865f9ac07da05345e9974bc71e5d074faab729148d0ee16b859b84ebd81e64736f6c634300081c0033a2646970667358221220f0c86978e9f7f059a23164735ea8a6387f09fd3b95fa34eee09c169739b0bbbe64736f6c634300081c00336080604052348015600f57600080fd5b5061292f8061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100df5760003560e01c806377989e771161008c578063c3ef90da11610066578063c3ef90da146101f7578063dfeaa4b31461020a578063f5a701ff1461021d578063fe55892d1461023057600080fd5b806377989e771461017857806384b0196e1461019857806396726af6146101b357600080fd5b806317d7de7c116100bd57806317d7de7c1461011f57806321df0da71461013d5780636c535be71461016557600080fd5b806308b1c805146100e45780630e02015a146100f9578063125a02371461010c575b600080fd5b6100f76100f2366004612074565b610243565b005b6100f76101073660046120a9565b61045e565b6100f761011a3660046120e9565b610848565b610127610ae3565b60405161013491906121e4565b60405180910390f35b60025460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610134565b6100f76101733660046121f7565b610b75565b61018b610186366004612223565b610bb0565b604051610134919061226b565b6101a0610cb1565b60405161013497969594939291906122d9565b6101e96101c136600461239a565b73ffffffffffffffffffffffffffffffffffffffff1660009081526003602052604090205490565b604051908152602001610134565b6100f76102053660046123b7565b610db2565b6100f7610218366004612223565b610fb0565b60055460ff16604051610134919061240d565b6100f761023e36600461244f565b6110eb565b61024b6112b6565b6102556001611330565b61025e33611395565b61026781611404565b60025461028c9073ffffffffffffffffffffffffffffffffffffffff1684308561150a565b6040518060c001604052808381526020014281526020018473ffffffffffffffffffffffffffffffffffffffff168152602001600060028111156102d2576102d261223c565b8152600160208083018290526000604093840181905285815260048252839020845181559084015191810191909155908201516002808301805473ffffffffffffffffffffffffffffffffffffffff9093167fffffffffffffffffffffffff000000000000000000000000000000000000000084168117825560608601519391927fffffffffffffffffffffff0000000000000000000000000000000000000000009092161790740100000000000000000000000000000000000000009084908111156103a1576103a161223c565b021790555060808201516002820180549115157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff90921691909117905560a0909101516003909101556040805173ffffffffffffffffffffffffffffffffffffffff85168152602081018490529081018290527f7d21ef3935fe7d9657ac99fe98a59e40da46146de3c917413ddf4fb52decc6369060600160405180910390a1505050565b6104666112b6565b6104706001611330565b61047933611395565b61048281611404565b6000838152600460209081526040808320815160c0810183528154815260018201549381019390935260028082015473ffffffffffffffffffffffffffffffffffffffff811693850193909352909160608401917401000000000000000000000000000000000000000090910460ff16908111156105025761050261223c565b60028111156105135761051361223c565b815260028201547501000000000000000000000000000000000000000000900460ff16151560208201526003909101546040909101526080810151909150610587576040517f43c02c5500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008160600151600281111561059f5761059f61223c565b146105d6576040517fc357622d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6105df81611593565b60a081015181516000916105f291612555565b90508084111561062e576040517f553531ac00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408201516002546106579073ffffffffffffffffffffffffffffffffffffffff168287611672565b848360a001516106679190612568565b60008781526004602090815260409182902060030192909255805160c081018252878152429281019290925273ffffffffffffffffffffffffffffffffffffffff8316908201526060810160028152600160208083018290526040928301899052600088815260048252839020845181559084015191810191909155908201516002808301805473ffffffffffffffffffffffffffffffffffffffff9093167fffffffffffffffffffffffff000000000000000000000000000000000000000084168117825560608601519391927fffffffffffffffffffffff0000000000000000000000000000000000000000009092161790740100000000000000000000000000000000000000009084908111156107835761078361223c565b02179055506080828101516002830180549115157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff90921691909117905560a0909201516003909101556040805188815273ffffffffffffffffffffffffffffffffffffffff84166020820152908101879052606081018690527fe15319dd10a12f32753daaee2634b65e852596eadaad6d88ab268aca668c51a7910160405180910390a1505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff166000811580156108935750825b905060008267ffffffffffffffff1660011480156108b05750303b155b9050811580156108be575080155b156108f5576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000016600117855583156109565784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b6000805473ffffffffffffffffffffffffffffffffffffffff808d167fffffffffffffffffffffffff00000000000000000000000000000000000000009283161790925560028054928c169290911691909117905560016109b8888a8361261c565b50600580548791907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600183818111156109f5576109f561223c565b0217905550610a6e6040518060400160405280601a81526020017f496d6d65727376652e46756e647353746f726167654c6f6769630000000000008152506040518060400160405280600181526020017f31000000000000000000000000000000000000000000000000000000000000008152506116b0565b610a766116c2565b8315610ad75784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050505050565b606060018054610af29061257b565b80601f0160208091040260200160405190810160405280929190818152602001828054610b1e9061257b565b8015610b6b5780601f10610b4057610100808354040283529160200191610b6b565b820191906000526020600020905b815481529060010190602001808311610b4e57829003601f168201915b5050505050905090565b610b7d6112b6565b610b8633611395565b60025473ffffffffffffffffffffffffffffffffffffffff16610bab8184308561150a565b505050565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a0810191909152600082815260046020908152604091829020825160c0810184528154815260018201549281019290925260028082015473ffffffffffffffffffffffffffffffffffffffff81169484019490945291929091606084019174010000000000000000000000000000000000000000900460ff1690811115610c6457610c6461223c565b6002811115610c7557610c7561223c565b815260028201547501000000000000000000000000000000000000000000900460ff161515602082015260039091015460409091015292915050565b600060608082808083817fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1008054909150158015610cf057506001810154155b610d5b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4549503731323a20556e696e697469616c697a6564000000000000000000000060448201526064015b60405180910390fd5b610d636116d4565b610d6b6117a9565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009c939b5091995046985030975095509350915050565b610dba6112b6565b610dc46001611330565b610dcd33611395565b610dd681611404565b6040518060c001604052808381526020014281526020018573ffffffffffffffffffffffffffffffffffffffff16815260200160016002811115610e1c57610e1c61223c565b8152600160208083018290526000604093840181905285815260048252839020845181559084015191810191909155908201516002808301805473ffffffffffffffffffffffffffffffffffffffff9093167fffffffffffffffffffffffff000000000000000000000000000000000000000084168117825560608601519391927fffffffffffffffffffffff000000000000000000000000000000000000000000909216179074010000000000000000000000000000000000000000908490811115610eeb57610eeb61223c565b02179055506080828101516002830180549115157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff90921691909117905560a0909201516003909101556040805173ffffffffffffffffffffffffffffffffffffffff878116825286166020820152908101849052606081018390527f07ed227ae1ca3d28b0af8938dee03ab2355de9dbd5e3f2dae93bd2ad1bea912c910160405180910390a150505050565b610fb86112b6565b610fc133611395565b600080546002546040517f20f47f2700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201529116906320f47f2790602401602060405180830381865afa158015611034573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110589190612718565b905073ffffffffffffffffffffffffffffffffffffffff81166110c3576002546040517f06439c6b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602401610d52565b6002546110e79073ffffffffffffffffffffffffffffffffffffffff168284611672565b5050565b6110f36117fa565b6110fb6112b6565b6111056000611330565b8242111561113f576040517f2730e78400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360009081526003602052604090205461115a906001612568565b8214611192576040517f5e3312b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080517ffb11d65370c515a75d6d2e4455dbe146db87055102d011540dfa18c581cba39b60208201523391810191909152606081018590526080810184905260a081018390526000906111fe9060c0016040516020818303038152906040528051906020012061187b565b905061120a81836118c9565b3360009081526003602052604090208390558415611246576002546112469073ffffffffffffffffffffffffffffffffffffffff163387611672565b7f8b501036de8a7422d7f8b7311d40441e079b4221e9edc276b3452124024e32cb33868686600060405161127e959493929190612735565b60405180910390a1506112b060017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b50505050565b60008054604080517f71c62948000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff909216926371c6294892600480840193829003018186803b15801561131c57600080fd5b505afa1580156112b0573d6000803e3d6000fd5b60055460ff168160018111156113485761134861223c565b81600181111561135a5761135a61223c565b146110e75780826040517fccf269a2000000000000000000000000000000000000000000000000000000008152600401610d52929190612781565b60005473ffffffffffffffffffffffffffffffffffffffff828116911614611401576040517f903edfc000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401610d52565b50565b6000818152600460209081526040808320815160c0810183528154815260018201549381019390935260028082015473ffffffffffffffffffffffffffffffffffffffff811693850193909352909160608401917401000000000000000000000000000000000000000090910460ff16908111156114845761148461223c565b60028111156114955761149561223c565b815260028201547501000000000000000000000000000000000000000000900460ff16151560208201526003909101546040909101526080810151909150156110e7576040517f6538f59800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390526112b09186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611985565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e0e956616040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611603573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162791906127a7565b82602001516116369190612568565b9050804211156110e7576040517faf5556c400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff838116602483015260448201839052610bab91859182169063a9059cbb9060640161154c565b6116b8611a1b565b6110e78282611a82565b6116ca611a1b565b6116d2611af5565b565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10280546060917fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100916117259061257b565b80601f01602080910402602001604051908101604052809291908181526020018280546117519061257b565b801561179e5780601f106117735761010080835404028352916020019161179e565b820191906000526020600020905b81548152906001019060200180831161178157829003601f168201915b505050505091505090565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10380546060917fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100916117259061257b565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0080547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01611875576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60029055565b60006118c3611888611afd565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b92915050565b60006118d58383611b0c565b6000546040517f6c30da7200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8084166004830152929350911690636c30da729060240160006040518083038186803b15801561194257600080fd5b505afa158015611956573d6000803e3d6000fd5b50505050505050565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b60006119a773ffffffffffffffffffffffffffffffffffffffff841683611b36565b905080516000141580156119cc5750808060200190518101906119ca91906127c0565b155b15610bab576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84166004820152602401610d52565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff166116d2576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611a8a611a1b565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1007fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d102611ad684826127e2565b5060038101611ae583826127e2565b5060008082556001909101555050565b61195f611a1b565b6000611b07611b4b565b905090565b600080600080611b1c8686611bbf565b925092509250611b2c8282611c0c565b5090949350505050565b6060611b4483836000611d10565b9392505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611b76611dd3565b611b7e611e4f565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b60008060008351604103611bf95760208401516040850151606086015160001a611beb88828585611ea5565b955095509550505050611c05565b50508151600091506002905b9250925092565b6000826003811115611c2057611c2061223c565b03611c29575050565b6001826003811115611c3d57611c3d61223c565b03611c74576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002826003811115611c8857611c8861223c565b03611cc2576040517ffce698f700000000000000000000000000000000000000000000000000000000815260048101829052602401610d52565b6003826003811115611cd657611cd661223c565b036110e7576040517fd78bce0c00000000000000000000000000000000000000000000000000000000815260048101829052602401610d52565b606081471015611d4e576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401610d52565b6000808573ffffffffffffffffffffffffffffffffffffffff168486604051611d7791906128dd565b60006040518083038185875af1925050503d8060008114611db4576040519150601f19603f3d011682016040523d82523d6000602084013e611db9565b606091505b5091509150611dc9868383611f81565b9695505050505050565b60007fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10081611dff6116d4565b805190915015611e1757805160209091012092915050565b81548015611e26579392505050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470935050505090565b60007fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10081611e7b6117a9565b805190915015611e9357805160209091012092915050565b60018201548015611e26579392505050565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115611ee05750600091506003905082611f77565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015611f34573d6000803e3d6000fd5b5050604051601f19015191505073ffffffffffffffffffffffffffffffffffffffff8116611f6d57506000925060019150829050611f77565b9250600091508190505b9450945094915050565b606082611f9657611f9182612010565b611b44565b8151158015611fba575073ffffffffffffffffffffffffffffffffffffffff84163b155b15612009576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602401610d52565b5080611b44565b8051156120205780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461140157600080fd5b60008060006060848603121561208957600080fd5b833561209481612052565b95602085013595506040909401359392505050565b6000806000606084860312156120be57600080fd5b505081359360208301359350604090920135919050565b8035600281106120e457600080fd5b919050565b60008060008060006080868803121561210157600080fd5b853561210c81612052565b9450602086013561211c81612052565b9350604086013567ffffffffffffffff81111561213857600080fd5b8601601f8101881361214957600080fd5b803567ffffffffffffffff81111561216057600080fd5b88602082840101111561217257600080fd5b60209190910193509150612188606087016120d5565b90509295509295909350565b60005b838110156121af578181015183820152602001612197565b50506000910152565b600081518084526121d0816020860160208601612194565b601f01601f19169290920160200192915050565b602081526000611b4460208301846121b8565b6000806040838503121561220a57600080fd5b823561221581612052565b946020939093013593505050565b60006020828403121561223557600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600060c082019050825182526020830151602083015273ffffffffffffffffffffffffffffffffffffffff60408401511660408301526060830151600381106122b6576122b661223c565b8060608401525060808301511515608083015260a083015160a083015292915050565b7fff000000000000000000000000000000000000000000000000000000000000008816815260e06020820152600061231460e08301896121b8565b828103604084015261232681896121b8565b6060840188905273ffffffffffffffffffffffffffffffffffffffff8716608085015260a0840186905283810360c08501528451808252602080870193509091019060005b8181101561238957835183526020938401939092019160010161236b565b50909b9a5050505050505050505050565b6000602082840312156123ac57600080fd5b8135611b4481612052565b600080600080608085870312156123cd57600080fd5b84356123d881612052565b935060208501356123e881612052565b93969395505050506040820135916060013590565b600281106114015761140161223c565b6020810161241a836123fd565b91905290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000806080858703121561246557600080fd5b843593506020850135925060408501359150606085013567ffffffffffffffff81111561249157600080fd5b8501601f810187136124a257600080fd5b803567ffffffffffffffff8111156124bc576124bc612420565b604051601f19603f601f19601f8501160116810181811067ffffffffffffffff821117156124ec576124ec612420565b60405281815282820160200189101561250457600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156118c3576118c3612526565b808201808211156118c3576118c3612526565b600181811c9082168061258f57607f821691505b6020821081036125c8577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b601f821115610bab57806000526020600020601f840160051c810160208510156125f55750805b601f840160051c820191505b818110156126155760008155600101612601565b5050505050565b67ffffffffffffffff83111561263457612634612420565b61264883612642835461257b565b836125ce565b6000601f84116001811461269a57600085156126645750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355612615565b600083815260209020601f19861690835b828110156126cb57868501358255602094850194600190920191016126ab565b5086821015612706577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555050505050565b60006020828403121561272a57600080fd5b8151611b4481612052565b600060a08201905073ffffffffffffffffffffffffffffffffffffffff87168252856020830152846040830152836060830152612771836123fd565b8260808301529695505050505050565b6040810161278e846123fd565b83825261279a836123fd565b8260208301529392505050565b6000602082840312156127b957600080fd5b5051919050565b6000602082840312156127d257600080fd5b81518015158114611b4457600080fd5b815167ffffffffffffffff8111156127fc576127fc612420565b6128108161280a845461257b565b846125ce565b6020601f821160018114612862576000831561282c5750848201515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600385901b1c1916600184901b178455612615565b600084815260208120601f198516915b828110156128925787850151825560209485019460019092019101612872565b50848210156128ce57868401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b60f8161c191681555b50505050600190811b01905550565b600082516128ef818460208701612194565b919091019291505056fea264697066735822122015ec66638f38272b1058c4074a10db41b6d697fa115edc340f56a5a5f193b12764736f6c634300081c0033

Deployed Bytecode

0x6080604052600436106102f25760003560e01c806372241f1f1161018f5780639eff927d116100e1578063ca0eab921161008a578063e0c5b96411610064578063e0c5b964146108fd578063e0e956611461091b578063f135d06f1461093057600080fd5b8063ca0eab92146108c8578063d547741f14610454578063daa68a01146108e857600080fd5b8063a77280a4116100bb578063a77280a41461083f578063ad3cb1cc1461085f578063ad738079146108a857600080fd5b80639eff927d146107d4578063a14ec1c8146107f4578063a217fddf1461082a57600080fd5b8063882d25d4116101435780639d766e601161011d5780639d766e60146107605780639dc68d27146107805780639ed27e72146107b457600080fd5b8063882d25d4146106bb5780638986dc92146106db57806391d14854146106fb57600080fd5b80637eda3065116101745780637eda30651461066f57806383999e86146106915780638456cb59146106a657600080fd5b806372241f1f1461060e5780637445e85c1461063b57600080fd5b806339abfe67116102485780635bb08bcd116101fc578063641ef0b0116101d6578063641ef0b0146105bb5780636c30da72146105d957806371c62948146105f957600080fd5b80635bb08bcd146105445780635c975abb146105645780636211773e1461059b57600080fd5b80634cd88b761161022d5780634cd88b76146104fc5780634f1ef2861461051c57806352d1902d1461052f57600080fd5b806339abfe67146104c95780633f4ba83a146104e757600080fd5b806320f47f27116102aa578063356b73a711610284578063356b73a71461047457806336568abe1461048957806336e89453146104a957600080fd5b806320f47f27146103cc578063248a9ca3146104055780632f2ff15d1461045457600080fd5b80630d8e6e2c116102db5780630d8e6e2c146103535780630e04e445146103715780631526e087146103aa57600080fd5b806301ffc9a7146102f75780630d25a1411461032c575b600080fd5b34801561030357600080fd5b5061031761031236600461279a565b610950565b60405190151581526020015b60405180910390f35b34801561033857600080fd5b50305b6040516001600160a01b039091168152602001610323565b34801561035f57600080fd5b5060015b604051908152602001610323565b34801561037d57600080fd5b5061031761038c3660046127f1565b6001600160a01b031660009081526005602052604090205460ff1690565b3480156103b657600080fd5b506103ca6103c53660046127f1565b6109e9565b005b3480156103d857600080fd5b5061033b6103e73660046127f1565b6001600160a01b039081166000908152600660205260409020541690565b34801561041157600080fd5b5061036361042036600461280e565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b34801561046057600080fd5b506103ca61046f366004612827565b610a18565b34801561048057600080fd5b506103ca610a4a565b34801561049557600080fd5b506103ca6104a4366004612827565b610a9f565b3480156104b557600080fd5b506103ca6104c4366004612857565b610aeb565b3480156104d557600080fd5b506002546001600160a01b031661033b565b3480156104f357600080fd5b506103ca610b45565b34801561050857600080fd5b506103ca6105173660046128ce565b610b63565b6103ca61052a3660046129c8565b610bb5565b34801561053b57600080fd5b50610363610cbd565b34801561055057600080fd5b506103ca61055f3660046127f1565b610cec565b34801561057057600080fd5b507fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16610317565b3480156105a757600080fd5b506103ca6105b6366004612a75565b610d29565b3480156105c757600080fd5b506001546001600160a01b031661033b565b3480156105e557600080fd5b506103ca6105f43660046127f1565b610e05565b34801561060557600080fd5b506103ca610e86565b34801561061a57600080fd5b5061062e610629366004612abb565b610e98565b6040516103239190612b16565b34801561064757600080fd5b506103637f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f81565b34801561067b57600080fd5b50610684610f6a565b6040516103239190612bc7565b34801561069d57600080fd5b506103ca610ffc565b3480156106b257600080fd5b506103ca61103a565b3480156106c757600080fd5b506103ca6106d63660046127f1565b611055565b3480156106e757600080fd5b506103ca6106f636600461280e565b611092565b34801561070757600080fd5b50610317610716366004612827565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561076c57600080fd5b506103ca61077b3660046127f1565b6110e9565b34801561078c57600080fd5b506103637f4824dd03b57de4bb122dd97fb0eac61746a2848a58aaec225ff6798314b82e2b81565b3480156107c057600080fd5b506103ca6107cf3660046127f1565b611126565b3480156107e057600080fd5b506103ca6107ef366004612bda565b611163565b34801561080057600080fd5b5061036361080f3660046127f1565b6001600160a01b031660009081526007602052604090205490565b34801561083657600080fd5b50610363600081565b34801561084b57600080fd5b506103ca61085a366004612c15565b611207565b34801561086b57600080fd5b506106846040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b3480156108b457600080fd5b506103ca6108c3366004612bda565b61143f565b3480156108d457600080fd5b5061033b6108e3366004612c66565b6115f1565b3480156108f457600080fd5b506106846117a4565b34801561090957600080fd5b506000546001600160a01b031661033b565b34801561092757600080fd5b506103636117b3565b34801561093c57600080fd5b506103ca61094b366004612cd2565b6117c4565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806109e357507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b6109f161191b565b60006109fc816119eb565b610a076000836119f5565b50610a13600033611ac4565b505050565b6040517fc357622d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a5261191b565b6000610a5d816119eb565b50600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b6001600160a01b0381163314610ae1576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a138282611ac4565b610af361191b565b6000610afe816119eb565b506001600160a01b03918216600090815260066020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001691909216179055565b610b4d61191b565b6000610b58816119eb565b610b60611b6a565b50565b610b6b61191b565b6000610b76816119eb565b6000546001600160a01b0316151580610b9157610b91611bdc565b6003610b9e848683612dce565b506004610bac868883612dce565b50505050505050565b610bbd61191b565b610bc78282611e5c565b600082905060008054906101000a90046001600160a01b03166001600160a01b0316633659cfe6826001600160a01b031663641ef0b06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c509190612eca565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401600060405180830381600087803b158015610ca957600080fd5b505af1158015610bac573d6000803e3d6000fd5b6000610cc7611e7b565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b610cf461191b565b6000610cff816119eb565b610a137f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f836119f5565b610d3161191b565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f610d5b816119eb565b610d63611edd565b610d6b611f39565b6000610d7686611f8d565b6040517f08b1c8050000000000000000000000000000000000000000000000000000000081526001600160a01b0387811660048301526024820187905260448201869052919250908216906308b1c805906064015b600060405180830381600087803b158015610de557600080fd5b505af1158015610df9573d6000803e3d6000fd5b50505050505050505050565b610e0d61191b565b610e15611edd565b6001600160a01b03811660009081527f30fdd05c961c3b53fafbb4bb42e92ecd0d99e9875668e3f346965af1473a07fb602052604090205460ff16610b60576040517f2b1fcd6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e8e61191b565b610e96611edd565b565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a0810191909152610ed261191b565b6000610edd84611f8d565b6040517f77989e77000000000000000000000000000000000000000000000000000000008152600481018590529091506001600160a01b038216906377989e779060240160c060405180830381865afa158015610f3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f629190612efc565b949350505050565b606060038054610f7990612d2d565b80601f0160208091040260200160405190810160405280929190818152602001828054610fa590612d2d565b8015610ff25780601f10610fc757610100808354040283529160200191610ff2565b820191906000526020600020905b815481529060010190602001808311610fd557829003601f168201915b5050505050905090565b61100461191b565b600061100f816119eb565b50600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b61104261191b565b600061104d816119eb565b610b60611ff3565b61105d61191b565b6000611068816119eb565b610a137f4824dd03b57de4bb122dd97fb0eac61746a2848a58aaec225ff6798314b82e2b836119f5565b61109a61191b565b60006110a5816119eb565b6301e133808211156110e3576040517fc357622d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600955565b6110f161191b565b60006110fc816119eb565b610a137f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f83611ac4565b61112e61191b565b6000611139816119eb565b610a137f4824dd03b57de4bb122dd97fb0eac61746a2848a58aaec225ff6798314b82e2b83611ac4565b61116b61191b565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f611195816119eb565b61119d611edd565b6111a5611f39565b60006111b086611f8d565b6040517f0e02015a0000000000000000000000000000000000000000000000000000000081526004810187905260248101869052604481018590529091506001600160a01b03821690630e02015a90606401610dcb565b61120f61191b565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f611239816119eb565b611241611edd565b8115611279576040517faa6905cc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03861660009081526007602052604090205461129d906001612f77565b83146112d5576040517f5e3312b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006112e087611f8d565b90506000816001600160a01b03166321df0da76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611322573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113469190612eca565b90506113518161204e565b6040517f6c535be70000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015260248201889052831690636c535be790604401600060405180830381600087803b1580156113b457600080fd5b505af11580156113c8573d6000803e3d6000fd5b505050506001600160a01b038881166000818152600760209081526040918290208990558151928352928a1692820192909252908101879052606081018690527fcd7c65ed8cfeb9a0e64513e51c9a506b7f49a353fc48b42affd6993c2af80eb49060800160405180910390a15050505050505050565b61144761191b565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f611471816119eb565b611479611edd565b81156114b1576040517faa6905cc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006114bc86611f8d565b6001600160a01b0387166000908152600760205260409020549091506114e3906001612f77565b841461151b576040517f5e3312b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdfeaa4b3000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b0382169063dfeaa4b390602401600060405180830381600087803b15801561157657600080fd5b505af115801561158a573d6000803e3d6000fd5b505050506001600160a01b0386166000818152600760209081526040918290208790558151928352820187905281018590527f93744be23632b71c15fda59d4fcb485fc80f35677969b2262f752f3c26a12a829060600160405180910390a1505050505050565b60006115fb61191b565b611603611edd565b61160c8561204e565b6040517fffffffffffffffffffffffff0000000000000000000000000000000000000000906000906116419087908790612fb1565b6040519081900390209050600061165a33848416612f77565b600080546040805183815260208101909152929350909183916001600160a01b03169060405161168990612780565b611694929190612fc1565b8190604051809103906000f59050801580156116b4573d6000803e3d6000fd5b506040517f125a02370000000000000000000000000000000000000000000000000000000081529091506001600160a01b0382169063125a0237906117059030908d908d908d908d9060040161300e565b600060405180830381600087803b15801561171f57600080fd5b505af1158015611733573d6000803e3d6000fd5b5050506001600160a01b03821660009081526005602052604090819020805460ff19166001179055517f52eb04d640c7a602488455e1c58ec60f4aca2ba18be6496ca4d8f719ca3c91259150611790908b9084908c908c90613062565b60405180910390a198975050505050505050565b606060048054610f7990612d2d565b60006117bd61191b565b5060095490565b6117cc61191b565b7f6666bf5bfee463d10a7fc50448047f8a53b7762d7e28fbc5c643182785f3fd3f6117f6816119eb565b6117fe611edd565b611806611f39565b600061181187611f8d565b6040517fc3ef90da0000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152878116602483015260448201879052606482018690529192509082169063c3ef90da90608401600060405180830381600087803b15801561188757600080fd5b505af115801561189b573d6000803e3d6000fd5b505050506000816001600160a01b03166321df0da76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119039190612eca565b9050611911818789886120aa565b5050505050505050565b306001600160a01b037f000000000000000000000000b6279106b9789938aa1a4a6ac8507459cc4c95651614806119b457507f000000000000000000000000b6279106b9789938aa1a4a6ac8507459cc4c95656001600160a01b03166119a87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614155b15610e96576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610b608133612138565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff16611aba576000848152602082815260408083206001600160a01b03871684529091529020805460ff19166001179055611a703390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506109e3565b60009150506109e3565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff1615611aba576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506109e3565b611b726121c5565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0080546002919068010000000000000000900460ff1680611c2b5750805467ffffffffffffffff808416911610155b15611c62576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000001667ffffffffffffffff83161768010000000000000000178155611ca761191b565b6000611cda7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b90506000819050806001600160a01b031663641ef0b06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d439190612eca565b30604051611d509061278d565b6001600160a01b03928316815291166020820152604001604051809103906000f080158015611d83573d6000803e3d6000fd5b50600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055611dc4612220565b5050600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16905562093a8060095580547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16815560405167ffffffffffffffff831681527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050565b611e6461191b565b611e6d82612230565b611e77828261223b565b5050565b306001600160a01b037f000000000000000000000000b6279106b9789938aa1a4a6ac8507459cc4c95651614610e96576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1615610e96576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60085474010000000000000000000000000000000000000000900460ff16610e96576040517f03b395ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03811660009081526005602052604081205460ff16611fef576040517fe22117bd0000000000000000000000000000000000000000000000000000000081526001600160a01b03831660048201526024015b60405180910390fd5b5090565b611ffb611edd565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833611bbe565b6001600160a01b0381811660009081526006602052604090205416610b60576040517f06439c6b0000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611fe6565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905261213290859061233c565b50505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408083206001600160a01b038516845290915290205460ff16611e77576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401611fe6565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff16610e96576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6122286123b8565b610e9661241f565b6000611e77816119eb565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612295575060408051601f3d908101601f1916820190925261229291810190613094565b60015b6122d6576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401611fe6565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114612332576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401611fe6565b610a138383612452565b60006123516001600160a01b038416836124a8565b9050805160001415801561237657508080602001905181019061237491906130ad565b155b15610a13576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401611fe6565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16610e96576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6124276123b8565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300805460ff19169055565b61245b826124bd565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a28051156124a057610a138282612565565b611e776125db565b60606124b683836000612613565b9392505050565b806001600160a01b03163b60000361250c576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611fe6565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6060600080846001600160a01b03168460405161258291906130c8565b600060405180830381855af49150503d80600081146125bd576040519150601f19603f3d011682016040523d82523d6000602084013e6125c2565b606091505b50915091506125d28583836126c9565b95945050505050565b3415610e96576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081471015612651576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401611fe6565b600080856001600160a01b0316848660405161266d91906130c8565b60006040518083038185875af1925050503d80600081146126aa576040519150601f19603f3d011682016040523d82523d6000602084013e6126af565b606091505b50915091506126bf8683836126c9565b9695505050505050565b6060826126de576126d98261273e565b6124b6565b81511580156126f557506001600160a01b0384163b155b15612737576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401611fe6565b50806124b6565b80511561274e5780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6105eb806130e583390190565b610545806136d083390190565b6000602082840312156127ac57600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146124b657600080fd5b6001600160a01b0381168114610b6057600080fd5b60006020828403121561280357600080fd5b81356124b6816127dc565b60006020828403121561282057600080fd5b5035919050565b6000806040838503121561283a57600080fd5b82359150602083013561284c816127dc565b809150509250929050565b6000806040838503121561286a57600080fd5b8235612875816127dc565b9150602083013561284c816127dc565b60008083601f84011261289757600080fd5b50813567ffffffffffffffff8111156128af57600080fd5b6020830191508360208285010111156128c757600080fd5b9250929050565b600080600080604085870312156128e457600080fd5b843567ffffffffffffffff8111156128fb57600080fd5b61290787828801612885565b909550935050602085013567ffffffffffffffff81111561292757600080fd5b61293387828801612885565b95989497509550505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160c0810167ffffffffffffffff811182821017156129915761299161293f565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156129c0576129c061293f565b604052919050565b600080604083850312156129db57600080fd5b82356129e6816127dc565b9150602083013567ffffffffffffffff811115612a0257600080fd5b8301601f81018513612a1357600080fd5b803567ffffffffffffffff811115612a2d57612a2d61293f565b612a406020601f19601f84011601612997565b818152866020838501011115612a5557600080fd5b816020840160208301376000602083830101528093505050509250929050565b60008060008060808587031215612a8b57600080fd5b8435612a96816127dc565b93506020850135612aa6816127dc565b93969395505050506040820135916060013590565b60008060408385031215612ace57600080fd5b8235612ad9816127dc565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600060c08201905082518252602083015160208301526001600160a01b036040840151166040830152606083015160038110612b5457612b54612ae7565b8060608401525060808301511515608083015260a083015160a083015292915050565b60005b83811015612b92578181015183820152602001612b7a565b50506000910152565b60008151808452612bb3816020860160208601612b77565b601f01601f19169290920160200192915050565b6020815260006124b66020830184612b9b565b60008060008060808587031215612bf057600080fd5b8435612bfb816127dc565b966020860135965060408601359560600135945092505050565b600080600080600060a08688031215612c2d57600080fd5b8535612c38816127dc565b94506020860135612c48816127dc565b94979496505050506040830135926060810135926080909101359150565b60008060008060608587031215612c7c57600080fd5b8435612c87816127dc565b9350602085013567ffffffffffffffff811115612ca357600080fd5b612caf87828801612885565b909450925050604085013560028110612cc757600080fd5b939692955090935050565b600080600080600060a08688031215612cea57600080fd5b8535612cf5816127dc565b94506020860135612d05816127dc565b93506040860135612d15816127dc565b94979396509394606081013594506080013592915050565b600181811c90821680612d4157607f821691505b602082108103612d7a577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b601f821115610a1357806000526020600020601f840160051c81016020851015612da75750805b601f840160051c820191505b81811015612dc75760008155600101612db3565b5050505050565b67ffffffffffffffff831115612de657612de661293f565b612dfa83612df48354612d2d565b83612d80565b6000601f841160018114612e4c5760008515612e165750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355612dc7565b600083815260209020601f19861690835b82811015612e7d5786850135825560209485019460019092019101612e5d565b5086821015612eb8577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555050505050565b600060208284031215612edc57600080fd5b81516124b6816127dc565b80518015158114612ef757600080fd5b919050565b600060c0828403128015612f0f57600080fd5b506000612f1a61296e565b83518152602080850151908201526040840151612f36816127dc565b6040820152606084015160038110612f4c578283fd5b6060820152612f5d60808501612ee7565b608082015260a09384015193810193909352509092915050565b808201808211156109e3577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8183823760009101908152919050565b6001600160a01b0383168152604060208201526000610f626040830184612b9b565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b6001600160a01b03861681526001600160a01b0385166020820152608060408201526000613040608083018587612fe3565b90506002831061305257613052612ae7565b8260608301529695505050505050565b6001600160a01b03851681526001600160a01b03841660208201526060604082015260006126bf606083018486612fe3565b6000602082840312156130a657600080fd5b5051919050565b6000602082840312156130bf57600080fd5b6124b682612ee7565b600082516130da818460208701612b77565b919091019291505056fe60a06040526040516105eb3803806105eb83398101604081905261002291610387565b61002c828261003e565b506001600160a01b0316608052610484565b610047826100fe565b6040516001600160a01b038316907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e90600090a28051156100f2576100ed826001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e7919061044d565b82610211565b505050565b6100fa610288565b5050565b806001600160a01b03163b60000361013957604051631933b43b60e21b81526001600160a01b03821660048201526024015b60405180910390fd5b807fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5080546001600160a01b0319166001600160a01b0392831617905560408051635c60da1b60e01b81529051600092841691635c60da1b9160048083019260209291908290030181865afa1580156101b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d9919061044d565b9050806001600160a01b03163b6000036100fa57604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610130565b6060600080846001600160a01b03168460405161022e9190610468565b600060405180830381855af49150503d8060008114610269576040519150601f19603f3d011682016040523d82523d6000602084013e61026e565b606091505b50909250905061027f8583836102a9565b95945050505050565b34156102a75760405163b398979f60e01b815260040160405180910390fd5b565b6060826102be576102b982610308565b610301565b81511580156102d557506001600160a01b0384163b155b156102fe57604051639996b31560e01b81526001600160a01b0385166004820152602401610130565b50805b9392505050565b8051156103185780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80516001600160a01b038116811461034857600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561037e578181015183820152602001610366565b50506000910152565b6000806040838503121561039a57600080fd5b6103a383610331565b60208401519092506001600160401b038111156103bf57600080fd5b8301601f810185136103d057600080fd5b80516001600160401b038111156103e9576103e961034d565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104175761041761034d565b60405281815282820160200187101561042f57600080fd5b610440826020830160208601610363565b8093505050509250929050565b60006020828403121561045f57600080fd5b61030182610331565b6000825161047a818460208701610363565b9190910192915050565b60805161014d61049e60003960006024015261014d6000f3fe608060405261000c61000e565b005b61001e610019610020565b6100b6565b565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561008d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100b191906100da565b905090565b3660008037600080366000845af43d6000803e8080156100d5573d6000f35b3d6000fd5b6000602082840312156100ec57600080fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811461011057600080fd5b939250505056fea2646970667358221220847da51342687254596c326192e2f3d8105e3ef1bf337cd24124316a6711d7ad64736f6c634300081c0033608060405234801561001057600080fd5b5060405161054538038061054583398101604081905261002f91610165565b806001600160a01b03811661005f57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61006881610079565b50610072826100c9565b5050610198565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b806001600160a01b03163b6000036100ff5760405163211eb15960e21b81526001600160a01b0382166004820152602401610056565b600180546001600160a01b0319166001600160a01b0383169081179091556040517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b80516001600160a01b038116811461016057600080fd5b919050565b6000806040838503121561017857600080fd5b61018183610149565b915061018f60208401610149565b90509250929050565b61039e806101a76000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c8063715018a611610050578063715018a6146100c45780638da5cb5b146100cc578063f2fde38b146100ea57600080fd5b80633659cfe61461006c5780635c60da1b14610081575b600080fd5b61007f61007a36600461032b565b6100fd565b005b60015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61007f610111565b60005473ffffffffffffffffffffffffffffffffffffffff1661009b565b61007f6100f836600461032b565b610125565b61010561018b565b61010e816101de565b50565b61011961018b565b61012360006102b6565b565b61012d61018b565b73ffffffffffffffffffffffffffffffffffffffff8116610182576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b61010e816102b6565b60005473ffffffffffffffffffffffffffffffffffffffff163314610123576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610179565b8073ffffffffffffffffffffffffffffffffffffffff163b600003610247576040517f847ac56400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401610179565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561033d57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461036157600080fd5b939250505056fea2646970667358221220e240865f9ac07da05345e9974bc71e5d074faab729148d0ee16b859b84ebd81e64736f6c634300081c0033a2646970667358221220f0c86978e9f7f059a23164735ea8a6387f09fd3b95fa34eee09c169739b0bbbe64736f6c634300081c0033

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
0xb6279106b9789938Aa1A4a6aC8507459CC4c9565
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]

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