creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlUpgradeable.sol\";\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../utils/StringsUpgradeable.sol\";\nimport \"../utils/introspection/ERC165Upgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n *     require(hasRole(MY_ROLE, msg.sender));\n *     ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {\n    struct RoleData {\n        mapping(address => bool) members;\n        bytes32 adminRole;\n    }\n\n    mapping(bytes32 => RoleData) private _roles;\n\n    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n    /**\n     * @dev Modifier that checks that an account has a specific role. Reverts\n     * with a standardized message including the required role.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     *\n     * _Available since v4.1._\n     */\n    modifier onlyRole(bytes32 role) {\n        _checkRole(role);\n        _;\n    }\n\n    function __AccessControl_init() internal onlyInitializing {\n    }\n\n    function __AccessControl_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n        return _roles[role].members[account];\n    }\n\n    /**\n     * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n     * Overriding this function changes the behavior of the {onlyRole} modifier.\n     *\n     * Format of the revert message is described in {_checkRole}.\n     *\n     * _Available since v4.6._\n     */\n    function _checkRole(bytes32 role) internal view virtual {\n        _checkRole(role, _msgSender());\n    }\n\n    /**\n     * @dev Revert with a standard message if `account` is missing `role`.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     */\n    function _checkRole(bytes32 role, address account) internal view virtual {\n        if (!hasRole(role, account)) {\n            revert(\n                string(\n                    abi.encodePacked(\n                        \"AccessControl: account \",\n                        StringsUpgradeable.toHexString(account),\n                        \" is missing role \",\n                        StringsUpgradeable.toHexString(uint256(role), 32)\n                    )\n                )\n            );\n        }\n    }\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n        return _roles[role].adminRole;\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been revoked `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function renounceRole(bytes32 role, address account) public virtual override {\n        require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event. Note that unlike {grantRole}, this function doesn't perform any\n     * checks on the calling account.\n     *\n     * May emit a {RoleGranted} event.\n     *\n     * [WARNING]\n     * ====\n     * This function should only be called from the constructor when setting\n     * up the initial roles for the system.\n     *\n     * Using this function in any other way is effectively circumventing the admin\n     * system imposed by {AccessControl}.\n     * ====\n     *\n     * NOTE: This function is deprecated in favor of {_grantRole}.\n     */\n    function _setupRole(bytes32 role, address account) internal virtual {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Sets `adminRole` as ``role``'s admin role.\n     *\n     * Emits a {RoleAdminChanged} event.\n     */\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n        bytes32 previousAdminRole = getRoleAdmin(role);\n        _roles[role].adminRole = adminRole;\n        emit RoleAdminChanged(role, previousAdminRole, adminRole);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function _grantRole(bytes32 role, address account) internal virtual {\n        if (!hasRole(role, account)) {\n            _roles[role].members[account] = true;\n            emit RoleGranted(role, account, _msgSender());\n        }\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function _revokeRole(bytes32 role, address account) internal virtual {\n        if (hasRole(role, account)) {\n            _roles[role].members[account] = false;\n            emit RoleRevoked(role, account, _msgSender());\n        }\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControlUpgradeable {\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     *\n     * _Available since v3.1._\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {AccessControl-_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     */\n    function renounceRole(bytes32 role, address account) external;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    function __Ownable_init() internal onlyInitializing {\n        __Ownable_init_unchained();\n    }\n\n    function __Ownable_init_unchained() internal onlyInitializing {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts.\n     *\n     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n     * constructor.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n     * are added through upgrades and that require initialization.\n     *\n     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n     * cannot be nested. If one is invoked in the context of another, execution will revert.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     *\n     * WARNING: setting the version to 255 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     *\n     * Emits an {Initialized} event the first time it is successfully executed.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized != type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint8) {\n        return _initialized;\n    }\n\n    /**\n     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n     */\n    function _isInitializing() internal view returns (bool) {\n        return _initializing;\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    bool private _paused;\n\n    /**\n     * @dev Initializes the contract in unpaused state.\n     */\n    function __Pausable_init() internal onlyInitializing {\n        __Pausable_init_unchained();\n    }\n\n    function __Pausable_init_unchained() internal onlyInitializing {\n        _paused = false;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        _requireNotPaused();\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        _requirePaused();\n        _;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        return _paused;\n    }\n\n    /**\n     * @dev Throws if the contract is paused.\n     */\n    function _requireNotPaused() internal view virtual {\n        require(!paused(), \"Pausable: paused\");\n    }\n\n    /**\n     * @dev Throws if the contract is not paused.\n     */\n    function _requirePaused() internal view virtual {\n        require(paused(), \"Pausable: not paused\");\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        _paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        _paused = false;\n        emit Unpaused(_msgSender());\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/security/PullPaymentUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (security/PullPayment.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/escrow/EscrowUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Simple implementation of a\n * https://consensys.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls[pull-payment]\n * strategy, where the paying contract doesn't interact directly with the\n * receiver account, which must withdraw its payments itself.\n *\n * Pull-payments are often considered the best practice when it comes to sending\n * Ether, security-wise. It prevents recipients from blocking execution, and\n * eliminates reentrancy concerns.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n *\n * To use, derive from the `PullPayment` contract, and use {_asyncTransfer}\n * instead of Solidity's `transfer` function. Payees can query their due\n * payments with {payments}, and retrieve them with {withdrawPayments}.\n *\n * @custom:storage-size 51\n */\nabstract contract PullPaymentUpgradeable is Initializable {\n    EscrowUpgradeable private _escrow;\n\n    function __PullPayment_init() internal onlyInitializing {\n        __PullPayment_init_unchained();\n    }\n\n    function __PullPayment_init_unchained() internal onlyInitializing {\n        _escrow = new EscrowUpgradeable();\n        _escrow.initialize();\n    }\n\n    /**\n     * @dev Withdraw accumulated payments, forwarding all gas to the recipient.\n     *\n     * Note that _any_ account can call this function, not just the `payee`.\n     * This means that contracts unaware of the `PullPayment` protocol can still\n     * receive funds this way, by having a separate account call\n     * {withdrawPayments}.\n     *\n     * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.\n     * Make sure you trust the recipient, or are either following the\n     * checks-effects-interactions pattern or using {ReentrancyGuard}.\n     *\n     * @param payee Whose payments will be withdrawn.\n     *\n     * Causes the `escrow` to emit a {Withdrawn} event.\n     */\n    function withdrawPayments(address payable payee) public virtual {\n        _escrow.withdraw(payee);\n    }\n\n    /**\n     * @dev Returns the payments owed to an address.\n     * @param dest The creditor's address.\n     */\n    function payments(address dest) public view returns (uint256) {\n        return _escrow.depositsOf(dest);\n    }\n\n    /**\n     * @dev Called by the payer to store the sent amount as credit to be pulled.\n     * Funds sent in this way are stored in an intermediate {Escrow} contract, so\n     * there is no danger of them being spent before withdrawal.\n     *\n     * @param dest The destination address of the funds.\n     * @param amount The amount to transfer.\n     *\n     * Causes the `escrow` to emit a {Deposited} event.\n     */\n    function _asyncTransfer(address dest, uint256 amount) internal virtual {\n        _escrow.deposit{value: amount}(dest);\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant _NOT_ENTERED = 1;\n    uint256 private constant _ENTERED = 2;\n\n    uint256 private _status;\n\n    function __ReentrancyGuard_init() internal onlyInitializing {\n        __ReentrancyGuard_init_unchained();\n    }\n\n    function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        _nonReentrantBefore();\n        _;\n        _nonReentrantAfter();\n    }\n\n    function _nonReentrantBefore() private {\n        // On the first call to nonReentrant, _status will be _NOT_ENTERED\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n     * `nonReentrant` function in the call stack.\n     */\n    function _reentrancyGuardEntered() internal view returns (bool) {\n        return _status == _ENTERED;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n *     doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n *     token.safeTransferFrom(msg.sender, address(this), value);\n *     ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20PermitUpgradeable {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     *\n     * CAUTION: See Security Considerations above.\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n    using AddressUpgradeable for address;\n\n    /**\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    /**\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n     */\n    function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    /**\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n        uint256 oldAllowance = token.allowance(address(this), spender);\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n    }\n\n    /**\n     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n        }\n    }\n\n    /**\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n     * to be set to zero before setting it to a non-zero value, such as USDT.\n     */\n    function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n        if (!_callOptionalReturnBool(token, approvalCall)) {\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n            _callOptionalReturn(token, approvalCall);\n        }\n    }\n\n    /**\n     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n     * Revert on invalid signature.\n     */\n    function safePermit(\n        IERC20PermitUpgradeable token,\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal {\n        uint256 nonceBefore = token.nonces(owner);\n        token.permit(owner, spender, value, deadline, v, r, s);\n        uint256 nonceAfter = token.nonces(owner);\n        require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     *\n     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n     */\n    function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n        // and not revert is the subcall reverts.\n\n        (bool success, bytes memory returndata) = address(token).call(data);\n        return\n            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token));\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     *\n     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary CountersUpgradeable {\n    struct Counter {\n        // This variable should never be directly accessed by users of the library: interactions must be restricted to\n        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n        // this feature: see https://github.com/ethereum/solidity/issues/4637\n        uint256 _value; // default: 0\n    }\n\n    function current(Counter storage counter) internal view returns (uint256) {\n        return counter._value;\n    }\n\n    function increment(Counter storage counter) internal {\n        unchecked {\n            counter._value += 1;\n        }\n    }\n\n    function decrement(Counter storage counter) internal {\n        uint256 value = counter._value;\n        require(value > 0, \"Counter: decrement overflow\");\n        unchecked {\n            counter._value = value - 1;\n        }\n    }\n\n    function reset(Counter storage counter) internal {\n        counter._value = 0;\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/escrow/EscrowUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/escrow/Escrow.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../access/OwnableUpgradeable.sol\";\nimport \"../AddressUpgradeable.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @title Escrow\n * @dev Base escrow contract, holds funds designated for a payee until they\n * withdraw them.\n *\n * Intended usage: This contract (and derived escrow contracts) should be a\n * standalone contract, that only interacts with the contract that instantiated\n * it. That way, it is guaranteed that all Ether will be handled according to\n * the `Escrow` rules, and there is no need to check for payable functions or\n * transfers in the inheritance tree. The contract that uses the escrow as its\n * payment method should be its owner, and provide public methods redirecting\n * to the escrow's deposit and withdraw.\n */\ncontract EscrowUpgradeable is Initializable, OwnableUpgradeable {\n    using AddressUpgradeable for address payable;\n\n    event Deposited(address indexed payee, uint256 weiAmount);\n    event Withdrawn(address indexed payee, uint256 weiAmount);\n\n    mapping(address => uint256) private _deposits;\n\n    function __Escrow_init() internal onlyInitializing {\n        __Ownable_init_unchained();\n    }\n\n    function __Escrow_init_unchained() internal onlyInitializing {\n    }\n    function initialize() public virtual initializer {\n        __Escrow_init();\n    }\n    function depositsOf(address payee) public view returns (uint256) {\n        return _deposits[payee];\n    }\n\n    /**\n     * @dev Stores the sent amount as credit to be withdrawn.\n     * @param payee The destination address of the funds.\n     *\n     * Emits a {Deposited} event.\n     */\n    function deposit(address payee) public payable virtual onlyOwner {\n        uint256 amount = msg.value;\n        _deposits[payee] += amount;\n        emit Deposited(payee, amount);\n    }\n\n    /**\n     * @dev Withdraw accumulated balance for a payee, forwarding all gas to the\n     * recipient.\n     *\n     * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.\n     * Make sure you trust the recipient, or are either following the\n     * checks-effects-interactions pattern or using {ReentrancyGuard}.\n     *\n     * @param payee The address whose funds will be withdrawn and transferred to.\n     *\n     * Emits a {Withdrawn} event.\n     */\n    function withdraw(address payable payee) public virtual onlyOwner {\n        uint256 payment = _deposits[payee];\n\n        _deposits[payee] = 0;\n\n        payee.sendValue(payment);\n\n        emit Withdrawn(payee, payment);\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n    function __ERC165_init() internal onlyInitializing {\n    }\n\n    function __ERC165_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165Upgradeable).interfaceId;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod0 := mul(x, y)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1, \"Math: mulDiv overflow\");\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n            // See https://cs.stackexchange.com/q/138556/92363.\n\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 twos = denominator & (~denominator + 1);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/math/SignedMathUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMathUpgradeable {\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two signed numbers.\n     */\n    function min(int256 a, int256 b) internal pure returns (int256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two signed numbers without overflow.\n     * The result is rounded towards zero.\n     */\n    function average(int256 a, int256 b) internal pure returns (int256) {\n        // Formula from the book \"Hacker's Delight\"\n        int256 x = (a & b) + ((a ^ b) >> 1);\n        return x + (int256(uint256(x) >> 255) & (a ^ b));\n    }\n\n    /**\n     * @dev Returns the absolute unsigned value of a signed value.\n     */\n    function abs(int256 n) internal pure returns (uint256) {\n        unchecked {\n            // must be unchecked in order to support `n = type(int256).min`\n            return uint256(n >= 0 ? n : -n);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\nimport \"./math/SignedMathUpgradeable.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n    bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n    uint8 private constant _ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            uint256 length = MathUpgradeable.log10(value) + 1;\n            string memory buffer = new string(length);\n            uint256 ptr;\n            /// @solidity memory-safe-assembly\n            assembly {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                /// @solidity memory-safe-assembly\n                assembly {\n                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toString(int256 value) internal pure returns (string memory) {\n        return string(abi.encodePacked(value < 0 ? \"-\" : \"\", toString(SignedMathUpgradeable.abs(value))));\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            return toHexString(value, MathUpgradeable.log256(value) + 1);\n        }\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n}\n"
      },
      "contracts/interfaces/IFeeDistributor.sol": {
        "content": "// SPDX-License-Identifier: UNLICSENSED\npragma solidity 0.8.18;\n\ninterface IFeeDistributor {\n    /**\n     * @dev Defines a fee item during a fee distribution request. It specifies\n     * the following fields:\n     * - `payee` who should receve a fee transfer\n     * - `token` symbol (e.g. ETH, MATIC, USDC, APE)\n     * - `amount` which the `payee` should receive\n     */\n    struct Fee {\n        address payable payee;\n        bytes32 token;\n        uint256 amount;\n    }\n\n    /**\n     * @dev Emitted when some Ether amount received by the current contract.\n     */\n    event EtherReceived(address sender, uint256 value);\n\n    /**\n     * @dev Emitted when a limit of fee item count is set for a given caller.\n     */\n    event FeeCountLimitSet(uint256 feeCountLimit);\n\n    /**\n     * @dev Emitted when an ERC20 token used for fee distribution is registered.\n     */\n    event TokenAddressSet(bytes32 tokenSymbol, address tokenAddress);\n\n    /**\n     * @dev Emitted when fees are distributed for a given caller.\n     */\n    event FeesDistributed(uint256 feeCount);\n\n    /**\n     * @dev Fee item count exceeded an upper boundary for a given caller.\n     */\n    error FeeCountLimitExceeded(uint256 feeCount);\n\n    /**\n     * @dev Sets an item limit for each fee distribution request. The limit is specific for\n     * each caller. If the limit is not set, the contract-wide default value is used.\n     *\n     * Emits a {FeeCountLimitSet} event.\n     */\n    function setFeeCountLimit(address contractAddress, uint256 feeCountLimit) external;\n\n    /**\n     * @dev Set an ERC20 token which is allowed to be used for fee distribution.\n     *\n     * Emits a {TokenAddressSet} event.\n     */\n    function setTokenAddress(bytes32 tokenSymbol, address tokenAddress) external;\n\n    /**\n     * @dev Pauses the current contract, e.g. in case of an emergency.\n     *\n     * Emits a {Paused} event.\n     */\n    function pause() external;\n\n    /**\n     * @dev Unpauses the current contract.\n     *\n     * Emits an {Unpaused} event.\n     */\n    function unpause() external;\n\n    /**\n     * @dev Distributes fees, which can be expressed both in a native token\n     * (e.g. Ether, Matic) and/or in a registered ERC20 token. Native and ERC20 fee\n     * distributions can be intermixed in a single request.\n     *\n     * Requirements:\n     *\n     * - the `fees` item count is limited for each caller. If the limit for a caller\n     * is not specified, the contract-wide default value is used.\n     *\n     * WARNING: If a caller sends some excessive native token amount, it is locked up\n     * in an escrow. This amount can be released further by executing\n     * `withdrawPayments` method for the given caller.\n     *\n     * Emits a {FeesDistributed} event.\n     *\n     * Also, can emit an {EtherReceived} event if a caller sends an execessive native\n     * token amount.\n     */\n    function distributeFees(Fee[] calldata fees) external payable;\n\n    /**\n     * @dev Returns the token address by its symbol.\n     */\n    function tokenAddresses(bytes32 tokenSymbol) external view returns (address);\n}\n"
      },
      "contracts/interfaces/IIncinerator.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.18;\n\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\n\ninterface IIncinerator {\n    /**\n     * @dev Defines data required to burn a token within an NFT collection\n     *  - `collection` is the address of an NFT collection.\n     *  - `tokenId` is the token identifier within this NFT collection.\n     */\n    struct NFTItem {\n        address collection;\n        uint256 tokenId;\n    }\n\n    /**\n     * @dev Defines data required to burn items with a permit. See\n     * the {permitBurnItems} method for more details.\n     *  - `hash` is a hash signed by a user.\n     *  - `signature` is a user's signatured.\n     */\n    struct Message {\n        bytes32 hash;\n        bytes signature;\n    }\n\n    /**\n     * @dev Emitted when some Ether amount received by the current contract.\n     */\n    event EtherReceived(address sender, uint256 value);\n\n    /**\n     * @dev Emitted when the address of a verifier contract is set.\n     */\n    event VerifierSet(address indexed verifier);\n\n    /**\n     * @dev Emitted when an allowed range of tokens to be burnt.\n     *\n     * Emits an {NFTItemRangeSet} event.\n     */\n    event NFTItemRangeSet(uint8[2] nftItemRange);\n\n    /**\n     * @dev Emitted when the address of a NFT operator contract is set.\n     */\n    event NFTOperatorSet(address indexed nftOperator);\n\n    /**\n     * @dev Emitted when the address of a fee distributor contract is set.\n     */\n    event FeeDistributorSet(address indexed feeDistributor);\n\n    /**\n     * @dev Emitted when a group of tokens burnt within an NFT collection.\n     */\n    event TokensBurnt(uint256 nftItemCount);\n\n    /**\n     * @dev Emitted when a group of tokens burnt within an NFT collection.\n     */\n    event TransactionProcessed(uint256 indexed transactionId);\n\n    /**\n     * @dev The zero address of a verifier contract is given.\n     */\n    error ZeroVerifier();\n\n    /**\n     * @dev The zero address of an NFT operator contract is given.\n     */\n    error ZeroNFTOperator();\n\n    /**\n     * @dev The zero address of a fee distributor contract is given.\n     */\n    error ZeroFeeDistributor();\n\n    /**\n     * @dev The item count is out of an allowed range.\n     */\n    error NFTItemRangeMissed(uint8[2] nftItemRange, uint256 currentNFTItemCount);\n\n    /**\n     * @dev The lower boundary of an item range is greater than the upper one.\n     */\n    error InconsistentNFTItemRange(uint8[2] nftItemRange);\n\n    /**\n     * @dev The upper boundary for token burns within a certain deduplication group\n     * identifier is reached.\n     */\n    error MaxItemUsageReached(uint256 deduplicationId, uint256 currentUsage);\n\n    /**\n     * @dev An invalid NFT owner attempts to burn a token with a permit.\n     */\n    error InvalidNFTOwner(address collection, uint256 tokenId, address currentOwner, address claimedOnwer);\n\n    /**\n     * @dev Sets the address of a verifier contract, which allows to verify\n     * signatures restricted to authorized callers only.\n     *\n     * Emits a {VerifierSet} event.\n     */\n    function setVerifier(address verifier) external;\n\n    /**\n     * @dev Sets an allowed range of tokens to be burnt.\n     *\n     * Emits an {NFTItemRangeSet} event.\n     */\n    function setNFTItemRange(uint8[2] calldata nftItemRange) external;\n\n    /**\n     * @dev Sets the address of an NFT oeperator contract, which manages token\n     * approvals.\n     *\n     * Emits an {NFTOperatorSet} event.\n     */\n    function setNFTOperator(address nftOperator) external;\n\n    /**\n     * @dev Sets the address of a fee distributor contract, which handles fee\n     * distribution from a caller.\n     *\n     * Emits a {FeeDistributor} event.\n     */\n    function setFeeDistributor(address feeDistributor) external;\n\n    /**\n     * @dev Pauses the current contract, e.g. in case of an emergency.\n     *\n     * Emits a {Paused} event.\n     */\n    function pause() external;\n\n    /**\n     * @dev Unpauses the current contract.\n     *\n     * Emits an {Unpaused} event.\n     */\n    function unpause() external;\n\n    /**\n     * @dev Handles token burning within an NFT collection.\n     *\n     * Requirements:\n     *\n     * - Before calling this method, it is required to generate a hash from the hash\n     *   getter with corresponding parameters and sign it by an authorized caller\n     *   registerd at the {Verifier} contract.\n     *\n     * Emits {TokensBurnt} and {TransactionProcessed} events.\n     */\n    function burnItems(\n        uint256 transactionId,\n        uint256 deduplicationId,\n        uint256 maxUsage,\n        NFTItem[] calldata nftItems,\n        IFeeDistributor.Fee[] calldata fees,\n        bytes calldata signature\n    ) external payable;\n\n    /**\n     * @dev Handles token burning within an NFT collection with a permit, i.e. it\n     * it is required to provide a user's signatures to enable gasless transactions.\n     *\n     * Requirements:\n     *\n     * - Before calling this method, it is required to generate a hash from the hash\n     *   getter with corresponding parameters and sign it by an authorized caller\n     *   registerd at the {Verifier} contract.\n     *\n     * Emits {TokensBurnt} and {TransactionProcessed} events.\n     */\n    function permitBurnItems(\n        uint256 transactionId,\n        uint256 deduplicationId,\n        uint256 maxUsage,\n        NFTItem[] calldata nftItems,\n        IFeeDistributor.Fee[] calldata fees,\n        Message calldata message,\n        bytes calldata signature\n    ) external payable;\n\n    /**\n     * @dev Generates a hash in order to call the method to burn items.\n     */\n    function burnItemsHash(\n        uint256 transactionId,\n        uint256 deduplicationId,\n        uint256 maxUsage,\n        NFTItem[] calldata nftItems,\n        IFeeDistributor.Fee[] calldata fees,\n        address sender\n    ) external pure returns (bytes32);\n\n    /**\n     * @dev Generates a hash in order to call the method to burn items with a permit.\n     */\n    function permitBurnItemsHash(\n        uint256 transactionId,\n        uint256 deduplicationId,\n        uint256 maxUsage,\n        NFTItem[] calldata nftItems,\n        IFeeDistributor.Fee[] calldata fees,\n        Message calldata message,\n        address sender\n    ) external pure returns (bytes32);\n}\n"
      },
      "contracts/interfaces/INFTFactory.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.18;\n\nimport { CountersUpgradeable } from \"@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol\";\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\nimport { IRoyaltySplitter } from \"./IRoyaltySplitter.sol\";\n\ninterface INFTFactory {\n    /**\n     * @dev Defines parameters to create an NFT collection:\n     *  - `transactionId` is an transaction identifier required to track it on\n     *    the caller's side.\n     *  - `collectionsId` is an NFT collection identifier required to track it on\n     *    the caller's side.\n     *  - `name` is an NFT collection name.\n     *  - `symbol` is an NFT collection symbol.\n     *  - `itemLimit` is the upper boundary for token mints within an NFT collection.\n     *  - `royalites` is an optional list of royalties to be distributed between\n     *    payees with their shares at the collection wide level.\n     *  - `fees` is an optional list of fees to be distributed between payees.\n     */\n    struct CreateCollectionParams {\n        uint256 transactionId;\n        uint256 collectionId;\n        string name;\n        string symbol;\n        uint256 itemLimit;\n        IRoyaltySplitter.Royalty[] royalties;\n        IFeeDistributor.Fee[] fees;\n    }\n\n    /**\n     * @dev Defines parameters to mint an item within an NFT collection:\n     *  - `transactionId` is an transaction identifier required to track it on\n     *    the caller's side.\n     *  - `collectionsId` is a NFT collection identifier required to track it on\n     *    the caller's side.\n     *  - `deduplicationId` is deduplication group identifier used to define\n     *    the upper boundary of token mints within an NFT collection.\n     *  - `maxItemSupply` is the maximum item limit set for a certain deduplication\n     *    group identifier.\n     *  - `tokenId` is a token identifier generated on the caller's side.\n     *  - `tokenReceiver` is an account which is intended to receive a token.\n     *  - `tokenURI` is a token URI generated on the caller's side.\n     *  - `deadline` is a timestamp when a request expires. It is required for pass\n     *     claiming only and ignored during direct item minting\n     *  - `royalites` is an optional list of royalties to be distributed between\n     *    payees with their shares at the token level.\n     *  - `fees` is an optional list of fees to be distributed between payees.\n     */\n    struct MintItemParams {\n        uint256 transactionId;\n        uint256 collectionId;\n        uint256 deduplicationId;\n        uint256 maxItemSupply;\n        uint256 tokenId;\n        address tokenReceiver;\n        string tokenURI;\n        uint256 deadline;\n        IRoyaltySplitter.Royalty[] royalties;\n        IFeeDistributor.Fee[] fees;\n    }\n\n    /**\n     * @dev Defines a registered NFT collection:\n     *  - `nft` is the address of an NFT collection.\n     *  - `itemLimit` is the upper boundary for token mints within an NFT collection.\n     *  - `itemCount` is the current number of token mints within an NFT collection.\n     */\n    struct Collection {\n        address nft;\n        uint256 itemLimit;\n        CountersUpgradeable.Counter itemCount;\n    }\n\n    /**\n     * @dev Emitted when some Ether amount received by the current contract.\n     */\n    event EtherReceived(address sender, uint256 value);\n\n    /**\n     * @dev Emitted when the address of a verifier contract is set.\n     */\n    event VerifierSet(address indexed verifier);\n\n    /**\n     * @dev Emitted when the address of an NFT deployer contract is set.\n     */\n    event NFTDeployerSet(address indexed nftDeployer);\n\n    /**\n     * @dev Emitted when the default royalty for an NFT collection is set.\n     */\n    event NFTDefaultRoyaltySet(uint256 indexed collectionId, address receiver, uint96 feeNumerator);\n\n    /**\n     * @dev Emitted when a token royalty for an NFT collection is set.\n     */\n    event NFTTokenRoyaltySet(\n        uint256 indexed collectionId,\n        uint256 indexed tokenId,\n        address receiver,\n        uint96 feeNumerator\n    );\n\n    /**\n     * @dev Emitted when the address of a royalty splitter contract is set.\n     */\n    event RoyaltySplitterSet(address indexed royaltySplitter);\n\n    /**\n     * @dev Emitted when the address of a fee distributor contract is set.\n     */\n    event FeeDistributorSet(address indexed feeDistributor);\n\n    /**\n     * @dev Emitted when a disablement status of an whitelist/blacklist registry for\n     * a registered NFT collection is set.\n     */\n    event NFTRegistryDisabled(uint256 indexed collectionId, bool registryDisabled);\n\n    /**\n     * @dev Emitted when ownership of a registered NFT collection is transferred to\n     * another account.\n     */\n    event NFTOwnershipTransferred(uint256 indexed collectionId, address newOwner);\n\n    /**\n     * @dev Emitted when the upper boundary for token mints within an NFT collection\n     * is set.\n     */\n    event MaxItemSupplySet(uint256 maxItemSupply);\n\n    /**\n     * @dev Emitted when an NFT collection is deployed into a blockchain.\n     */\n    event CollectionCreated(uint256 indexed collectionId);\n\n    /**\n     * @dev Emitted when a token is minted within an NFT collection.\n     */\n    event TokenMinted(uint256 indexed collectionId, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when either an NFT collection is created or a token within\n     * an NFT collection is minted.\n     */\n    event TransactionProcessed(uint256 indexed transactionId);\n\n    /**\n     * @dev Emitted when fees are distributed for a given caller.\n     */\n    event FeesDistributed(uint256 feeCount);\n\n    /**\n     * @dev The zero address of a verifier contract is given.\n     */\n    error ZeroVerifier();\n\n    /**\n     * @dev The zero address of a NFT deployer contract is given.\n     */\n    error ZeroNFTDeployer();\n\n    /**\n     * @dev The zero address of an royalty splitter contract is given.\n     */\n    error ZeroRoyaltySplitter();\n\n    /**\n     * @dev The zero address of a fee distributor contract is given.\n     */\n    error ZeroFeeDistributor();\n\n    /**\n     * @dev An NFT collection has been already registered in the current contract.\n     */\n    error CollectionExists(uint256 collectionId);\n\n    /**\n     * @dev An NFT collection is not registred in the current contract.\n     */\n    error CollectionNotFound(uint256 collectionId);\n\n    /**\n     * @dev The maximum number of token mints within an NFT collection exceeds\n     * the allowed upper boundary.\n     */\n    error CollectionItemLimitExceeded(uint256 collectionId, uint256 currentItemCount);\n\n    /**\n     * @dev The maximum number of token mints within a deduplication group identifier\n     * exceeds the allowed upper boundary.\n     */\n    error ItemSupplyLimitExceeded(uint256 collectionId, uint256 deduplicationId, uint256 currentItemSupply);\n\n    /**\n     * @dev Sets the address of a verifier contract, which allows to verify\n     * signatures restricted to authorized callers only.\n     *\n     * Emits a {VerifierSet} event.\n     */\n    function setVerifier(address verifier) external;\n\n    /**\n     * @dev Sets the address of a NFT deployer contract, which is responsible for\n     * deployment of NFT collections into a blockchain.\n     *\n     * Emits an {NFTDeployerSet} event.\n     */\n    function setNFTDeployer(address nftDeployer) external;\n\n    /**\n     * @dev Sets the address of a royalty splitter contract, which manages royalty\n     * shares for created NFT collections and tokens related to them.\n     *\n     * Emits a {RoyaltySplitterSet} event.\n     */\n    function setRoyaltySplitter(address royaltySplitter) external;\n\n    /**\n     * @dev Sets the address of a fee distributor contract, which handles any fee\n     * transfers connected with NFT collection creation and a token mint.\n     *\n     * Emits a {FeeDistributorSet} event.\n     */\n    function setFeeDistributor(address feeDistributor) external;\n\n    /**\n     * @dev Pauses the current contract, e.g. in case of an emergency.\n     *\n     * Emits a {Paused} event.\n     */\n    function pause() external;\n\n    /**\n     * @dev Unpauses the current contract.\n     *\n     * Emits an {Unpaused} event.\n     */\n    function unpause() external;\n\n    /**\n     * @dev Sets the disablement status of a whitelist/blacklist registry in an NFT\n     * collection registered in the current contract.\n     *\n     * Emits an {NFTRegistryDisabled} event.\n     */\n    function setNFTRegistryDisabled(uint256 collectionId, bool registryDisabled) external;\n\n    /**\n     * @dev Sets the default royalty for a given NFT collection.\n     *\n     * Emits an {NFTDefaultRoyaltySet} event.\n     */\n    function setNFTDefaultRoyalty(uint256 collectionId, address receiver, uint96 feeNumerator) external;\n\n    /**\n     * @dev Sets the token royalty for a given NFT collection.\n     *\n     * Emits an {NFTTokenRoyaltySet} event.\n     */\n    function setNFTTokenRoyalty(uint256 collectionId, uint256 tokenId, address receiver, uint96 feeNumerator) external;\n\n    /**\n     * @dev Transfers NFT collection's ownership from the current contract to a new\n     * account.\n     *\n     * Emits an {NFTOwnershipTransferred} event.\n     */\n    function transferNFTOwnership(uint256 collectionId, address newOwner) external;\n\n    /**\n     * @dev Deploys an upgradealbe NFT collection into a blockchain. The collection\n     * is represented by proxy and implementation contracts.\n     *\n     * A caller might additionally pass a list of collection wide royalties with\n     * payees and their shares. It causes creation a royalty fowrader contract bound\n     * to a royalty splitter contract. See the {RoyaltyForwarder} and\n     * {RoyaltySplitter} contracts for more detail.\n     *\n     * Also, a caller might additionally pass a list of fees, which are required to\n     * be distributed between payees.\n     *\n     * Requirements:\n     *\n     * - Before calling this method, it is required to generate a hash from the hash\n     *   getter with corresponding parameters and sign it by an authorized caller\n     *   registerd at the {Verifier} contract.\n     *\n     * Emits {CollectionCreated} and {TransactionProcessed} events.\n     */\n    function createCollection(CreateCollectionParams calldata params, bytes calldata signature) external payable;\n\n    /**\n     * @dev Mints a token within a registered NFT collection.\n     *\n     * A caller might additionally pass a list of token specific royalties with\n     * payees and their shares. It causes creation a royalty fowrader contract bound\n     * to a royalty splitter contract. See the {RoyaltyForwarder} and\n     * {RoyaltySplitter} contracts for more detail.\n     *\n     * Also, a caller might additionally pass a list of fees, which are required to\n     * be distributed between payees.\n     *\n     * Requirements:\n     *\n     * - Before calling this method, it is required to generate a hash from the hash\n     *   getter with corresponding parameters and sign it by an authorized caller\n     *   registerd at the {Verifier} contract.\n     *\n     * Emits {CollectionCreated} and {TransactionProcessed} events.\n     */\n    function mintItem(MintItemParams calldata params, bytes calldata signature) external payable;\n\n    /**\n     * @dev Mints a token within a registered NFT collection by an authorized account\n     * with the minter role (e.g. the {PassClaim} contract).\n     *\n     * A caller might additionally pass a list of token specific royalties with\n     * payees and their shares. It causes creation a royalty fowrader contract bound\n     * to a royalty splitter contract. See the {RoyaltyForwarder} and\n     * {RoyaltySplitter} contracts for more detail.\n     *\n     * Also, a caller might additionally pass a list of fees, which are required to\n     * be distributed between payees.\n     *\n     * Requirements:\n     *\n     * - Before calling this method, it is required to generate a hash from the hash\n     *   getter with corresponding parameters and sign it by an authorized caller\n     *   registerd at the {Verifier} contract.\n     *\n     * Emits {CollectionCreated} and {TransactionProcessed} events.\n     */\n    function mintItemUnsigned(MintItemParams calldata params) external payable;\n\n    /**\n     * @dev Computes the address of an NFT collection address based on the Create2\n     * opcode.\n     */\n    function computeCollectionAddress(\n        uint256 collectionId,\n        string memory name,\n        string memory symbol\n    ) external view returns (address);\n\n    /**\n     * @dev Generates a hash in order to call the method to create an NFT collection.\n     */\n    function createCollectionHash(\n        CreateCollectionParams calldata params,\n        address sender\n    ) external pure returns (bytes32);\n\n    /**\n     * @dev Generates a hash in order to call the method to mint a token inside\n     * an NFT collection.\n     */\n    function mintItemHash(MintItemParams calldata params, address sender) external pure returns (bytes32);\n}\n"
      },
      "contracts/interfaces/IPassClaim.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.18;\n\nimport { INFTFactory } from \"./INFTFactory.sol\";\n\ninterface IPassClaim {\n    /**\n     * @dev Defines data required to check given NFT Items.\n     *  - `collection` is the address of an NFT collection.\n     *  - `tokenId` is the token identifier within this NFT collection.\n     *  - `deduplicationId` is the deduplication group identifier used to check\n     *     maximum usage of a given token.\n     *  - `maxUsage` is the maximum usage allowed for a given token.\n     */\n    struct NFTItem {\n        address collection;\n        uint256 tokenId;\n        uint256 deduplicationId;\n        uint256 maxUsage;\n    }\n\n    /**\n     * @dev Emitted when some Ether amount received by the current contract.\n     */\n    event EtherReceived(address sender, uint256 value);\n\n    /**\n     * @dev Emitted when the address of a verifier contract is set.\n     */\n    event VerifierSet(address indexed verifier);\n\n    /**\n     * @dev Emitted when the address of an NFT contract is set.\n     */\n    event NFTFactorySet(address indexed nftFactory);\n\n    /**\n     * @dev Emitted when the address of an hot wallet contract is set. The address is\n     * allowed to be zero.\n     */\n    event HotWalletSet(address indexed hotWallet);\n\n    /**\n     * @dev Emitted when an allowed range of NFT items is set.\n     */\n    event NFTItemRangeSet(uint8[2] nftItemRange);\n\n    /**\n     * @dev Emitted when item usage for given deduplication group identifiers within\n     * an NFT collection.\n     */\n    event ItemUsagesReset(address indexed collection, uint256 deduplicationIdCount);\n\n    /**\n     * @dev Emitted when an item is minted.\n     */\n    event ItemMinted(\n        uint256 indexed transactionId,\n        uint256 indexed collectionId,\n        uint256 deduplicationId,\n        uint256 maxItemSupply,\n        uint256 tokenId,\n        address tokenReceiver\n    );\n\n    /**\n     * @dev The zero address of a verifier contract is given.\n     */\n    error ZeroVerifier();\n\n    /**\n     * @dev Emitted when the address of a NFT contract is set.\n     */\n    error ZeroNFTFactory();\n\n    /**\n     * @dev The item count is out of an allowed range.\n     */\n    error NFTItemRangeMissed(uint8[2] nftItemRange, uint256 currentNFTItemCount);\n\n    /**\n     * @dev The lower boundary of an item range is greater than the upper one.\n     */\n    error InconsistentNFTItemRange(uint8[2] nftItemRange);\n\n    /**\n     * @dev A request dealine exceeds the current block timestamp.\n     */\n    error DeadlineExceeded(uint256 currentTimestamp, uint256 deadline);\n\n    /**\n     * @dev The upper boundary for token burns within a certain deduplication group\n     * identifier is reached.\n     */\n    error MaxItemUsageReached(address collection, uint256 deduplicationId, uint256 currentUsage);\n\n    /**\n     * @dev The sender is not the owner of a given token.\n     */\n    error InvalidNFTOwner(address collection, uint256 tokenId, address sender);\n\n    /**\n     * @dev Sets the address of a verifier contract, which allows to verify\n     * signatures restricted to authorized callers only.\n     *\n     * Emits a {VerifierSet} event.\n     */\n    function setVerifier(address verifier) external;\n\n    /**\n     * @dev Sets the address of an NFT factory contract, which produces NFT passes.\n     *\n     * Emits a {NFTFactorySet} event.\n     */\n    function setNFTFactory(address nftFactory) external;\n\n    /**\n     * @dev Sets the address of an external hot wallet contract, which used to check\n     * NFT's ownership.\n     *\n     * Emits a {HotWalletSet} event.\n     */\n    function setHotWallet(address hotWallet) external;\n\n    /**\n     * @dev Sets an allowed range of tokens to be checked.\n     *\n     * Emits an {NFTItemRangeSet} event.\n     */\n    function setNFTItemRange(uint8[2] calldata nftItemRange) external;\n\n    /**\n     * @dev Pauses the current contract, e.g. in case of an emergency.\n     *\n     * Emits a {Paused} event.\n     */\n    function pause() external;\n\n    /**\n     * @dev Unpauses the current contract.\n     *\n     * Emits an {Unpaused} event.\n     */\n    function unpause() external;\n\n    /**\n     * @dev Handles item (NFT pass) minting over an NFT factory contract.\n     *\n     * Requirements:\n     *\n     * - Before calling this method, it is required to generate a hash from the hash\n     *   getter with corresponding parameters and sign it by an authorized caller\n     *   registerd at the {Verifier} contract.\n     *\n     * Emits an {ItemMinted} event.\n     */\n    function mintItem(\n        NFTItem[] calldata nftItems,\n        INFTFactory.MintItemParams calldata params,\n        bytes calldata signature\n    ) external payable;\n\n    /**\n     * @dev Resets item usage for given deduplication group identifiers within\n     * an NFT collection.\n     *\n     * Emits an {ItemUsagesReset} event.\n     */\n    function resetItemUsages(address collection, uint256[] calldata deduplicationIds) external;\n\n    /**\n     * @dev Generates a hash in order to call the method to mint an item.\n     */\n    function mintItemHash(\n        NFTItem[] calldata nftItems,\n        INFTFactory.MintItemParams calldata params,\n        address sender\n    ) external pure returns (bytes32);\n}\n"
      },
      "contracts/interfaces/IPayment.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.18;\n\nimport { IFeeDistributor } from \"./IFeeDistributor.sol\";\n\ninterface IPayment {\n    /**\n     * @dev Emitted when some Ether amount received by the current contract.\n     */\n    event EtherReceived(address sender, uint256 value);\n\n    /**\n     * @dev Emitted when the address of a verifier contract is set.\n     */\n    event VerifierSet(address indexed verifier);\n\n    /**\n     * @dev Emitted when the address of a fee distributor contract is set.\n     */\n    event FeeDistributorSet(address indexed feeDistributor);\n\n    /**\n     * @dev Emitted when an item is paid.\n     */\n    event Paid();\n\n    /**\n     * @dev Emitted when an item is paid.\n     */\n    event TransactionProcessed(uint256 indexed transactionId);\n\n    /**\n     * @dev Emitted when fees are distributed for a given caller.\n     */\n    event FeesDistributed(uint256 feeCount);\n\n    /**\n     * @dev The zero address of a verifier contract is given.\n     */\n    error ZeroVerifier();\n\n    /**\n     * @dev The zero address of a fee distributor contract is given.\n     */\n    error ZeroFeeDistributor();\n\n    /**\n     * @dev The upper usage limit for a paid item within its bound deduplication\n     * identifier is reached.\n     */\n    error MaxItemUsageReached(uint256 deduplicationId, uint256 currentUsage);\n\n    /**\n     * @dev Sets the address of a verifier contract, which allows to verify\n     * signatures restricted to authorized callers only.\n     *\n     * Emits a {VerifierSet} event.\n     */\n    function setVerifier(address verifier) external;\n\n    /**\n     * @dev Sets the address of a fee distributor contract, which handles fee\n     * distribution from a caller.\n     *\n     * Emits an {FeeDistributorSet} event.\n     */\n    function setFeeDistributor(address feeDistributor) external;\n\n    /**\n     * @dev Pauses the current contract, e.g. in case of an emergency.\n     *\n     * Emits a {Paused} event.\n     */\n    function pause() external;\n\n    /**\n     * @dev Unpauses the current contract.\n     *\n     * Emits an {Unpaused} event.\n     */\n    function unpause() external;\n\n    /**\n     * @dev Handles a user's payment for an item. The payment is expressed as an Ether\n     * or ERC20 token fee, which handled by a related fee distributor contract.\n     *\n     * Requirements:\n     *\n     * - Before calling this method, it is required to generate a hash from the hash\n     *  getter with corresponding parameters and sign it by an authorized caller.\n     *\n     * WARNING: The method call is restricted to authorized callers only, which are\n     * registered at a verifier contract.\n     *\n     * Emits {Paid} and {TransactionProcessed} events.\n     */\n    function pay(\n        uint256 transactionId,\n        uint256 deduplicationId,\n        uint256 maxUsage,\n        IFeeDistributor.Fee[] calldata fees,\n        bytes calldata signature\n    ) external payable;\n\n    /**\n     * @dev Generates a hash in order to call the method to handle a user's payment\n     * for an item.\n     */\n    function payHash(\n        uint256 transactionId,\n        uint256 deduplicationId,\n        uint256 maxUsage,\n        IFeeDistributor.Fee[] calldata fees,\n        address sender\n    ) external pure returns (bytes32);\n}\n"
      },
      "contracts/interfaces/IRoyaltySplitter.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.18;\n\ninterface IRoyaltySplitter {\n    /**\n     * @dev Royalty data passed for registration in the contract.\n     *\n     * Required fields:\n     *\n     * - `payee` is an account that should receive Ether or ERC20 royalty amount.\n     * - `share` is a share from a list of all registered royalty payees for a given\n     *    collection or for a non fungible token.\n     */\n    struct Royalty {\n        address payable payee;\n        uint96 share;\n    }\n\n    /**\n     * @dev Royalty information about royalty payees and their total shares stored\n     * in the contract.\n     *\n     * Required fields:\n     *\n     * - `royalties` is a list of royalties.\n     * - `totalShares` is the total share of all registered royalty payees.\n     */\n    struct RoyaltyInfo {\n        Royalty[] royalties;\n        uint96 totalShares;\n    }\n\n    /**\n     * @dev Emitted when collection wide royalty information is registered in\n     * the contract and when a royalty forwarder contract is deployed into\n     * the blockchain.\n     */\n    event CollectionRoyaltyRegistered(address indexed forwarder, address indexed collection, uint256 totalShares);\n\n    /**\n     * @dev Emitted when a token royalty information is registered in the contract\n     * and when a royalty forwarder contract is deployed into\n     * the blockchain.\n     */\n    event TokenRoyaltyRegistered(\n        address indexed forwarder,\n        address indexed collection,\n        uint256 indexed tokenId,\n        uint256 totalShares\n    );\n\n    /**\n     * @dev Emitted when Ether royalty amounts are transferred to royalty payees\n     * according to their shares.\n     */\n    event EtherRoyaltyReleased(address indexed forwarder, uint256 amount);\n\n    /**\n     * @dev Emitted when ERC20 royalty amounts are transferred to royalty payees\n     * according to their shares.\n     */\n    event ERC20RoyaltyReleased(address indexed forwarder, address indexed token, uint256 amount);\n\n    /**\n     * @dev No royalty data is passed to be registered in the contract.\n     */\n    error NoRoyaltiesFound();\n\n    /**\n     * @dev The zero payee address passed in royalty data to be registered in\n     * the contract.\n     */\n    error ZeroRoyaltyPayee();\n\n    /**\n     * @dev The zero payee share passed in royalty data to be registered in\n     * the contract.\n     */\n    error ZeroRoyaltyShare();\n\n    /**\n     * @dev The zero royalty amount is passed during a royalty release.\n     */\n    error ZeroRoyaltyAmount();\n\n    /**\n     * @dev A royalty payee has been already set from a passed list of royalties.\n     */\n    error RoyaltyPayeeIsSet(address roayltyPayee);\n\n    /**\n     * @dev No registered royalty information is found in the contract during\n     * a royalty release.\n     */\n    error NoRoyaltyInfoRegistered(address forwarder);\n\n    /**\n     * @dev Registers royalty shares for an NFT collection in this contract and\n     * deploys a related royalty forwarder contract into a blockchain.\n     *\n     * Emits a {CollectionRoyltyRegistered} event.\n     */\n    function registerCollectionRoyalty(\n        address collection,\n        Royalty[] calldata royalties\n    ) external returns (address, uint96);\n\n    /**\n     * @dev Registers royalty shares for a given non fungible token in this contract\n     *and deploys a related royalty forwarder contract into a blockchain.\n     *\n     * Emits a {TokenRoyltyRegistered} event.\n     */\n    function registerTokenRoyalty(\n        address collection,\n        uint256 tokenId,\n        Royalty[] calldata royalties\n    ) external returns (address royaltyForwarder, uint96 totalShares);\n\n    /**\n     * @dev Transfers Ether royalty amounts to royalty payees according to their shares.\n     *\n     * WARNING: The royalty contract should explicitly regitster a royalty forwarder\n     * contract, otherwise a transaction will be reverted.\n     *\n     * If a release amount is negligible, a royalty payee with a low share might have\n     * the zero Ether amount distributed consequently.\n     *\n     * Emits a {EtherRoyaltyReleased} event.\n     */\n    function releaseRoyalty() external payable;\n\n    /**\n     * @dev Transfers ERC20 royalty amounts to royalty payees according to their shares.\n     *\n     * WARNING: The royalty contract should explicitly regitster a royalty forwarder\n     * contract, otherwise a transaction will be reverted.\n     *\n     * If a release amount is negligible, a royalty payee with a low share might have\n     * the zero ERC20 token amount distributed consequently.\n     *\n     * Emits a {ERC20RoyaltyReleased} event.\n     */\n    function releaseRoyalty(address token, uint256 amount) external;\n\n    /**\n     * @dev Computes the address of a royalty forwarder contract, which should accept\n     * collection wide royalties.\n     */\n    function computeCollectionRoyaltyForwarderAddress(address collection) external view returns (address);\n\n    /**\n     * @dev Computes the address of a royalty forwarder contract, which should accept\n     * token royalties.\n     */\n    function computeTokenRoyaltyForwarderAddress(address collection, uint256 tokenId) external view returns (address);\n}\n"
      },
      "contracts/interfaces/IVerifier.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.18;\n\ninterface IVerifier {\n    /**\n     * @dev Emitted when the signer's address is added to the contract's storage.\n     */\n    event SignerAdded(address indexed signer);\n\n    /**\n     * @dev Emitted when the signer's address is removed from the contract's storage.\n     */\n    event SignerRemoved(address indexed signer);\n\n    /**\n     * @dev Emitted when the signer's address is recovered from the provided hash and signature.\n     */\n    event SignerRecovered(address indexed signer);\n\n    /**\n     * @dev A given hash signer is not verified based on the provided signature.\n     */\n    error SignerNotVerified(bytes32 hash, bytes signature);\n\n    /**\n     * @dev A signed hash has been already saved in the contract's storage.\n     */\n    error SignedHashAlreadyApplied(bytes32 hash);\n\n    /**\n     * @dev Recovers a signer's address from a provided `hash` and `singature`.\n     *\n     * Requirements:\n     *\n     * - the `hash` can be used only once for each successful recovery\n     *\n     * WARNING: This check requires a client to send a transaction, as it requires\n     * to write a checked hash into the contract's storage.\n     *\n     * Emits a `SignerRecovered` event.\n     */\n    function recoverSigner(bytes32 hash, bytes memory signature) external returns (address);\n\n    /**\n     * @dev Verifies if a given hash signed by an authorized signer.\n     */\n    function verifySigner(bytes32 hash, bytes memory signature) external view returns (bool);\n\n    /**\n     * @dev Checks if a given hash has been already applied.\n     */\n    function signedHashApplied(bytes32 hash) external view returns (bool);\n}\n"
      },
      "contracts/libraries/LFeeDistributor.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.18;\n\nimport { AddressUpgradeable } from \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport { IFeeDistributor } from \"../interfaces/IFeeDistributor.sol\";\n\nlibrary LFeeDistributor {\n    using AddressUpgradeable for address payable;\n    using SafeERC20Upgradeable for IERC20Upgradeable;\n\n    function distributeFeesForPayer(\n        IFeeDistributor feeDistributor,\n        IFeeDistributor.Fee[] memory fees,\n        address payer\n    ) internal {\n        uint256 feeCount = fees.length;\n\n        for (uint256 i = 0; i < feeCount; ) {\n            IFeeDistributor.Fee memory fee = fees[i];\n\n            address tokenAddress = feeDistributor.tokenAddresses(fee.token);\n            // slither-disable-next-line arbitrary-send-erc20\n            tokenAddress == address(0)\n                ? fee.payee.sendValue(fee.amount)\n                : IERC20Upgradeable(tokenAddress).safeTransferFrom(payer, fee.payee, fee.amount);\n\n            unchecked {\n                ++i;\n            }\n        }\n    }\n}\n"
      },
      "contracts/libraries/LParamEncoder.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.18;\n\nimport { IFeeDistributor } from \"../interfaces/IFeeDistributor.sol\";\nimport { IRoyaltySplitter } from \"../interfaces/IRoyaltySplitter.sol\";\nimport { IPassClaim } from \"../interfaces/IPassClaim.sol\";\nimport { IIncinerator } from \"../interfaces/IIncinerator.sol\";\n\nlibrary LParamEncoder {\n    function encodeFees(IFeeDistributor.Fee[] calldata fees) internal pure returns (bytes memory encodedFees) {\n        uint256 feeCount = fees.length;\n        for (uint256 i = 0; i < feeCount; ) {\n            IFeeDistributor.Fee calldata fee = fees[i];\n            encodedFees = bytes.concat(encodedFees, abi.encode(fee.payee, fee.token, fee.amount));\n\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    function encodeRoyalties(\n        IRoyaltySplitter.Royalty[] calldata royalties\n    ) internal pure returns (bytes memory encodedRoyalties) {\n        uint256 royaltyCount = royalties.length;\n        for (uint256 i = 0; i < royaltyCount; ) {\n            IRoyaltySplitter.Royalty calldata royalty = royalties[i];\n            encodedRoyalties = bytes.concat(encodedRoyalties, abi.encode(royalty.payee, royalty.share));\n\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    // slither-disable-next-line dead-code\n    function encodeNFTItems(\n        IPassClaim.NFTItem[] calldata nftItems\n    ) internal pure returns (bytes memory encodedNFTItems) {\n        uint256 nftItemCount = nftItems.length;\n        for (uint256 i = 0; i < nftItemCount; ) {\n            IPassClaim.NFTItem calldata nftItem = nftItems[i];\n            bytes.concat(\n                encodedNFTItems,\n                abi.encode(nftItem.collection, nftItem.tokenId, nftItem.deduplicationId, nftItem.maxUsage)\n            );\n\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    // slither-disable-next-line dead-code\n    function encodeNFTItems(\n        IIncinerator.NFTItem[] calldata nftItems\n    ) internal pure returns (bytes memory encodedNFTItems) {\n        uint256 nftItemCount = nftItems.length;\n        for (uint256 i = 0; i < nftItemCount; ) {\n            IIncinerator.NFTItem calldata nftItem = nftItems[i];\n            bytes.concat(encodedNFTItems, abi.encode(nftItem.collection, nftItem.tokenId));\n\n            unchecked {\n                ++i;\n            }\n        }\n    }\n}\n"
      },
      "contracts/Payment.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.18;\n\nimport { Initializable } from \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport { AccessControlUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport { ReentrancyGuardUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport { PausableUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport { PullPaymentUpgradeable } from \"@openzeppelin/contracts-upgradeable/security/PullPaymentUpgradeable.sol\";\nimport { CountersUpgradeable } from \"@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol\";\nimport { IPayment } from \"./interfaces/IPayment.sol\";\nimport { IFeeDistributor } from \"./interfaces/IFeeDistributor.sol\";\nimport { IVerifier } from \"./interfaces/IVerifier.sol\";\nimport { LFeeDistributor } from \"./libraries/LFeeDistributor.sol\";\nimport { LParamEncoder } from \"./libraries/LParamEncoder.sol\";\n\n/**\n * @dev This contract is used to handle user's payments for items.\n */\ncontract Payment is\n    IPayment,\n    Initializable,\n    AccessControlUpgradeable,\n    ReentrancyGuardUpgradeable,\n    PausableUpgradeable,\n    PullPaymentUpgradeable\n{\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n    using LFeeDistributor for IFeeDistributor;\n\n    bytes32 public constant VERSION = \"1.1.0\";\n\n    IVerifier public verifier;\n    IFeeDistributor public feeDistributor;\n    // slither-disable-next-line uninitialized-state\n    mapping(uint256 deduplicationId => CountersUpgradeable.Counter itemUsage) public itemUsages;\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    function initialize(address verifier_, address feeDistributor_) external initializer {\n        AccessControlUpgradeable.__AccessControl_init();\n        ReentrancyGuardUpgradeable.__ReentrancyGuard_init();\n        PausableUpgradeable.__Pausable_init();\n        PullPaymentUpgradeable.__PullPayment_init();\n\n        if (verifier_ == address(0)) {\n            revert ZeroVerifier();\n        }\n        verifier = IVerifier(verifier_);\n\n        if (feeDistributor_ == address(0)) {\n            revert ZeroFeeDistributor();\n        }\n        feeDistributor = IFeeDistributor(feeDistributor_);\n\n        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n    }\n\n    /**\n     * @dev Receives Ether sent to the current contract.\n     *\n     * Emits an {EtherReceived} event.\n     */\n    receive() external payable {\n        _asyncTransfer(msg.sender, msg.value);\n        emit EtherReceived(msg.sender, msg.value);\n    }\n\n    /**\n     * @dev Sets the address of a verifier contract, which allows to verify\n     * signatures restricted to authorized callers only.\n     *\n     * Emits a {VerifierSet} event.\n     */\n    function setVerifier(address verifier_) external onlyRole(DEFAULT_ADMIN_ROLE) {\n        if (verifier_ == address(0)) {\n            revert ZeroVerifier();\n        }\n\n        verifier = IVerifier(verifier_);\n        emit VerifierSet(verifier_);\n    }\n\n    /**\n     * @dev Sets the address of a fee distributor contract, which handles fee\n     * distribution from a caller.\n     *\n     * Emits a {FeeDistributor} event.\n     */\n    function setFeeDistributor(address feeDistributor_) external onlyRole(DEFAULT_ADMIN_ROLE) {\n        if (feeDistributor_ == address(0)) {\n            revert ZeroFeeDistributor();\n        }\n\n        feeDistributor = IFeeDistributor(feeDistributor_);\n        emit FeeDistributorSet(feeDistributor_);\n    }\n\n    /**\n     * @dev Pauses the current contract, e.g. in case of an emergency.\n     *\n     * Emits a {Paused} event.\n     */\n    function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {\n        _pause();\n    }\n\n    /**\n     * @dev Unpauses the current contract.\n     *\n     * Emits an {Unpaused} event.\n     */\n    function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {\n        _unpause();\n    }\n\n    /**\n     * @dev Handles a user's payment for an item. The payment is expressed as an Ether\n     * or ERC20 token fee, which handled by a related fee distributor contract.\n     *\n     * Requirements:\n     *\n     * - Before calling this method, it is required to generate a hash from the hash\n     *   getter with corresponding parameters and sign it by an authorized caller\n     *   registerd at the {Verifier} contract.\n     *\n     * Emits {Paid} and {TransactionProcessed} events.\n     */\n    function pay(\n        uint256 transactionId,\n        uint256 deduplicationId,\n        uint256 maxUsage,\n        IFeeDistributor.Fee[] calldata fees,\n        bytes calldata signature\n    ) external payable nonReentrant whenNotPaused {\n        bytes32 hash = _payHash(transactionId, deduplicationId, maxUsage, fees, msg.sender);\n        bool verified = verifier.verifySigner(hash, signature);\n        if (!verified) {\n            revert IVerifier.SignerNotVerified(hash, signature);\n        }\n\n        _setItemUsage(deduplicationId, maxUsage);\n        _distributeFees(fees, msg.sender);\n\n        emit Paid();\n        emit TransactionProcessed(transactionId);\n    }\n\n    /**\n     * @dev Generates a hash in order to call the method to handle a user's payment\n     * for an item.\n     */\n    function payHash(\n        uint256 transactionId,\n        uint256 deduplicationId,\n        uint256 maxUsage,\n        IFeeDistributor.Fee[] calldata fees,\n        address sender\n    ) external pure returns (bytes32) {\n        return _payHash(transactionId, deduplicationId, maxUsage, fees, sender);\n    }\n\n    /**\n     * @dev Distributes fees, which can be expressed both in a native token\n     * (e.g. Ether, Matic) and/or in a registered ERC20 token. Native and ERC20 fee\n     * distributions can be intermixed in a single request.\n     *\n     * A caller can be an externally owned account or a Coinflow contract.\n     *\n     * WARNING: If the caller is the Coinflow contract the fees are disributed\n     * in place on behalf of the current contract, because the Coinflow contract sets\n     * ERC20 approvals directly on it.\n     *\n     * Emits a {FeesDistributed} event.\n     *\n     * Also, can emit a {EtherReceived} event if a caller sends an execessive native\n     * token amount.\n     */\n    function _distributeFees(IFeeDistributor.Fee[] memory fees, address caller) private {\n        uint256 feeCount = fees.length;\n        if (feeCount == 0) {\n            return;\n        }\n\n        /* solhint-disable avoid-tx-origin */\n        // slither-disable-next-line tx-origin\n        if (tx.origin == caller) {\n            feeDistributor.distributeFees{ value: msg.value }(fees);\n        } else {\n            feeDistributor.distributeFeesForPayer(fees, caller);\n            emit FeesDistributed(feeCount);\n        }\n        /* solhint-enable avoid-tx-origin */\n    }\n\n    /**\n     * @dev Sets the upper usage limit for a paid item within its bound deduplication\n     * identifier.\n     */\n    function _setItemUsage(uint256 deduplicationId, uint256 maxUsage) private {\n        CountersUpgradeable.Counter storage currentUsage = itemUsages[deduplicationId];\n        if (maxUsage != 0 && currentUsage.current() >= maxUsage) {\n            revert MaxItemUsageReached(deduplicationId, currentUsage.current());\n        }\n        currentUsage.increment();\n    }\n\n    /**\n     * @dev Generates a hash in order to call the method to handle a user's payment\n     * for an item.\n     */\n    function _payHash(\n        uint256 transactionId,\n        uint256 deduplicationId,\n        uint256 maxUsage,\n        IFeeDistributor.Fee[] calldata fees,\n        address sender\n    ) private pure returns (bytes32) {\n        return\n            keccak256(\n                abi.encodePacked(transactionId, deduplicationId, maxUsage, LParamEncoder.encodeFees(fees), sender)\n            );\n    }\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}