creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@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/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/cryptography/MerkleProofUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.2) (utils/cryptography/MerkleProof.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev These functions deal with verification of Merkle Tree proofs.\n *\n * The tree and the proofs can be generated using our\n * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].\n * You will find a quickstart guide in the readme.\n *\n * WARNING: You should avoid using leaf values that are 64 bytes long prior to\n * hashing, or use a hash function other than keccak256 for hashing leaves.\n * This is because the concatenation of a sorted pair of internal nodes in\n * the merkle tree could be reinterpreted as a leaf value.\n * OpenZeppelin's JavaScript library generates merkle trees that are safe\n * against this attack out of the box.\n */\nlibrary MerkleProofUpgradeable {\n    /**\n     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree\n     * defined by `root`. For this, a `proof` must be provided, containing\n     * sibling hashes on the branch from the leaf to the root of the tree. Each\n     * pair of leaves and each pair of pre-images are assumed to be sorted.\n     */\n    function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {\n        return processProof(proof, leaf) == root;\n    }\n\n    /**\n     * @dev Calldata version of {verify}\n     *\n     * _Available since v4.7._\n     */\n    function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {\n        return processProofCalldata(proof, leaf) == root;\n    }\n\n    /**\n     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up\n     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt\n     * hash matches the root of the tree. When processing the proof, the pairs\n     * of leafs & pre-images are assumed to be sorted.\n     *\n     * _Available since v4.4._\n     */\n    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {\n        bytes32 computedHash = leaf;\n        for (uint256 i = 0; i < proof.length; i++) {\n            computedHash = _hashPair(computedHash, proof[i]);\n        }\n        return computedHash;\n    }\n\n    /**\n     * @dev Calldata version of {processProof}\n     *\n     * _Available since v4.7._\n     */\n    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {\n        bytes32 computedHash = leaf;\n        for (uint256 i = 0; i < proof.length; i++) {\n            computedHash = _hashPair(computedHash, proof[i]);\n        }\n        return computedHash;\n    }\n\n    /**\n     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by\n     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.\n     *\n     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.\n     *\n     * _Available since v4.7._\n     */\n    function multiProofVerify(\n        bytes32[] memory proof,\n        bool[] memory proofFlags,\n        bytes32 root,\n        bytes32[] memory leaves\n    ) internal pure returns (bool) {\n        return processMultiProof(proof, proofFlags, leaves) == root;\n    }\n\n    /**\n     * @dev Calldata version of {multiProofVerify}\n     *\n     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.\n     *\n     * _Available since v4.7._\n     */\n    function multiProofVerifyCalldata(\n        bytes32[] calldata proof,\n        bool[] calldata proofFlags,\n        bytes32 root,\n        bytes32[] memory leaves\n    ) internal pure returns (bool) {\n        return processMultiProofCalldata(proof, proofFlags, leaves) == root;\n    }\n\n    /**\n     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction\n     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another\n     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false\n     * respectively.\n     *\n     * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree\n     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the\n     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).\n     *\n     * _Available since v4.7._\n     */\n    function processMultiProof(\n        bytes32[] memory proof,\n        bool[] memory proofFlags,\n        bytes32[] memory leaves\n    ) internal pure returns (bytes32 merkleRoot) {\n        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by\n        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the\n        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of\n        // the merkle tree.\n        uint256 leavesLen = leaves.length;\n        uint256 proofLen = proof.length;\n        uint256 totalHashes = proofFlags.length;\n\n        // Check proof validity.\n        require(leavesLen + proofLen - 1 == totalHashes, \"MerkleProof: invalid multiproof\");\n\n        // The xxxPos values are \"pointers\" to the next value to consume in each array. All accesses are done using\n        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's \"pop\".\n        bytes32[] memory hashes = new bytes32[](totalHashes);\n        uint256 leafPos = 0;\n        uint256 hashPos = 0;\n        uint256 proofPos = 0;\n        // At each step, we compute the next hash using two values:\n        // - a value from the \"main queue\". If not all leaves have been consumed, we get the next leaf, otherwise we\n        //   get the next hash.\n        // - depending on the flag, either another value from the \"main queue\" (merging branches) or an element from the\n        //   `proof` array.\n        for (uint256 i = 0; i < totalHashes; i++) {\n            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];\n            bytes32 b = proofFlags[i]\n                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])\n                : proof[proofPos++];\n            hashes[i] = _hashPair(a, b);\n        }\n\n        if (totalHashes > 0) {\n            require(proofPos == proofLen, \"MerkleProof: invalid multiproof\");\n            unchecked {\n                return hashes[totalHashes - 1];\n            }\n        } else if (leavesLen > 0) {\n            return leaves[0];\n        } else {\n            return proof[0];\n        }\n    }\n\n    /**\n     * @dev Calldata version of {processMultiProof}.\n     *\n     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.\n     *\n     * _Available since v4.7._\n     */\n    function processMultiProofCalldata(\n        bytes32[] calldata proof,\n        bool[] calldata proofFlags,\n        bytes32[] memory leaves\n    ) internal pure returns (bytes32 merkleRoot) {\n        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by\n        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the\n        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of\n        // the merkle tree.\n        uint256 leavesLen = leaves.length;\n        uint256 proofLen = proof.length;\n        uint256 totalHashes = proofFlags.length;\n\n        // Check proof validity.\n        require(leavesLen + proofLen - 1 == totalHashes, \"MerkleProof: invalid multiproof\");\n\n        // The xxxPos values are \"pointers\" to the next value to consume in each array. All accesses are done using\n        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's \"pop\".\n        bytes32[] memory hashes = new bytes32[](totalHashes);\n        uint256 leafPos = 0;\n        uint256 hashPos = 0;\n        uint256 proofPos = 0;\n        // At each step, we compute the next hash using two values:\n        // - a value from the \"main queue\". If not all leaves have been consumed, we get the next leaf, otherwise we\n        //   get the next hash.\n        // - depending on the flag, either another value from the \"main queue\" (merging branches) or an element from the\n        //   `proof` array.\n        for (uint256 i = 0; i < totalHashes; i++) {\n            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];\n            bytes32 b = proofFlags[i]\n                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])\n                : proof[proofPos++];\n            hashes[i] = _hashPair(a, b);\n        }\n\n        if (totalHashes > 0) {\n            require(proofPos == proofLen, \"MerkleProof: invalid multiproof\");\n            unchecked {\n                return hashes[totalHashes - 1];\n            }\n        } else if (leavesLen > 0) {\n            return leaves[0];\n        } else {\n            return proof[0];\n        }\n    }\n\n    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {\n        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);\n    }\n\n    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            mstore(0x00, a)\n            mstore(0x20, b)\n            value := keccak256(0x00, 0x40)\n        }\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/proxy/Clones.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/Clones.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for\n * deploying minimal proxy contracts, also known as \"clones\".\n *\n * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies\n * > a minimal bytecode implementation that delegates all calls to a known, fixed address.\n *\n * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`\n * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the\n * deterministic method.\n *\n * _Available since v3.4._\n */\nlibrary Clones {\n    /**\n     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\n     *\n     * This function uses the create opcode, which should never revert.\n     */\n    function clone(address implementation) internal returns (address instance) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes\n            // of the `implementation` address with the bytecode before the address.\n            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))\n            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.\n            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))\n            instance := create(0, 0x09, 0x37)\n        }\n        require(instance != address(0), \"ERC1167: create failed\");\n    }\n\n    /**\n     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\n     *\n     * This function uses the create2 opcode and a `salt` to deterministically deploy\n     * the clone. Using the same `implementation` and `salt` multiple time will revert, since\n     * the clones cannot be deployed twice at the same address.\n     */\n    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes\n            // of the `implementation` address with the bytecode before the address.\n            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))\n            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.\n            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))\n            instance := create2(0, 0x09, 0x37, salt)\n        }\n        require(instance != address(0), \"ERC1167: create2 failed\");\n    }\n\n    /**\n     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\n     */\n    function predictDeterministicAddress(\n        address implementation,\n        bytes32 salt,\n        address deployer\n    ) internal pure returns (address predicted) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let ptr := mload(0x40)\n            mstore(add(ptr, 0x38), deployer)\n            mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)\n            mstore(add(ptr, 0x14), implementation)\n            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)\n            mstore(add(ptr, 0x58), salt)\n            mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))\n            predicted := keccak256(add(ptr, 0x43), 0x55)\n        }\n    }\n\n    /**\n     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\n     */\n    function predictDeterministicAddress(\n        address implementation,\n        bytes32 salt\n    ) internal view returns (address predicted) {\n        return predictDeterministicAddress(implementation, salt, address(this));\n    }\n}\n"
      },
      "contracts/interfaces/IOracleOrL2OracleWithSequencerCheck.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.21;\n\ninterface IOracleOrL2OracleWithSequencerCheck {\n    function decimals() external view returns (uint8); \n    \n    function latestRoundData() external view returns (\n      uint80 roundId,\n      int256 answer,\n      uint256 startedAt,\n      uint256 updatedAt,\n      uint80 answeredInRound\n    );\n}\n"
      },
      "contracts/sale/v2.1/FlatPriceSale.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.21;\n// pragma abicoder v2;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/PullPaymentUpgradeable.sol\";\nimport \"./Sale.sol\";\nimport \"../../interfaces/IOracleOrL2OracleWithSequencerCheck.sol\";\n/**\nAllow qualified users to participate in a sale according to sale rules.\n\nManagement\n- the address that deploys the sale is the sale owner\n- owners may change some sale parameters (e.g. start and end times)\n- sale proceeds are sent to the sale recipient\n\nQualification\n- public sale: anyone can participate\n- private sale: only users who can prove membership in a merkle tree can participate\n\nSale Rules\n- timing: purchases can only be made\n  - after the sale opens\n  - after the per-account random queue time has elapsed\n  - before the sale ends\n- purchase quantity: quantity is limited by\n  - per-address limit\n  - total sale limit\n- payment method: participants can pay using either\n  - the native token on the network (e.g. ETH)\n  - a single ERC-20 token (e.g. USDC)\n- number of purchases: there is no limit to the number of compliant purchases a user may make\n\nToken Distribution\n- this contract does not distribute any purchased tokens\n\nMetrics\n- purchase count: number of purchases made in this sale\n- user count: number of unique addresses that participated in this sale\n- total bought: value of purchases denominated in a base currency (e.g. USD) as an integer (to get the float value, divide by oracle decimals)\n- bought per user: value of a user's purchases denominated in a base currency (e.g. USD)\n\ntotal bought and bought per user metrics are inclusive of any fee charged (if a fee is charged, the sale recipient will receive less than the total spend)\n*/\n\n// Sale can only be updated post-initialization by the contract owner!\nstruct Config {\n\t// the address that will receive sale proceeds (tokens and native) minus any fees sent to the fee recipient\n\taddress payable recipient;\n\t// the merkle root used for proving access\n\tbytes32 merkleRoot;\n\t// max that can be spent in the sale in the base currency\n\tuint256 saleMaximum;\n\t// max that can be spent per user in the base currency\n\tuint256 userMaximum;\n\t// minimum that can be bought in a specific purchase\n\tuint256 purchaseMinimum;\n\t// the time at which the sale starts (users will have an additional random delay if maxQueueTime is set)\n\tuint256 startTime;\n\t// the time at which the sale will end, regardless of tokens raised\n\tuint256 endTime;\n\t// what is the maximum length of time a user could wait in the queue after the sale starts?\n\tuint256 maxQueueTime;\n\t// a link to off-chain information about this sale\n\tstring URI;\n}\n\n// Metrics are only updated by the buyWithToken() and buyWithNative() functions\nstruct Metrics {\n\t// number of purchases\n\tuint256 purchaseCount;\n\t// number of buyers\n\tuint256 buyerCount;\n\t// amount bought denominated in a base currency\n\tuint256 purchaseTotal;\n\t// amount bought for each user denominated in a base currency\n\tmapping(address => uint256) buyerTotal;\n}\n\nstruct PaymentTokenInfo {\n\tIOracleOrL2OracleWithSequencerCheck oracle;\n\tuint8 decimals;\n}\n\ncontract FlatPriceSale_v_2_1 is Sale, PullPaymentUpgradeable {\n\tusing SafeERC20Upgradeable for IERC20Upgradeable;\n\n\tevent ImplementationConstructor(address payable indexed feeRecipient, uint256 feeBips);\n\tevent Update(Config config);\n\tevent Initialize(\n\t\tConfig config,\n\t\tstring baseCurrency,\n\t\tIOracleOrL2OracleWithSequencerCheck nativeOracle,\n\t\tbool nativePaymentsEnabled\n\t);\n\tevent SetPaymentTokenInfo(IERC20Upgradeable token, PaymentTokenInfo paymentTokenInfo);\n\tevent SweepToken(address indexed token, uint256 amount);\n\tevent SweepNative(uint256 amount);\n\tevent RegisterDistributor(address distributor);\n\n\t// All supported chains must use 18 decimals (e.g. 1e18 wei / eth)\n\tuint256 internal constant NATIVE_TOKEN_DECIMALS = 18;\n\n\t// flag for additional merkle root data\n\tuint8 internal constant PER_USER_PURCHASE_LIMIT = 1;\n\tuint8 internal constant PER_USER_END_TIME = 2;\n\n\t/**\n  Variables set by implementation contract constructor (immutable)\n  */\n\n\t// a fee may be charged by the sale manager\n\tuint256 immutable feeBips;\n\tuint256 constant fractionDenominator = 10000;\n\n\t// the recipient of the fee\n\taddress payable immutable feeRecipient;\n\n\t// an optional address where buyers can receive distributed tokens\n\taddress distributor;\n\n\t/**\n  Variables set during initialization of clone contracts (\"immutable\" on each instance)\n  */\n\n\t// the base currency being used, e.g. 'USD'\n\tstring public baseCurrency;\n\n\tstring public constant VERSION = \"2.2\";\n\n\t// <native token>/<base currency> price, e.g. ETH/USD price\n\tIOracleOrL2OracleWithSequencerCheck public nativeTokenPriceOracle;\n\n\t// whether native payments are enabled (set during intialization)\n\tbool nativePaymentsEnabled;\n\n\t// <ERC20 token>/<base currency> price oracles, eg USDC address => ETH/USDC price\n\tmapping(IERC20Upgradeable => PaymentTokenInfo) public paymentTokens;\n\n\t// owner can update these\n\tConfig public config;\n\n\t// derived from payments\n\tMetrics public metrics;\n\n\t// reasonably random value: xor of merkle root and blockhash for transaction setting merkle root\n\tuint160 internal randomValue;\n\n\t// All clones will share the information in the implementation constructor\n\tconstructor(uint256 _feeBips, address payable _feeRecipient) {\n\t\tif (_feeBips > 0) {\n\t\t\trequire(_feeRecipient != address(0), \"feeRecipient == 0\");\n\t\t}\n\t\tfeeRecipient = _feeRecipient;\n\t\tfeeBips = _feeBips;\n\n\t\temit ImplementationConstructor(feeRecipient, feeBips);\n\t}\n\n\t/**\n  Replacement for constructor for clones of the implementation contract\n  Important: anyone can call the initialize function!\n  */\n\tfunction initialize(\n\t\taddress _owner,\n\t\tConfig calldata _config,\n\t\tstring calldata _baseCurrency,\n\t\tbool _nativePaymentsEnabled,\n\t\tIOracleOrL2OracleWithSequencerCheck _nativeTokenPriceOracle,\n\t\tIERC20Upgradeable[] calldata tokens,\n\t\tIOracleOrL2OracleWithSequencerCheck[] calldata oracles,\n\t\tuint8[] calldata decimals\n\t) public initializer validUpdate(_config) {\n\t\t// initialize the PullPayment escrow contract\n\t\t__PullPayment_init();\n\n\t\t// validate the new sale\n\t\trequire(tokens.length == oracles.length, \"token and oracle lengths !=\");\n\t\trequire(tokens.length == decimals.length, \"token and decimals lengths !=\");\n\t\trequire(address(_nativeTokenPriceOracle) != address(0), \"native oracle == 0\");\n\n\t\t// save the new sale\n\t\tconfig = _config;\n\n\t\t// save payment config\n\t\tbaseCurrency = _baseCurrency;\n\t\tnativeTokenPriceOracle = _nativeTokenPriceOracle;\n\t\tnativePaymentsEnabled = _nativePaymentsEnabled;\n\t\temit Initialize(config, baseCurrency, nativeTokenPriceOracle, _nativePaymentsEnabled);\n\n\t\tfor (uint256 i = 0; i < tokens.length; i++) {\n\t\t\t// double check that tokens and oracles are real addresses\n\t\t\trequire(address(tokens[i]) != address(0), \"payment token == 0\");\n\t\t\trequire(address(oracles[i]) != address(0), \"token oracle == 0\");\n\t\t\t// save the payment token info\n\t\t\tpaymentTokens[tokens[i]] = PaymentTokenInfo({ oracle: oracles[i], decimals: decimals[i] });\n\n\t\t\temit SetPaymentTokenInfo(tokens[i], paymentTokens[tokens[i]]);\n\t\t}\n\n\t\t// Set the random value for the fair queue time\n\t\trandomValue = generatePseudorandomValue(config.merkleRoot);\n\n\t\t// transfer ownership to the user initializing the sale\n\t\t_transferOwnership(_owner);\n\t}\n\n\t/**\n  Check that the user can currently participate in the sale based on the merkle root\n\n  Merkle root options:\n  - bytes32(0): this is a public sale, any address can participate\n  - otherwise: this is a private sale, users must submit a merkle proof that their address is included in the merkle root\n  */\n\tmodifier canAccessSale(bytes calldata data, bytes32[] calldata proof) {\n\t\t// make sure the buyer is an EOA\n\t\t// TODO: Review this check for meta-transactions\n\t\trequire((_msgSender() == tx.origin), \"Must buy with an EOA\");\n\n\t\t// If the merkle root is non-zero this is a private sale and requires a valid proof\n\t\tif (config.merkleRoot == bytes32(0)) {\n\t\t\t// this is a public sale\n\t\t\t// IMPORTANT: data is only validated if the merkle root is checked! Public sales do not check any merkle roots!\n\t\t\trequire(data.length == 0, \"data not permitted on public sale\");\n\t\t} else {\n\t\t\t// this is a private sale\n\t\t\trequire(\n\t\t\t\tthis.isValidMerkleProof(config.merkleRoot, _msgSender(), data, proof) == true,\n\t\t\t\t\"bad merkle proof for sale\"\n\t\t\t);\n\t\t}\n\n\t\t// Require the sale to be open\n\t\trequire(block.timestamp > config.startTime, \"sale has not started yet\");\n\t\trequire(block.timestamp < config.endTime, \"sale has ended\");\n\t\trequire(metrics.purchaseTotal < config.saleMaximum, \"sale buy limit reached\");\n\n\t\t// Reduce congestion by randomly assigning each user a delay time in a virtual queue based on comparing their address and a random value\n\t\t// if config.maxQueueTime == 0 the delay is 0\n\t\trequire(\n\t\t\tblock.timestamp - config.startTime > getFairQueueTime(_msgSender()),\n\t\t\t\"not your turn yet\"\n\t\t);\n\t\t_;\n\t}\n\n\t/**\n  Check that the new sale is a valid update\n  - If the config already exists, it must not be over (cannot edit sale after it concludes)\n  - Sale start, end, and max queue times must be consistent and not too far in the future\n   */\n\tmodifier validUpdate(Config calldata newConfig) {\n\t\t// get the existing config\n\t\tConfig memory oldConfig = config;\n\n\t\t/**\n     - @notice - Block updates after sale is over \n     - @dev - Since validUpdate is called by initialize(), we can have a new\n     - sale here, identifiable by default randomValue of 0\n     */\n\t\tif (randomValue != 0) {\n\t\t\t// this is an existing sale: cannot update after it has ended\n\t\t\trequire(block.timestamp < oldConfig.endTime, \"sale is over: cannot upate\");\n\t\t\tif (block.timestamp > oldConfig.startTime) {\n\t\t\t\t// the sale has already started, some things should not be edited\n\t\t\t\trequire(\n\t\t\t\t\toldConfig.saleMaximum == newConfig.saleMaximum,\n\t\t\t\t\t\"editing saleMaximum after sale start\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// the total sale limit must be at least as large as the per-user limit\n\n\t\t// all required values must be present and reasonable\n\t\t// check if the caller accidentally entered a value in milliseconds instead of seconds\n\t\trequire(newConfig.startTime <= 4102444800, \"start > 4102444800 (Jan 1 2100)\");\n\t\trequire(newConfig.endTime <= 4102444800, \"end > 4102444800 (Jan 1 2100)\");\n\t\trequire(newConfig.maxQueueTime <= 604800, \"max queue time > 604800 (1 week)\");\n\t\trequire(newConfig.recipient != address(0), \"recipient == address(0)\");\n\n\t\t// sale, user, and purchase limits must be compatible\n\t\trequire(newConfig.saleMaximum > 0, \"saleMaximum == 0\");\n\t\trequire(newConfig.userMaximum > 0, \"userMaximum == 0\");\n\t\trequire(newConfig.userMaximum <= newConfig.saleMaximum, \"userMaximum > saleMaximum\");\n\t\trequire(newConfig.purchaseMinimum <= newConfig.userMaximum, \"purchaseMinimum > userMaximum\");\n\n\t\t// new sale times must be internally consistent\n\t\trequire(\n\t\t\tnewConfig.startTime + newConfig.maxQueueTime < newConfig.endTime,\n\t\t\t\"sale must be open for at least maxQueueTime\"\n\t\t);\n\n\t\t_;\n\t}\n\n\tmodifier validPaymentToken(IERC20Upgradeable token) {\n\t\t// check that this token is configured as a payment method\n\t\tPaymentTokenInfo memory info = paymentTokens[token];\n\t\trequire(address(info.oracle) != address(0), \"invalid payment token\");\n\n\t\t_;\n\t}\n\n\tmodifier areNativePaymentsEnabled() {\n\t\trequire(nativePaymentsEnabled, \"native payments disabled\");\n\n\t\t_;\n\t}\n\n\t// Get info on a payment token\n\tfunction getPaymentToken(IERC20Upgradeable token)\n\t\texternal\n\t\tview\n\t\treturns (PaymentTokenInfo memory)\n\t{\n\t\treturn paymentTokens[token];\n\t}\n\n\t// Get a positive token price from a chainlink oracle\n\tfunction getOraclePrice(IOracleOrL2OracleWithSequencerCheck oracle) public view returns (uint256) {\n\t\t(\n\t\t\tuint80 roundID,\n\t\t\tint256 _price,\n\t\t\t/* uint256 startedAt */,\n\t\t\tuint256 timeStamp,\n\t\t\tuint80 answeredInRound\n\t\t) = oracle.latestRoundData();\n\n\t\trequire(_price > 0, \"negative price\");\n\t\trequire(answeredInRound > 0, \"answer == 0\");\n\t\trequire(timeStamp > 0, \"round not complete\");\n\t\trequire(answeredInRound >= roundID, \"stale price\");\n\n\t\treturn uint256(_price);\n\t}\n\n\t/**\n    Generate a pseudorandom value\n    This is not a truly random value:\n    - miners can alter the block hash\n    - owners can repeatedly call setMerkleRoot()\n    - owners can choose when to submit the transaction\n  */\n\tfunction generatePseudorandomValue(bytes32 merkleRoot) public view returns (uint160) {\n\t\treturn uint160(uint256(blockhash(block.number - 1))) ^ uint160(uint256(merkleRoot));\n\t}\n\n\t/**\n    Get the delay in seconds that a specific buyer must wait after the sale begins in order to buy tokens in the sale\n\n    Buyers cannot exploit the fair queue when:\n    - The sale is private (merkle root != bytes32(0))\n    - Each eligible buyer gets exactly one address in the merkle root\n\n    Although miners and sellers can minimize the delay for an arbitrary address, these are not significant threats:\n    - the economic opportunity to miners is zero or relatively small (only specific addresses can participate in private sales, and a better queue postion does not imply high returns)\n    - sellers can repeatedly set merkle roots to achieve a favorable queue time for any address, but sellers already control the tokens being sold!\n  */\n\tfunction getFairQueueTime(address buyer) public view returns (uint256) {\n\t\tif (config.maxQueueTime == 0) {\n\t\t\t// there is no delay: all addresses may participate immediately\n\t\t\treturn 0;\n\t\t}\n\n\t\t// calculate a distance between the random value and the user's address using the XOR distance metric (c.f. Kademlia)\n\t\tuint160 distance = uint160(buyer) ^ randomValue;\n\n\t\t// calculate a speed at which the queue is exhausted such that all users complete the queue by sale.maxQueueTime\n\t\tuint160 distancePerSecond = type(uint160).max / uint160(config.maxQueueTime);\n\t\t// return the delay (seconds)\n\t\treturn distance / distancePerSecond;\n\t}\n\n\t/**\n  Convert a token quantity (e.g. USDC or ETH) to a base currency (e.g. USD) with the same number of decimals as the price oracle (e.g. 8)\n\n  Example: given 2 NCT tokens, each worth $1.23, tokensToBaseCurrency should return 246000000 ($2.46)\n\n  Function arguments\n  - tokenQuantity: 2000000000000000000\n  - tokenDecimals: 18\n\n  NCT/USD chainlink oracle (important! the oracle must be <token>/<base currency> not <currency>/<base token>, e.g. ETH/USD, ~$2000 not USD/ETH, ~0.0005)\n  - baseCurrencyPerToken: 123000000\n  - baseCurrencyDecimals: 8\n\n  Calculation: 2000000000000000000 * 123000000 / 1000000000000000000\n\n  Returns: 246000000\n  */\n\t// function tokensToBaseCurrency(SafeERC20Upgradeable token, uint256 quantity) public view validPaymentToken(token) returns (uint256) {\n\t//   PaymentTokenInfo info = paymentTokens[token];\n\t//   return quantity * getOraclePrice(info.oracle) / (10 ** info.decimals);\n\t// }\n\tfunction tokensToBaseCurrency(\n\t\tuint256 tokenQuantity,\n\t\tuint256 tokenDecimals,\n\t\tIOracleOrL2OracleWithSequencerCheck oracle\n\t) public view returns (uint256 value) {\n\t\treturn (tokenQuantity * getOraclePrice(oracle)) / (10**tokenDecimals);\n\t}\n\n\tfunction total() external view override returns (uint256) {\n\t\treturn metrics.purchaseTotal;\n\t}\n\n\tfunction isOver() public view override returns (bool) {\n\t\treturn config.endTime <= block.timestamp || metrics.purchaseTotal >= config.saleMaximum;\n\t}\n\n\tfunction isOpen() public view override returns (bool) {\n\t\treturn\n\t\t\tconfig.startTime < block.timestamp &&\n\t\t\tconfig.endTime > block.timestamp &&\n\t\t\tmetrics.purchaseTotal < config.saleMaximum;\n\t}\n\n\t// return the amount bought by this user in base currency\n\tfunction buyerTotal(address user) external view override returns (uint256) {\n\t\treturn metrics.buyerTotal[user];\n\t}\n\n\t/**\n  Records a purchase\n  Follow the Checks -> Effects -> Interactions pattern\n  * Checks: CALLER MUST ENSURE BUYER IS PERMITTED TO PARTICIPATE IN THIS SALE: THIS METHOD DOES NOT CHECK WHETHER THE BUYER SHOULD BE ABLE TO ACCESS THE SALE!\n  * Effects: record the payment\n  * Interactions: none!\n  */\n\tfunction _execute(uint256 baseCurrencyQuantity, bytes calldata data) internal {\n\t\t// Checks\n\t\tuint256 userLimit = config.userMaximum;\n\n\t\tif (data.length > 0) {\n\t\t\trequire(uint8(bytes1(data[0:1])) == PER_USER_PURCHASE_LIMIT, \"unknown data\");\n\t\t\trequire(data.length == 33, \"data length != 33 bytes\");\n\t\t\tuserLimit = uint256(bytes32(data[1:33]));\n\t\t}\n\n\t\trequire(\n\t\t\tbaseCurrencyQuantity + metrics.buyerTotal[_msgSender()] <= userLimit,\n\t\t\t\"purchase exceeds your limit\"\n\t\t);\n\n\t\trequire(\n\t\t\tbaseCurrencyQuantity + metrics.purchaseTotal <= config.saleMaximum,\n\t\t\t\"purchase exceeds sale limit\"\n\t\t);\n\n\t\trequire(baseCurrencyQuantity >= config.purchaseMinimum, \"purchase under minimum\");\n\n\t\t// Effects\n\t\tmetrics.purchaseCount += 1;\n\t\tif (metrics.buyerTotal[_msgSender()] == 0) {\n\t\t\t// if no prior purchases, this is a new buyer\n\t\t\tmetrics.buyerCount += 1;\n\t\t}\n\t\tmetrics.purchaseTotal += baseCurrencyQuantity;\n\t\tmetrics.buyerTotal[_msgSender()] += baseCurrencyQuantity;\n\t}\n\n\t/**\n  Settle payment made with payment token\n  Important: this function has no checks! Only call if the purchase is valid!\n  */\n\tfunction _settlePaymentToken(\n\t\tuint256 baseCurrencyValue,\n\t\tIERC20Upgradeable token,\n\t\tuint256 quantity\n\t) internal {\n\t\tuint256 fee = 0;\n\t\tif (feeBips > 0) {\n\t\t\tfee = (quantity * feeBips) / fractionDenominator;\n\t\t\ttoken.safeTransferFrom(_msgSender(), feeRecipient, fee);\n\t\t}\n\t\ttoken.safeTransferFrom(_msgSender(), address(this), quantity - fee);\n\t\temit Buy(_msgSender(), address(token), baseCurrencyValue, quantity, fee);\n\t}\n\n\t/**\n  Settle payment made with native token\n  Important: this function has no checks! Only call if the purchase is valid!\n  */\n\tfunction _settleNativeToken(uint256 baseCurrencyValue, uint256 nativeTokenQuantity) internal {\n\t\tuint256 nativeFee = 0;\n\t\tif (feeBips > 0) {\n\t\t\tnativeFee = (nativeTokenQuantity * feeBips) / fractionDenominator;\n\t\t\t_asyncTransfer(feeRecipient, nativeFee);\n\t\t}\n\t\t_asyncTransfer(config.recipient, nativeTokenQuantity - nativeFee);\n\t\t// This contract will hold the native token until claimed by the owner\n\t\temit Buy(_msgSender(), address(0), baseCurrencyValue, nativeTokenQuantity, nativeFee);\n\t}\n\n\t/**\n  Pay with the payment token (e.g. USDC)\n  */\n\tfunction buyWithToken(\n\t\tIERC20Upgradeable token,\n\t\tuint256 quantity,\n\t\tbytes calldata data,\n\t\tbytes32[] calldata proof\n\t) external override canAccessSale(data, proof) validPaymentToken(token) nonReentrant {\n\t\t// convert to base currency from native tokens\n\t\tPaymentTokenInfo memory tokenInfo = paymentTokens[token];\n\t\tuint256 baseCurrencyValue = tokensToBaseCurrency(\n\t\t\tquantity,\n\t\t\ttokenInfo.decimals,\n\t\t\ttokenInfo.oracle\n\t\t);\n\t\t// Checks and Effects\n\t\t_execute(baseCurrencyValue, data);\n\t\t// Interactions\n\t\t_settlePaymentToken(baseCurrencyValue, token, quantity);\n\t}\n\n\t/**\n  Pay with the native token (e.g. ETH)\n   */\n\tfunction buyWithNative(bytes calldata data, bytes32[] calldata proof)\n\t\texternal\n\t\tpayable\n\t\toverride\n\t\tcanAccessSale(data, proof)\n\t\tareNativePaymentsEnabled\n\t\tnonReentrant\n\t{\n\t\t// convert to base currency from native tokens\n\t\tuint256 baseCurrencyValue = tokensToBaseCurrency(\n\t\t\tmsg.value,\n\t\t\tNATIVE_TOKEN_DECIMALS,\n\t\t\tnativeTokenPriceOracle\n\t\t);\n\t\t// Checks and Effects\n\t\t_execute(baseCurrencyValue, data);\n\t\t// Interactions\n\t\t_settleNativeToken(baseCurrencyValue, msg.value);\n\t}\n\n\t/**\n  External management functions (only the owner may update the sale)\n  */\n\tfunction update(Config calldata _config) external validUpdate(_config) onlyOwner {\n\t\tconfig = _config;\n\t\t// updates always reset the random value\n\t\trandomValue = generatePseudorandomValue(config.merkleRoot);\n\t\temit Update(config);\n\t}\n\n\t// Tell users where they can claim tokens\n\tfunction registerDistributor(address _distributor) external onlyOwner {\n\t\trequire(_distributor != address(0), \"Distributor == address(0)\");\n\t\tdistributor = _distributor;\n\t\temit RegisterDistributor(distributor);\n\t}\n\n\t/**\n  Public management functions\n  */\n\t// Sweep an ERC20 token to the recipient (public function)\n\tfunction sweepToken(IERC20Upgradeable token) external {\n\t\tuint256 amount = token.balanceOf(address(this));\n\t\ttoken.safeTransfer(config.recipient, amount);\n\t\temit SweepToken(address(token), amount);\n\t}\n\n\t// sweep native token to the recipient (public function)\n\tfunction sweepNative() external {\n\t\tuint256 amount = address(this).balance;\n\t\t(bool success, ) = config.recipient.call{ value: amount }(\"\");\n\t\trequire(success, \"Transfer failed.\");\n\t\temit SweepNative(amount);\n\t}\n}\n"
      },
      "contracts/sale/v2.1/FlatPriceSaleFactory.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity =0.8.21;\n\nimport \"@openzeppelin/contracts/proxy/Clones.sol\";\nimport \"./FlatPriceSale.sol\";\n\ncontract FlatPriceSaleFactory_v_2_1 {\n\taddress public immutable implementation;\n\tstring public constant VERSION = \"2.0\";\n\n\tevent NewSale(\n\t\taddress indexed implementation,\n\t\tFlatPriceSale_v_2_1 indexed clone,\n\t\tConfig config,\n\t\tstring baseCurrency,\n\t\tIOracleOrL2OracleWithSequencerCheck nativeOracle,\n\t\tbool nativePaymentsEnabled\n\t);\n\n\tconstructor(address _implementation) {\n\t\timplementation = _implementation;\n\t}\n\n\tfunction newSale(\n\t\taddress _owner,\n\t\tConfig calldata _config,\n\t\tstring calldata _baseCurrency,\n\t\tbool _nativePaymentsEnabled,\n\t\tIOracleOrL2OracleWithSequencerCheck _nativeTokenPriceOracle,\n\t\tIERC20Upgradeable[] calldata tokens,\n\t\tIOracleOrL2OracleWithSequencerCheck[] calldata oracles,\n\t\tuint8[] calldata decimals\n\t) external returns (FlatPriceSale_v_2_1 sale) {\n\t\tsale = FlatPriceSale_v_2_1(Clones.clone(address(implementation)));\n\n\t\temit NewSale(\n\t\t\timplementation,\n\t\t\tsale,\n\t\t\t_config,\n\t\t\t_baseCurrency,\n\t\t\t_nativeTokenPriceOracle,\n\t\t\t_nativePaymentsEnabled\n\t\t);\n\n\t\tsale.initialize(\n\t\t\t_owner,\n\t\t\t_config,\n\t\t\t_baseCurrency,\n\t\t\t_nativePaymentsEnabled,\n\t\t\t_nativeTokenPriceOracle,\n\t\t\ttokens,\n\t\t\toracles,\n\t\t\tdecimals\n\t\t);\n\t}\n}\n"
      },
      "contracts/sale/v2.1/Sale.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.21;\n\nimport \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol\";\n\n// Upgradeable contracts are required to use clone() in SaleFactory\nabstract contract Sale is ReentrancyGuardUpgradeable, OwnableUpgradeable {\n\tusing SafeERC20Upgradeable for IERC20Upgradeable;\n\tevent Buy(\n\t\taddress indexed buyer,\n\t\taddress indexed token,\n\t\tuint256 baseCurrencyValue,\n\t\tuint256 tokenValue,\n\t\tuint256 tokenFee\n\t);\n\n\t/**\n  Important: the constructor is only called once on the implementation contract (which is never initialized)\n  Clones using this implementation cannot use this constructor method.\n  Thus every clone must use the same fields stored in the constructor (feeBips, feeRecipient)\n  */\n\n\t/// @custom:oz-upgrades-unsafe-allow constructor\n\tconstructor() {\n\t\t_disableInitializers();\n\t}\n\n\t// is this user permitted to access a sale?\n\tfunction isValidMerkleProof(\n\t\tbytes32 root,\n\t\taddress account,\n\t\tbytes calldata data,\n\t\tbytes32[] calldata proof\n\t) public pure returns (bool) {\n\t\t// check if the account is in the merkle tree\n\t\tbytes32 leaf = keccak256(abi.encodePacked(account, data));\n\t\tif (MerkleProofUpgradeable.verify(proof, root, leaf)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tfunction buyWithToken(\n\t\tIERC20Upgradeable token,\n\t\tuint256 quantity,\n\t\tbytes calldata data,\n\t\tbytes32[] calldata proof\n\t) external virtual {}\n\n\tfunction buyWithNative(bytes calldata data, bytes32[] calldata proof) external payable virtual {}\n\n\tfunction isOpen() public view virtual returns (bool) {}\n\n\tfunction isOver() public view virtual returns (bool) {}\n\n\tfunction buyerTotal(address user) external view virtual returns (uint256) {}\n\n\tfunction total() external view virtual returns (uint256) {}\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "viaIR": true,
      "evmVersion": "paris",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}