creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    function __Ownable_init() internal onlyInitializing {\n        __Ownable_init_unchained();\n    }\n\n    function __Ownable_init_unchained() internal onlyInitializing {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts.\n     *\n     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n     * constructor.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n     * are added through upgrades and that require initialization.\n     *\n     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n     * cannot be nested. If one is invoked in the context of another, execution will revert.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     *\n     * WARNING: setting the version to 255 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     *\n     * Emits an {Initialized} event the first time it is successfully executed.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized < type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint8) {\n        return _initialized;\n    }\n\n    /**\n     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n     */\n    function _isInitializing() internal view returns (bool) {\n        return _initializing;\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    bool private _paused;\n\n    /**\n     * @dev Initializes the contract in unpaused state.\n     */\n    function __Pausable_init() internal onlyInitializing {\n        __Pausable_init_unchained();\n    }\n\n    function __Pausable_init_unchained() internal onlyInitializing {\n        _paused = false;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        _requireNotPaused();\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        _requirePaused();\n        _;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        return _paused;\n    }\n\n    /**\n     * @dev Throws if the contract is paused.\n     */\n    function _requireNotPaused() internal view virtual {\n        require(!paused(), \"Pausable: paused\");\n    }\n\n    /**\n     * @dev Throws if the contract is not paused.\n     */\n    function _requirePaused() internal view virtual {\n        require(paused(), \"Pausable: not paused\");\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        _paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        _paused = false;\n        emit Unpaused(_msgSender());\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant _NOT_ENTERED = 1;\n    uint256 private constant _ENTERED = 2;\n\n    uint256 private _status;\n\n    function __ReentrancyGuard_init() internal onlyInitializing {\n        __ReentrancyGuard_init_unchained();\n    }\n\n    function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        _nonReentrantBefore();\n        _;\n        _nonReentrantAfter();\n    }\n\n    function _nonReentrantBefore() private {\n        // On the first call to nonReentrant, _status will be _NOT_ENTERED\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\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://diligence.consensys.net/posts/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.5.11/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(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) 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 Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/ETH/PresaleV1.sol": {
        "content": "//SPDX-License-Identifier: MIT\r\n//               _    _____                                        _\r\n// __      _____| |__|___ / _ __   __ _ _   _ _ __ ___   ___ _ __ | |_ ___\r\n// \\ \\ /\\ / / _ \\ '_ \\ |_ \\| '_ \\ / _` | | | | '_ ` _ \\ / _ \\ '_ \\| __/ __|\r\n//  \\ V  V /  __/ |_) |__) | |_) | (_| | |_| | | | | | |  __/ | | | |_\\__ \\\r\n//   \\_/\\_/ \\___|_.__/____/| .__/ \\__,_|\\__, |_| |_| |_|\\___|_| |_|\\__|___/\r\n//                         |_|          |___/\r\n//\r\npragma solidity 0.8.9;\r\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\r\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\r\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\r\nimport \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\r\n\r\ninterface Aggregator {\r\n  function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);\r\n}\r\n\r\ninterface StakingManager {\r\n  function depositByPresale(address _user, uint256 _amount) external;\r\n}\r\n\r\ncontract PresaleV1 is Initializable, ReentrancyGuardUpgradeable, OwnableUpgradeable, PausableUpgradeable {\r\n  uint256 public totalTokensSold;\r\n  uint256 public startTime;\r\n  uint256 public endTime;\r\n  uint256 public claimStart;\r\n  address public saleToken;\r\n  uint256 public baseDecimals;\r\n  uint256 public maxTokensToBuy;\r\n  uint256 public currentStep;\r\n  uint256 public checkPoint;\r\n  uint256 public usdRaised;\r\n  uint256 public timeConstant;\r\n  uint256 public totalBoughtAndStaked;\r\n  uint256[][3] public rounds;\r\n  uint256[] public prevCheckpoints;\r\n  uint256[] public remainingTokensTracker;\r\n  uint256[] public percentages;\r\n  address[] public wallets;\r\n  address public paymentWallet;\r\n  address public admin;\r\n  bool public dynamicTimeFlag;\r\n  bool public whitelistClaimOnly;\r\n  bool public stakeingWhitelistStatus;\r\n\r\n  IERC20Upgradeable public USDTInterface;\r\n  Aggregator public aggregatorInterface;\r\n  mapping(address => uint256) public userDeposits;\r\n  mapping(address => bool) public hasClaimed;\r\n  mapping(address => bool) public isBlacklisted;\r\n  mapping(address => bool) public isWhitelisted;\r\n  mapping(address => bool) public wertWhitelisted;\r\n\r\n  StakingManager public stakingManagerInterface;\r\n\r\n  event SaleTimeSet(uint256 _start, uint256 _end, uint256 timestamp);\r\n  event SaleTimeUpdated(bytes32 indexed key, uint256 prevValue, uint256 newValue, uint256 timestamp);\r\n  event TokensBought(address indexed user, uint256 indexed tokensBought, address indexed purchaseToken, uint256 amountPaid, uint256 usdEq, uint256 timestamp);\r\n  event TokensAdded(address indexed token, uint256 noOfTokens, uint256 timestamp);\r\n  event TokensClaimed(address indexed user, uint256 amount, uint256 timestamp);\r\n  event ClaimStartUpdated(uint256 prevValue, uint256 newValue, uint256 timestamp);\r\n  event MaxTokensUpdated(uint256 prevValue, uint256 newValue, uint256 timestamp);\r\n  event TokensBoughtAndStaked(address indexed user, uint256 indexed tokensBought, address indexed purchaseToken, uint256 amountPaid, uint256 usdEq, uint256 timestamp);\r\n  event TokensClaimedAndStaked(address indexed user, uint256 amount, uint256 timestamp);\r\n\r\n  /// @custom:oz-upgrades-unsafe-allow constructor\r\n  constructor() initializer {}\r\n\r\n  /**\r\n   * @dev Initializes the contract and sets key parameters\r\n   * @param _oracle Oracle contract to fetch ETH/USDT price\r\n   * @param _usdt USDT token contract address\r\n   * @param _startTime start time of the presale\r\n   * @param _endTime end time of the presale\r\n   * @param _rounds array of round details\r\n   * @param _maxTokensToBuy amount of max tokens to buy\r\n   * @param _paymentWallet address to recive payments\r\n   */\r\n  function initialize(address _oracle, address _usdt, uint256 _startTime, uint256 _endTime, uint256[][3] memory _rounds, uint256 _maxTokensToBuy, address _paymentWallet) external initializer {\r\n    require(_oracle != address(0), \"Zero aggregator address\");\r\n    require(_usdt != address(0), \"Zero USDT address\");\r\n    require(_startTime > block.timestamp && _endTime > _startTime, \"Invalid time\");\r\n    __Pausable_init_unchained();\r\n    __Ownable_init_unchained();\r\n    __ReentrancyGuard_init_unchained();\r\n    baseDecimals = (10 ** 18);\r\n    aggregatorInterface = Aggregator(_oracle);\r\n    USDTInterface = IERC20Upgradeable(_usdt);\r\n    startTime = _startTime;\r\n    endTime = _endTime;\r\n    rounds = _rounds;\r\n    maxTokensToBuy = _maxTokensToBuy;\r\n    paymentWallet = _paymentWallet;\r\n    emit SaleTimeSet(startTime, endTime, block.timestamp);\r\n  }\r\n\r\n  /**\r\n   * @dev To pause the presale\r\n   */\r\n  function pause() external onlyOwner {\r\n    _pause();\r\n  }\r\n\r\n  /**\r\n   * @dev To unpause the presale\r\n   */\r\n  function unpause() external onlyOwner {\r\n    _unpause();\r\n  }\r\n\r\n  /**\r\n   * @dev To calculate the price in USD for given amount of tokens.\r\n   * @param _amount No of tokens\r\n   */\r\n  function calculatePrice(uint256 _amount) public view returns (uint256) {\r\n    uint256 USDTAmount;\r\n    uint256 total = checkPoint == 0 ? totalTokensSold : checkPoint;\r\n    require(_amount <= maxTokensToBuy, \"Amount exceeds max tokens to buy\");\r\n    if (_amount + total > rounds[0][currentStep] || block.timestamp >= rounds[2][currentStep]) {\r\n      require(currentStep < (rounds[0].length - 1), \"Wrong params\");\r\n      if (block.timestamp >= rounds[2][currentStep]) {\r\n        require(rounds[0][currentStep] + _amount <= rounds[0][currentStep + 1], \"Cant Purchase More in individual tx\");\r\n        USDTAmount = _amount * rounds[1][currentStep + 1];\r\n      } else {\r\n        uint256 tokenAmountForCurrentPrice = rounds[0][currentStep] - total;\r\n        USDTAmount = tokenAmountForCurrentPrice * rounds[1][currentStep] + (_amount - tokenAmountForCurrentPrice) * rounds[1][currentStep + 1];\r\n      }\r\n    } else USDTAmount = _amount * rounds[1][currentStep];\r\n    return USDTAmount;\r\n  }\r\n\r\n  /**\r\n   * @dev To update the sale times\r\n   * @param _startTime New start time\r\n   * @param _endTime New end time\r\n   */\r\n  function changeSaleTimes(uint256 _startTime, uint256 _endTime) external onlyOwner {\r\n    require(_startTime > 0 || _endTime > 0, \"Invalid parameters\");\r\n    if (_startTime > 0) {\r\n      require(block.timestamp < startTime, \"Sale already started\");\r\n      require(block.timestamp < _startTime, \"Sale time in past\");\r\n      uint256 prevValue = startTime;\r\n      startTime = _startTime;\r\n      emit SaleTimeUpdated(bytes32(\"START\"), prevValue, _startTime, block.timestamp);\r\n    }\r\n    if (_endTime > 0) {\r\n      require(_endTime > startTime, \"Invalid endTime\");\r\n      uint256 prevValue = endTime;\r\n      endTime = _endTime;\r\n      emit SaleTimeUpdated(bytes32(\"END\"), prevValue, _endTime, block.timestamp);\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @dev To get latest ETH price in 10**18 format\r\n   */\r\n  function getLatestPrice() public view returns (uint256) {\r\n    (, int256 price, , , ) = aggregatorInterface.latestRoundData();\r\n    price = (price * (10 ** 10));\r\n    return uint256(price);\r\n  }\r\n\r\n  function setSplits(address[] memory _wallets, uint256[] memory _percentages) public onlyOwner {\r\n    require(_wallets.length == _percentages.length, \"Mismatched arrays\");\r\n    delete wallets;\r\n    delete percentages;\r\n    uint256 totalPercentage = 0;\r\n\r\n    for (uint256 i = 0; i < _wallets.length; i++) {\r\n      require(_percentages[i] > 0, \"Percentage must be greater than 0\");\r\n      totalPercentage += _percentages[i];\r\n      wallets.push(_wallets[i]);\r\n      percentages.push(_percentages[i]);\r\n    }\r\n\r\n    require(totalPercentage == 100, \"Total percentage must equal 100\");\r\n  }\r\n\r\n  modifier checkSaleState(uint256 amount) {\r\n    require(block.timestamp >= startTime && block.timestamp <= endTime, \"Invalid time for buying\");\r\n    require(amount > 0, \"Invalid sale amount\");\r\n    _;\r\n  }\r\n\r\n  /**\r\n   * @dev To buy into a presale using USDT\r\n   * @param amount No of tokens to buy\r\n   * @param stake boolean flag for token staking\r\n   */\r\n  function buyWithUSDT(uint256 amount, bool stake) external checkSaleState(amount) whenNotPaused returns (bool) {\r\n    uint256 usdPrice = calculatePrice(amount);\r\n    totalTokensSold += amount;\r\n    uint256 price = usdPrice / (10 ** 12);\r\n    if (checkPoint != 0) checkPoint += amount;\r\n    uint256 total = totalTokensSold > checkPoint ? totalTokensSold : checkPoint;\r\n    if (total > rounds[0][currentStep] || block.timestamp >= rounds[2][currentStep]) {\r\n      if (block.timestamp >= rounds[2][currentStep]) {\r\n        checkPoint = rounds[0][currentStep] + amount;\r\n      }\r\n      if (dynamicTimeFlag) {\r\n        manageTimeDiff();\r\n      }\r\n      uint256 unsoldTokens = total > rounds[0][currentStep] ? 0 : rounds[0][currentStep] - total - amount;\r\n      remainingTokensTracker.push(unsoldTokens);\r\n      currentStep += 1;\r\n    }\r\n    if (stake) {\r\n      if (stakeingWhitelistStatus) {\r\n        require(isWhitelisted[_msgSender()], \"User not whitelisted for stake\");\r\n      }\r\n      stakingManagerInterface.depositByPresale(_msgSender(), amount * baseDecimals);\r\n      totalBoughtAndStaked += amount;\r\n      emit TokensBoughtAndStaked(_msgSender(), amount, address(USDTInterface), price, usdPrice, block.timestamp);\r\n    } else {\r\n      userDeposits[_msgSender()] += (amount * baseDecimals);\r\n      emit TokensBought(_msgSender(), amount, address(USDTInterface), price, usdPrice, block.timestamp);\r\n    }\r\n    usdRaised += usdPrice;\r\n    uint256 ourAllowance = USDTInterface.allowance(_msgSender(), address(this));\r\n    require(price <= ourAllowance, \"Make sure to add enough allowance\");\r\n    splitUSDTValue(price);\r\n\r\n    return true;\r\n  }\r\n\r\n  /**\r\n   * @dev To buy into a presale using ETH\r\n   * @param amount No of tokens to buy\r\n   * @param stake boolean flag for token staking\r\n   */\r\n  function buyWithEth(uint256 amount, bool stake) external payable checkSaleState(amount) whenNotPaused nonReentrant returns (bool) {\r\n    uint256 usdPrice = calculatePrice(amount);\r\n    uint256 ethAmount = (usdPrice * baseDecimals) / getLatestPrice();\r\n    require(msg.value >= ethAmount, \"Less payment\");\r\n    uint256 excess = msg.value - ethAmount;\r\n    totalTokensSold += amount;\r\n    if (checkPoint != 0) checkPoint += amount;\r\n    uint256 total = totalTokensSold > checkPoint ? totalTokensSold : checkPoint;\r\n    if (total > rounds[0][currentStep] || block.timestamp >= rounds[2][currentStep]) {\r\n      if (block.timestamp >= rounds[2][currentStep]) {\r\n        checkPoint = rounds[0][currentStep] + amount;\r\n      }\r\n      if (dynamicTimeFlag) {\r\n        manageTimeDiff();\r\n      }\r\n      uint256 unsoldTokens = total > rounds[0][currentStep] ? 0 : rounds[0][currentStep] - total - amount;\r\n      remainingTokensTracker.push(unsoldTokens);\r\n      currentStep += 1;\r\n    }\r\n    if (stake) {\r\n      if (stakeingWhitelistStatus) {\r\n        require(isWhitelisted[_msgSender()], \"User not whitelisted for stake\");\r\n      }\r\n      stakingManagerInterface.depositByPresale(_msgSender(), amount * baseDecimals);\r\n      totalBoughtAndStaked += amount;\r\n      emit TokensBoughtAndStaked(_msgSender(), amount, address(0), ethAmount, usdPrice, block.timestamp);\r\n    } else {\r\n      userDeposits[_msgSender()] += (amount * baseDecimals);\r\n      emit TokensBought(_msgSender(), amount, address(0), ethAmount, usdPrice, block.timestamp);\r\n    }\r\n    usdRaised += usdPrice;\r\n    splitETHValue(ethAmount);\r\n    if (excess > 0) sendValue(payable(_msgSender()), excess);\r\n    return true;\r\n  }\r\n\r\n  /**\r\n   * @dev To buy ETH directly from wert .*wert contract address should be whitelisted if wertBuyRestrictionStatus is set true\r\n   * @param _user address of the user\r\n   * @param _amount No of ETH to buy\r\n   * @param stake boolean flag for token staking\r\n   */\r\n  function buyWithETHWert(address _user, uint256 _amount, bool stake) external payable checkSaleState(_amount) whenNotPaused nonReentrant returns (bool) {\r\n    require(wertWhitelisted[_msgSender()], \"User not whitelisted for this tx\");\r\n    uint256 usdPrice = calculatePrice(_amount);\r\n    uint256 ethAmount = (usdPrice * baseDecimals) / getLatestPrice();\r\n    require(msg.value >= ethAmount, \"Less payment\");\r\n    uint256 excess = msg.value - ethAmount;\r\n    totalTokensSold += _amount;\r\n    if (checkPoint != 0) checkPoint += _amount;\r\n    uint256 total = totalTokensSold > checkPoint ? totalTokensSold : checkPoint;\r\n    if (total > rounds[0][currentStep] || block.timestamp >= rounds[2][currentStep]) {\r\n      if (block.timestamp >= rounds[2][currentStep]) {\r\n        checkPoint = rounds[0][currentStep] + _amount;\r\n      }\r\n      if (dynamicTimeFlag) {\r\n        manageTimeDiff();\r\n      }\r\n      uint256 unsoldTokens = total > rounds[0][currentStep] ? 0 : rounds[0][currentStep] - total - _amount;\r\n      remainingTokensTracker.push(unsoldTokens);\r\n      currentStep += 1;\r\n    }\r\n    if (stake) {\r\n      if (stakeingWhitelistStatus) {\r\n        require(isWhitelisted[_user], \"User not whitelisted for stake\");\r\n      }\r\n      stakingManagerInterface.depositByPresale(_user, _amount * baseDecimals);\r\n      totalBoughtAndStaked += _amount;\r\n      emit TokensBoughtAndStaked(_user, _amount, address(0), ethAmount, usdPrice, block.timestamp);\r\n    } else {\r\n      userDeposits[_user] += (_amount * baseDecimals);\r\n      emit TokensBought(_user, _amount, address(0), ethAmount, usdPrice, block.timestamp);\r\n    }\r\n    usdRaised += usdPrice;\r\n    splitETHValue(ethAmount);\r\n    if (excess > 0) sendValue(payable(_user), excess);\r\n    return true;\r\n  }\r\n\r\n  /**\r\n   * @dev Helper funtion to get ETH price for given amount\r\n   * @param amount No of tokens to buy\r\n   */\r\n  function ethBuyHelper(uint256 amount) external view returns (uint256 ethAmount) {\r\n    uint256 usdPrice = calculatePrice(amount);\r\n    ethAmount = (usdPrice * baseDecimals) / getLatestPrice();\r\n  }\r\n\r\n  /**\r\n   * @dev Helper funtion to get USDT price for given amount\r\n   * @param amount No of tokens to buy\r\n   */\r\n  function usdtBuyHelper(uint256 amount) external view returns (uint256 usdPrice) {\r\n    usdPrice = calculatePrice(amount);\r\n    usdPrice = usdPrice / (10 ** 12);\r\n  }\r\n\r\n  function sendValue(address payable recipient, uint256 amount) internal {\r\n    require(address(this).balance >= amount, \"Low balance\");\r\n    (bool success, ) = recipient.call{value: amount}(\"\");\r\n    require(success, \"ETH Payment failed\");\r\n  }\r\n\r\n  function splitETHValue(uint256 _amount) internal {\r\n    if (wallets.length == 0) {\r\n      require(paymentWallet != address(0), \"Payment wallet not set\");\r\n      sendValue(payable(paymentWallet), _amount);\r\n    } else {\r\n      uint256 tempCalc;\r\n      for (uint256 i = 0; i < wallets.length; i++) {\r\n        uint256 amountToTransfer = (_amount * percentages[i]) / 100;\r\n        sendValue(payable(wallets[i]), amountToTransfer);\r\n        tempCalc += amountToTransfer;\r\n      }\r\n      if ((_amount - tempCalc) > 0) {\r\n        sendValue(payable(wallets[wallets.length - 1]), _amount - tempCalc);\r\n      }\r\n    }\r\n  }\r\n\r\n  function splitUSDTValue(uint256 _amount) internal {\r\n    if (wallets.length == 0) {\r\n      require(paymentWallet != address(0), \"Payment wallet not set\");\r\n      (bool success, ) = address(USDTInterface).call(abi.encodeWithSignature(\"transferFrom(address,address,uint256)\", _msgSender(), paymentWallet, _amount));\r\n      require(success, \"Token payment failed\");\r\n    } else {\r\n      uint256 tempCalc;\r\n      for (uint256 i = 0; i < wallets.length; i++) {\r\n        uint256 amountToTransfer = (_amount * percentages[i]) / 100;\r\n        (bool success, ) = address(USDTInterface).call(abi.encodeWithSignature(\"transferFrom(address,address,uint256)\", _msgSender(), wallets[i], amountToTransfer));\r\n        require(success, \"Token payment failed\");\r\n        tempCalc += amountToTransfer;\r\n      }\r\n      if ((_amount - tempCalc) > 0) {\r\n        (bool success, ) = address(USDTInterface).call(abi.encodeWithSignature(\"transferFrom(address,address,uint256)\", _msgSender(), wallets[wallets.length - 1], _amount - tempCalc));\r\n        require(success, \"Token payment failed\");\r\n      }\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @dev to initialize staking manager with new addredd\r\n   * @param _stakingManagerAddress address of the staking smartcontract\r\n   */\r\n  function setStakingManager(address _stakingManagerAddress) external onlyOwner {\r\n    require(_stakingManagerAddress != address(0), \"staking manager cannot be inatialized with zero address\");\r\n    stakingManagerInterface = StakingManager(_stakingManagerAddress);\r\n    IERC20Upgradeable(saleToken).approve(_stakingManagerAddress, type(uint256).max);\r\n  }\r\n\r\n  /**\r\n   * @dev To set the claim start time and sale token address by the owner\r\n   * @param _claimStart claim start time\r\n   * @param noOfTokens no of tokens to add to the contract\r\n   * @param _saleToken sale toke address\r\n   */\r\n  function startClaim(uint256 _claimStart, uint256 noOfTokens, address _saleToken, address _stakingManagerAddress) external onlyOwner returns (bool) {\r\n    require(_saleToken != address(0), \"Zero token address\");\r\n    require(claimStart == 0, \"Claim already set\");\r\n    claimStart = _claimStart;\r\n    saleToken = _saleToken;\r\n    whitelistClaimOnly = true;\r\n    stakingManagerInterface = StakingManager(_stakingManagerAddress);\r\n    IERC20Upgradeable(_saleToken).approve(_stakingManagerAddress, type(uint256).max);\r\n    bool success = IERC20Upgradeable(_saleToken).transferFrom(_msgSender(), address(this), noOfTokens);\r\n    require(success, \"Token transfer failed\");\r\n    emit TokensAdded(_saleToken, noOfTokens, block.timestamp);\r\n    return true;\r\n  }\r\n\r\n  /**\r\n   * @dev To set status for claim whitelisting\r\n   * @param _status bool value\r\n   */\r\n  function setStakeingWhitelistStatus(bool _status) external onlyOwner {\r\n    stakeingWhitelistStatus = _status;\r\n  }\r\n\r\n  /**\r\n   * @dev To change the claim start time by the owner\r\n   * @param _claimStart new claim start time\r\n   */\r\n  function changeClaimStart(uint256 _claimStart) external onlyOwner returns (bool) {\r\n    require(claimStart > 0, \"Initial claim data not set\");\r\n    require(_claimStart > endTime, \"Sale in progress\");\r\n    require(_claimStart > block.timestamp, \"Claim start in past\");\r\n    uint256 prevValue = claimStart;\r\n    claimStart = _claimStart;\r\n    emit ClaimStartUpdated(prevValue, _claimStart, block.timestamp);\r\n    return true;\r\n  }\r\n\r\n  /**\r\n   * @dev To claim tokens after claiming starts\r\n   */\r\n  function claim() external whenNotPaused returns (bool) {\r\n    require(saleToken != address(0), \"Sale token not added\");\r\n    require(!isBlacklisted[_msgSender()], \"This Address is Blacklisted\");\r\n    if (whitelistClaimOnly) {\r\n      require(isWhitelisted[_msgSender()], \"User not whitelisted for claim\");\r\n    }\r\n    require(block.timestamp >= claimStart, \"Claim has not started yet\");\r\n    require(!hasClaimed[_msgSender()], \"Already claimed\");\r\n    hasClaimed[_msgSender()] = true;\r\n    uint256 amount = userDeposits[_msgSender()];\r\n    require(amount > 0, \"Nothing to claim\");\r\n    delete userDeposits[_msgSender()];\r\n    bool success = IERC20Upgradeable(saleToken).transfer(_msgSender(), amount);\r\n    require(success, \"Token transfer failed\");\r\n    emit TokensClaimed(_msgSender(), amount, block.timestamp);\r\n    return true;\r\n  }\r\n\r\n  function claimAndStake() external whenNotPaused returns (bool) {\r\n    require(saleToken != address(0), \"Sale token not added\");\r\n    require(!isBlacklisted[_msgSender()], \"This Address is Blacklisted\");\r\n    if (stakeingWhitelistStatus) {\r\n      require(isWhitelisted[_msgSender()], \"User not whitelisted for stake\");\r\n    }\r\n    uint256 amount = userDeposits[_msgSender()];\r\n    require(amount > 0, \"Nothing to stake\");\r\n    stakingManagerInterface.depositByPresale(_msgSender(), amount);\r\n    delete userDeposits[_msgSender()];\r\n    emit TokensClaimedAndStaked(_msgSender(), amount, block.timestamp);\r\n    return true;\r\n  }\r\n\r\n  /**\r\n   * @dev To add wert contract addresses to whitelist\r\n   * @param _addressesToWhitelist addresses of the contract\r\n   */\r\n  function whitelistUsersForWERT(address[] calldata _addressesToWhitelist) external onlyOwner {\r\n    for (uint256 i = 0; i < _addressesToWhitelist.length; i++) {\r\n      wertWhitelisted[_addressesToWhitelist[i]] = true;\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @dev To remove wert contract addresses to whitelist\r\n   * @param _addressesToRemoveFromWhitelist addresses of the contracts\r\n   */\r\n  function removeFromWhitelistForWERT(address[] calldata _addressesToRemoveFromWhitelist) external onlyOwner {\r\n    for (uint256 i = 0; i < _addressesToRemoveFromWhitelist.length; i++) {\r\n      wertWhitelisted[_addressesToRemoveFromWhitelist[i]] = false;\r\n    }\r\n  }\r\n\r\n  function changeMaxTokensToBuy(uint256 _maxTokensToBuy) external onlyOwner {\r\n    require(_maxTokensToBuy > 0, \"Zero max tokens to buy value\");\r\n    uint256 prevValue = maxTokensToBuy;\r\n    maxTokensToBuy = _maxTokensToBuy;\r\n    emit MaxTokensUpdated(prevValue, _maxTokensToBuy, block.timestamp);\r\n  }\r\n\r\n  function changeRoundsData(uint256[][3] memory _rounds) external onlyOwner {\r\n    rounds = _rounds;\r\n  }\r\n\r\n  /**\r\n   * @dev To add users to blacklist which restricts blacklisted users from claiming\r\n   * @param _usersToBlacklist addresses of the users\r\n   */\r\n  function blacklistUsers(address[] calldata _usersToBlacklist) external onlyOwner {\r\n    for (uint256 i = 0; i < _usersToBlacklist.length; i++) {\r\n      isBlacklisted[_usersToBlacklist[i]] = true;\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @dev To remove users from blacklist which restricts blacklisted users from claiming\r\n   * @param _userToRemoveFromBlacklist addresses of the users\r\n   */\r\n  function removeFromBlacklist(address[] calldata _userToRemoveFromBlacklist) external onlyOwner {\r\n    for (uint256 i = 0; i < _userToRemoveFromBlacklist.length; i++) {\r\n      isBlacklisted[_userToRemoveFromBlacklist[i]] = false;\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @dev To add users to whitelist which restricts users from claiming if claimWhitelistStatus is true\r\n   * @param _usersToWhitelist addresses of the users\r\n   */\r\n  function whitelistUsers(address[] calldata _usersToWhitelist) external onlyOwner {\r\n    for (uint256 i = 0; i < _usersToWhitelist.length; i++) {\r\n      isWhitelisted[_usersToWhitelist[i]] = true;\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @dev To remove users from whitelist which restricts users from claiming if claimWhitelistStatus is true\r\n   * @param _userToRemoveFromWhitelist addresses of the users\r\n   */\r\n  function removeFromWhitelist(address[] calldata _userToRemoveFromWhitelist) external onlyOwner {\r\n    for (uint256 i = 0; i < _userToRemoveFromWhitelist.length; i++) {\r\n      isWhitelisted[_userToRemoveFromWhitelist[i]] = false;\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @dev To set status for claim whitelisting\r\n   * @param _status bool value\r\n   */\r\n  function setClaimWhitelistStatus(bool _status) external onlyOwner {\r\n    whitelistClaimOnly = _status;\r\n  }\r\n\r\n  /**\r\n   * @dev To set payment wallet address\r\n   * @param _newPaymentWallet new payment wallet address\r\n   */\r\n  function changePaymentWallet(address _newPaymentWallet) external onlyOwner {\r\n    require(_newPaymentWallet != address(0), \"address cannot be zero\");\r\n    paymentWallet = _newPaymentWallet;\r\n  }\r\n\r\n  /**\r\n   * @dev To manage time gap between two rounds\r\n   */\r\n  function manageTimeDiff() internal {\r\n    for (uint256 i; i < rounds[2].length - currentStep; i++) {\r\n      rounds[2][currentStep + i] = block.timestamp + i * timeConstant;\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @dev To set time constant for manageTimeDiff()\r\n   * @param _timeConstant time in <days>*24*60*60 format\r\n   */\r\n  function setTimeConstant(uint256 _timeConstant) external onlyOwner {\r\n    timeConstant = _timeConstant;\r\n  }\r\n\r\n  /**\r\n   * @dev To get array of round details at once\r\n   * @param _no array index\r\n   */\r\n  function roundDetails(uint256 _no) external view returns (uint256[] memory) {\r\n    return rounds[_no];\r\n  }\r\n\r\n  /**\r\n   * @dev to update userDeposits for purchases made on BSC\r\n   * @param _users array of users\r\n   * @param _userDeposits array of userDeposits associated with users\r\n   */\r\n  function updateFromBSC(address[] calldata _users, uint256[] calldata _userDeposits) external onlyOwner {\r\n    require(_users.length == _userDeposits.length, \"Length mismatch\");\r\n    for (uint256 i = 0; i < _users.length; i++) {\r\n      userDeposits[_users[i]] += _userDeposits[i];\r\n    }\r\n  }\r\n\r\n  /**\r\n   * @dev To increment the rounds from backend\r\n   */\r\n  function incrementCurrentStep() external {\r\n    require(msg.sender == admin || msg.sender == owner(), \"caller not admin or owner\");\r\n    prevCheckpoints.push(checkPoint);\r\n    if (dynamicTimeFlag) {\r\n      manageTimeDiff();\r\n    }\r\n    if (checkPoint < rounds[0][currentStep]) {\r\n      if (currentStep == 0) {\r\n        remainingTokensTracker.push(rounds[0][currentStep] - totalTokensSold);\r\n      } else {\r\n        remainingTokensTracker.push(rounds[0][currentStep] - checkPoint);\r\n      }\r\n      checkPoint = rounds[0][currentStep];\r\n    }\r\n    currentStep++;\r\n  }\r\n\r\n  /**\r\n   * @dev To set admin\r\n   * @param _admin new admin wallet address\r\n   */\r\n  function setAdmin(address _admin) external onlyOwner {\r\n    admin = _admin;\r\n  }\r\n\r\n  /**\r\n   * @dev To change details of the round\r\n   * @param _step round for which you want to change the details\r\n   * @param _checkpoint token tracker amount\r\n   */\r\n  function setCurrentStep(uint256 _step, uint256 _checkpoint) external onlyOwner {\r\n    currentStep = _step;\r\n    checkPoint = _checkpoint;\r\n  }\r\n\r\n  /**\r\n   * @dev To set time shift functionality on/off\r\n   * @param _dynamicTimeFlag bool value\r\n   */\r\n  function setDynamicTimeFlag(bool _dynamicTimeFlag) external onlyOwner {\r\n    dynamicTimeFlag = _dynamicTimeFlag;\r\n  }\r\n\r\n  /**\r\n   * @dev     Function to return remainingTokenTracker Array\r\n   */\r\n  function trackRemainingTokens() external view returns (uint256[] memory) {\r\n    return remainingTokensTracker;\r\n  }\r\n\r\n  /**\r\n   * @dev     To update remainingTokensTracker Array\r\n   * @param   _unsoldTokens  input parameters in uint256 array format\r\n   */\r\n  function setRemainingTokensArray(uint256[] memory _unsoldTokens) public {\r\n    require(msg.sender == admin || msg.sender == owner(), \"caller not admin or owner\");\r\n    require(_unsoldTokens.length != 0, \"cannot update invalid values\");\r\n    delete remainingTokensTracker;\r\n    for (uint256 i; i < _unsoldTokens.length; i++) {\r\n      remainingTokensTracker.push(_unsoldTokens[i]);\r\n    }\r\n  }\r\n}\r\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}