creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {ContextUpgradeable} from \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * 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    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable\n    struct OwnableStorage {\n        address _owner;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Ownable\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;\n\n    function _getOwnableStorage() private pure returns (OwnableStorage storage $) {\n        assembly {\n            $.slot := OwnableStorageLocation\n        }\n    }\n\n    /**\n     * @dev The caller account is not authorized to perform an operation.\n     */\n    error OwnableUnauthorizedAccount(address account);\n\n    /**\n     * @dev The owner is not a valid owner account. (eg. `address(0)`)\n     */\n    error OwnableInvalidOwner(address owner);\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n     */\n    function __Ownable_init(address initialOwner) internal onlyInitializing {\n        __Ownable_init_unchained(initialOwner);\n    }\n\n    function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {\n        if (initialOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(initialOwner);\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        OwnableStorage storage $ = _getOwnableStorage();\n        return $._owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        if (owner() != _msgSender()) {\n            revert OwnableUnauthorizedAccount(_msgSender());\n        }\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\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        OwnableStorage storage $ = _getOwnableStorage();\n        address oldOwner = $._owner;\n        $._owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Storage of the initializable contract.\n     *\n     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n     * when using with upgradeable contracts.\n     *\n     * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n     */\n    struct InitializableStorage {\n        /**\n         * @dev Indicates that the contract has been initialized.\n         */\n        uint64 _initialized;\n        /**\n         * @dev Indicates that the contract is in the process of being initialized.\n         */\n        bool _initializing;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n    /**\n     * @dev The contract is already initialized.\n     */\n    error InvalidInitialization();\n\n    /**\n     * @dev The contract is not initializing.\n     */\n    error NotInitializing();\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint64 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 in the context of a constructor an `initializer` may be invoked any\n     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n     * production.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        // Cache values to avoid duplicated sloads\n        bool isTopLevelCall = !$._initializing;\n        uint64 initialized = $._initialized;\n\n        // Allowed calls:\n        // - initialSetup: the contract is not in the initializing state and no previous version was\n        //                 initialized\n        // - construction: the contract is initialized at version 1 (no reininitialization) and the\n        //                 current contract is just being deployed\n        bool initialSetup = initialized == 0 && isTopLevelCall;\n        bool construction = initialized == 1 && address(this).code.length == 0;\n\n        if (!initialSetup && !construction) {\n            revert InvalidInitialization();\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 2**64 - 1 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint64 version) {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        if ($._initializing || $._initialized >= version) {\n            revert InvalidInitialization();\n        }\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        _checkInitializing();\n        _;\n    }\n\n    /**\n     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n     */\n    function _checkInitializing() internal view virtual {\n        if (!_isInitializing()) {\n            revert NotInitializing();\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        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        if ($._initializing) {\n            revert InvalidInitialization();\n        }\n        if ($._initialized != type(uint64).max) {\n            $._initialized = type(uint64).max;\n            emit Initialized(type(uint64).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint64) {\n        return _getInitializableStorage()._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 _getInitializableStorage()._initializing;\n    }\n\n    /**\n     * @dev Returns a pointer to the storage namespace.\n     */\n    // solhint-disable-next-line var-name-mixedcase\n    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n        assembly {\n            $.slot := INITIALIZABLE_STORAGE\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)\n\npragma solidity ^0.8.20;\n\nimport {ContextUpgradeable} from \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n    /// @custom:storage-location erc7201:openzeppelin.storage.Pausable\n    struct PausableStorage {\n        bool _paused;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Pausable\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;\n\n    function _getPausableStorage() private pure returns (PausableStorage storage $) {\n        assembly {\n            $.slot := PausableStorageLocation\n        }\n    }\n\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    /**\n     * @dev The operation failed because the contract is paused.\n     */\n    error EnforcedPause();\n\n    /**\n     * @dev The operation failed because the contract is not paused.\n     */\n    error ExpectedPause();\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        PausableStorage storage $ = _getPausableStorage();\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        PausableStorage storage $ = _getPausableStorage();\n        return $._paused;\n    }\n\n    /**\n     * @dev Throws if the contract is paused.\n     */\n    function _requireNotPaused() internal view virtual {\n        if (paused()) {\n            revert EnforcedPause();\n        }\n    }\n\n    /**\n     * @dev Throws if the contract is not paused.\n     */\n    function _requirePaused() internal view virtual {\n        if (!paused()) {\n            revert ExpectedPause();\n        }\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        PausableStorage storage $ = _getPausableStorage();\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        PausableStorage storage $ = _getPausableStorage();\n        $._paused = false;\n        emit Unpaused(_msgSender());\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)\n\npragma solidity ^0.8.20;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant NOT_ENTERED = 1;\n    uint256 private constant ENTERED = 2;\n\n    /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard\n    struct ReentrancyGuardStorage {\n        uint256 _status;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.ReentrancyGuard\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;\n\n    function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {\n        assembly {\n            $.slot := ReentrancyGuardStorageLocation\n        }\n    }\n\n    /**\n     * @dev Unauthorized reentrant call.\n     */\n    error ReentrancyGuardReentrantCall();\n\n    function __ReentrancyGuard_init() internal onlyInitializing {\n        __ReentrancyGuard_init_unchained();\n    }\n\n    function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\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        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n        // On the first call to nonReentrant, _status will be NOT_ENTERED\n        if ($._status == ENTERED) {\n            revert ReentrancyGuardReentrantCall();\n        }\n\n        // Any calls to nonReentrant after this point will fail\n        $._status = ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\n        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        $._status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n     * `nonReentrant` function in the call stack.\n     */\n    function _reentrancyGuardEntered() internal view returns (bool) {\n        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n        return $._status == ENTERED;\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\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 value of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the value of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens as the allowance of `spender` over the\n     * 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 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\n     * allowance mechanism. `value` 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 value) external returns (bool);\n}\n"
      },
      "contracts/presale/production/ethereumPresaleV2.sol": {
        "content": "//SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.20;\r\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\r\nimport '@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol';\r\nimport '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';\r\nimport '@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol';\r\n\r\ninterface IAggregator {\r\n    function latestRoundData()\r\n        external\r\n        view\r\n        returns (\r\n            uint80 roundId,\r\n            int256 answer,\r\n            uint256 startedAt,\r\n            uint256 updatedAt,\r\n            uint80 answeredInRound\r\n        );\r\n}\r\n\r\ncontract EthereumPresaleV2 is\r\n    Initializable,\r\n    ReentrancyGuardUpgradeable,\r\n    OwnableUpgradeable,\r\n    PausableUpgradeable\r\n{\r\n    uint256 public totalTokensSold;\r\n    uint256 public claimStart;\r\n    uint256 public baseScale;\r\n    uint256 public baseDecimals;\r\n    uint256 public maxTokensToBuy;\r\n    uint256 public minTokensToBuy;\r\n    uint256 public currentStep;\r\n    uint256 public checkPoint;\r\n    uint256 public usdRaised;\r\n    uint256 public timeConstant;\r\n    uint256[][3] private rounds;\r\n    uint256[] private remainingTokensTracker;\r\n    address public saleToken;\r\n    address private paymentWallet;\r\n    address public USDTtoken;\r\n    address public USDCtoken;\r\n    address public DAItoken;\r\n    address public aggregatorInterface;\r\n    bool public dynamicTimeFlag;\r\n    mapping(address => uint256) public userDeposits;\r\n    mapping(uint256 => uint256) public usdTokenDecimals;\r\n\r\n    event TokensBought(\r\n        address indexed user,\r\n        uint256 indexed tokensBought,\r\n        address indexed purchaseToken,\r\n        uint256 amountPaid,\r\n        uint256 usdEq,\r\n        uint256 timestamp\r\n    );\r\n\r\n    event TokensAdded(\r\n        address indexed token,\r\n        uint256 noOfTokens,\r\n        uint256 timestamp\r\n    );\r\n\r\n    event TokensClaimed(\r\n        address indexed user,\r\n        uint256 amount,\r\n        uint256 timestamp\r\n    );\r\n\r\n    event StepIncremented(uint256 newStep, uint256 timestamp);\r\n\r\n    constructor() initializer {}\r\n\r\n    function initialize(\r\n        address _oracle,\r\n        address _usdt,\r\n        address _usdc,\r\n        address _dai,\r\n        uint256[][3] memory _rounds,\r\n        uint256 _timeConstant,\r\n        uint256 _maxTokensToBuy,\r\n        uint256 _minTokensToBuy,\r\n        address _paymentWallet\r\n    ) external initializer {\r\n        require(_oracle != address(0), 'Zero aggregator address');\r\n        require(_usdt != address(0), 'Zero USDT address');\r\n        require(_usdc != address(0), 'Zero USDC address');\r\n        require(_dai != address(0), 'Zero DAI address');\r\n        __Pausable_init_unchained();\r\n        __Ownable_init_unchained(_msgSender());\r\n        __ReentrancyGuard_init_unchained();\r\n        baseScale = 18;\r\n        baseDecimals = (10 ** baseScale);\r\n        aggregatorInterface = _oracle;\r\n        USDTtoken = _usdt;\r\n        USDCtoken = _usdc;\r\n        DAItoken = _dai;\r\n        rounds = _rounds;\r\n        maxTokensToBuy = _maxTokensToBuy > _rounds[0][0]\r\n            ? _rounds[0][0]\r\n            : _maxTokensToBuy;\r\n        minTokensToBuy = _minTokensToBuy >= _maxTokensToBuy\r\n            ? 0\r\n            : _minTokensToBuy;\r\n        paymentWallet = _paymentWallet;\r\n        dynamicTimeFlag = true;\r\n        timeConstant = _timeConstant;\r\n\r\n        usdTokenDecimals[0] = 6; //USDT\r\n        usdTokenDecimals[1] = 6; //USDC\r\n        usdTokenDecimals[2] = 18; //DAI\r\n    }\r\n\r\n    function pause() external onlyOwner {\r\n        _pause();\r\n    }\r\n\r\n    function unpause() external onlyOwner {\r\n        _unpause();\r\n    }\r\n\r\n    function calculatePrice(uint256 _amount) public view returns (uint256) {\r\n        uint256 usdAmount;\r\n        bool isLastRound = currentStep >= rounds[0].length - 1;\r\n        uint256 total = (isLastRound || checkPoint == 0)\r\n            ? totalTokensSold\r\n            : checkPoint;\r\n\r\n        if (\r\n            !isLastRound &&\r\n            (_amount + total > rounds[0][currentStep] ||\r\n                block.timestamp >= rounds[2][currentStep])\r\n        ) {\r\n            if (block.timestamp >= rounds[2][currentStep]) {\r\n                require(\r\n                    rounds[0][currentStep] + _amount <=\r\n                        rounds[0][currentStep + 1],\r\n                    'Cant purchase more in one transaction'\r\n                );\r\n\r\n                usdAmount = _amount * rounds[1][currentStep + 1];\r\n            } else {\r\n                uint256 tokenAmountForCurrentPrice = rounds[0][currentStep] -\r\n                    total;\r\n\r\n                uint256 tokenAmountForNextPrice = _amount -\r\n                    tokenAmountForCurrentPrice;\r\n\r\n                usdAmount =\r\n                    tokenAmountForCurrentPrice *\r\n                    rounds[1][currentStep] +\r\n                    tokenAmountForNextPrice *\r\n                    rounds[1][currentStep + 1];\r\n            }\r\n        } else {\r\n            usdAmount = _amount * rounds[1][currentStep];\r\n        }\r\n\r\n        return usdAmount;\r\n    }\r\n\r\n    function getLatestPrice() public view returns (uint256) {\r\n        (, int256 price, , , ) = IAggregator(aggregatorInterface)\r\n            .latestRoundData();\r\n        price = (price * (10 ** 10));\r\n        return uint256(price);\r\n    }\r\n\r\n    function manageRounds(uint256 amount) private {\r\n        uint256 totalBefore = totalTokensSold > checkPoint\r\n            ? totalTokensSold\r\n            : checkPoint;\r\n\r\n        totalTokensSold += amount;\r\n        if (checkPoint != 0) checkPoint += amount;\r\n\r\n        uint256 total = totalTokensSold > checkPoint\r\n            ? totalTokensSold\r\n            : checkPoint;\r\n\r\n        if (\r\n            currentStep < (rounds[0].length - 1) &&\r\n            (total >= rounds[0][currentStep] ||\r\n                block.timestamp >= rounds[2][currentStep])\r\n        ) {\r\n            uint256 unsoldTokens = total >= rounds[0][currentStep]\r\n                ? 0\r\n                : rounds[0][currentStep] - total;\r\n\r\n            if (block.timestamp >= rounds[2][currentStep]) {\r\n                checkPoint = rounds[0][currentStep] + amount;\r\n\r\n                unsoldTokens = totalBefore >= rounds[0][currentStep]\r\n                    ? 0\r\n                    : rounds[0][currentStep] - totalBefore;\r\n            }\r\n\r\n            if (dynamicTimeFlag) manageTimeDiff();\r\n\r\n            remainingTokensTracker.push(unsoldTokens);\r\n            currentStep += 1;\r\n        }\r\n    }\r\n\r\n    function checkEthAmount(\r\n        uint256 amount\r\n    ) private returns (uint256 excess, uint256 usdPrice, uint256 ethAmount) {\r\n        excess = 0;\r\n        usdPrice = calculatePrice(amount);\r\n        ethAmount = (usdPrice * baseDecimals) / getLatestPrice();\r\n        uint256 relEthAmount = ethAmount - ((ethAmount * 5) / 1000);\r\n        require(msg.value >= relEthAmount, 'Less payment');\r\n        if (msg.value > ethAmount) excess = msg.value - ethAmount;\r\n    }\r\n\r\n    modifier checkSaleState(uint256 amount) {\r\n        require(\r\n            amount >= minTokensToBuy &&\r\n                amount <= maxTokensToBuy &&\r\n                totalTokensSold + amount <= rounds[0][rounds[0].length - 1],\r\n            'Invalid sale amount'\r\n        );\r\n        _;\r\n    }\r\n\r\n    function buyWithUSD(\r\n        uint256 amount,\r\n        uint256 purchaseToken\r\n    ) external checkSaleState(amount) whenNotPaused {\r\n        require(\r\n            usdTokenDecimals[purchaseToken] != 0,\r\n            'Incorrect USD token provided'\r\n        );\r\n        uint256 usdPrice = calculatePrice(amount);\r\n        uint256 price = usdPrice /\r\n            getDecimalsDivider(usdTokenDecimals[purchaseToken]);\r\n\r\n        manageRounds(amount);\r\n\r\n        userDeposits[_msgSender()] += (amount * baseDecimals);\r\n        usdRaised += usdPrice;\r\n\r\n        IERC20 usdInterface;\r\n        if (purchaseToken == 0) usdInterface = IERC20(USDTtoken);\r\n        else if (purchaseToken == 1) usdInterface = IERC20(USDCtoken);\r\n        else if (purchaseToken == 2) usdInterface = IERC20(DAItoken);\r\n        else revert('Incorrect USD token provided');\r\n\r\n        uint256 ourAllowance = usdInterface.allowance(\r\n            _msgSender(),\r\n            address(this)\r\n        );\r\n\r\n        require(price <= ourAllowance, 'Make sure to add enough allowance');\r\n\r\n        (bool success, ) = address(usdInterface).call(\r\n            abi.encodeWithSignature(\r\n                'transferFrom(address,address,uint256)',\r\n                _msgSender(),\r\n                paymentWallet,\r\n                price\r\n            )\r\n        );\r\n\r\n        require(success, 'Token payment failed');\r\n\r\n        emit TokensBought(\r\n            _msgSender(),\r\n            amount,\r\n            address(usdInterface),\r\n            price,\r\n            usdPrice,\r\n            block.timestamp\r\n        );\r\n    }\r\n\r\n    function buyWithETH(\r\n        uint256 amount\r\n    ) external payable checkSaleState(amount) whenNotPaused nonReentrant {\r\n        (uint256 excess, uint256 usdPrice, uint256 ethAmount) = checkEthAmount(\r\n            amount\r\n        );\r\n\r\n        manageRounds(amount);\r\n\r\n        userDeposits[_msgSender()] += (amount * baseDecimals);\r\n        usdRaised += usdPrice;\r\n\r\n        sendValue(payable(paymentWallet), ethAmount);\r\n        if (excess > 0) sendValue(payable(_msgSender()), excess);\r\n\r\n        emit TokensBought(\r\n            _msgSender(),\r\n            amount,\r\n            address(0),\r\n            ethAmount,\r\n            usdPrice,\r\n            block.timestamp\r\n        );\r\n    }\r\n\r\n    function ethBuyHelper(\r\n        uint256 amount\r\n    ) external view returns (uint256 ethAmount) {\r\n        uint256 usdPrice = calculatePrice(amount);\r\n        ethAmount = (usdPrice * baseDecimals) / getLatestPrice();\r\n    }\r\n\r\n    function usdBuyHelper(\r\n        uint256 amount,\r\n        uint256 purchaseToken\r\n    ) external view returns (uint256 usdPrice) {\r\n        require(\r\n            usdTokenDecimals[purchaseToken] != 0,\r\n            'Incorrect USD token provided'\r\n        );\r\n        usdPrice = calculatePrice(amount);\r\n        usdPrice =\r\n            usdPrice /\r\n            getDecimalsDivider(usdTokenDecimals[purchaseToken]);\r\n    }\r\n\r\n    function claim() external whenNotPaused {\r\n        require(saleToken != address(0), 'Sale token not added');\r\n        require(block.timestamp >= claimStart, 'Claim has not started yet');\r\n        uint256 amount = userDeposits[_msgSender()];\r\n        require(amount > 0, 'Nothing to claim');\r\n        delete userDeposits[_msgSender()];\r\n        bool success = IERC20(saleToken).transfer(_msgSender(), amount);\r\n        require(success, 'Token transfer failed');\r\n        emit TokensClaimed(_msgSender(), amount, block.timestamp);\r\n    }\r\n\r\n    function getDecimalsDivider(\r\n        uint256 decimals\r\n    ) internal view returns (uint256) {\r\n        if (baseDecimals > (10 ** decimals))\r\n            return (10 ** (baseScale - decimals));\r\n        else return 1;\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 changeMaxTokensToBuy(uint256 _maxTokensToBuy) external onlyOwner {\r\n        require(\r\n            _maxTokensToBuy > 0 && _maxTokensToBuy <= rounds[0][0],\r\n            'Zero max tokens to buy value'\r\n        );\r\n        maxTokensToBuy = _maxTokensToBuy;\r\n    }\r\n\r\n    function changeMinTokensToBuy(uint256 _minTokensToBuy) external onlyOwner {\r\n        require(\r\n            _minTokensToBuy >= 0 && _minTokensToBuy < maxTokensToBuy,\r\n            'Invalid min tokens to buy value'\r\n        );\r\n        minTokensToBuy = _minTokensToBuy;\r\n    }\r\n\r\n    function startClaim(\r\n        uint256 _claimStart,\r\n        uint256 amountOfTokens,\r\n        address _saleToken\r\n    ) external onlyOwner {\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\r\n        bool success = IERC20(saleToken).transferFrom(\r\n            _msgSender(),\r\n            address(this),\r\n            amountOfTokens\r\n        );\r\n\r\n        require(success, 'Token transfer failed');\r\n        emit TokensAdded(saleToken, amountOfTokens, block.timestamp);\r\n    }\r\n\r\n    function changeClaimStart(uint256 _claimStart) external onlyOwner {\r\n        require(claimStart > 0, 'Initial claim data not set');\r\n        claimStart = _claimStart;\r\n    }\r\n\r\n    function changeRoundsData(uint256[][3] memory _rounds) external onlyOwner {\r\n        rounds = _rounds;\r\n    }\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    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    function setTimeConstant(uint256 _timeConstant) external onlyOwner {\r\n        timeConstant = _timeConstant;\r\n    }\r\n\r\n    function updateUserDeposits(\r\n        address[] calldata _users,\r\n        uint256[] calldata _userDeposits\r\n    ) 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    function changeOracle(address _newOracle) external onlyOwner {\r\n        require(_newOracle != address(0), 'Address cannot be zero');\r\n        aggregatorInterface = _newOracle;\r\n    }\r\n\r\n    function incrementCurrentStep() external onlyOwner {\r\n        require(\r\n            currentStep < (rounds[0].length - 1),\r\n            'Current round is the last one'\r\n        );\r\n\r\n        if (dynamicTimeFlag) manageTimeDiff();\r\n\r\n        if (checkPoint < rounds[0][currentStep]) {\r\n            uint256 sub = totalTokensSold > checkPoint\r\n                ? totalTokensSold\r\n                : checkPoint;\r\n\r\n            remainingTokensTracker.push(rounds[0][currentStep] - sub);\r\n            checkPoint = rounds[0][currentStep];\r\n        }\r\n\r\n        currentStep++;\r\n\r\n        emit StepIncremented(currentStep, block.timestamp);\r\n    }\r\n\r\n    function setDynamicTimeFlag(bool _dynamicTimeFlag) external onlyOwner {\r\n        dynamicTimeFlag = _dynamicTimeFlag;\r\n    }\r\n\r\n    function setCurrentStep(\r\n        uint256 _step,\r\n        uint256 _checkpoint\r\n    ) external onlyOwner {\r\n        currentStep = _step;\r\n        checkPoint = _checkpoint;\r\n    }\r\n\r\n    function trackRemainingTokens() external view returns (uint256[] memory) {\r\n        return remainingTokensTracker;\r\n    }\r\n\r\n    function setRemainingTokensArray(\r\n        uint256[] memory _unsoldTokens\r\n    ) public onlyOwner {\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    function roundDetails(\r\n        uint256 _no\r\n    ) external view returns (uint256[] memory) {\r\n        return rounds[_no];\r\n    }\r\n\r\n    function withdrawTokens(address token, uint256 amount) external onlyOwner {\r\n        IERC20(token).transfer(paymentWallet, amount);\r\n    }\r\n\r\n    function withdrawEthers() external onlyOwner {\r\n        (bool success, ) = paymentWallet.call{value: address(this).balance}('');\r\n        require(success, 'Failed to withdraw');\r\n    }\r\n}\r\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "evmVersion": "paris",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    }
  }}