creation_sourcecode: {{
    "language": "Solidity",
    "settings": {
      "evmVersion": "london",
      "libraries": {},
      "metadata": {
        "bytecodeHash": "none",
        "useLiteralContent": true
      },
      "optimizer": {
        "enabled": true,
        "runs": 10
      },
      "remappings": [],
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    },
    "sources": {
      "@openzeppelin/contracts/token/ERC20/IERC20.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 IERC20 {\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/token/ERC20/extensions/IERC20Permit.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 IERC20Permit {\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/token/ERC20/utils/SafeERC20.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 \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.sol\";\nimport \"../../../utils/Address.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 SafeERC20 {\n    using Address 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(IERC20 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(IERC20 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(IERC20 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(IERC20 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(IERC20 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(IERC20 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        IERC20Permit 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(IERC20 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(IERC20 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))) && Address.isContract(address(token));\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Address.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 Address {\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/utils/math/SafeMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)\n\npragma solidity ^0.8.0;\n\n// CAUTION\n// This version of SafeMath should only be used with Solidity 0.8 or later,\n// because it relies on the compiler's built in overflow checks.\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations.\n *\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\n * now has built in overflow checking.\n */\nlibrary SafeMath {\n    /**\n     * @dev Returns the addition of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            uint256 c = a + b;\n            if (c < a) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b > a) return (false, 0);\n            return (true, a - b);\n        }\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n            // benefit is lost if 'b' is also tested.\n            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n            if (a == 0) return (true, 0);\n            uint256 c = a * b;\n            if (c / a != b) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a / b);\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a % b);\n        }\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `+` operator.\n     *\n     * Requirements:\n     *\n     * - Addition cannot overflow.\n     */\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a + b;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a - b;\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `*` operator.\n     *\n     * Requirements:\n     *\n     * - Multiplication cannot overflow.\n     */\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a * b;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator.\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a / b;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a % b;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n     * overflow (when the result is negative).\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {trySub}.\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        unchecked {\n            require(b <= a, errorMessage);\n            return a - b;\n        }\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        unchecked {\n            require(b > 0, errorMessage);\n            return a / b;\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting with custom message when dividing by zero.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryMod}.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        unchecked {\n            require(b > 0, errorMessage);\n            return a % b;\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n *     // Add the library methods\n *     using EnumerableSet for EnumerableSet.AddressSet;\n *\n *     // Declare a set state variable\n *     EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n    // To implement this library for multiple types with as little code\n    // repetition as possible, we write it in terms of a generic Set type with\n    // bytes32 values.\n    // The Set implementation uses private functions, and user-facing\n    // implementations (such as AddressSet) are just wrappers around the\n    // underlying Set.\n    // This means that we can only create new EnumerableSets for types that fit\n    // in bytes32.\n\n    struct Set {\n        // Storage of set values\n        bytes32[] _values;\n        // Position of the value in the `values` array, plus 1 because index 0\n        // means a value is not in the set.\n        mapping(bytes32 => uint256) _indexes;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function _add(Set storage set, bytes32 value) private returns (bool) {\n        if (!_contains(set, value)) {\n            set._values.push(value);\n            // The value is stored at length-1, but we add 1 to all indexes\n            // and use 0 as a sentinel value\n            set._indexes[value] = set._values.length;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function _remove(Set storage set, bytes32 value) private returns (bool) {\n        // We read and store the value's index to prevent multiple reads from the same storage slot\n        uint256 valueIndex = set._indexes[value];\n\n        if (valueIndex != 0) {\n            // Equivalent to contains(set, value)\n            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n            // the array, and then remove the last element (sometimes called as 'swap and pop').\n            // This modifies the order of the array, as noted in {at}.\n\n            uint256 toDeleteIndex = valueIndex - 1;\n            uint256 lastIndex = set._values.length - 1;\n\n            if (lastIndex != toDeleteIndex) {\n                bytes32 lastValue = set._values[lastIndex];\n\n                // Move the last value to the index where the value to delete is\n                set._values[toDeleteIndex] = lastValue;\n                // Update the index for the moved value\n                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n            }\n\n            // Delete the slot where the moved value was stored\n            set._values.pop();\n\n            // Delete the index for the deleted slot\n            delete set._indexes[value];\n\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function _contains(Set storage set, bytes32 value) private view returns (bool) {\n        return set._indexes[value] != 0;\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function _length(Set storage set) private view returns (uint256) {\n        return set._values.length;\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function _at(Set storage set, uint256 index) private view returns (bytes32) {\n        return set._values[index];\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function _values(Set storage set) private view returns (bytes32[] memory) {\n        return set._values;\n    }\n\n    // Bytes32Set\n\n    struct Bytes32Set {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _add(set._inner, value);\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _remove(set._inner, value);\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n        return _contains(set._inner, value);\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(Bytes32Set storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n        return _at(set._inner, index);\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        bytes32[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // AddressSet\n\n    struct AddressSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(AddressSet storage set, address value) internal returns (bool) {\n        return _add(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(AddressSet storage set, address value) internal returns (bool) {\n        return _remove(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(AddressSet storage set, address value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(AddressSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(AddressSet storage set, uint256 index) internal view returns (address) {\n        return address(uint160(uint256(_at(set._inner, index))));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(AddressSet storage set) internal view returns (address[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        address[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // UintSet\n\n    struct UintSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(UintSet storage set, uint256 value) internal returns (bool) {\n        return _add(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(UintSet storage set, uint256 value) internal returns (bool) {\n        return _remove(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(UintSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n        return uint256(_at(set._inner, index));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(UintSet storage set) internal view returns (uint256[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        uint256[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n}\n"
      },
      "@solidstate/contracts/access/access_control/AccessControlInternal.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { EnumerableSet } from '../../data/EnumerableSet.sol';\nimport { AddressUtils } from '../../utils/AddressUtils.sol';\nimport { UintUtils } from '../../utils/UintUtils.sol';\nimport { IAccessControlInternal } from './IAccessControlInternal.sol';\nimport { AccessControlStorage } from './AccessControlStorage.sol';\n\n/**\n * @title Role-based access control system\n * @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts (MIT license)\n */\nabstract contract AccessControlInternal is IAccessControlInternal {\n    using AddressUtils for address;\n    using EnumerableSet for EnumerableSet.AddressSet;\n    using UintUtils for uint256;\n\n    modifier onlyRole(bytes32 role) {\n        _checkRole(role);\n        _;\n    }\n\n    /*\n     * @notice query whether role is assigned to account\n     * @param role role to query\n     * @param account account to query\n     * @return whether role is assigned to account\n     */\n    function _hasRole(\n        bytes32 role,\n        address account\n    ) internal view virtual returns (bool) {\n        return\n            AccessControlStorage.layout().roles[role].members.contains(account);\n    }\n\n    /**\n     * @notice revert if sender does not have given role\n     * @param role role to query\n     */\n    function _checkRole(bytes32 role) internal view virtual {\n        _checkRole(role, msg.sender);\n    }\n\n    /**\n     * @notice revert if given account does not have given role\n     * @param role role to query\n     * @param account to query\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                        account.toString(),\n                        ' is missing role ',\n                        uint256(role).toHexString(32)\n                    )\n                )\n            );\n        }\n    }\n\n    /*\n     * @notice query admin role for given role\n     * @param role role to query\n     * @return admin role\n     */\n    function _getRoleAdmin(\n        bytes32 role\n    ) internal view virtual returns (bytes32) {\n        return AccessControlStorage.layout().roles[role].adminRole;\n    }\n\n    /**\n     * @notice set role as admin role\n     * @param role role to set\n     * @param adminRole admin role to set\n     */\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n        bytes32 previousAdminRole = _getRoleAdmin(role);\n        AccessControlStorage.layout().roles[role].adminRole = adminRole;\n        emit RoleAdminChanged(role, previousAdminRole, adminRole);\n    }\n\n    /*\n     * @notice assign role to given account\n     * @param role role to assign\n     * @param account recipient of role assignment\n     */\n    function _grantRole(bytes32 role, address account) internal virtual {\n        AccessControlStorage.layout().roles[role].members.add(account);\n        emit RoleGranted(role, account, msg.sender);\n    }\n\n    /*\n     * @notice unassign role from given account\n     * @param role role to unassign\n     * @parm account\n     */\n    function _revokeRole(bytes32 role, address account) internal virtual {\n        AccessControlStorage.layout().roles[role].members.remove(account);\n        emit RoleRevoked(role, account, msg.sender);\n    }\n\n    /**\n     * @notice relinquish role\n     * @param role role to relinquish\n     */\n    function _renounceRole(bytes32 role) internal virtual {\n        _revokeRole(role, msg.sender);\n    }\n\n    /**\n     * @notice query role for member at given index\n     * @param role role to query\n     * @param index index to query\n     */\n    function _getRoleMember(\n        bytes32 role,\n        uint256 index\n    ) internal view virtual returns (address) {\n        return AccessControlStorage.layout().roles[role].members.at(index);\n    }\n\n    /**\n     * @notice query role for member count\n     * @param role role to query\n     */\n    function _getRoleMemberCount(\n        bytes32 role\n    ) internal view virtual returns (uint256) {\n        return AccessControlStorage.layout().roles[role].members.length();\n    }\n}\n"
      },
      "@solidstate/contracts/access/access_control/AccessControlStorage.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { EnumerableSet } from '../../data/EnumerableSet.sol';\n\nlibrary AccessControlStorage {\n    struct RoleData {\n        EnumerableSet.AddressSet members;\n        bytes32 adminRole;\n    }\n\n    struct Layout {\n        mapping(bytes32 => RoleData) roles;\n    }\n\n    bytes32 internal constant DEFAULT_ADMIN_ROLE = 0x00;\n\n    bytes32 internal constant STORAGE_SLOT =\n        keccak256('solidstate.contracts.storage.AccessControl');\n\n    function layout() internal pure returns (Layout storage l) {\n        bytes32 slot = STORAGE_SLOT;\n        assembly {\n            l.slot := slot\n        }\n    }\n}\n"
      },
      "@solidstate/contracts/access/access_control/IAccessControl.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IAccessControlInternal } from './IAccessControlInternal.sol';\n\n/**\n * @title AccessControl interface\n */\ninterface IAccessControl is IAccessControlInternal {\n    /*\n     * @notice query whether role is assigned to account\n     * @param role role to query\n     * @param account account to query\n     * @return whether role is assigned to account\n     */\n    function hasRole(\n        bytes32 role,\n        address account\n    ) external view returns (bool);\n\n    /*\n     * @notice query admin role for given role\n     * @param role role to query\n     * @return admin role\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /*\n     * @notice assign role to given account\n     * @param role role to assign\n     * @param account recipient of role assignment\n     */\n    function grantRole(bytes32 role, address account) external;\n\n    /*\n     * @notice unassign role from given account\n     * @param role role to unassign\n     * @parm account\n     */\n    function revokeRole(bytes32 role, address account) external;\n\n    /**\n     * @notice relinquish role\n     * @param role role to relinquish\n     */\n    function renounceRole(bytes32 role) external;\n\n    /**\n     * @notice Returns one of the accounts that have `role`. `index` must be a\n     * value between 0 and {getRoleMemberCount}, non-inclusive.\n     *\n     * Role bearers are not sorted in any particular way, and their ordering may\n     * change at any point.\n     *\n     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n     * you perform all queries on the same block. See the following\n     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n     * for more information.\n     */\n    function getRoleMember(\n        bytes32 role,\n        uint256 index\n    ) external view returns (address);\n\n    /**\n     * @notice Returns the number of accounts that have `role`. Can be used\n     * together with {getRoleMember} to enumerate all bearers of a role.\n     */\n    function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n"
      },
      "@solidstate/contracts/access/access_control/IAccessControlInternal.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title Partial AccessControl interface needed by internal functions\n */\ninterface IAccessControlInternal {\n    event RoleAdminChanged(\n        bytes32 indexed role,\n        bytes32 indexed previousAdminRole,\n        bytes32 indexed newAdminRole\n    );\n\n    event RoleGranted(\n        bytes32 indexed role,\n        address indexed account,\n        address indexed sender\n    );\n\n    event RoleRevoked(\n        bytes32 indexed role,\n        address indexed account,\n        address indexed sender\n    );\n}\n"
      },
      "@solidstate/contracts/data/EnumerableSet.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.8;\n\n/**\n * @title Set implementation with enumeration functions\n * @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts (MIT license)\n */\nlibrary EnumerableSet {\n    error EnumerableSet__IndexOutOfBounds();\n\n    struct Set {\n        bytes32[] _values;\n        // 1-indexed to allow 0 to signify nonexistence\n        mapping(bytes32 => uint256) _indexes;\n    }\n\n    struct Bytes32Set {\n        Set _inner;\n    }\n\n    struct AddressSet {\n        Set _inner;\n    }\n\n    struct UintSet {\n        Set _inner;\n    }\n\n    function at(\n        Bytes32Set storage set,\n        uint256 index\n    ) internal view returns (bytes32) {\n        return _at(set._inner, index);\n    }\n\n    function at(\n        AddressSet storage set,\n        uint256 index\n    ) internal view returns (address) {\n        return address(uint160(uint256(_at(set._inner, index))));\n    }\n\n    function at(\n        UintSet storage set,\n        uint256 index\n    ) internal view returns (uint256) {\n        return uint256(_at(set._inner, index));\n    }\n\n    function contains(\n        Bytes32Set storage set,\n        bytes32 value\n    ) internal view returns (bool) {\n        return _contains(set._inner, value);\n    }\n\n    function contains(\n        AddressSet storage set,\n        address value\n    ) internal view returns (bool) {\n        return _contains(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    function contains(\n        UintSet storage set,\n        uint256 value\n    ) internal view returns (bool) {\n        return _contains(set._inner, bytes32(value));\n    }\n\n    function indexOf(\n        Bytes32Set storage set,\n        bytes32 value\n    ) internal view returns (uint256) {\n        return _indexOf(set._inner, value);\n    }\n\n    function indexOf(\n        AddressSet storage set,\n        address value\n    ) internal view returns (uint256) {\n        return _indexOf(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    function indexOf(\n        UintSet storage set,\n        uint256 value\n    ) internal view returns (uint256) {\n        return _indexOf(set._inner, bytes32(value));\n    }\n\n    function length(Bytes32Set storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    function length(AddressSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    function length(UintSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    function add(\n        Bytes32Set storage set,\n        bytes32 value\n    ) internal returns (bool) {\n        return _add(set._inner, value);\n    }\n\n    function add(\n        AddressSet storage set,\n        address value\n    ) internal returns (bool) {\n        return _add(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    function add(UintSet storage set, uint256 value) internal returns (bool) {\n        return _add(set._inner, bytes32(value));\n    }\n\n    function remove(\n        Bytes32Set storage set,\n        bytes32 value\n    ) internal returns (bool) {\n        return _remove(set._inner, value);\n    }\n\n    function remove(\n        AddressSet storage set,\n        address value\n    ) internal returns (bool) {\n        return _remove(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    function remove(\n        UintSet storage set,\n        uint256 value\n    ) internal returns (bool) {\n        return _remove(set._inner, bytes32(value));\n    }\n\n    function toArray(\n        Bytes32Set storage set\n    ) internal view returns (bytes32[] memory) {\n        return set._inner._values;\n    }\n\n    function toArray(\n        AddressSet storage set\n    ) internal view returns (address[] memory) {\n        bytes32[] storage values = set._inner._values;\n        address[] storage array;\n\n        assembly {\n            array.slot := values.slot\n        }\n\n        return array;\n    }\n\n    function toArray(\n        UintSet storage set\n    ) internal view returns (uint256[] memory) {\n        bytes32[] storage values = set._inner._values;\n        uint256[] storage array;\n\n        assembly {\n            array.slot := values.slot\n        }\n\n        return array;\n    }\n\n    function _at(\n        Set storage set,\n        uint256 index\n    ) private view returns (bytes32) {\n        if (index >= set._values.length)\n            revert EnumerableSet__IndexOutOfBounds();\n        return set._values[index];\n    }\n\n    function _contains(\n        Set storage set,\n        bytes32 value\n    ) private view returns (bool) {\n        return set._indexes[value] != 0;\n    }\n\n    function _indexOf(\n        Set storage set,\n        bytes32 value\n    ) private view returns (uint256) {\n        unchecked {\n            return set._indexes[value] - 1;\n        }\n    }\n\n    function _length(Set storage set) private view returns (uint256) {\n        return set._values.length;\n    }\n\n    function _add(\n        Set storage set,\n        bytes32 value\n    ) private returns (bool status) {\n        if (!_contains(set, value)) {\n            set._values.push(value);\n            set._indexes[value] = set._values.length;\n            status = true;\n        }\n    }\n\n    function _remove(\n        Set storage set,\n        bytes32 value\n    ) private returns (bool status) {\n        uint256 valueIndex = set._indexes[value];\n\n        if (valueIndex != 0) {\n            unchecked {\n                bytes32 last = set._values[set._values.length - 1];\n\n                // move last value to now-vacant index\n\n                set._values[valueIndex - 1] = last;\n                set._indexes[last] = valueIndex;\n            }\n            // clear last index\n\n            set._values.pop();\n            delete set._indexes[value];\n\n            status = true;\n        }\n    }\n}\n"
      },
      "@solidstate/contracts/security/pausable/IPausable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.8;\n\nimport { IPausableInternal } from './IPausableInternal.sol';\n\ninterface IPausable is IPausableInternal {\n    /**\n     * @notice query whether contract is paused\n     * @return status whether contract is paused\n     */\n    function paused() external view returns (bool status);\n}\n"
      },
      "@solidstate/contracts/security/pausable/IPausableInternal.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.8;\n\ninterface IPausableInternal {\n    error Pausable__Paused();\n    error Pausable__NotPaused();\n\n    event Paused(address account);\n    event Unpaused(address account);\n}\n"
      },
      "@solidstate/contracts/security/pausable/Pausable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.8;\n\nimport { IPausable } from './IPausable.sol';\nimport { PausableInternal } from './PausableInternal.sol';\n\n/**\n * @title Pausable security control module.\n */\nabstract contract Pausable is IPausable, PausableInternal {\n    /**\n     * @inheritdoc IPausable\n     */\n    function paused() external view virtual returns (bool status) {\n        status = _paused();\n    }\n}\n"
      },
      "@solidstate/contracts/security/pausable/PausableInternal.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.8;\n\nimport { IPausableInternal } from './IPausableInternal.sol';\nimport { PausableStorage } from './PausableStorage.sol';\n\n/**\n * @title Internal functions for Pausable security control module.\n */\nabstract contract PausableInternal is IPausableInternal {\n    modifier whenNotPaused() {\n        if (_paused()) revert Pausable__Paused();\n        _;\n    }\n\n    modifier whenPaused() {\n        if (!_paused()) revert Pausable__NotPaused();\n        _;\n    }\n\n    /**\n     * @notice query whether contract is paused\n     * @return status whether contract is paused\n     */\n    function _paused() internal view virtual returns (bool status) {\n        status = PausableStorage.layout().paused;\n    }\n\n    /**\n     * @notice Triggers paused state, when contract is unpaused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        PausableStorage.layout().paused = true;\n        emit Paused(msg.sender);\n    }\n\n    /**\n     * @notice Triggers unpaused state, when contract is paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        delete PausableStorage.layout().paused;\n        emit Unpaused(msg.sender);\n    }\n}\n"
      },
      "@solidstate/contracts/security/pausable/PausableStorage.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.8;\n\nlibrary PausableStorage {\n    struct Layout {\n        bool paused;\n    }\n\n    bytes32 internal constant STORAGE_SLOT =\n        keccak256('solidstate.contracts.storage.Pausable');\n\n    function layout() internal pure returns (Layout storage l) {\n        bytes32 slot = STORAGE_SLOT;\n        assembly {\n            l.slot := slot\n        }\n    }\n}\n"
      },
      "@solidstate/contracts/security/reentrancy_guard/IReentrancyGuard.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface IReentrancyGuard {\n    error ReentrancyGuard__ReentrantCall();\n}\n"
      },
      "@solidstate/contracts/security/reentrancy_guard/ReentrancyGuard.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.8;\n\nimport { IReentrancyGuard } from './IReentrancyGuard.sol';\nimport { ReentrancyGuardStorage } from './ReentrancyGuardStorage.sol';\n\n/**\n * @title Utility contract for preventing reentrancy attacks\n */\nabstract contract ReentrancyGuard is IReentrancyGuard {\n    uint256 internal constant REENTRANCY_STATUS_LOCKED = 2;\n    uint256 internal constant REENTRANCY_STATUS_UNLOCKED = 1;\n\n    modifier nonReentrant() virtual {\n        if (_isReentrancyGuardLocked()) revert ReentrancyGuard__ReentrantCall();\n        _lockReentrancyGuard();\n        _;\n        _unlockReentrancyGuard();\n    }\n\n    /**\n     * @notice returns true if the reentrancy guard is locked, false otherwise\n     */\n    function _isReentrancyGuardLocked() internal view virtual returns (bool) {\n        return\n            ReentrancyGuardStorage.layout().status == REENTRANCY_STATUS_LOCKED;\n    }\n\n    /**\n     * @notice lock functions that use the nonReentrant modifier\n     */\n    function _lockReentrancyGuard() internal virtual {\n        ReentrancyGuardStorage.layout().status = REENTRANCY_STATUS_LOCKED;\n    }\n\n    /**\n     * @notice unlock functions that use the nonReentrant modifier\n     */\n    function _unlockReentrancyGuard() internal virtual {\n        ReentrancyGuardStorage.layout().status = REENTRANCY_STATUS_UNLOCKED;\n    }\n}\n"
      },
      "@solidstate/contracts/security/reentrancy_guard/ReentrancyGuardStorage.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.8;\n\nlibrary ReentrancyGuardStorage {\n    struct Layout {\n        uint256 status;\n    }\n\n    bytes32 internal constant STORAGE_SLOT =\n        keccak256('solidstate.contracts.storage.ReentrancyGuard');\n\n    function layout() internal pure returns (Layout storage l) {\n        bytes32 slot = STORAGE_SLOT;\n        assembly {\n            l.slot := slot\n        }\n    }\n}\n"
      },
      "@solidstate/contracts/utils/AddressUtils.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.8;\n\nimport { UintUtils } from './UintUtils.sol';\n\nlibrary AddressUtils {\n    using UintUtils for uint256;\n\n    error AddressUtils__InsufficientBalance();\n    error AddressUtils__NotContract();\n    error AddressUtils__SendValueFailed();\n\n    function toString(address account) internal pure returns (string memory) {\n        return uint256(uint160(account)).toHexString(20);\n    }\n\n    function isContract(address account) internal view returns (bool) {\n        uint256 size;\n        assembly {\n            size := extcodesize(account)\n        }\n        return size > 0;\n    }\n\n    function sendValue(address payable account, uint256 amount) internal {\n        (bool success, ) = account.call{ value: amount }('');\n        if (!success) revert AddressUtils__SendValueFailed();\n    }\n\n    function functionCall(\n        address target,\n        bytes memory data\n    ) internal returns (bytes memory) {\n        return\n            functionCall(target, data, 'AddressUtils: failed low-level call');\n    }\n\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory error\n    ) internal returns (bytes memory) {\n        return _functionCallWithValue(target, data, 0, error);\n    }\n\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return\n            functionCallWithValue(\n                target,\n                data,\n                value,\n                'AddressUtils: failed low-level call with value'\n            );\n    }\n\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory error\n    ) internal returns (bytes memory) {\n        if (value > address(this).balance)\n            revert AddressUtils__InsufficientBalance();\n        return _functionCallWithValue(target, data, value, error);\n    }\n\n    /**\n     * @notice execute arbitrary external call with limited gas usage and amount of copied return data\n     * @dev derived from https://github.com/nomad-xyz/ExcessivelySafeCall (MIT License)\n     * @param target recipient of call\n     * @param gasAmount gas allowance for call\n     * @param value native token value to include in call\n     * @param maxCopy maximum number of bytes to copy from return data\n     * @param data encoded call data\n     * @return success whether call is successful\n     * @return returnData copied return data\n     */\n    function excessivelySafeCall(\n        address target,\n        uint256 gasAmount,\n        uint256 value,\n        uint16 maxCopy,\n        bytes memory data\n    ) internal returns (bool success, bytes memory returnData) {\n        returnData = new bytes(maxCopy);\n\n        assembly {\n            // execute external call via assembly to avoid automatic copying of return data\n            success := call(\n                gasAmount,\n                target,\n                value,\n                add(data, 0x20),\n                mload(data),\n                0,\n                0\n            )\n\n            // determine whether to limit amount of data to copy\n            let toCopy := returndatasize()\n\n            if gt(toCopy, maxCopy) {\n                toCopy := maxCopy\n            }\n\n            // store the length of the copied bytes\n            mstore(returnData, toCopy)\n\n            // copy the bytes from returndata[0:toCopy]\n            returndatacopy(add(returnData, 0x20), 0, toCopy)\n        }\n    }\n\n    function _functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory error\n    ) private returns (bytes memory) {\n        if (!isContract(target)) revert AddressUtils__NotContract();\n\n        (bool success, bytes memory returnData) = target.call{ value: value }(\n            data\n        );\n\n        if (success) {\n            return returnData;\n        } else if (returnData.length > 0) {\n            assembly {\n                let returnData_size := mload(returnData)\n                revert(add(32, returnData), returnData_size)\n            }\n        } else {\n            revert(error);\n        }\n    }\n}\n"
      },
      "@solidstate/contracts/utils/UintUtils.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.8;\n\n/**\n * @title utility functions for uint256 operations\n * @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts/ (MIT license)\n */\nlibrary UintUtils {\n    error UintUtils__InsufficientHexLength();\n\n    bytes16 private constant HEX_SYMBOLS = '0123456789abcdef';\n\n    function add(uint256 a, int256 b) internal pure returns (uint256) {\n        return b < 0 ? sub(a, -b) : a + uint256(b);\n    }\n\n    function sub(uint256 a, int256 b) internal pure returns (uint256) {\n        return b < 0 ? add(a, -b) : a - uint256(b);\n    }\n\n    function toString(uint256 value) internal pure returns (string memory) {\n        if (value == 0) {\n            return '0';\n        }\n\n        uint256 temp = value;\n        uint256 digits;\n\n        while (temp != 0) {\n            digits++;\n            temp /= 10;\n        }\n\n        bytes memory buffer = new bytes(digits);\n\n        while (value != 0) {\n            digits -= 1;\n            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n            value /= 10;\n        }\n\n        return string(buffer);\n    }\n\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        if (value == 0) {\n            return '0x00';\n        }\n\n        uint256 length = 0;\n\n        for (uint256 temp = value; temp != 0; temp >>= 8) {\n            unchecked {\n                length++;\n            }\n        }\n\n        return toHexString(value, length);\n    }\n\n    function toHexString(\n        uint256 value,\n        uint256 length\n    ) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = '0';\n        buffer[1] = 'x';\n\n        unchecked {\n            for (uint256 i = 2 * length + 1; i > 1; --i) {\n                buffer[i] = HEX_SYMBOLS[value & 0xf];\n                value >>= 4;\n            }\n        }\n\n        if (value != 0) revert UintUtils__InsufficientHexLength();\n\n        return string(buffer);\n    }\n}\n"
      },
      "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol": {
        "content": "pragma solidity >=0.6.2;\n\ninterface IUniswapV2Router01 {\n    function factory() external pure returns (address);\n    function WETH() external pure returns (address);\n\n    function addLiquidity(\n        address tokenA,\n        address tokenB,\n        uint amountADesired,\n        uint amountBDesired,\n        uint amountAMin,\n        uint amountBMin,\n        address to,\n        uint deadline\n    ) external returns (uint amountA, uint amountB, uint liquidity);\n    function addLiquidityETH(\n        address token,\n        uint amountTokenDesired,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline\n    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\n    function removeLiquidity(\n        address tokenA,\n        address tokenB,\n        uint liquidity,\n        uint amountAMin,\n        uint amountBMin,\n        address to,\n        uint deadline\n    ) external returns (uint amountA, uint amountB);\n    function removeLiquidityETH(\n        address token,\n        uint liquidity,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline\n    ) external returns (uint amountToken, uint amountETH);\n    function removeLiquidityWithPermit(\n        address tokenA,\n        address tokenB,\n        uint liquidity,\n        uint amountAMin,\n        uint amountBMin,\n        address to,\n        uint deadline,\n        bool approveMax, uint8 v, bytes32 r, bytes32 s\n    ) external returns (uint amountA, uint amountB);\n    function removeLiquidityETHWithPermit(\n        address token,\n        uint liquidity,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline,\n        bool approveMax, uint8 v, bytes32 r, bytes32 s\n    ) external returns (uint amountToken, uint amountETH);\n    function swapExactTokensForTokens(\n        uint amountIn,\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external returns (uint[] memory amounts);\n    function swapTokensForExactTokens(\n        uint amountOut,\n        uint amountInMax,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external returns (uint[] memory amounts);\n    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\n        external\n        payable\n        returns (uint[] memory amounts);\n    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n        external\n        returns (uint[] memory amounts);\n    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n        external\n        returns (uint[] memory amounts);\n    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\n        external\n        payable\n        returns (uint[] memory amounts);\n\n    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\n    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\n    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\n    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\n    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\n}\n"
      },
      "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol": {
        "content": "pragma solidity >=0.6.2;\n\nimport './IUniswapV2Router01.sol';\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n    function removeLiquidityETHSupportingFeeOnTransferTokens(\n        address token,\n        uint liquidity,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline\n    ) external returns (uint amountETH);\n    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n        address token,\n        uint liquidity,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline,\n        bool approveMax, uint8 v, bytes32 r, bytes32 s\n    ) external returns (uint amountETH);\n\n    function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n        uint amountIn,\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external;\n    function swapExactETHForTokensSupportingFeeOnTransferTokens(\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external payable;\n    function swapExactTokensForETHSupportingFeeOnTransferTokens(\n        uint amountIn,\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external;\n}\n"
      },
      "contracts/common/diamonds/interfaces/IDiamondCut.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.23;\n\n/******************************************************************************\\\n* Author: Nick Mudge <nick@perfectabstractions.com> (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n/******************************************************************************/\n\ninterface IDiamondCut {\n    enum FacetCutAction {\n        Add,\n        Replace,\n        Remove\n    }\n    // Add=0, Replace=1, Remove=2\n\n    struct FacetCut {\n        address facetAddress;\n        FacetCutAction action;\n        bytes4[] functionSelectors;\n    }\n\n    /// @notice Add/replace/remove any number of functions and optionally execute\n    ///         a function with delegatecall\n    /// @param _diamondCut Contains the facet addresses and function selectors\n    /// @param _init The address of the contract or facet to execute _calldata\n    /// @param _calldata A function call, including function selector and arguments\n    ///                  _calldata is executed with delegatecall on _init\n    function diamondCut(FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata) external;\n}\n"
      },
      "contracts/launchpad/facets/LaunchPadProjectFacet.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.23;\n\nimport { AccessControlInternal } from \"@solidstate/contracts/access/access_control/AccessControlInternal.sol\";\nimport { IAccessControl } from \"@solidstate/contracts/access/access_control/IAccessControl.sol\";\nimport { AccessControlStorage } from \"@solidstate/contracts/access/access_control/AccessControlStorage.sol\";\nimport { Pausable } from \"@solidstate/contracts/security/pausable/Pausable.sol\";\nimport { ReentrancyGuard } from \"@solidstate/contracts/security/reentrancy_guard/ReentrancyGuard.sol\";\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { SafeMath } from \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport { IUniswapV2Router02 } from \"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\";\n\nimport { ILaunchPadFactory } from \"../interfaces/ILaunchPadFactory.sol\";\nimport { ILaunchPadQuerier } from \"../interfaces/ILaunchPadQuerier.sol\";\nimport { ILaunchPadPayment } from \"../interfaces/ILaunchPadPayment.sol\";\nimport { ILaunchPadProject, ILaunchPadCommon } from \"../interfaces/ILaunchPadProject.sol\";\nimport { LibLaunchPadProjectStorage } from \"../libraries/LaunchPadProjectStorage.sol\";\nimport { LibLaunchPadPaymentStorage } from \"../libraries/LaunchPadPaymentStorage.sol\";\nimport { LibLaunchPadConsts } from \"../libraries/LaunchPadConsts.sol\";\n\ncontract LaunchPadProjectFacet is ILaunchPadProject, ReentrancyGuard, Pausable, AccessControlInternal {\n    using SafeMath for uint256;\n    using SafeERC20 for IERC20;\n\n    function buyTokens(uint256 tokenAmount) external payable override whenNotPaused whenSaleInProgress(6) nonReentrant {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n\n        if (ds.purchasedInfoByUser[msg.sender].purchasedTokenAmount == 0) {\n            ds.investors.push(msg.sender);\n        }\n\n        ds.purchasedInfoByUser[msg.sender].purchasedTokenAmount = ds.purchasedInfoByUser[msg.sender].purchasedTokenAmount.add(tokenAmount);\n        ds.totalTokensSold = ds.totalTokensSold.add(tokenAmount);\n\n        require(\n            ds.purchasedInfoByUser[msg.sender].purchasedTokenAmount <= ds.launchPadInfo.maxInvestPerWallet,\n            \"LaunchPad:buyTokens: Max invest per wallet reached\"\n        );\n        require(ds.totalTokensSold <= ds.launchPadInfo.fundTarget.hardCap, \"LaunchPad:buyTokens: Hard cap reached\");\n\n        uint256 cost = (tokenAmount * ds.launchPadInfo.price) / (10 ** tokenDecimals());\n        if (ds.launchPadInfo.paymentTokenAddress == address(0)) {\n            require(msg.value == cost, \"LaunchPad:buyTokens: Not enough ETH\");\n            ds.purchasedInfoByUser[msg.sender].paidTokenAmount = ds.purchasedInfoByUser[msg.sender].paidTokenAmount.add(cost);\n        } else {\n            IERC20 paymentToken = IERC20(ds.launchPadInfo.paymentTokenAddress);\n            uint256 initialPaymentTokenBalance = paymentToken.balanceOf(address(this));\n            require(paymentToken.allowance(msg.sender, address(this)) >= cost, \"LaunchPad:buyTokens: Not enough allowance\");\n            paymentToken.safeTransferFrom(msg.sender, address(this), cost);\n            uint256 paidAmount = paymentToken.balanceOf(address(this)).sub(initialPaymentTokenBalance);\n            ds.purchasedInfoByUser[msg.sender].paidTokenAmount = ds.purchasedInfoByUser[msg.sender].paidTokenAmount.add(paidAmount);\n        }\n\n        // Emit event\n        ILaunchPadFactory(ds.launchPadFactory).addInvestorToLaunchPad(msg.sender);\n        emit LibLaunchPadProjectStorage.TokensPurchased(msg.sender, tokenAmount);\n    }\n\n    function buyTokensWithSupercharger(\n        ILaunchPadProject.BuyTokenInput memory input\n    ) external payable override whenNotPaused whenSaleInProgress(getCurrentTier()) onlySupercharger nonReentrant {\n        require(block.timestamp <= input.deadline, \"LaunchPad:checkSignature: Signature expired\");\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n\n        require(input.tier <= getCurrentTier(), \"LaunchPad:buyTokensWithSupercharger: User not allowed in this tier\");\n\n        // Validate signature and nonce\n        require(ds.buyTokenNonces[msg.sender].length == input.nonce, \"LaunchPad:buyTokensWithSupercharger: Nonce already used\");\n        ds.buyTokenNonces[msg.sender].push(input.nonce);\n        checkSignature(msg.sender, input.tier, input.nonce, input.deadline, input.signature);\n\n        if (ds.purchasedInfoByUser[msg.sender].purchasedTokenAmount == 0) {\n            ds.investors.push(msg.sender);\n        }\n\n        ds.purchasedInfoByUser[msg.sender].purchasedTokenAmount = ds.purchasedInfoByUser[msg.sender].purchasedTokenAmount + input.tokenAmount;\n        ds.totalTokensSold = ds.totalTokensSold.add(input.tokenAmount);\n        uint256 currentTier = getCurrentTier();\n        uint256 purchasedInBasisPoint = ds.purchasedInfoByUser[msg.sender].purchasedTokenAmount.mul(LibLaunchPadConsts.BASIS_POINTS);\n\n        require(purchasedInBasisPoint <= getMaxInvestPerWalletPerTier(currentTier), \"LaunchPad:buyTokens: Max invest per wallet reached\");\n        require(ds.totalTokensSold <= getHardCapPerTier(currentTier), \"LaunchPad:buyTokens: Hard cap reached\");\n\n        uint256 cost = (input.tokenAmount * ds.launchPadInfo.price) / (10 ** tokenDecimals());\n\n        if (ds.launchPadInfo.paymentTokenAddress == address(0)) {\n            require(msg.value == cost, \"LaunchPad:buyTokens: Not enough ETH\");\n            ds.purchasedInfoByUser[msg.sender].paidTokenAmount = ds.purchasedInfoByUser[msg.sender].paidTokenAmount.add(cost);\n        } else {\n            IERC20 paymentToken = IERC20(ds.launchPadInfo.paymentTokenAddress);\n            uint256 initialPaymentTokenBalance = paymentToken.balanceOf(address(this));\n            require(paymentToken.allowance(msg.sender, address(this)) >= cost, \"LaunchPad:buyTokens: Not enough allowance\");\n            paymentToken.safeTransferFrom(msg.sender, address(this), cost);\n            uint256 paidAmount = paymentToken.balanceOf(address(this)).sub(initialPaymentTokenBalance);\n            ds.purchasedInfoByUser[msg.sender].paidTokenAmount = ds.purchasedInfoByUser[msg.sender].paidTokenAmount.add(paidAmount);\n        }\n\n        // Emit event\n        ILaunchPadFactory(ds.launchPadFactory).addInvestorToLaunchPad(msg.sender);\n        emit LibLaunchPadProjectStorage.TokensPurchased(msg.sender, input.tokenAmount);\n    }\n\n    function checkSignature(address wallet, uint256 tier, uint256 nonce, uint256 deadline, bytes memory signature) public view override {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        address signer = ILaunchPadQuerier(ds.launchPadFactory).getSignerAddress();\n        bytes32 messageHash = _prefixed(keccak256(abi.encodePacked(wallet, tier, nonce, deadline)));\n        address recoveredSigner = recoverSigner(messageHash, signature);\n        require(signer == recoveredSigner, \"LaunchPad:validSignature: Invalid signature\");\n    }\n\n    function claimTokens() external override whenNotPaused whenSaleEnded nonReentrant {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n\n        require(ds.launchPadInfo.tokenAddress != address(0), \"LaunchPad:claimTokens: Token address is 0 - token does not exist\");\n\n        uint256 claimableAmount = getTokensAvailableToBeClaimed(msg.sender);\n        if (claimableAmount == 0) return;\n\n        ds.totalTokensClaimed = ds.totalTokensClaimed.add(claimableAmount);\n        ds.purchasedInfoByUser[msg.sender].claimedTokenAmount = ds.purchasedInfoByUser[msg.sender].claimedTokenAmount.add(claimableAmount);\n\n        // Transfer tokens to buyer\n        IERC20 token = IERC20(ds.launchPadInfo.tokenAddress);\n        require(token.balanceOf(address(this)) >= claimableAmount, \"LaunchPad:claimTokens: Not enough tokens in contract\");\n        token.safeTransfer(msg.sender, claimableAmount);\n    }\n\n    function getCurrentTier() public view override returns (uint256) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        uint256[] memory headstarts = ILaunchPadQuerier(ds.launchPadFactory).getSuperChargerHeadstarts();\n        if (ds.launchPadInfo.startTimestamp < block.timestamp) return headstarts.length; // last tier\n        uint256 secondsLeft = ds.launchPadInfo.startTimestamp - block.timestamp;\n        for (uint256 i = 0; i < headstarts.length; i++) {\n            if (secondsLeft > headstarts[i]) return i;\n        }\n        return 0; // not active yet\n    }\n\n    function getFeeShare() public view override returns (uint256) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        uint256 totalRaised = getTotalRaised();\n        return totalRaised.mul(ds.feePercentage).div(LibLaunchPadConsts.BASIS_POINTS);\n    }\n\n    function getHardCapPerTier(uint256 tier) public view override returns (uint256) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        uint256 tokensPerc = ILaunchPadQuerier(ds.launchPadFactory).getSuperChargerTokensPercByTier(tier);\n        return (ds.launchPadInfo.fundTarget.hardCap * tokensPerc) / LibLaunchPadConsts.BASIS_POINTS;\n    }\n\n    function getMaxInvestPerWalletPerTier(uint256 tier) public view override returns (uint256) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        uint256 multiplier = ILaunchPadQuerier(ds.launchPadFactory).getSuperChargerMultiplierByTier(tier);\n        return (ds.launchPadInfo.maxInvestPerWallet * multiplier);\n    }\n\n    function getNextNonce(address user) external view override returns (uint256) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ds.buyTokenNonces[user].length;\n    }\n\n    function getTotalRaised() public view override returns (uint256) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ds.totalTokensSold.mul(ds.launchPadInfo.price).div(10 ** tokenDecimals());\n    }\n\n    function getLaunchPadAddress() external view override returns (address) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ds.launchPadFactory;\n    }\n\n    function getLaunchPadInfo() external view override returns (ILaunchPadCommon.LaunchPadInfo memory) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ds.launchPadInfo;\n    }\n\n    function getProjectOwnerRole() external pure override returns (bytes32) {\n        return LibLaunchPadProjectStorage.LAUNCHPAD_OWNER_ROLE;\n    }\n\n    function getReleaseSchedule() external view override returns (ILaunchPadCommon.ReleaseScheduleV2[] memory) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ds.releaseScheduleV2;\n    }\n\n    function getReleasedTokensPercentage() public view override returns (uint256 releasedPerc) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        uint256 releaseScheduleV2Length = ds.releaseScheduleV2.length;\n        for (uint256 i = 0; i < releaseScheduleV2Length; i++) {\n            if (ds.releaseScheduleV2[i].timestamp <= block.timestamp) {\n                releasedPerc += ds.releaseScheduleV2[i].percent;\n            } else if (i > 0 && ds.releaseScheduleV2[i].isVesting && ds.releaseScheduleV2[i - 1].timestamp <= block.timestamp) {\n                releasedPerc +=\n                    (ds.releaseScheduleV2[i].percent * (block.timestamp - ds.releaseScheduleV2[i - 1].timestamp)) /\n                    (ds.releaseScheduleV2[i].timestamp - ds.releaseScheduleV2[i - 1].timestamp);\n                break;\n            }\n        }\n        return releasedPerc;\n    }\n\n    function getTokensAvailableToBeClaimed(address user) public view override returns (uint256) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        uint256 releasedPerc = getReleasedTokensPercentage();\n        if (releasedPerc == LibLaunchPadConsts.BASIS_POINTS)\n            return ds.purchasedInfoByUser[user].purchasedTokenAmount.sub(ds.purchasedInfoByUser[user].claimedTokenAmount);\n        if (releasedPerc == 0) return 0;\n        uint256 claimableAmount = ds.purchasedInfoByUser[user].purchasedTokenAmount.mul(releasedPerc).div(LibLaunchPadConsts.BASIS_POINTS);\n        return claimableAmount.sub(ds.purchasedInfoByUser[user].claimedTokenAmount);\n    }\n\n    function getTokenCreationDeadline() external view override returns (uint256) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ds.launchPadInfo.tokenCreationDeadline;\n    }\n\n    function getPurchasedInfoByUser(address user) external view override returns (PurchasedInfo memory) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ds.purchasedInfoByUser[user];\n    }\n\n    function getInvestorsLength() external view override returns (uint256) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ds.investors.length;\n    }\n\n    function getAllInvestors() external view override returns (address[] memory) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ds.investors;\n    }\n\n    function getInvestorAddressByIndex(uint256 index) external view override returns (address) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ds.investors[index];\n    }\n\n    function isSuperchargerEnabled() external view override returns (bool) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ds.isSuperchargerEnabled;\n    }\n\n    /// builds a prefixed hash to mimic the behavior of eth_sign.\n    function _prefixed(bytes32 hash) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n    }\n\n    function recoverSigner(bytes32 message, bytes memory signature) public pure returns (address) {\n        require(signature.length == 65, \"LaunchPad:recoverSigner: Signature length is invalid\");\n        bytes32 r;\n        bytes32 s;\n        uint8 v;\n\n        assembly {\n            r := mload(add(signature, 32))\n            s := mload(add(signature, 64))\n            v := byte(0, mload(add(signature, 96)))\n        }\n        return ecrecover(message, v, r, s);\n    }\n\n    function _refundPaymentToken(address user, uint256 tokenAmount, uint256 refundAmount, uint256 penaltyFee) private {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n\n        ds.purchasedInfoByUser[user].purchasedTokenAmount -= tokenAmount;\n        ds.purchasedInfoByUser[user].paidTokenAmount -= refundAmount;\n\n        uint256 _refundableAmount = refundAmount - penaltyFee;\n        require(_refundableAmount > 0, \"LaunchPad:refund: refundable amount must be greater than zero\");\n\n        if (ds.launchPadInfo.paymentTokenAddress == address(0)) {\n            // We specifically ignore this return value.\n            (bool success, ) = payable(user).call{ value: _refundableAmount }(\"\");\n            require(success, \"LaunchPad:refund: Failed to transfer ETH to buyer\");\n        } else {\n            IERC20 paymentToken = IERC20(ds.launchPadInfo.paymentTokenAddress);\n            paymentToken.safeTransfer(user, _refundableAmount);\n        }\n\n        emit LibLaunchPadProjectStorage.TokensRefunded(user, tokenAmount);\n    }\n\n    function refund(uint256 tokenAmount) external override whenSaleInProgress(6) nonReentrant {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        require(ds.purchasedInfoByUser[msg.sender].purchasedTokenAmount >= tokenAmount, \"LaunchPad:refund: Amount must be less than ds.purchasedAmountByUser\");\n        require(block.timestamp <= ds.launchPadInfo.startTimestamp.add(ds.launchPadInfo.refundInfo.expireDuration), \"LaunchPad:refund: Refund time has passed\");\n\n        uint256 refundAmount = tokenAmount.mul(ds.launchPadInfo.price).div(10 ** tokenDecimals());\n        require(\n            refundAmount <= ds.purchasedInfoByUser[msg.sender].paidTokenAmount,\n            \"LaunchPad:refund: Amount of paymentToken must be less than ds.paidTokenAmountByUser\"\n        );\n\n        uint256 penaltyFee = refundAmount.mul(ds.launchPadInfo.refundInfo.penaltyFeePercent).div(LibLaunchPadConsts.BASIS_POINTS);\n\n        _refundPaymentToken(msg.sender, tokenAmount, refundAmount, penaltyFee);\n    }\n\n    function refundOnTokenCreationExpired(uint256 tokenAmount) external override whenSaleEnded nonReentrant {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        require(ds.launchPadInfo.tokenAddress == address(0), \"LaunchPad:refundOnTokenCreationExpired: Token has been created\");\n        require(block.timestamp > ds.launchPadInfo.tokenCreationDeadline, \"LaunchPad:refundOnTokenCreationExpired: Token creation deadline has not passed\");\n        require(\n            ds.purchasedInfoByUser[msg.sender].purchasedTokenAmount >= tokenAmount,\n            \"LaunchPad:refundOnTokenCreationExpired: Amount must be less than ds.purchasedAmountByUser\"\n        );\n\n        uint256 refundAmount = tokenAmount.mul(ds.launchPadInfo.price).div(10 ** tokenDecimals());\n        require(refundAmount <= ds.purchasedInfoByUser[msg.sender].paidTokenAmount, \"LaunchPad:refundOnTokenCreationExpired: Amount of paymentToken too big\");\n        _refundPaymentToken(msg.sender, tokenAmount, refundAmount, 0);\n    }\n\n    function refundOnSoftCapFailure() external override whenSaleEnded nonReentrant {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        require(ds.totalTokensSold < ds.launchPadInfo.fundTarget.softCap, \"LaunchPad:refundOnSoftCapFailure: Soft cap has been reached\");\n        _refundPaymentToken(msg.sender, ds.purchasedInfoByUser[msg.sender].purchasedTokenAmount, ds.purchasedInfoByUser[msg.sender].paidTokenAmount, 0);\n    }\n\n    function tokenDecimals() public view override returns (uint256) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ILaunchPadQuerier(ds.launchPadFactory).launchPadTokenInfo(address(this)).decimals;\n    }\n\n    function totalTokensSold() external view override returns (uint256) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ds.totalTokensSold;\n    }\n\n    function totalTokensClaimed() external view override returns (uint256) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        return ds.totalTokensClaimed;\n    }\n\n    /**\n        This intentionally doesn't require permissions.\n        Anyone can call this, the fees will be sent to the current treasury.\n    */\n    function withdrawFees() public override whenSaleEnded {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        require(ds.launchPadInfo.tokenAddress != address(0), \"LaunchPad:withdrawFees: Token must be created first\");\n        require(\n            _hasRole(LibLaunchPadProjectStorage.LAUNCHPAD_OWNER_ROLE, msg.sender) ||\n                IAccessControl(ds.launchPadFactory).hasRole(AccessControlStorage.DEFAULT_ADMIN_ROLE, msg.sender),\n            \"LaunchPad:withdrawFees: Only owner can withdraw fees\"\n        );\n        if (ds.feeShareCollected) return;\n        ds.feeShareCollected = true;\n        address tokenFiToken = ILaunchPadPayment(ds.launchPadFactory).getTokenFiToken();\n\n        uint256 _feeAmount = getFeeShare();\n        require(_feeAmount > 0, \"LaunchPad:withdrawFees: Fee amount must be greater than zero\");\n        address treasury = ILaunchPadPayment(ds.launchPadFactory).getTreasury();\n\n        if (ds.launchPadInfo.paymentTokenAddress == address(0)) {\n            // We specifically ignore this return value.\n            (bool success, ) = payable(treasury).call{ value: _feeAmount }(\"\");\n            require(success, \"LaunchPad:withdrawFees: Failed to transfer ETH to owner\");\n        } else {\n            IERC20 paymentToken = IERC20(ds.launchPadInfo.paymentTokenAddress);\n\n            // BURN TOKENFI\n            if (address(tokenFiToken) != address(0)) {\n                IUniswapV2Router02 router = IUniswapV2Router02(ILaunchPadPayment(ds.launchPadFactory).getRouterAddress());\n                uint256 _burnShare = (_feeAmount * LibLaunchPadConsts.BURN_BASIS_POINTS) / LibLaunchPadConsts.BASIS_POINTS;\n\n                _feeAmount -= _burnShare;\n\n                uint256 tokenBalance = IERC20(tokenFiToken).balanceOf(LibLaunchPadConsts.BURN_ADDRESS);\n\n                address[] memory path = new address[](3);\n                path[0] = ds.launchPadInfo.paymentTokenAddress;\n                path[1] = router.WETH();\n                path[2] = address(tokenFiToken);\n                if (paymentToken.allowance(address(this), address(router)) != 0) {\n                    paymentToken.approve(address(router), 0);\n                }\n                paymentToken.safeApprove(address(router), _burnShare);\n                router.swapExactTokensForTokensSupportingFeeOnTransferTokens(_burnShare, 0, path, LibLaunchPadConsts.BURN_ADDRESS, block.timestamp);\n                uint256 tokenBurned = IERC20(tokenFiToken).balanceOf(LibLaunchPadConsts.BURN_ADDRESS) - tokenBalance;\n                emit LibLaunchPadPaymentStorage.TokenBurned(address(this), tokenFiToken, tokenBurned);\n            }\n\n            paymentToken.safeTransfer(treasury, _feeAmount);\n        }\n    }\n\n    /** ADMIN */\n\n    function setSupercharger(bool enabled) external override beforeSaleStart onlyRole(AccessControlStorage.DEFAULT_ADMIN_ROLE) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        ds.isSuperchargerEnabled = enabled;\n    }\n\n    function setTokenAddress(address tokenAddress) external override whenSaleEnded onlyRole(AccessControlStorage.DEFAULT_ADMIN_ROLE) {\n        require(tokenAddress != address(0), \"LaunchPad:setTokenAddress: Token address is 0\");\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        require(ds.totalTokensSold >= ds.launchPadInfo.fundTarget.softCap, \"LaunchPad:withdrawTokens: Soft cap has not been reached\");\n        require(ds.launchPadInfo.tokenAddress == address(0), \"LaunchPad:setTokenAddress: Token address is already set\");\n\n        ds.launchPadInfo.tokenAddress = tokenAddress;\n    }\n\n    function withdrawTokens(address tokenAddress) external override whenSaleEnded onlyRole(LibLaunchPadProjectStorage.LAUNCHPAD_OWNER_ROLE) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        require(ds.launchPadInfo.tokenAddress != address(0), \"LaunchPad:withdrawTokens: Token must be created first\");\n        if (tokenAddress == ds.launchPadInfo.paymentTokenAddress) {\n            require(ds.totalTokensSold >= ds.launchPadInfo.fundTarget.softCap, \"LaunchPad:withdrawTokens: Soft cap has not been reached\");\n            withdrawFees();\n            uint256 balanceOfContract = IERC20(ds.launchPadInfo.paymentTokenAddress).balanceOf(address(this));\n            IERC20(tokenAddress).safeTransfer(ds.launchPadInfo.owner, balanceOfContract);\n        } else if (tokenAddress == address(0)) {\n            // We specifically ignore this return value.\n            (bool success, ) = payable(ds.launchPadInfo.owner).call{ value: address(this).balance }(\"\");\n            require(success, \"LaunchPad:withdrawTokens: Failed to transfer ETH to owner\");\n        } else if (tokenAddress == ds.launchPadInfo.tokenAddress) {\n            uint256 tokenAmountToBeClaimed = (ds.totalTokensSold.sub(ds.totalTokensClaimed));\n            uint256 balanceOfContract = IERC20(tokenAddress).balanceOf(address(this));\n            uint256 amount = balanceOfContract.sub(tokenAmountToBeClaimed);\n            IERC20(tokenAddress).safeTransfer(ds.launchPadInfo.owner, amount);\n        }\n    }\n\n    function withdrawTokensToRecipient(\n        address tokenAddress,\n        address recipient\n    ) external override whenSaleEnded onlyRole(LibLaunchPadProjectStorage.LAUNCHPAD_OWNER_ROLE) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        require(ds.launchPadInfo.tokenAddress != address(0), \"LaunchPad:withdrawTokens: Token must be created first\");\n        if (tokenAddress == ds.launchPadInfo.paymentTokenAddress) {\n            require(ds.totalTokensSold >= ds.launchPadInfo.fundTarget.softCap, \"LaunchPad:withdrawTokens: Soft cap has not been reached\");\n            withdrawFees();\n            uint256 balanceOfContract = IERC20(ds.launchPadInfo.paymentTokenAddress).balanceOf(address(this));\n            IERC20(tokenAddress).safeTransfer(recipient, balanceOfContract);\n        } else if (tokenAddress == address(0)) {\n            // We specifically ignore this return value.\n            (bool success, ) = payable(recipient).call{ value: address(this).balance }(\"\");\n            require(success, \"LaunchPad:withdrawTokens: Failed to transfer ETH to owner\");\n        } else if (tokenAddress == ds.launchPadInfo.tokenAddress) {\n            uint256 tokenAmountToBeClaimed = (ds.totalTokensSold.sub(ds.totalTokensClaimed));\n            uint256 balanceOfContract = IERC20(tokenAddress).balanceOf(address(this));\n            uint256 amount = balanceOfContract.sub(tokenAmountToBeClaimed);\n            IERC20(tokenAddress).safeTransfer(recipient, amount);\n        }\n    }\n\n    /** MODIFIER */\n\n    modifier onlySupercharger() {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        require(ds.isSuperchargerEnabled, \"LaunchPad:onlySupercharger: Supercharger is not enabled\");\n        _;\n    }\n\n    modifier beforeSaleStart() {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        uint256 headstart = ILaunchPadQuerier(ds.launchPadFactory).getSuperChargerHeadstartByTier(1);\n        uint256 startTimestamp = ds.launchPadInfo.startTimestamp - headstart;\n        require(block.timestamp < startTimestamp && block.timestamp <= ds.launchPadInfo.startTimestamp.add(ds.launchPadInfo.duration), \"Sale has started\");\n        _;\n    }\n\n    modifier whenSaleInProgress(uint256 tier) {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        require(tier > 0, \"LaunchPad:whenSaleInProgress: Tier must be greater than 0\");\n        uint256 headstart = ILaunchPadQuerier(ds.launchPadFactory).getSuperChargerHeadstartByTier(tier);\n        uint256 startTimestamp = ds.launchPadInfo.startTimestamp - headstart;\n        require(\n            block.timestamp >= startTimestamp && block.timestamp <= ds.launchPadInfo.startTimestamp.add(ds.launchPadInfo.duration),\n            \"Sale is outside of the duration\"\n        );\n        _;\n    }\n\n    modifier whenSaleEnded() {\n        LibLaunchPadProjectStorage.DiamondStorage storage ds = LibLaunchPadProjectStorage.diamondStorage();\n        require(block.timestamp > ds.launchPadInfo.startTimestamp.add(ds.launchPadInfo.duration), \"Sale is still ongoing\");\n        _;\n    }\n}\n"
      },
      "contracts/launchpad/interfaces/ILaunchPadCommon.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.23;\n\ninterface ILaunchPadCommon {\n    enum LaunchPadType {\n        FlokiPadCreatedBefore,\n        FlokiPadCreatedAfter\n    }\n\n    enum PaymentMethod {\n        NATIVE,\n        USD,\n        TOKENFI\n    }\n\n    struct IdoInfo {\n        bool enabled;\n        address dexRouter;\n        address pairToken;\n        uint256 price;\n        uint256 amountToList;\n    }\n\n    struct RefundInfo {\n        uint256 penaltyFeePercent;\n        uint256 expireDuration;\n    }\n\n    struct FundTarget {\n        uint256 softCap;\n        uint256 hardCap;\n    }\n\n    struct ReleaseSchedule {\n        uint256 timestamp;\n        uint256 percent;\n    }\n\n    struct ReleaseScheduleV2 {\n        uint256 timestamp;\n        uint256 percent;\n        bool isVesting;\n    }\n\n    struct CreateErc20Input {\n        string name;\n        string symbol;\n        string logo;\n        uint8 decimals;\n        uint256 maxSupply;\n        address owner;\n        uint256 treasuryReserved;\n    }\n\n    struct LaunchPadInfo {\n        address owner;\n        address tokenAddress;\n        address paymentTokenAddress;\n        uint256 price;\n        FundTarget fundTarget;\n        uint256 maxInvestPerWallet;\n        uint256 startTimestamp;\n        uint256 duration;\n        uint256 tokenCreationDeadline;\n        RefundInfo refundInfo;\n        IdoInfo idoInfo;\n    }\n\n    struct CreateLaunchPadInput {\n        LaunchPadType launchPadType;\n        LaunchPadInfo launchPadInfo;\n        ReleaseScheduleV2[] releaseSchedule;\n        CreateErc20Input createErc20Input;\n        address referrer;\n        bool isSuperchargerEnabled;\n        PaymentMethod paymentMethod;\n    }\n}\n"
      },
      "contracts/launchpad/interfaces/ILaunchPadFactory.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.23;\n\nimport { ILaunchPadCommon } from \"./ILaunchPadCommon.sol\";\nimport { IDiamondCut } from \"../../common/diamonds/interfaces/IDiamondCut.sol\";\n\ninterface ILaunchPadFactory is ILaunchPadCommon {\n    struct StoreLaunchPadInput {\n        ILaunchPadCommon.LaunchPadType launchPadType;\n        address launchPadAddress;\n        address owner;\n        address referrer;\n        uint256 usdPrice;\n    }\n\n    function addInvestorToLaunchPad(address investor) external;\n\n    function createLaunchPad(ILaunchPadCommon.CreateLaunchPadInput memory input) external payable;\n\n    function createTokenAfterICO(address launchPadAddress) external payable;\n\n    function setExistingTokenAfterICO(address launchPad, address tokenAddress, uint256 amount) external;\n\n    function setExistingTokenAfterTransfer(address launchPad, address tokenAddress) external;\n\n    function createV2LiquidityPool(address launchPadAddress) external payable;\n\n    function updateLaunchPadOwner(address tokenAddress, address newOwner) external;\n}\n"
      },
      "contracts/launchpad/interfaces/ILaunchPadPayment.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.23;\n\nimport { ILaunchPadCommon } from \"./ILaunchPadCommon.sol\";\n\ninterface ILaunchPadPayment is ILaunchPadCommon {\n    struct ProcessPaymentInput {\n        address referrer;\n        uint256 usdPrice;\n        address user;\n        PaymentMethod paymentMethod;\n    }\n\n    struct ProcessPaymentOutput {\n        PaymentMethod paymentMethod;\n        uint256 paymentAmount;\n        uint256 burnedAmount;\n        uint256 treasuryShare;\n    }\n\n    function getRouterAddress() external view returns (address);\n\n    function getTokenFiToken() external view returns (address);\n\n    function getTreasury() external view returns (address);\n\n    function getUsdToken() external view returns (address);\n\n    function processPayment(ProcessPaymentInput memory params) external payable;\n}\n"
      },
      "contracts/launchpad/interfaces/ILaunchPadProject.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.23;\n\nimport { ILaunchPadCommon } from \"./ILaunchPadCommon.sol\";\n\ninterface ILaunchPadProject {\n    struct PurchasedInfo {\n        uint256 purchasedTokenAmount;\n        uint256 claimedTokenAmount;\n        uint256 paidTokenAmount;\n    }\n\n    struct BuyTokenInput {\n        uint256 tokenAmount;\n        uint256 tier;\n        uint256 nonce;\n        uint256 deadline;\n        bytes signature;\n    }\n\n    function buyTokens(uint256 tokenAmount) external payable;\n\n    function buyTokensWithSupercharger(BuyTokenInput memory input) external payable;\n\n    function checkSignature(address wallet, uint256 tier, uint256 nonce, uint256 deadline, bytes memory signature) external view;\n\n    function claimTokens() external;\n\n    function getAllInvestors() external view returns (address[] memory);\n\n    function getCurrentTier() external view returns (uint256);\n\n    function getFeeShare() external view returns (uint256);\n\n    function getHardCapPerTier(uint256 tier) external view returns (uint256);\n\n    function getInvestorAddressByIndex(uint256 index) external view returns (address);\n\n    function getInvestorsLength() external view returns (uint256);\n\n    function getLaunchPadAddress() external view returns (address);\n\n    function getLaunchPadInfo() external view returns (ILaunchPadCommon.LaunchPadInfo memory);\n\n    function getMaxInvestPerWalletPerTier(uint256 tier) external view returns (uint256);\n\n    function getNextNonce(address user) external view returns (uint256);\n\n    function getProjectOwnerRole() external view returns (bytes32);\n\n    function getPurchasedInfoByUser(address user) external view returns (PurchasedInfo memory);\n\n    function getReleasedTokensPercentage() external view returns (uint256);\n\n    function getReleaseSchedule() external view returns (ILaunchPadCommon.ReleaseScheduleV2[] memory);\n\n    function getTokensAvailableToBeClaimed(address user) external view returns (uint256);\n\n    function getTokenCreationDeadline() external view returns (uint256);\n\n    function getTotalRaised() external view returns (uint256);\n\n    function isSuperchargerEnabled() external view returns (bool);\n\n    function recoverSigner(bytes32 message, bytes memory signature) external view returns (address);\n\n    function refund(uint256 tokenAmount) external;\n\n    function refundOnSoftCapFailure() external;\n\n    function refundOnTokenCreationExpired(uint256 tokenAmount) external;\n\n    function setSupercharger(bool isSuperchargerEnabled) external;\n\n    function setTokenAddress(address tokenAddress) external;\n\n    function tokenDecimals() external view returns (uint256);\n\n    function totalTokensClaimed() external view returns (uint256);\n\n    function totalTokensSold() external view returns (uint256);\n\n    function withdrawFees() external;\n\n    function withdrawTokens(address tokenAddress) external;\n\n    function withdrawTokensToRecipient(address tokenAddress, address recipient) external;\n}\n"
      },
      "contracts/launchpad/interfaces/ILaunchPadQuerier.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.23;\n\nimport { ILaunchPadCommon } from \"./ILaunchPadCommon.sol\";\n\ninterface ILaunchPadQuerier is ILaunchPadCommon {\n    function getLaunchPadsPaginated(uint256 quantity, uint256 page) external view returns (address[] memory);\n\n    function getLaunchPadsCount() external view returns (uint256);\n\n    function getLaunchPadsByInvestorPaginated(address investor, uint256 quantity, uint256 page) external view returns (address[] memory);\n\n    function getLaunchPadsByInvestorCount() external view returns (uint256);\n\n    function getLaunchPadCountByOwner(address owner) external view returns (uint256);\n\n    function getLaunchPadsByOwnerPaginated(address owner, uint256 quantity, uint256 page) external view returns (address[] memory);\n\n    function getMaxTokenCreationDeadline() external view returns (uint256);\n\n    function getSignerAddress() external view returns (address);\n\n    function getSuperChargerHeadstartByTier(uint256 tier) external view returns (uint256);\n\n    function getSuperChargerHeadstarts() external view returns (uint256[] memory);\n\n    function getSuperChargerMultiplierByTier(uint256 tier) external view returns (uint256);\n\n    function getSuperChargerTokensPercByTier(uint256 tier) external view returns (uint256);\n\n    function launchPadTokenInfo(address launchPadAddress) external view returns (CreateErc20Input memory createErc20Input);\n\n    function tokenLauncherERC20() external view returns (address);\n}\n"
      },
      "contracts/launchpad/libraries/LaunchPadConsts.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.23;\n\nlibrary LibLaunchPadConsts {\n    bytes32 internal constant PRODUCT_ID = keccak256(\"tokenfi.launchpad\");\n    uint256 internal constant BASIS_POINTS = 10_000;\n    uint256 internal constant REFERRER_BASIS_POINTS = 2_500;\n    uint256 internal constant BURN_BASIS_POINTS = 5_000;\n    address internal constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;\n}\n"
      },
      "contracts/launchpad/libraries/LaunchPadPaymentStorage.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.23;\n\nimport { ILaunchPadPayment } from \"../interfaces/ILaunchPadPayment.sol\";\nimport { EnumerableSet } from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\n/// @notice storage for LaunchPad\n\nlibrary LibLaunchPadPaymentStorage {\n    bytes32 internal constant DIAMOND_STORAGE_POSITION = keccak256(\"tokenfi.launchpad.payment.diamond.storage\");\n\n    struct DiamondStorage {\n        address tokenfiToken;\n        address usdToken;\n        address router;\n        address treasury;\n    }\n\n    event TreasuryAddressUpdated(address indexed oldTreasury, address indexed newTreasury);\n    event PaymentProcessed(uint256 indexed previousBlock, ILaunchPadPayment.ProcessPaymentOutput paymentOutput);\n    event TokenBurned(address indexed from, address indexed tokenAddress, uint256 amount);\n\n    function diamondStorage() internal pure returns (DiamondStorage storage ds) {\n        bytes32 position = DIAMOND_STORAGE_POSITION;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            ds.slot := position\n        }\n    }\n}\n"
      },
      "contracts/launchpad/libraries/LaunchPadProjectStorage.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.23;\n\nimport { ILaunchPadCommon } from \"../interfaces/ILaunchPadProject.sol\";\nimport { ILaunchPadProject } from \"../interfaces/ILaunchPadProject.sol\";\n\n/// @notice storage for LaunchPads created by users\n\nlibrary LibLaunchPadProjectStorage {\n    bytes32 internal constant DIAMOND_STORAGE_POSITION = keccak256(\"tokenfi.launchpad.project.diamond.storage\");\n    bytes32 internal constant LAUNCHPAD_OWNER_ROLE = keccak256(\"LAUNCHPAD_OWNER_ROLE\");\n    bytes32 internal constant PAUSER_ROLE = keccak256(\"PAUSER_ROLE\");\n\n    struct DiamondStorage {\n        ILaunchPadCommon.LaunchPadInfo launchPadInfo;\n        address launchPadFactory;\n        uint256 totalTokensSold;\n        uint256 totalTokensClaimed;\n        uint256 feePercentage; // in basis points 1e4\n        bool feeShareCollected;\n        bool isSuperchargerEnabled;\n        ILaunchPadCommon.ReleaseSchedule[] releaseSchedule;\n        ILaunchPadCommon.ReleaseScheduleV2[] releaseScheduleV2;\n        mapping(address => ILaunchPadProject.PurchasedInfo) purchasedInfoByUser;\n        address[] investors;\n        mapping(address => uint256[]) buyTokenNonces;\n    }\n\n    event TokensPurchased(address indexed buyer, uint256 amount);\n    event TokensRefunded(address indexed buyer, uint256 amount);\n\n    function diamondStorage() internal pure returns (DiamondStorage storage ds) {\n        bytes32 position = DIAMOND_STORAGE_POSITION;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            ds.slot := position\n        }\n    }\n}\n"
      }
    }
  }}