creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "contracts/PreSale.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/utils/Pausable.sol\";\n\n/**\n * @dev This contract is designed to work as pre sale token.\n * Has function to buy token with stable coin.\n * Has function to withdraw token after period of time.\n */\ncontract PreSale is Ownable, AccessControl, ReentrancyGuard, Pausable {\n    using SafeERC20 for IERC20;\n\n    struct StableCoinInfo {\n        address stableCoinAddress;\n        string symbol;\n        uint256 totalAmount;\n    }\n    struct UserInfo {\n        uint256 totalStableCoinAmount;\n        uint256 timesOfBuy;\n    }\n\n    struct OrderInfo {\n        uint256 stableCoinId;\n        uint256 stableCoinAmount;\n        uint256 tokenAmount;\n        uint256 claimedTokenAmount;\n        uint256 boughtDate;\n    }\n\n    struct RoundPaid {\n        uint256 paidIntervals;\n        uint256 paidPortions;\n    }\n\n    bytes32 public constant PROJECTOWNER = keccak256(\"PROJECTOWNER\");\n    uint256 public constant DAY = 86400;\n    uint256 public constant TOKENDECIMAL = 1000000000000000000;\n    IERC20 public immutable token;\n    uint256 public immutable maxContractBuyingLimit;\n    uint256 public immutable rate;\n    uint256 public immutable minUserBuyingLimit;\n    uint256 public immutable maxUserBuyingLimit;\n    uint256 public startDate;\n    uint256 public endDate;\n    uint256 public totalToken;\n    uint256 public totalTokenBought;\n    bool public closeSale;\n\n    RoundPaid[] roundPaid;\n    uint256 public currentTotalToken;\n    uint256 public userCount;\n    uint256 public totalClaimedToken;\n    uint256 public totalStableCoin;\n    uint256 public totalWithdrawnStableCoin;\n\n    mapping(address => UserInfo) users;\n    mapping(uint256 => StableCoinInfo) stableCoinInfo;\n    mapping(address => mapping(uint256 => OrderInfo)) orders;\n\n    event RoundPaidAdded(\n        uint256 indexed index,\n        uint256 paidInterval,\n        uint256 paidPortion\n    );\n    event TokenBought(\n        address indexed userAddress,\n        uint256 stableCoinId,\n        uint256 stableCoinAmount,\n        uint256 tokenAmount,\n        uint256 timesOfBuy\n    );\n    event TokenWithdrawn(address indexed userAddress, uint256 tokenAmount);\n    event TokenClaimed(\n        address indexed userAddress,\n        uint256 tokenAmount,\n        uint256 timesOfBuy\n    );\n    event ClaimAll(\n        address indexed userAddress,\n        uint256 tokenAmount,\n        uint256 timesOfBuy\n    );\n    event ClaimAlls(address indexed userAddress, uint256 totalClaimAmount);\n    event StableCoinWithdrawn(\n        address indexed receiver,\n        uint256 stableCoinId,\n        uint256 stableCoinAmount\n    );\n    event AddStableCoin(\n        uint256 stableCoinId,\n        address stableCoinAddress,\n        string symbol\n    );\n    event EditStableCoin(\n        uint256 stableCoinId,\n        address stableCoinAddress,\n        string symbol\n    );\n    event RemoveStableCoin(\n        uint256 stableCoinId,\n        address stableCoinAddress,\n        string symbol\n    );\n    event StartSale(uint256 tokenAmount, uint256 startSale, uint256 endSale);\n    event EndSale(uint256 endSaleTimes);\n\n    /**\n     * @dev Setup contract params and interface.\n     * Setup role for deployer.\n     */\n\n    constructor(\n        address _tokenAddress,\n        uint256 _maxContractBuyingLimit,\n        uint256 _rate,\n        uint256 _maxUserBuyingLimit,\n        RoundPaid[] memory _roundPaid,\n        address _projectOwner\n    ) Ownable(_projectOwner) {\n        token = IERC20(_tokenAddress);\n        rate = _rate;\n        maxUserBuyingLimit = _maxUserBuyingLimit * 10**6;\n        maxContractBuyingLimit = _maxContractBuyingLimit * 10**6;\n        for (uint256 i = 0; i < _roundPaid.length; i++) {\n            roundPaid.push(_roundPaid[i]);\n            emit RoundPaidAdded(\n                i,\n                _roundPaid[i].paidIntervals,\n                _roundPaid[i].paidPortions\n            );\n        }\n        _grantRole(DEFAULT_ADMIN_ROLE, _projectOwner);\n        _grantRole(PROJECTOWNER, _projectOwner);\n    }\n\n    /**\n     * @dev Only allow user who bought token.\n     */\n    modifier onlyBought(address _userAddress, uint256 _numOfbuy) {\n        OrderInfo memory order = orders[_userAddress][_numOfbuy];\n        require(\n            order.stableCoinAmount > 0,\n            \"[PreSale] Cannot withdraw if user balance is 0\"\n        );\n        _;\n    }\n\n    /**\n     * @dev Revert receive and fallback functions.\n     */\n    receive() external payable {\n        revert(\"[PreSale] Revert receive function\");\n    }\n\n    fallback() external payable {\n        revert(\"[PreSale] Revert fallback function\");\n    }\n\n    /**\n     * @dev Add a new stable coin to the list of accepted stable coins.\n     * @param _stableCoinId The ID of the stable coin to be added.\n     * @param _stableCoinAddress The address of the stable coin contract.\n     * @param _symbol The symbol of the stable coin.\n     * This function can only be called by the project owner.\n     */\n    function addStableCoin(\n        uint256 _stableCoinId,\n        address _stableCoinAddress,\n        string memory _symbol\n    ) external onlyRole(PROJECTOWNER) {\n        require(\n            stableCoinInfo[_stableCoinId].stableCoinAddress == address(0),\n            \"This stable coin id has been added\"\n        );\n        stableCoinInfo[_stableCoinId].stableCoinAddress = _stableCoinAddress;\n        stableCoinInfo[_stableCoinId].symbol = _symbol;\n        emit AddStableCoin(_stableCoinId, _stableCoinAddress, _symbol);\n    }\n\n    /**\n     * @dev Edit the details of an existing stable coin in the list.\n     * @param _stableCoinId The ID of the stable coin to be edited.\n     * @param _stableCoinAddress The new address of the stable coin contract.\n     * @param _symbol The new symbol of the stable coin.\n     * This function can only be called by the project owner.\n     */\n    function editStableCoin(\n        uint256 _stableCoinId,\n        address _stableCoinAddress,\n        string memory _symbol\n    ) external onlyRole(PROJECTOWNER) {\n        require(\n            stableCoinInfo[_stableCoinId].stableCoinAddress != address(0),\n            \"This stable coin id has not been added yet\"\n        );\n        stableCoinInfo[_stableCoinId].stableCoinAddress = _stableCoinAddress;\n        stableCoinInfo[_stableCoinId].symbol = _symbol;\n        emit EditStableCoin(_stableCoinId, _stableCoinAddress, _symbol);\n    }\n\n    /**\n     * @dev Remove a stable coin from the list of accepted stable coins.\n     * @param _stableCoinId The ID of the stable coin to be removed.\n     * This function can only be called by the project owner.\n     */\n    function removeStableCoin(uint256 _stableCoinId)\n        external\n        onlyRole(PROJECTOWNER)\n    {\n        StableCoinInfo memory stableCoin = stableCoinInfo[_stableCoinId];\n        require(\n            stableCoin.stableCoinAddress != address(0),\n            \"This stable coin id has not been added yet\"\n        );\n        emit RemoveStableCoin(\n            _stableCoinId,\n            stableCoin.stableCoinAddress,\n            stableCoin.symbol\n        );\n        delete stableCoinInfo[_stableCoinId];\n    }\n\n    /**\n     * @dev Allow the project owner to withdraw stable coins from the contract.\n     * @param _to The address to receive the withdrawn stable coins.\n     * @param _stableCoinId The ID of the stable coin to be withdrawn.\n     * This function can only be called by the project owner.\n     */\n    function withdrawStableCoin(address _to, uint256 _stableCoinId)\n        external\n        onlyRole(PROJECTOWNER)\n    {\n        StableCoinInfo storage stableCoin = stableCoinInfo[_stableCoinId];\n        uint256 withdrawAmount = stableCoin.totalAmount;\n        require(\n            stableCoin.stableCoinAddress != address(0),\n            \"This stable coin id has not been added yet\"\n        );\n        require(\n            withdrawAmount > 0,\n            \"Insufficient stable coin available for withdraw\"\n        );\n        IERC20(stableCoin.stableCoinAddress).safeTransfer(_to, withdrawAmount);\n        stableCoin.totalAmount -= withdrawAmount;\n        totalWithdrawnStableCoin += withdrawAmount;\n        totalStableCoin -= withdrawAmount;\n\n        emit StableCoinWithdrawn(_to, _stableCoinId, withdrawAmount);\n    }\n\n    /**\n     * @dev Allow the project owner to withdraw unsold tokens from the contract after the sale period ends.\n     * This function can only be called by the project owner, and only after the sale period has ended.\n     */\n    function withdrawToken() external onlyRole(PROJECTOWNER) {\n        require(\n            block.timestamp >= endDate || closeSale,\n            \"Pre sale must close the sale first\"\n        );\n\n        require(\n            currentTotalToken != 0,\n            \"Insufficient tokens available for withdraw\"\n        );\n        uint256 withdrawAmount = currentTotalToken;\n        currentTotalToken = 0;\n        token.safeTransfer(msg.sender, withdrawAmount);\n        emit TokenWithdrawn(msg.sender, withdrawAmount);\n    }\n\n    /**\n     * @dev Allow users to buy tokens using stable coins.\n     * @param _stableCoinId The ID of the stable coin used for the purchase.\n     * @param _stableAmount The amount of stable coins used for the purchase.\n     * This function enforces the maximum user and contract buying limits, and ensures that\n     * there are enough tokens available for purchase.\n     */\n    function buyToken(uint256 _stableCoinId, uint256 _stableAmount) external {\n        uint256 tokenAmount = (rate * _stableAmount) / TOKENDECIMAL;\n        StableCoinInfo memory stableCoin = stableCoinInfo[_stableCoinId];\n        UserInfo memory userInfo = users[msg.sender];\n        require(block.timestamp < endDate, \"Sale period has ended\");\n        require(!closeSale,\"Close Salesed\");\n        require(\n            stableCoin.stableCoinAddress != address(0),\n            \"This stable coin id has not been added yet\"\n        );\n        require(\n            tokenAmount <= currentTotalToken,\n            \"Insufficient tokens available for buy\"\n        );\n        require(_stableAmount > 0, \"Stable Coin amount must be greater than 0\");\n        require(\n            userInfo.totalStableCoinAmount + _stableAmount <=\n                maxUserBuyingLimit,\n            \"Exceed max user buying limit\"\n        );\n        require(\n            totalStableCoin + _stableAmount <= maxContractBuyingLimit,\n            \"Exceed max contract buying limit\"\n        );\n\n        if (users[msg.sender].timesOfBuy == 0) {\n            userCount++;\n        }\n        totalStableCoin += _stableAmount;\n        users[msg.sender].totalStableCoinAmount += _stableAmount;\n        users[msg.sender].timesOfBuy++;\n        uint256 timesOfbuy = users[msg.sender].timesOfBuy;\n        orders[msg.sender][timesOfbuy].boughtDate = block.timestamp;\n        orders[msg.sender][timesOfbuy].stableCoinId = _stableCoinId;\n        orders[msg.sender][timesOfbuy].stableCoinAmount += _stableAmount;\n        orders[msg.sender][timesOfbuy].tokenAmount += tokenAmount;\n        totalTokenBought += tokenAmount;\n        currentTotalToken -= tokenAmount;\n        stableCoinInfo[_stableCoinId].totalAmount += _stableAmount;\n        IERC20(stableCoinInfo[_stableCoinId].stableCoinAddress)\n            .safeTransferFrom(msg.sender, address(this), _stableAmount);\n\n        emit TokenBought(\n            msg.sender,\n            _stableCoinId,\n            _stableAmount,\n            tokenAmount,\n            timesOfbuy\n        );\n    }\n\n    /**\n     * @dev Allow users to claim their purchased tokens after a certain period of time.\n     * @param _numOfbuy The number of the user's purchase order.\n     * This function uses the `onlyBought` modifier to ensure that the user has a valid purchase order,\n     * and the `nonReentrant` modifier to prevent reentrancy attacks.\n     */\n    function claimToken(uint256 _numOfbuy)\n        public\n        nonReentrant\n        onlyBought(msg.sender, _numOfbuy)\n    {\n        uint256 claimAmount = calculateClaimAmount(msg.sender, _numOfbuy);\n        require(claimAmount > 0, \"Zero claim amount\");\n\n        totalClaimedToken += claimAmount;\n        orders[msg.sender][_numOfbuy].claimedTokenAmount += claimAmount;\n        token.safeTransfer(msg.sender, claimAmount);\n\n        emit TokenClaimed(msg.sender, claimAmount, _numOfbuy);\n    }\n\n    /**\n     * @dev Allow users to claim all their purchased tokens at once.\n     * This function uses the `nonReentrant` modifier to prevent reentrancy attacks.\n     */\n    function claimAll() external nonReentrant {\n        uint256 totalClaimAmount;\n        uint256 claimAmounts;\n        uint256 _numOfbuy;\n        UserInfo memory userInfo = users[msg.sender];\n        for (uint256 i = 1; i <= userInfo.timesOfBuy; i++) {\n            uint256 claimAmount = calculateClaimAmount(msg.sender, i);\n            if (claimAmount > 0) {\n                claimAmounts = claimAmount;\n                _numOfbuy = i;\n                totalClaimAmount += claimAmount;\n                orders[msg.sender][_numOfbuy].claimedTokenAmount += claimAmount;\n                emit ClaimAll(msg.sender, claimAmounts, _numOfbuy);\n            }\n        }\n        require(totalClaimAmount > 0, \"Zero claim amount\");\n        totalClaimedToken += totalClaimAmount;\n        token.safeTransfer(msg.sender, totalClaimAmount);\n        emit ClaimAlls(msg.sender, totalClaimAmount);\n    }\n\n    function startSale(uint256 _tokenAmount, uint8 _periodSale)\n        external\n        onlyRole(PROJECTOWNER)\n    {\n        require(startDate == 0, \"Sale has already started\");\n        require(_tokenAmount > 0, \"Token amount must be greater than 0\");\n        require(_periodSale > 0, \"Sale period must be greater than 0\");\n        totalToken += _tokenAmount;\n        currentTotalToken += _tokenAmount;\n        startDate = block.timestamp;\n        endDate = startDate + _periodSale * DAY;\n        token.safeTransferFrom(msg.sender, address(this), _tokenAmount);\n        emit StartSale(_tokenAmount, startDate, endDate);\n    }\n\n    function endSale() external onlyRole(PROJECTOWNER) {\n        require( !closeSale, \"Sale has already close Salesed\");\n        closeSale = true;\n        emit EndSale(block.timestamp);\n    }\n\n    /**\n     * @dev Calculate the amount of tokens that a user can claim for a given purchase order.\n     * @param _userAddress The address of the user.\n     * @param _numOfbuy The number of the user's purchase order.\n     * @return The amount of tokens that the user can claim.\n     */\n    function calculateClaimAmount(address _userAddress, uint256 _numOfbuy)\n        public\n        view\n        returns (uint256)\n    {\n        OrderInfo memory order = orders[_userAddress][_numOfbuy];\n        uint256 claimAmount;\n        uint256 totalPaidPortion;\n        uint256 currentTime = block.timestamp;\n\n        // Create a memory array from roundPaid\n        RoundPaid[] memory roundPaidMemory = roundPaid;\n\n        if (\n            currentTime >=\n            order.boughtDate + (roundPaidMemory[0].paidIntervals * DAY)\n        ) {\n            for (uint256 i = 0; i < roundPaidMemory.length; i++) {\n                if (\n                    currentTime >=\n                    order.boughtDate + (roundPaidMemory[i].paidIntervals * DAY)\n                ) {\n                    totalPaidPortion += roundPaidMemory[i].paidPortions;\n                } else {\n                    break;\n                }\n            }\n            claimAmount =\n                ((totalPaidPortion * order.tokenAmount) / 10000) -\n                order.claimedTokenAmount;\n        }\n        return claimAmount;\n    }\n\n    /**\n     * @dev Get the round paid schedule for token claims.\n     * @return An array of `RoundPaid` structs representing the round paid schedule.\n     */\n    function getRoundPaid() external view returns (RoundPaid[] memory) {\n        return roundPaid;\n    }\n\n    /**\n     * @dev Get the details of a user's purchase order.\n     * @param _userAddress The address of the user.\n     * @param _numOfbuy The number of the user's purchase order.\n     */\n\n    function getOrderInfo(address _userAddress, uint256 _numOfbuy)\n        public\n        view\n        returns (\n            uint256 stableCoinId,\n            uint256 stableCoinAmount,\n            uint256 tokenAmount,\n            uint256 claimedTokenAmount,\n            uint256 boughtDate\n        )\n    {\n        OrderInfo memory order = orders[_userAddress][_numOfbuy];\n        stableCoinId = order.stableCoinId;\n        stableCoinAmount = order.stableCoinAmount;\n        tokenAmount = order.tokenAmount;\n        claimedTokenAmount = order.claimedTokenAmount;\n        boughtDate = order.boughtDate;\n    }\n\n    /**\n     * @dev Get the total stable coin amount and number of purchases for a user.\n     * @param _userAddress The address of the user.\n     */\n    function getUserInfo(address _userAddress)\n        public\n        view\n        returns (uint256 totalStableCoinAmount, uint256 timesOfBuy)\n    {\n        UserInfo memory user = users[_userAddress];\n        totalStableCoinAmount = user.totalStableCoinAmount;\n        timesOfBuy = user.timesOfBuy;\n    }\n\n    /**\n     * @dev Get the details of a stable coin in the list.\n     * @param _stableCoinId The ID of the stable coin.\n     */\n    function getStableCoinInfo(uint256 _stableCoinId)\n        public\n        view\n        returns (\n            address stableCoinAddress,\n            string memory symbol,\n            uint256 totalAmount\n        )\n    {\n        StableCoinInfo memory stableCoin = stableCoinInfo[_stableCoinId];\n        stableCoinAddress = stableCoin.stableCoinAddress;\n        symbol = stableCoin.symbol;\n        totalAmount = stableCoin.totalAmount;\n    }\n\n    /**\n     * @dev Get the number of days passed since a user's purchase order.\n     * @param _userAddress The address of the user.\n     * @param _numOfbuy The number of the user's purchase order.\n     * @return The number of days passed since the purchase order.\n     */\n    function getDayPassed(address _userAddress, uint256 _numOfbuy)\n        public\n        view\n        returns (uint256)\n    {\n        OrderInfo memory order = orders[_userAddress][_numOfbuy];\n        uint256 currentTime = block.timestamp;\n        uint256 elapsedTime = currentTime - order.boughtDate;\n        uint256 dayPassed = elapsedTime / DAY;\n        return dayPassed;\n    }\n\n    /**\n     * @dev Check the total amount of tokens that a user can claim for all their purchase orders.\n     * @param _userAddress The address of the user.\n     * @return The total amount of tokens that the user can claim.\n     */\n    function checkClaimAllAmount(address _userAddress)\n        public\n        view\n        returns (uint256)\n    {\n        uint256 totalClaimAmount;\n        UserInfo memory userInfo = users[_userAddress];\n        for (uint256 i = 1; i <= userInfo.timesOfBuy; i++) {\n            uint256 claimAmount = calculateClaimAmount(_userAddress, i);\n            if (claimAmount > 0) {\n                totalClaimAmount += claimAmount;\n            }\n        }\n        return totalClaimAmount;\n    }\n\n    /**\n     * @dev Get the stable coin amounts and purchase dates for a user's purchase orders.\n     * @param _userAddress The address of the user.\n     */\n    function getStableCoinAndTimeBought(address _userAddress)\n        public\n        view\n        returns (uint256[] memory stableCoinAmount, uint256[] memory timeBought)\n    {\n        uint256 length = users[_userAddress].timesOfBuy;\n        stableCoinAmount = new uint256[](length);\n        timeBought = new uint256[](length);\n        for (uint256 i = 1; i <= length; i++) {\n            OrderInfo memory order = orders[_userAddress][i];\n            stableCoinAmount[i - 1] = order.stableCoinAmount;\n            timeBought[i - 1] = order.boughtDate;\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Pausable.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 {Context} from \"../utils/Context.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 Pausable is Context {\n    bool private _paused;\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    constructor() {\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        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        _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"
      },
      "@openzeppelin/contracts/utils/ReentrancyGuard.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)\n\npragma solidity ^0.8.20;\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 ReentrancyGuard {\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    /**\n     * @dev Unauthorized reentrant call.\n     */\n    error ReentrancyGuardReentrantCall();\n\n    constructor() {\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        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        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n     * `nonReentrant` function in the call stack.\n     */\n    function _reentrancyGuardEntered() internal view returns (bool) {\n        return _status == ENTERED;\n    }\n}\n"
      },
      "@openzeppelin/contracts/access/AccessControl.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.20;\n\nimport {IAccessControl} from \"./IAccessControl.sol\";\nimport {Context} from \"../utils/Context.sol\";\nimport {ERC165} from \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n *     require(hasRole(MY_ROLE, msg.sender));\n *     ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n    struct RoleData {\n        mapping(address account => bool) hasRole;\n        bytes32 adminRole;\n    }\n\n    mapping(bytes32 role => RoleData) private _roles;\n\n    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n    /**\n     * @dev Modifier that checks that an account has a specific role. Reverts\n     * with an {AccessControlUnauthorizedAccount} error including the required role.\n     */\n    modifier onlyRole(bytes32 role) {\n        _checkRole(role);\n        _;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n        return _roles[role].hasRole[account];\n    }\n\n    /**\n     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n     */\n    function _checkRole(bytes32 role) internal view virtual {\n        _checkRole(role, _msgSender());\n    }\n\n    /**\n     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n     * is missing `role`.\n     */\n    function _checkRole(bytes32 role, address account) internal view virtual {\n        if (!hasRole(role, account)) {\n            revert AccessControlUnauthorizedAccount(account, role);\n        }\n    }\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n        return _roles[role].adminRole;\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been revoked `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `callerConfirmation`.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n        if (callerConfirmation != _msgSender()) {\n            revert AccessControlBadConfirmation();\n        }\n\n        _revokeRole(role, callerConfirmation);\n    }\n\n    /**\n     * @dev Sets `adminRole` as ``role``'s admin role.\n     *\n     * Emits a {RoleAdminChanged} event.\n     */\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n        bytes32 previousAdminRole = getRoleAdmin(role);\n        _roles[role].adminRole = adminRole;\n        emit RoleAdminChanged(role, previousAdminRole, adminRole);\n    }\n\n    /**\n     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n        if (!hasRole(role, account)) {\n            _roles[role].hasRole[account] = true;\n            emit RoleGranted(role, account, _msgSender());\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n        if (hasRole(role, account)) {\n            _roles[role].hasRole[account] = false;\n            emit RoleRevoked(role, account, _msgSender());\n            return true;\n        } else {\n            return false;\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/access/Ownable.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 {Context} from \"../utils/Context.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 Ownable is Context {\n    address private _owner;\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    constructor(address initialOwner) {\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        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        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\nimport {IERC20Permit} from \"../extensions/IERC20Permit.sol\";\nimport {Address} from \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    /**\n     * @dev An operation with an ERC20 token failed.\n     */\n    error SafeERC20FailedOperation(address token);\n\n    /**\n     * @dev Indicates a failed `decreaseAllowance` request.\n     */\n    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);\n\n    /**\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));\n    }\n\n    /**\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n     */\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));\n    }\n\n    /**\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 oldAllowance = token.allowance(address(this), spender);\n        forceApprove(token, spender, oldAllowance + value);\n    }\n\n    /**\n     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no\n     * value, non-reverting calls are assumed to be successful.\n     */\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {\n        unchecked {\n            uint256 currentAllowance = token.allowance(address(this), spender);\n            if (currentAllowance < requestedDecrease) {\n                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);\n            }\n            forceApprove(token, spender, currentAllowance - requestedDecrease);\n        }\n    }\n\n    /**\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n     * to be set to zero before setting it to a non-zero value, such as USDT.\n     */\n    function forceApprove(IERC20 token, address spender, uint256 value) internal {\n        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));\n\n        if (!_callOptionalReturnBool(token, approvalCall)) {\n            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));\n            _callOptionalReturn(token, approvalCall);\n        }\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data);\n        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {\n            revert SafeERC20FailedOperation(address(token));\n        }\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     *\n     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n     */\n    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n        // and not revert is the subcall reverts.\n\n        (bool success, bytes memory returndata) = address(token).call(data);\n        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;\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"
      },
      "@openzeppelin/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\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 Context {\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/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev The ETH balance of the account is not enough to perform the operation.\n     */\n    error AddressInsufficientBalance(address account);\n\n    /**\n     * @dev There's no code at `target` (it is not a contract).\n     */\n    error AddressEmptyCode(address target);\n\n    /**\n     * @dev A call to an address target failed. The target may have reverted.\n     */\n    error FailedInnerCall();\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        if (address(this).balance < amount) {\n            revert AddressInsufficientBalance(address(this));\n        }\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        if (!success) {\n            revert FailedInnerCall();\n        }\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 or custom error, it is bubbled\n     * up by this function (like regular Solidity function calls). However, if\n     * the call reverted with no returned reason, this function reverts with a\n     * {FailedInnerCall} error.\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    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0);\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    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        if (address(this).balance < value) {\n            revert AddressInsufficientBalance(address(this));\n        }\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n     * unsuccessful call.\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata\n    ) internal view returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            // only check if target is a contract if the call was successful and the return data is empty\n            // otherwise we already know that it was a contract\n            if (returndata.length == 0 && target.code.length == 0) {\n                revert AddressEmptyCode(target);\n            }\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n     * revert reason or with a default {FailedInnerCall} error.\n     */\n    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n     */\n    function _revert(bytes memory returndata) 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 FailedInnerCall();\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n *     doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n *     token.safeTransferFrom(msg.sender, address(this), value);\n *     ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     *\n     * CAUTION: See Security Considerations above.\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
      },
      "@openzeppelin/contracts/utils/introspection/ERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
      },
      "@openzeppelin/contracts/access/IAccessControl.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n    /**\n     * @dev The `account` is missing a role.\n     */\n    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n    /**\n     * @dev The caller of a function is not the expected one.\n     *\n     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n     */\n    error AccessControlBadConfirmation();\n\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {AccessControl-_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `callerConfirmation`.\n     */\n    function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n"
      },
      "@openzeppelin/contracts/utils/introspection/IERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "abi"
          ]
        }
      },
      "remappings": []
    }
  }}