creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/LockNFT.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"./LockPeriodContract.sol\";\nimport \"./interfaces/ILockNFT.sol\";\nimport \"./interfaces/IUSAStakeReceiptNFT.sol\";\nimport \"@openzeppelin/contracts/token/ERC1155/IERC1155.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\";\n\n/**\n@title LockNFT\n@notice Contract for locking NFTs in the lock pool with USA tokens and DEDPRZ NFTS. Passive and gas efficient rewards farming. \n@author github @bullishpaisa\n */\ncontract LockNFT is LockPeriodContract, ILockNFT, IERC1155Receiver {\n    using Address for address;\n\n    mapping(uint256 => uint256) public amountUsaLocked;\n\n    uint256 public usaLockAmount;\n\n    IUSAStakeReceiptNFT public immutable receiptNFTContract; // DEPPRZ nft\n\n    IERC1155 public immutable lockTokenERC1155; // DEPPRZ nft\n\n    constructor(\n        address _rewardsToken_usa_1,\n        address _rewardsToken_WETH_2,\n        address _rewardsToken_Stable_3,\n        address _lockERC20,\n        address _owner,\n        address _multisig,\n        address _receiptNFT,\n        address _lockNFTAddress,\n        uint256 _lockDurationNextPeriod,\n        uint256 _defaultWindowDuration\n    )\n        LockPeriodContract(\n            _rewardsToken_usa_1,\n            _rewardsToken_WETH_2,\n            _rewardsToken_Stable_3,\n            _lockERC20,\n            _owner,\n            _multisig\n        )\n    {\n        lockDurationNextPeriod__ = _lockDurationNextPeriod;\n        defaultWindowDuration__ = _defaultWindowDuration;\n        lockTokenERC1155 = IERC1155(_lockNFTAddress);\n        receiptNFTContract = IUSAStakeReceiptNFT(_receiptNFT);\n        STAKE_TOKEN_DECIMALS_SCALE = 1;\n        usaLockAmount = 2500 * 1e18;\n    }\n\n    /// @inheritdoc ILockNFT\n    function lockSingleNFTInAnyPeriod(\n        uint256 _tokenId\n    ) external nonReentrant updateReward(msg.sender) {\n        _harvestRewards();\n\n        uint256 amountUSA_ = usaLockAmount;\n\n        require(\n            lockTokenERC20.balanceOf(msg.sender) >= amountUSA_,\n            \"LockNFT: Insufficient USA balance for locking NFT\"\n        );\n\n        require(\n            lockTokenERC1155.balanceOf(msg.sender, _tokenId) > 0,\n            \"LockNFT: user does not own NFT it is trying to lock\"\n        );\n\n        // if state is unlocked redeemable, then let the user lock tokens 'in the regular fashion\n        if (contractState__ == ContractState.UNLOCKED_REDEEMABLE) {\n            _stakeAssets(1);\n        } else if (contractState__ == ContractState.ACTIVE_LOCKED) {\n            _lockTokensDuringActivePeriod(1);\n        } else if (contractState__ == ContractState.FRESH_PERIOD) {\n            _stakeAssets(1);\n        } else {\n            revert(\"LockNFT: Pool is not in valid state to lock NFTs\");\n        }\n\n        amountUsaLocked[_tokenId] = amountUSA_;\n\n        _lockNFT(_tokenId);\n\n        _transferInERC20(amountUSA_);\n\n        emit NFTLocked(msg.sender, _tokenId, amountUSA_, activePeriodIndex__);\n    }\n\n    /// @inheritdoc ILockNFT\n    function lockBatchNFTInAnyPeriod(\n        uint256[] memory _tokenIds\n    ) external nonReentrant updateReward(msg.sender) {\n        _harvestRewards();\n\n        uint256 amountUSA_ = usaLockAmount * _tokenIds.length;\n\n        require(\n            lockTokenERC20.balanceOf(msg.sender) >= amountUSA_,\n            \"LockNFT: Insufficient USA balance for locking NFTs\"\n        );\n\n        require(_tokenIds.length > 0, \"LockNFT: empty tokenIds array\");\n\n        // if state is unlocked redeemable, then let the user lock tokens 'in the regular fashion\n        if (contractState__ == ContractState.UNLOCKED_REDEEMABLE) {\n            _stakeAssets(_tokenIds.length);\n        } else if (contractState__ == ContractState.ACTIVE_LOCKED) {\n            _lockTokensDuringActivePeriod(_tokenIds.length);\n        } else if (contractState__ == ContractState.FRESH_PERIOD) {\n            _stakeAssets(_tokenIds.length);\n        } else {\n            revert(\"LockNFT: Pool is not in valid state to lock NFTs\");\n        }\n\n        _lockNFTBatch(_tokenIds);\n\n        _transferInERC20(amountUSA_);\n\n        emit BatchNftLocked(\n            msg.sender,\n            _tokenIds,\n            amountUSA_,\n            activePeriodIndex__\n        );\n    }\n\n    function unstakeSingleNftIndex(\n        uint256 _tokenId\n    ) external nonReentrant updateReward(msg.sender) {\n        _harvestRewards();\n\n        require(\n            receiptNFTContract.isOwnerOf(msg.sender, _tokenId),\n            \"LockNFT: staker not staker of receipt NFT\"\n        );\n\n        if (contractState__ == ContractState.UNLOCKED_REDEEMABLE) {\n            _unstakeAssets(1);\n        } else if (contractState__ == ContractState.ACTIVE_LOCKED) {\n            revert(\n                \"LockNFT: Cannot unlock NFTs during active period wait until the period is over.\"\n            );\n        } else if (contractState__ == ContractState.FRESH_PERIOD) {\n            _unstakeAssets(1);\n        } else {\n            revert(\"LockNFT: Pool is not in valid state\");\n        }\n\n        uint256 amount_ = amountUsaLocked[_tokenId];\n\n        _transferOutERC20(amount_);\n\n        amountUsaLocked[_tokenId] = 0;\n\n        _burnNFT(_tokenId);\n\n        emit NftUnstaked(_tokenId);\n    }\n\n    function unstakeBatchOfNfts(\n        uint256[] memory _tokenIds\n    ) public nonReentrant updateReward(msg.sender) {\n        _harvestRewards();\n\n        if (contractState__ == ContractState.UNLOCKED_REDEEMABLE) {\n            _unstakeAssets(_tokenIds.length);\n        } else if (contractState__ == ContractState.ACTIVE_LOCKED) {\n            revert(\n                \"LockNFT: Cannot unlock NFTs during active period wait until the period is over.\"\n            );\n        } else if (contractState__ == ContractState.FRESH_PERIOD) {\n            _unstakeAssets(_tokenIds.length);\n        } else {\n            revert(\"LockNFT: Lock pool is not available for unstaking NFTs.\");\n        }\n\n        uint256 totalUsa_ = _unstakeBatch(_tokenIds);\n\n        _transferOutERC20(totalUsa_);\n\n        emit BatchOfNftsUnstaked(_tokenIds);\n    }\n\n    function harvestRewards()\n        external\n        nonReentrant\n        updateReward(msg.sender)\n        returns (\n            uint256 claimableReward_USA_1,\n            uint256 claimableReward_WETH_2,\n            uint256 claimableReward_Stable_3\n        )\n    {\n        (\n            claimableReward_USA_1,\n            claimableReward_WETH_2,\n            claimableReward_Stable_3\n        ) = _harvestRewards();\n    }\n\n    function setUsaLockAmount(uint256 _amount) external onlyOwner {\n        usaLockAmount = _amount;\n        emit SetUsaLockAmount(_amount);\n    }\n\n    // Internal functions\n\n    function _unstakeBatch(\n        uint256[] memory _tokenIds\n    ) internal returns (uint256) {\n        uint256 totalToReturn_;\n        for (uint256 i = 0; i < _tokenIds.length; i++) {\n            require(\n                receiptNFTContract.isOwnerOf(msg.sender, _tokenIds[i]),\n                \"LockNFT: user doesn't own the NFT it is trying to unlock\"\n            );\n            _burnNFT(_tokenIds[i]);\n            totalToReturn_ += amountUsaLocked[_tokenIds[i]];\n            amountUsaLocked[_tokenIds[i]] = 0;\n        }\n        return totalToReturn_;\n    }\n\n    function _lockNFTBatch(uint256[] memory _tokenIds) internal {\n        for (uint256 i = 0; i < _tokenIds.length; i++) {\n            require(\n                lockTokenERC1155.balanceOf(msg.sender, _tokenIds[i]) > 0,\n                \"LockNFT: not owner of NFT\"\n            );\n            _lockNFT(_tokenIds[i]);\n            amountUsaLocked[_tokenIds[i]] = usaLockAmount;\n        }\n    }\n\n    function _lockNFT(uint256 _tokenId) internal {\n        lockTokenERC1155.safeTransferFrom(\n            msg.sender,\n            address(this),\n            _tokenId,\n            1,\n            \"\"\n        );\n        receiptNFTContract.mintNft(msg.sender, _tokenId);\n    }\n\n    function _burnNFT(uint256 _tokenId) internal {\n        lockTokenERC1155.safeTransferFrom(\n            address(this),\n            msg.sender,\n            _tokenId,\n            1,\n            \"\"\n        );\n        receiptNFTContract.burnNft(_tokenId);\n    }\n\n    function executeAnyCall(address _target, bytes memory _data) external {\n        require(\n            msg.sender == migratorContractAddress,\n            \"LockPeriodContract: Only migrator contract can call this function\"\n        );\n        _target.functionCall(_data);\n    }\n\n    function onERC1155BatchReceived(\n        address operator,\n        address from,\n        uint256[] calldata ids,\n        uint256[] calldata values,\n        bytes calldata data\n    ) external override returns (bytes4) {\n        return\n            bytes4(\n                keccak256(\n                    \"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"\n                )\n            );\n    }\n\n    function onERC1155Received(\n        address operator,\n        address from,\n        uint256 id,\n        uint256 value,\n        bytes calldata data\n    ) external returns (bytes4) {\n        return\n            bytes4(\n                keccak256(\n                    \"onERC1155Received(address,address,uint256,uint256,bytes)\"\n                )\n            );\n    }\n\n    function supportsInterface(\n        bytes4 interfaceId\n    ) public view virtual returns (bool) {\n        return interfaceId == type(IERC1155).interfaceId;\n    }\n}\n"
      },
      "src/LockPeriodContract.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\n// contracts\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/utils/Pausable.sol\";\n\n// interfaces\nimport \"./interfaces/ILockPeriodContract.sol\";\n\n/**\n@title LockPeriodContract\n@notice Contract for locking NFTs in the lock pool with USA tokens and DEDPRZ NFTS. Passive and gas efficient rewards farming. \n@author github @bullishpaisa\n */\ncontract LockPeriodContract is\n    ILockPeriodContract,\n    Ownable,\n    ReentrancyGuard,\n    Pausable\n{\n    uint256 internal immutable STAKE_TOKEN_DECIMALS_SCALE;\n\n    address internal immutable MULTISIG_ADDRESS;\n\n    IERC20 internal immutable lockTokenERC20;\n\n    IERC20 internal immutable rewardToken_USA_1;\n\n    IERC20 internal immutable rewardToken_WETH_2;\n\n    IERC20 internal immutable rewardToken_Stable_3;\n\n    mapping(uint256 => PeriodInfo) internal periodInfo__;\n\n    mapping(address => StakeInfo) internal stakes__;\n\n    // the reward per staked/locked token for each period_\n    mapping(uint256 => uint256) internal periodRewardPerStakedToken_USA_1__;\n\n    // the reward per staked/locked token for each period_ for WETH\n    mapping(uint256 => uint256) internal periodRewardPerStakedToken_WETH_2__;\n\n    // the reward per staked/locked token for each period_ for Stable\n    mapping(uint256 => uint256) internal periodRewardPerStakedToken_Stable_3__;\n\n    ContractState internal contractState__;\n\n    // the index counters\n    uint256 internal periodIndexCounter__;\n\n    // the index of the current lock period\n    uint256 internal activePeriodIndex__;\n\n    // the index of the next lock period\n    uint256 internal nextPeriodIndex__;\n\n    // total amount of rewards distributed by the rewardsDistribution contract\n    uint256 internal totalRewardsDistributed_USA_1__;\n\n    uint256 internal totalRewardsDistributed_WETH_2__;\n\n    uint256 internal totalRewardsDistributed_Stable_3__;\n\n    uint256 internal lockDurationNextPeriod__;\n\n    uint256 internal defaultWindowDuration__;\n\n    uint256 internal totalAmountStakedAssets__;\n\n    address public rewardsDistribution;\n\n    address public migratorContractAddress;\n\n    constructor(\n        address _rewardsToken_usa_1,\n        address _rewardsToken_WETH_2,\n        address _rewardsToken_Stable_3,\n        address _lockERC20,\n        address _owner,\n        address _multisig\n    ) Ownable(_owner) {\n        rewardToken_USA_1 = IERC20(_rewardsToken_usa_1);\n        rewardToken_WETH_2 = IERC20(_rewardsToken_WETH_2);\n        rewardToken_Stable_3 = IERC20(_rewardsToken_Stable_3);\n        lockTokenERC20 = IERC20(_lockERC20);\n        MULTISIG_ADDRESS = _multisig;\n    }\n\n    /* ========== MODIFIERS ========== */\n\n    modifier updateReward(address _account) {\n        _updateContractState();\n        _calculateAndUpdateRewards(_account);\n        _;\n    }\n\n    modifier onlyRewardsDistribution() {\n        require(\n            msg.sender == rewardsDistribution,\n            \"LockPeriodContract: Caller is not RewardsDistribution contract\"\n        );\n        _;\n    }\n\n    /* ========== MUTATIVE FUNCTIONS ========== */\n\n    // function purpose is to check if the contractState__ is updated and if so, updates it\n    function _updateContractState() internal {\n        _checkIfNotPaused();\n        if (contractState__ == ContractState.ACTIVE_LOCKED) {\n            _processActivePeriod();\n        } else if (contractState__ == ContractState.UNLOCKED_REDEEMABLE) {\n            _processUnlockRedeemable();\n        } else if (contractState__ == ContractState.FRESH_PERIOD) {\n            _processFreshPeriod();\n        } else if (\n            contractState__ == ContractState.CONTRACT_UNLOCKED_INACTIVE\n        ) {\n            return;\n        } else {\n            revert(\n                \"LockPeriodContract: Lock contract is awaiting configuration\"\n            );\n        }\n    }\n\n    function _calculateAndUpdateRewards(address _account) internal {\n        unchecked {\n            uint256 newReward_USA_1_ = 0;\n            uint256 newReward_WETH_2_ = 0;\n            uint256 newReward_Stable_3_ = 0;\n\n            bool hasReward_ = false;\n\n            StakeInfo memory stakeInfo_ = stakes__[_account];\n\n            // Calculate new rewards since the last update\n            for (\n                uint256 i = stakeInfo_.lastUpdatePeriodIndex;\n                i < activePeriodIndex__;\n                ++i\n            ) {\n                if (periodInfo__[i].isFinalized == 0) {\n                    continue;\n                }\n\n                // if user has nothing staked, we exit the loop, but update the last updated period_ index\n                if (stakeInfo_.amountStaked == 0) {\n                    stakes__[_account].lastUpdatePeriodIndex = uint8(\n                        activePeriodIndex__\n                    );\n                    return;\n                }\n\n                newReward_USA_1_ +=\n                    (periodRewardPerStakedToken_USA_1__[i] *\n                        stakeInfo_.amountStaked) /\n                    STAKE_TOKEN_DECIMALS_SCALE;\n\n                newReward_WETH_2_ +=\n                    (periodRewardPerStakedToken_WETH_2__[i] *\n                        stakeInfo_.amountStaked) /\n                    STAKE_TOKEN_DECIMALS_SCALE;\n\n                newReward_Stable_3_ +=\n                    (periodRewardPerStakedToken_Stable_3__[i] *\n                        stakeInfo_.amountStaked) /\n                    STAKE_TOKEN_DECIMALS_SCALE;\n\n                hasReward_ = true;\n            }\n\n            if (hasReward_) {\n                // Update the reward debt to include new rewards\n                stakeInfo_.rewardDebt_USA_1 += uint88(newReward_USA_1_);\n                stakeInfo_.rewardDebt_WETH_2 += uint88(newReward_WETH_2_);\n                stakeInfo_.rewardDebt_Stable_3 += uint88(newReward_Stable_3_);\n\n                if (stakeInfo_.lastUpdatePeriodIndex < activePeriodIndex__) {\n                    // Update the last updated period_ index\n                    stakeInfo_.lastUpdatePeriodIndex = uint8(\n                        activePeriodIndex__\n                    );\n                }\n                stakes__[_account] = stakeInfo_;\n                return;\n            }\n        }\n    }\n\n    function _processActivePeriod() internal {\n        // the current contract state is active\n        PeriodInfo memory period_ = periodInfo__[activePeriodIndex__];\n        uint256 _activePeriodIndex = activePeriodIndex__;\n\n        if (block.timestamp <= period_.timestampPeriodEnd) {\n            // scenario 1 - the period is still active, no update is required\n            return;\n        } else {\n            // scenario 2 - the active period has expired, we need to process this\n            if (period_.isFinalized == 0) {\n                // if the period has not been finalized, we need to finalize it\n                periodInfo__[_activePeriodIndex].isFinalized = 1;\n\n                activePeriodIndex__ = _createNextPeriod(\n                    period_.timestampPeriodEnd + uint32(defaultWindowDuration__)\n                );\n            } else {\n                activePeriodIndex__ = nextPeriodIndex__;\n\n                nextPeriodIndex__ = 0;\n            }\n\n            _activePeriodIndex = activePeriodIndex__;\n\n            period_ = periodInfo__[_activePeriodIndex];\n\n            if (block.timestamp < period_.timestampPeriodStart) {\n                // the next period has not started yet, so the contract state is now UNLOCKED_REDEEMABLE\n                contractState__ = ContractState.UNLOCKED_REDEEMABLE;\n\n                emit ContractStateChanged(\n                    ContractState.UNLOCKED_REDEEMABLE,\n                    _activePeriodIndex\n                );\n            } else if (block.timestamp <= period_.timestampPeriodEnd) {\n                // register the total amount staked in the period\n                periodInfo__[_activePeriodIndex].totalLockedInPeriod = uint88(\n                    totalAmountStakedAssets__\n                );\n\n                emit ContractStateChanged(\n                    ContractState.ACTIVE_LOCKED,\n                    _activePeriodIndex\n                );\n            } else {\n                // the next period has ended, so a whole active period has gone by without the contract being updated\n\n                periodInfo__[_activePeriodIndex].isFinalized = 1;\n\n                // since the active state was skipped we need to store the total amount staked in the period\n                periodInfo__[_activePeriodIndex].totalLockedInPeriod = uint88(\n                    totalAmountStakedAssets__\n                );\n\n                activePeriodIndex__ = _createNextPeriod(\n                    period_.timestampPeriodEnd + uint32(defaultWindowDuration__)\n                );\n\n                if (\n                    block.timestamp <\n                    (period_.timestampPeriodEnd +\n                        uint32(defaultWindowDuration__))\n                ) {\n                    // the next period has not started yet, so the contract state is now UNLOCKED_REDEEMABLE\n                    contractState__ = ContractState.UNLOCKED_REDEEMABLE;\n\n                    emit ContractStateChanged(\n                        ContractState.UNLOCKED_REDEEMABLE,\n                        activePeriodIndex__\n                    );\n                } else {\n                    if (\n                        block.timestamp <=\n                        (period_.timestampPeriodEnd +\n                            uint32(\n                                defaultWindowDuration__ +\n                                    lockDurationNextPeriod__\n                            ))\n                    ) {\n                        // the next period has started, so the contract state is now ACTIVE_LOCKED\n                        contractState__ = ContractState.ACTIVE_LOCKED;\n\n                        periodInfo__[activePeriodIndex__]\n                            .totalLockedInPeriod = uint88(\n                            totalAmountStakedAssets__\n                        );\n\n                        emit ContractStateChanged(\n                            ContractState.ACTIVE_LOCKED,\n                            activePeriodIndex__\n                        );\n                    } else {\n                        // the contract has gone without admin updates for more than 2.5 periods, it kicks into the inactive state\n                        contractState__ = ContractState\n                            .CONTRACT_UNLOCKED_INACTIVE;\n\n                        periodInfo__[activePeriodIndex__]\n                            .totalLockedInPeriod = uint88(\n                            totalAmountStakedAssets__\n                        );\n\n                        // finalize the period\n                        periodInfo__[activePeriodIndex__].isFinalized = 1;\n\n                        emit ContractStateChanged(\n                            ContractState.CONTRACT_UNLOCKED_INACTIVE,\n                            activePeriodIndex__\n                        );\n                    }\n                }\n            }\n        }\n    }\n\n    function _processUnlockRedeemable() internal {\n        PeriodInfo memory period_ = periodInfo__[activePeriodIndex__];\n        uint256 _activePeriodIndex = activePeriodIndex__;\n\n        if (block.timestamp < period_.timestampPeriodStart) {\n            // the contract is in the correct state as the active period till has to start\n            return;\n        } else if (\n            block.timestamp >= period_.timestampPeriodStart &&\n            block.timestamp <= period_.timestampPeriodEnd\n        ) {\n            // the new lock period has started, the period is active we need to process this\n            contractState__ = ContractState.ACTIVE_LOCKED;\n\n            periodInfo__[_activePeriodIndex].totalLockedInPeriod = uint88(\n                totalAmountStakedAssets__\n            );\n        } else {\n            periodInfo__[_activePeriodIndex].isFinalized = 1;\n\n            // since the active state was skipped we need to store the total amount staked in the period\n            periodInfo__[_activePeriodIndex].totalLockedInPeriod = uint88(\n                totalAmountStakedAssets__\n            );\n\n            activePeriodIndex__ = _createNextPeriod(\n                period_.timestampPeriodEnd + uint32(defaultWindowDuration__)\n            );\n\n            _activePeriodIndex = activePeriodIndex__;\n\n            period_ = periodInfo__[_activePeriodIndex];\n\n            if (block.timestamp < period_.timestampPeriodStart) {\n                emit ContractStateChanged(\n                    ContractState.UNLOCKED_REDEEMABLE,\n                    _activePeriodIndex\n                );\n            } else if (block.timestamp <= period_.timestampPeriodEnd) {\n                // the next period has started, so the contract state is now ACTIVE_LOCKED, but the previous period has not been finalized (so skipped effectively)\n                contractState__ = ContractState.ACTIVE_LOCKED;\n\n                periodInfo__[_activePeriodIndex].totalLockedInPeriod = uint88(\n                    totalAmountStakedAssets__\n                );\n\n                emit ContractStateChanged(\n                    ContractState.ACTIVE_LOCKED,\n                    _activePeriodIndex\n                );\n            } else {\n                contractState__ = ContractState.CONTRACT_UNLOCKED_INACTIVE;\n\n                periodInfo__[_activePeriodIndex].isFinalized = 1;\n\n                periodInfo__[_activePeriodIndex].totalLockedInPeriod = uint88(\n                    totalAmountStakedAssets__\n                );\n\n                emit ContractStateChanged(\n                    ContractState.CONTRACT_UNLOCKED_INACTIVE,\n                    _activePeriodIndex\n                );\n            }\n        }\n    }\n\n    function _processFreshPeriod() internal {\n        unchecked {\n            PeriodInfo memory period_ = periodInfo__[activePeriodIndex__];\n            uint256 _activePeriodIndex = activePeriodIndex__;\n\n            if (block.timestamp < period_.timestampPeriodStart) {\n                // the period has not started yet, since it is a fresh period the state remains the same (so FRESH_PERIOD)\n            } else if (\n                block.timestamp >= period_.timestampPeriodStart &&\n                block.timestamp <= period_.timestampPeriodEnd\n            ) {\n                // the fresh period has ended, so the contract state is now ACTIVE_LOCKED\n                contractState__ = ContractState.ACTIVE_LOCKED;\n\n                // set the total amount staked in the period\n                periodInfo__[_activePeriodIndex].totalLockedInPeriod = uint88(\n                    totalAmountStakedAssets__\n                );\n\n                emit ContractStateChanged(\n                    ContractState.ACTIVE_LOCKED,\n                    _activePeriodIndex\n                );\n            } else {\n                periodInfo__[_activePeriodIndex].isFinalized = 1;\n\n                periodInfo__[_activePeriodIndex].totalLockedInPeriod = uint88(\n                    totalAmountStakedAssets__\n                );\n\n                activePeriodIndex__ = _createNextPeriod(\n                    period_.timestampPeriodEnd + uint32(defaultWindowDuration__)\n                );\n\n                _activePeriodIndex = activePeriodIndex__;\n\n                period_ = periodInfo__[_activePeriodIndex];\n\n                if (block.timestamp < period_.timestampPeriodStart) {\n                    contractState__ = ContractState.UNLOCKED_REDEEMABLE;\n\n                    emit ContractStateChanged(\n                        ContractState.UNLOCKED_REDEEMABLE,\n                        _activePeriodIndex\n                    );\n                } else if (block.timestamp <= period_.timestampPeriodEnd) {\n                    contractState__ = ContractState.ACTIVE_LOCKED;\n\n                    periodInfo__[_activePeriodIndex]\n                        .totalLockedInPeriod = uint88(\n                        totalAmountStakedAssets__\n                    );\n\n                    emit ContractStateChanged(\n                        ContractState.ACTIVE_LOCKED,\n                        _activePeriodIndex\n                    );\n                } else {\n                    contractState__ = ContractState.CONTRACT_UNLOCKED_INACTIVE;\n\n                    periodInfo__[_activePeriodIndex].isFinalized = 1;\n\n                    periodInfo__[_activePeriodIndex]\n                        .totalLockedInPeriod = uint88(\n                        totalAmountStakedAssets__\n                    );\n\n                    emit ContractStateChanged(\n                        ContractState.CONTRACT_UNLOCKED_INACTIVE,\n                        _activePeriodIndex\n                    );\n                }\n            }\n        }\n    }\n\n    /* ========== INTERNAL FUNCTIONS ========== */\n\n    function _totalClaimable(\n        address _account,\n        uint256 _activePeriodIndex\n    )\n        internal\n        view\n        returns (\n            uint256 totalClaimableUSA_,\n            uint256 totalClaimableWETH_,\n            uint256 totalClaimableStable_\n        )\n    {\n        unchecked {\n            StakeInfo memory stakeInfo_ = stakes__[_account];\n\n            // check how much the user can claim as per the updated state\n            totalClaimableUSA_ =\n                stakeInfo_.rewardDebt_USA_1 -\n                stakeInfo_.rewardPaid_USA_1;\n\n            totalClaimableWETH_ =\n                stakeInfo_.rewardDebt_WETH_2 -\n                stakeInfo_.rewardPaid_WETH_2;\n\n            totalClaimableStable_ =\n                stakeInfo_.rewardDebt_Stable_3 -\n                stakeInfo_.rewardPaid_Stable_3;\n\n            if (\n                block.timestamp >\n                periodInfo__[_activePeriodIndex].timestampPeriodEnd\n            ) {\n                _activePeriodIndex += 1;\n            }\n\n            for (\n                uint256 i = stakeInfo_.lastUpdatePeriodIndex;\n                i < _activePeriodIndex;\n                ++i\n            ) {\n                if (periodInfo__[i].isFinalized == 0) {\n                    continue;\n                }\n\n                if (stakeInfo_.amountStaked == 0) {\n                    return (0, 0, 0);\n                }\n\n                totalClaimableUSA_ +=\n                    (periodRewardPerStakedToken_USA_1__[i] *\n                        stakeInfo_.amountStaked) /\n                    STAKE_TOKEN_DECIMALS_SCALE;\n\n                totalClaimableWETH_ +=\n                    (periodRewardPerStakedToken_WETH_2__[i] *\n                        stakeInfo_.amountStaked) /\n                    STAKE_TOKEN_DECIMALS_SCALE;\n\n                totalClaimableStable_ +=\n                    (periodRewardPerStakedToken_Stable_3__[i] *\n                        stakeInfo_.amountStaked) /\n                    STAKE_TOKEN_DECIMALS_SCALE;\n            }\n\n            return (\n                totalClaimableUSA_,\n                totalClaimableWETH_,\n                totalClaimableStable_\n            );\n        }\n    }\n\n    function _harvestRewards()\n        internal\n        returns (\n            uint256 claimableReward_USA_1,\n            uint256 claimableReward_WETH_2,\n            uint256 claimableReward_Stable_3\n        )\n    {\n        StakeInfo memory stakeInfo_ = stakes__[msg.sender];\n\n        claimableReward_USA_1 =\n            stakeInfo_.rewardDebt_USA_1 -\n            stakeInfo_.rewardPaid_USA_1;\n\n        claimableReward_WETH_2 =\n            stakeInfo_.rewardDebt_WETH_2 -\n            stakeInfo_.rewardPaid_WETH_2;\n\n        claimableReward_Stable_3 =\n            stakeInfo_.rewardDebt_Stable_3 -\n            stakeInfo_.rewardPaid_Stable_3;\n\n        bool hasReward_ = false;\n\n        hasReward_ =\n            claimableReward_USA_1 > 0 ||\n            claimableReward_WETH_2 > 0 ||\n            claimableReward_Stable_3 > 0;\n\n        if (!hasReward_) {\n            return (0, 0, 0);\n        }\n\n        if (claimableReward_USA_1 > 0) {\n            stakeInfo_.rewardPaid_USA_1 += uint88(claimableReward_USA_1);\n\n            rewardToken_USA_1.transfer(msg.sender, claimableReward_USA_1);\n        }\n\n        if (claimableReward_WETH_2 > 0) {\n            stakeInfo_.rewardPaid_WETH_2 += uint88(claimableReward_WETH_2);\n\n            rewardToken_WETH_2.transfer(msg.sender, claimableReward_WETH_2);\n        }\n\n        if (claimableReward_Stable_3 > 0) {\n            stakeInfo_.rewardPaid_Stable_3 += uint88(claimableReward_Stable_3);\n\n            rewardToken_Stable_3.transfer(msg.sender, claimableReward_Stable_3);\n        }\n\n        stakes__[msg.sender] = stakeInfo_;\n\n        emit RewardsClaimed(\n            msg.sender,\n            claimableReward_USA_1,\n            claimableReward_WETH_2,\n            claimableReward_Stable_3\n        );\n\n        return (\n            claimableReward_USA_1,\n            claimableReward_WETH_2,\n            claimableReward_Stable_3\n        );\n    }\n\n    function _createNextPeriod(\n        uint32 _startNextPeriod\n    ) internal returns (uint256 newPeriodIndex_) {\n        unchecked {\n            periodIndexCounter__++;\n            newPeriodIndex_ = periodIndexCounter__;\n            PeriodInfo storage period_ = periodInfo__[newPeriodIndex_];\n            period_.timestampPeriodStart = _startNextPeriod;\n            period_.timestampPeriodEnd = uint32(\n                _startNextPeriod + lockDurationNextPeriod__\n            );\n\n            // log the start and end of the new period\n            emit NewPeriodCreated(\n                newPeriodIndex_,\n                _startNextPeriod,\n                period_.timestampPeriodEnd\n            );\n\n            // totalLockedInPeriod and totalRewardedInPeriod_USA_1 are not set yet (so are 0)\n            return newPeriodIndex_;\n        }\n    }\n\n    function _lockTokensDuringActivePeriod(uint256 _amount) internal {\n        StakeInfo memory stakeInfo_ = stakes__[msg.sender];\n\n        // user cannot have already staked tokens locked in the current active period\n        require(\n            stakeInfo_.amountStaked == 0,\n            \"LockPeriodContract: User already has NFTs in active lock, please use different wallet to lock new nfts or wait until the current lock period is over to add to this wallet\"\n        );\n\n        totalAmountStakedAssets__ += _amount;\n\n        stakeInfo_.amountStaked = uint88(_amount);\n\n        stakeInfo_.lastUpdatePeriodIndex = uint8(activePeriodIndex__ + 1);\n\n        stakes__[msg.sender] = stakeInfo_;\n    }\n\n    function _transferInERC20(uint256 _amount) internal {\n        require(_amount > 0, \"LockPeriodContract: Cannot lock 0\");\n\n        // transfer tokens from user to contract\n        lockTokenERC20.transferFrom(msg.sender, address(this), _amount);\n    }\n\n    function _transferOutERC20(uint256 _amount) internal {\n        lockTokenERC20.transfer(msg.sender, _amount);\n    }\n\n    function _stakeAssets(uint256 _amount) internal {\n        totalAmountStakedAssets__ += _amount;\n\n        stakes__[msg.sender].amountStaked += uint88(_amount);\n    }\n\n    function _unstakeAssets(uint256 _amount) internal {\n        require(\n            uint256(contractState__) >= 2,\n            \"LockPeriodContract: Cannot unstake in current state, wait for the contract to unlock\"\n        );\n\n        require(_amount > 0, \"LockPeriodContract: Cannot withdraw 0 nfts.\");\n\n        require(\n            _amount <= stakes__[msg.sender].amountStaked,\n            \"LockPeriodContract: Amount is higher than staked\"\n        );\n\n        totalAmountStakedAssets__ -= _amount;\n\n        stakes__[msg.sender].amountStaked -= uint88(_amount);\n    }\n\n    function _checkIfNotPaused() internal {\n        require(!paused(), \"LockPeriodContract: Contract is paused\");\n    }\n\n    /* ========== RESTRICTED FUNCTIONS ========== */\n\n    function restartLockContract(\n        uint32 _startFirstPeriod,\n        uint256 _lockDurationNextPeriod\n    ) external onlyOwner {\n        _updateContractState();\n        _restartLockContract(_startFirstPeriod, _lockDurationNextPeriod);\n    }\n\n    function _restartLockContract(\n        uint32 _startFirstPeriod,\n        uint256 _lockDurationNextPeriod\n    ) internal {\n        // set period for period 0 to finalized\n        periodInfo__[periodIndexCounter__].isFinalized = 1;\n\n        periodIndexCounter__++;\n\n        activePeriodIndex__ = periodIndexCounter__;\n\n        nextPeriodIndex__ = 0;\n\n        lockDurationNextPeriod__ = _lockDurationNextPeriod;\n\n        // set contractState__ to FRESH_PERIOD\n        contractState__ = ContractState.FRESH_PERIOD;\n\n        PeriodInfo storage period_ = periodInfo__[periodIndexCounter__];\n\n        period_.timestampPeriodStart = _startFirstPeriod;\n\n        period_.timestampPeriodEnd = uint32(\n            _startFirstPeriod + _lockDurationNextPeriod\n        );\n\n        emit ContractStateChanged(\n            ContractState.FRESH_PERIOD,\n            activePeriodIndex__\n        );\n\n        emit NewLockPeriodConfigured(\n            activePeriodIndex__,\n            _startFirstPeriod,\n            _lockDurationNextPeriod\n        );\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function configureFirstPeriod(\n        uint32 _startFirstPeriod,\n        uint256 _lockDurationNextPeriod\n    ) external onlyOwner {\n        require(\n            contractState__ == ContractState.NONE,\n            \"LockPeriodContract: Contract state is not NONE\"\n        );\n\n        lockDurationNextPeriod__ = _lockDurationNextPeriod;\n\n        // set period for period 0 to finalized\n        periodInfo__[0].isFinalized = 1;\n\n        periodIndexCounter__ = 1;\n\n        activePeriodIndex__ = 1;\n\n        contractState__ = ContractState.FRESH_PERIOD;\n\n        PeriodInfo storage period_ = periodInfo__[1];\n\n        period_.timestampPeriodStart = _startFirstPeriod;\n\n        period_.timestampPeriodEnd = uint32(\n            _startFirstPeriod + lockDurationNextPeriod__\n        );\n\n        emit NewLockPeriodConfigured(\n            activePeriodIndex__,\n            _startFirstPeriod,\n            _lockDurationNextPeriod\n        );\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function updateManual() external {\n        _updateContractState();\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function distributeRewardsForLatestPeriod(\n        uint256 _amountReward_usa_1,\n        uint256 _amountReward_weth_2,\n        uint256 _amountReward_stable_3\n    ) external onlyRewardsDistribution {\n        _updateContractState();\n\n        uint256 _periodIndex = activePeriodIndex__;\n\n        // require that the contract is in the active state\n        require(\n            contractState__ == ContractState.ACTIVE_LOCKED,\n            \"LockPeriodContract: Contract must be in active state to distribute rewards\"\n        );\n\n        PeriodInfo memory period_ = periodInfo__[_periodIndex];\n\n        if (period_.totalLockedInPeriod > 0) {\n            if (_amountReward_usa_1 > 0) {\n                periodRewardPerStakedToken_USA_1__[_periodIndex] +=\n                    (_amountReward_usa_1 * STAKE_TOKEN_DECIMALS_SCALE) /\n                    period_.totalLockedInPeriod;\n\n                period_.totalRewardedInPeriod_USA_1 += uint88(\n                    _amountReward_usa_1\n                );\n\n                totalRewardsDistributed_USA_1__ += _amountReward_usa_1;\n\n                rewardToken_USA_1.transferFrom(\n                    msg.sender,\n                    address(this),\n                    _amountReward_usa_1\n                );\n            }\n\n            if (_amountReward_weth_2 > 0) {\n                periodRewardPerStakedToken_WETH_2__[_periodIndex] +=\n                    (_amountReward_weth_2 * STAKE_TOKEN_DECIMALS_SCALE) /\n                    period_.totalLockedInPeriod;\n\n                period_.totalRewardedInPeriod_WETH_2 += uint88(\n                    _amountReward_weth_2\n                );\n\n                totalRewardsDistributed_WETH_2__ += _amountReward_weth_2;\n\n                rewardToken_WETH_2.transferFrom(\n                    msg.sender,\n                    address(this),\n                    _amountReward_weth_2\n                );\n            }\n\n            if (_amountReward_stable_3 > 0) {\n                periodRewardPerStakedToken_Stable_3__[_periodIndex] +=\n                    (_amountReward_stable_3 * STAKE_TOKEN_DECIMALS_SCALE) /\n                    period_.totalLockedInPeriod;\n\n                period_.totalRewardedInPeriod_Stable_3 += uint88(\n                    _amountReward_stable_3\n                );\n\n                totalRewardsDistributed_Stable_3__ += _amountReward_stable_3;\n\n                rewardToken_Stable_3.transferFrom(\n                    msg.sender,\n                    address(this),\n                    _amountReward_stable_3\n                );\n            }\n        } else {\n            revert(\"LockPeriodContract: No assets locked in this period\");\n        }\n\n        period_.isFinalized = 1;\n\n        emit DistributeRewardsForLatestPeriod(\n            _periodIndex,\n            _amountReward_usa_1,\n            _amountReward_weth_2,\n            _amountReward_stable_3,\n            period_.totalLockedInPeriod\n        );\n\n        periodInfo__[_periodIndex] = period_;\n\n        if (nextPeriodIndex__ == 0) {\n            nextPeriodIndex__ = _createNextPeriod(\n                period_.timestampPeriodEnd + uint32(defaultWindowDuration__)\n            );\n        }\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function setPoolState(ContractState _poolState) external onlyOwner {\n        contractState__ = _poolState;\n\n        emit PoolStateManualSet(_poolState);\n\n        emit ContractStateChanged(_poolState, activePeriodIndex__);\n    }\n\n    function unfinalizePeriod(uint256 _periodIndex) external onlyOwner {\n        require(\n            _periodIndex <= periodIndexCounter__,\n            \"LockPeriodContract: Period index is higher than period index counter\"\n        );\n        periodInfo__[_periodIndex].isFinalized = 0;\n    }\n\n    function pause() external onlyOwner {\n        _pause();\n    }\n\n    function unpause() external onlyOwner {\n        _unpause();\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function setStandardWindowDuration(\n        uint32 _standardWindowDuration\n    ) external onlyOwner {\n        defaultWindowDuration__ = _standardWindowDuration;\n\n        emit StandardWindowDurationUpdated(_standardWindowDuration);\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function setLockPeriodNextPeriod(\n        uint256 _lockPeriodNextPeriod\n    ) external onlyOwner {\n        lockDurationNextPeriod__ = _lockPeriodNextPeriod;\n\n        emit LockPeriodNextPeriodUpdated(_lockPeriodNextPeriod);\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function setRewardsDistribution(\n        address _rewardsDistribution\n    ) external onlyOwner {\n        rewardsDistribution = _rewardsDistribution;\n\n        emit RewardsDistributionUpdated(_rewardsDistribution);\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function setPeriodFinalized(uint256 _periodIndex) external onlyOwner {\n        require(\n            _periodIndex <= periodIndexCounter__,\n            \"LockPeriodContract: Period index is higher than period index counter\"\n        );\n        periodInfo__[_periodIndex].isFinalized = 1;\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function setTotalLockedInPeriod(\n        uint256 _periodIndex,\n        uint88 _totalLockedInPeriod\n    ) external onlyOwner {\n        require(\n            _periodIndex <= periodIndexCounter__,\n            \"LockPeriodContract: Period index is higher than period index counter\"\n        );\n        periodInfo__[_periodIndex].totalLockedInPeriod = _totalLockedInPeriod;\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function setPeriodAllInfo(\n        uint256 _periodIndex,\n        uint8 _isFinalized,\n        uint32 _timestampPeriodStart,\n        uint32 _timestampPeriodEnd,\n        uint88 _totalLockedInPeriod,\n        uint88 _totalRewardedInPeriod_USA_1,\n        uint88 _totalRewardedInPeriod_WETH_2,\n        uint88 _totalRewardedInPeriod_Stable_3\n    ) external onlyOwner {\n        // make sure _periodIndex is not higher than periodIndexCounter__\n        require(\n            _periodIndex <= periodIndexCounter__,\n            \"LockPeriodContract: Period index is higher than period index counter\"\n        );\n\n        periodInfo__[_periodIndex].isFinalized = _isFinalized;\n        periodInfo__[_periodIndex].timestampPeriodStart = _timestampPeriodStart;\n        periodInfo__[_periodIndex].timestampPeriodEnd = _timestampPeriodEnd;\n        periodInfo__[_periodIndex].totalLockedInPeriod = _totalLockedInPeriod;\n        periodInfo__[_periodIndex]\n            .totalRewardedInPeriod_USA_1 = _totalRewardedInPeriod_USA_1;\n        periodInfo__[_periodIndex]\n            .totalRewardedInPeriod_WETH_2 = _totalRewardedInPeriod_WETH_2;\n        periodInfo__[_periodIndex]\n            .totalRewardedInPeriod_Stable_3 = _totalRewardedInPeriod_Stable_3;\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function emergencyWithdrawToken(\n        address _token,\n        address _to,\n        uint256 _amount\n    ) external onlyOwner {\n        // check that the token is not the stake token\n        require(\n            _token != address(lockTokenERC20),\n            \"LockPeriodContract: Cannot withdraw staking token\"\n        );\n        IERC20(_token).transfer(_to, _amount);\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function transferStakedTokensToMultisig(\n        address _to,\n        uint256 _amount\n    ) external {\n        require(\n            msg.sender == MULTISIG_ADDRESS,\n            \"LockPeriodContract: Only multisig can call this function\"\n        );\n        lockTokenERC20.transfer(_to, _amount);\n    }\n\n    // /// @inheritdoc ILockPeriodContract\n    function setMigratorContract(address _migratorContract) external {\n        require(\n            msg.sender == MULTISIG_ADDRESS,\n            \"LockPeriodContract: Only multisig can call this function\"\n        );\n        migratorContractAddress = _migratorContract;\n    }\n\n    /* ========== VIEWS ========== */\n\n    function _checkActivePeriod()\n        internal\n        view\n        returns (ContractState state_, uint256 activePeriodIndex_)\n    {\n        PeriodInfo memory period_ = periodInfo__[activePeriodIndex__];\n\n        if (block.timestamp <= period_.timestampPeriodEnd) {\n            // the contract is up to date, the active period is ongoing, the contract is in the correct state\n            return (ContractState.ACTIVE_LOCKED, activePeriodIndex__);\n        } else {\n            // the period has ended, the contract is in the correct state as the active period has ended\n            uint32 nextPeriodStart_ = period_.timestampPeriodEnd +\n                uint32(defaultWindowDuration__);\n\n            if (block.timestamp < nextPeriodStart_) {\n                return (\n                    ContractState.UNLOCKED_REDEEMABLE,\n                    activePeriodIndex__ + 1\n                );\n            } else if (\n                block.timestamp <=\n                nextPeriodStart_ + uint32(lockDurationNextPeriod__)\n            ) {\n                return (ContractState.ACTIVE_LOCKED, activePeriodIndex__ + 1);\n            } else if (\n                block.timestamp <\n                nextPeriodStart_ +\n                    uint32(lockDurationNextPeriod__) +\n                    uint32(defaultWindowDuration__)\n            ) {\n                return (\n                    ContractState.UNLOCKED_REDEEMABLE,\n                    activePeriodIndex__ + 2\n                );\n            } else {\n                return (ContractState.ACTIVE_LOCKED, activePeriodIndex__ + 2);\n            }\n        }\n    }\n\n    function _checkUnlockRedeemable()\n        internal\n        view\n        returns (ContractState state_, uint256 activePeriodIndex_)\n    {\n        PeriodInfo memory period_ = periodInfo__[activePeriodIndex__];\n\n        if (block.timestamp < period_.timestampPeriodStart) {\n            // the contract is in the correct state as the active period till has to start\n            return (ContractState.UNLOCKED_REDEEMABLE, activePeriodIndex__);\n        } else if (\n            block.timestamp >= period_.timestampPeriodStart &&\n            block.timestamp <= period_.timestampPeriodEnd\n        ) {\n            return (ContractState.ACTIVE_LOCKED, activePeriodIndex__);\n        } else {\n            uint32 nextPeriodStart_ = period_.timestampPeriodEnd +\n                uint32(defaultWindowDuration__);\n            if (block.timestamp < nextPeriodStart_) {\n                return (\n                    ContractState.UNLOCKED_REDEEMABLE,\n                    activePeriodIndex__ + 1\n                );\n            } else if (\n                block.timestamp <=\n                nextPeriodStart_ + uint32(lockDurationNextPeriod__)\n            ) {\n                return (ContractState.ACTIVE_LOCKED, activePeriodIndex__ + 1);\n            } else {\n                return (\n                    ContractState.UNLOCKED_REDEEMABLE,\n                    activePeriodIndex__ + 2\n                );\n            }\n        }\n    }\n\n    function _checkFreshPeriod()\n        internal\n        view\n        returns (ContractState state_, uint256 activePeriodIndex_)\n    {\n        PeriodInfo memory period_ = periodInfo__[activePeriodIndex__];\n\n        if (block.timestamp < period_.timestampPeriodStart) {\n            // the contract is in the correct state as the active period till has to start\n            return (ContractState.FRESH_PERIOD, activePeriodIndex__);\n        } else if (\n            block.timestamp >= period_.timestampPeriodStart &&\n            block.timestamp <= period_.timestampPeriodEnd\n        ) {\n            return (ContractState.ACTIVE_LOCKED, activePeriodIndex__);\n        } else {\n            uint32 nextPeriodStart_ = period_.timestampPeriodEnd +\n                uint32(defaultWindowDuration__);\n            if (block.timestamp < nextPeriodStart_) {\n                return (\n                    ContractState.UNLOCKED_REDEEMABLE,\n                    activePeriodIndex__ + 1\n                );\n            } else {\n                return (\n                    ContractState.CONTRACT_UNLOCKED_INACTIVE,\n                    activePeriodIndex__ + 1\n                );\n            }\n        }\n    }\n\n    function returnContractPeriodState()\n        public\n        view\n        returns (ContractState state_, uint256 activePeriodIndex_)\n    {\n        if (contractState__ == ContractState.ACTIVE_LOCKED) {\n            (state_, activePeriodIndex_) = _checkActivePeriod();\n        } else if (contractState__ == ContractState.UNLOCKED_REDEEMABLE) {\n            (state_, activePeriodIndex_) = _checkUnlockRedeemable();\n        } else if (contractState__ == ContractState.FRESH_PERIOD) {\n            (state_, activePeriodIndex_) = _checkFreshPeriod();\n        } else if (\n            contractState__ == ContractState.CONTRACT_UNLOCKED_INACTIVE\n        ) {\n            return (\n                ContractState.CONTRACT_UNLOCKED_INACTIVE,\n                activePeriodIndex__\n            );\n        } else {\n            revert(\n                \"LockPeriodContract: Lock contract is awaiting configuration\"\n            );\n        }\n    }\n\n    function returnPendingRewards(\n        address _user\n    ) external view returns (uint256, uint256, uint256) {\n        return _totalClaimable(_user, activePeriodIndex__ + 1);\n    }\n\n    function returnPeriodInfoTime()\n        external\n        view\n        returns (\n            uint256 currentPeriodStart_,\n            uint256 currentPeriodEnd_,\n            uint256 nextPeriodStart_,\n            uint256 nextPeriodEnd_\n        )\n    {\n        (, uint256 activePeriodIndex_) = returnContractPeriodState();\n\n        PeriodInfo memory period_ = periodInfo__[activePeriodIndex__];\n\n        if (activePeriodIndex_ == activePeriodIndex__) {\n            currentPeriodStart_ = period_.timestampPeriodStart;\n\n            currentPeriodEnd_ = period_.timestampPeriodEnd;\n\n            nextPeriodStart_ =\n                period_.timestampPeriodEnd +\n                uint32(defaultWindowDuration__);\n\n            nextPeriodEnd_ =\n                nextPeriodStart_ +\n                uint32(lockDurationNextPeriod__);\n\n            return (\n                currentPeriodStart_,\n                currentPeriodEnd_,\n                nextPeriodStart_,\n                nextPeriodEnd_\n            );\n        } else if (activePeriodIndex_ == activePeriodIndex__ + 1) {\n            currentPeriodStart_ =\n                period_.timestampPeriodEnd +\n                uint32(defaultWindowDuration__);\n\n            currentPeriodEnd_ =\n                currentPeriodStart_ +\n                uint32(lockDurationNextPeriod__);\n\n            nextPeriodStart_ =\n                currentPeriodEnd_ +\n                uint32(defaultWindowDuration__);\n\n            nextPeriodEnd_ =\n                nextPeriodStart_ +\n                uint32(lockDurationNextPeriod__);\n        } else {\n            currentPeriodStart_ =\n                period_.timestampPeriodEnd +\n                uint32(defaultWindowDuration__) +\n                uint32(lockDurationNextPeriod__) +\n                uint32(defaultWindowDuration__);\n\n            currentPeriodEnd_ =\n                currentPeriodStart_ +\n                uint32(lockDurationNextPeriod__);\n\n            nextPeriodStart_ =\n                currentPeriodEnd_ +\n                uint32(defaultWindowDuration__);\n\n            nextPeriodEnd_ =\n                nextPeriodStart_ +\n                uint32(lockDurationNextPeriod__);\n        }\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function returnPeriodInfoStruct(\n        uint256 _periodIndex\n    ) external view returns (PeriodInfo memory) {\n        return periodInfo__[_periodIndex];\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function returnPeriodIndexCounter() external view returns (uint256) {\n        return periodIndexCounter__;\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function isActivePeriodFinalized() external view returns (bool) {\n        return periodInfo__[activePeriodIndex__].isFinalized == 1;\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function isPreviousPeriodFinalized() external view returns (bool) {\n        return periodInfo__[activePeriodIndex__ - 1].isFinalized == 1;\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function returnActivePeriodInContract() external view returns (uint256) {\n        return activePeriodIndex__;\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function returnNextPeriod() external view returns (uint256) {\n        return nextPeriodIndex__;\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function returnContractStateInContract()\n        external\n        view\n        returns (ContractState)\n    {\n        return contractState__;\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function returnPeriodRewardPerStakedToken(\n        uint256 _periodIndex\n    ) external view returns (uint256, uint256, uint256) {\n        return (\n            periodRewardPerStakedToken_USA_1__[_periodIndex],\n            periodRewardPerStakedToken_WETH_2__[_periodIndex],\n            periodRewardPerStakedToken_Stable_3__[_periodIndex]\n        );\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function returnTotalRewardsDistributed()\n        external\n        view\n        returns (\n            uint256 totalRewardsDistributed_USA_1,\n            uint256 totalRewardsDistributed_WETH_2,\n            uint256 totalRewardsDistributed_Stable_3\n        )\n    {\n        return (\n            totalRewardsDistributed_USA_1__,\n            totalRewardsDistributed_WETH_2__,\n            totalRewardsDistributed_Stable_3__\n        );\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function returnPeriodInfo(\n        uint256 _periodIndex\n    )\n        external\n        view\n        returns (\n            uint8 isFinalized,\n            uint88 totalLockedInPeriod,\n            uint88 totalRewardedInPeriod_USA_1,\n            uint32 timestampPeriodStart,\n            uint88 totalRewardedInPeriod_WETH_2,\n            uint88 totalRewardedInPeriod_Stable_3,\n            uint32 timestampPeriodEnd\n        )\n    {\n        PeriodInfo memory period_ = periodInfo__[_periodIndex];\n\n        return (\n            period_.isFinalized,\n            period_.totalLockedInPeriod,\n            period_.totalRewardedInPeriod_USA_1,\n            period_.timestampPeriodStart,\n            period_.totalRewardedInPeriod_WETH_2,\n            period_.totalRewardedInPeriod_Stable_3,\n            period_.timestampPeriodEnd\n        );\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function returnUserStakeInfo(\n        address _account\n    )\n        external\n        view\n        returns (\n            uint8 lastUpdatePeriodIndex,\n            uint88 amountStaked,\n            uint88 rewardDebt_USA_1,\n            uint88 rewardPaid_USA_1,\n            uint88 rewardDebt_WETH_2,\n            uint88 rewardPaid_WETH_2,\n            uint88 rewardDebt_Stable_3,\n            uint88 rewardPaid_Stable_3\n        )\n    {\n        StakeInfo memory stakeInfo_ = stakes__[_account];\n        return (\n            stakeInfo_.lastUpdatePeriodIndex,\n            stakeInfo_.amountStaked,\n            stakeInfo_.rewardDebt_USA_1,\n            stakeInfo_.rewardPaid_USA_1,\n            stakeInfo_.rewardDebt_WETH_2,\n            stakeInfo_.rewardPaid_WETH_2,\n            stakeInfo_.rewardDebt_Stable_3,\n            stakeInfo_.rewardPaid_Stable_3\n        );\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function totalTokensLocked() external view returns (uint256) {\n        return totalAmountStakedAssets__;\n    }\n\n    function returnLockPeriod() external view returns (uint256) {\n        return lockDurationNextPeriod__;\n    }\n\n    function returnStandardWindowDuration() external view returns (uint256) {\n        return defaultWindowDuration__;\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function amountLocked(address _account) external view returns (uint256) {\n        return stakes__[_account].amountStaked;\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function returnRewardClaimableUser(\n        address _account\n    ) external view returns (uint256, uint256, uint256) {\n        return _totalClaimable(_account, activePeriodIndex__);\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function rewardPerToken_USA_1(\n        uint256 _periodIndex\n    ) external view returns (uint256) {\n        return periodRewardPerStakedToken_USA_1__[_periodIndex];\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function rewardPerToken_WETH_2(\n        uint256 _periodIndex\n    ) external view returns (uint256) {\n        return periodRewardPerStakedToken_WETH_2__[_periodIndex];\n    }\n\n    /// @inheritdoc ILockPeriodContract\n    function rewardPerToken_Stable_3(\n        uint256 _periodIndex\n    ) external view returns (uint256) {\n        return periodRewardPerStakedToken_Stable_3__[_periodIndex];\n    }\n}\n"
      },
      "src/interfaces/ILockNFT.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\ninterface ILockNFT {\n    function lockBatchNFTInAnyPeriod(uint256[] calldata _tokenIds) external;\n\n    function lockSingleNFTInAnyPeriod(uint256 _tokenId) external;\n\n    event NFTLocked(\n        address staker,\n        uint256 nftIndex,\n        uint256 amountUSA,\n        uint256 activerPeriodIndex\n    );\n\n    event BatchNftLocked(\n        address stakerAddress,\n        uint256[] tokenIds,\n        uint256 totalUSAStaked,\n        uint256 activePeriodIndex\n    );\n\n    event SetUsaLockAmount(uint256 _amount);\n\n    event BatchOfNftsUnstaked(uint256[] _tokenIds);\n\n    event NftUnstaked(uint256 tokenId);\n}\n"
      },
      "src/interfaces/IUSAStakeReceiptNFT.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol\";\n\ninterface IUSAStakeReceiptNFT is IERC721Enumerable {\n    function mintNft(address _to, uint256 _tokenId) external;\n\n    function burnNft(uint256 _tokenId) external;\n\n    function mintBatch(address _to, uint256[] memory _tokenIds) external;\n\n    function setStakeContract(address _stakeContract) external;\n\n    function returnArrayWithNfts(\n        address _user\n    ) external view returns (uint256[] memory indexArray_);\n\n    function isOwnerOf(\n        address _user,\n        uint256 _tokenId\n    ) external view returns (bool);\n\n    function burnBatch(uint256[] memory _tokenIds) external;\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC-1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[ERC].\n */\ninterface IERC1155 is IERC165 {\n    /**\n     * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.\n     */\n    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n    /**\n     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n     * transfers.\n     */\n    event TransferBatch(\n        address indexed operator,\n        address indexed from,\n        address indexed to,\n        uint256[] ids,\n        uint256[] values\n    );\n\n    /**\n     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n     * `approved`.\n     */\n    event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n    /**\n     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n     *\n     * If an {URI} event was emitted for `id`, the standard\n     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n     * returned by {IERC1155MetadataURI-uri}.\n     */\n    event URI(string value, uint256 indexed id);\n\n    /**\n     * @dev Returns the value of tokens of token type `id` owned by `account`.\n     */\n    function balanceOf(address account, uint256 id) external view returns (uint256);\n\n    /**\n     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n     *\n     * Requirements:\n     *\n     * - `accounts` and `ids` must have the same length.\n     */\n    function balanceOfBatch(\n        address[] calldata accounts,\n        uint256[] calldata ids\n    ) external view returns (uint256[] memory);\n\n    /**\n     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n     *\n     * Emits an {ApprovalForAll} event.\n     *\n     * Requirements:\n     *\n     * - `operator` cannot be the zero address.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n     *\n     * See {setApprovalForAll}.\n     */\n    function isApprovedForAll(address account, address operator) external view returns (bool);\n\n    /**\n     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.\n     *\n     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens\n     * to an untrusted contract, when invoking {onERC1155Received} on the receiver.\n     * Ensure to follow the checks-effects-interactions pattern and consider employing\n     * reentrancy guards when interacting with untrusted contracts.\n     *\n     * Emits a {TransferSingle} event.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n     * - `from` must have a balance of tokens of type `id` of at least `value` amount.\n     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n     * acceptance magic value.\n     */\n    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;\n\n    /**\n     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n     *\n     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens\n     * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.\n     * Ensure to follow the checks-effects-interactions pattern and consider employing\n     * reentrancy guards when interacting with untrusted contracts.\n     *\n     * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.\n     *\n     * Requirements:\n     *\n     * - `ids` and `values` must have the same length.\n     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n     * acceptance magic value.\n     */\n    function safeBatchTransferFrom(\n        address from,\n        address to,\n        uint256[] calldata ids,\n        uint256[] calldata values,\n        bytes calldata data\n    ) external;\n}\n"
      },
      "lib/openzeppelin-contracts/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\nimport {Errors} from \"./Errors.sol\";\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev There's no code at `target` (it is not a contract).\n     */\n    error AddressEmptyCode(address target);\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 Errors.InsufficientBalance(address(this).balance, amount);\n        }\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        if (!success) {\n            revert Errors.FailedCall();\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     * {Errors.FailedCall} 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 Errors.InsufficientBalance(address(this).balance, value);\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 {Errors.FailedCall}) in case\n     * of an 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 {Errors.FailedCall} 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 {Errors.FailedCall}.\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 Errors.FailedCall();\n        }\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC1155/IERC1155Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface that must be implemented by smart contracts in order to receive\n * ERC-1155 token transfers.\n */\ninterface IERC1155Receiver is IERC165 {\n    /**\n     * @dev Handles the receipt of a single ERC-1155 token type. This function is\n     * called at the end of a `safeTransferFrom` after the balance has been updated.\n     *\n     * NOTE: To accept the transfer, this must return\n     * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n     * (i.e. 0xf23a6e61, or its own function selector).\n     *\n     * @param operator The address which initiated the transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param id The ID of the token being transferred\n     * @param value The amount of tokens being transferred\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n     */\n    function onERC1155Received(\n        address operator,\n        address from,\n        uint256 id,\n        uint256 value,\n        bytes calldata data\n    ) external returns (bytes4);\n\n    /**\n     * @dev Handles the receipt of a multiple ERC-1155 token types. This function\n     * is called at the end of a `safeBatchTransferFrom` after the balances have\n     * been updated.\n     *\n     * NOTE: To accept the transfer(s), this must return\n     * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n     * (i.e. 0xbc197c81, or its own function selector).\n     *\n     * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param ids An array containing ids of each token being transferred (order and length must match values array)\n     * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n     */\n    function onERC1155BatchReceived(\n        address operator,\n        address from,\n        uint256[] calldata ids,\n        uint256[] calldata values,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
      },
      "lib/openzeppelin-contracts/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"
      },
      "lib/openzeppelin-contracts/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 ERC-20 standard as defined in the ERC.\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"
      },
      "lib/openzeppelin-contracts/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"
      },
      "lib/openzeppelin-contracts/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"
      },
      "src/interfaces/ILockPeriodContract.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\ninterface ILockPeriodContract {\n    /**\n     * @param isFinalized 0 = not finalized, 1 = finalized\n     * @param periodDuration the duration of the period_ in seconds\n     * @param timestampPeriodEnd the timestamp of the end of the period_\n     * @param totalLockedInPeriod the total amount of tokens locked in the period_\n     * @param totalRewardedInPeriod_USA_1 the total amount of WETH rewarded in the period_\n     * @param totalRewardedInPeriod_WETH_2 the total amount of WETH rewarded in the period_\n     * @param totalRewardedInPeriod_Stable_3 the total amount of WETH rewarded in the period_\n     * @param timestampPeriodStart the timestamp of the start of the period_\n     */\n    struct PeriodInfo {\n        uint8 isFinalized; // 0 = not finalized, 1 = finalized\n        uint88 totalLockedInPeriod;\n        uint88 totalRewardedInPeriod_USA_1;\n        uint32 timestampPeriodStart;\n        uint88 totalRewardedInPeriod_WETH_2;\n        uint88 totalRewardedInPeriod_Stable_3;\n        uint32 timestampPeriodEnd;\n    }\n\n    /**\n     * @param amountStaked the amount of tokens staked\n     * @param rewardDebt_USA_1 the amount of rewards(WETH) that have been distributed but not yet claimed\n     * @param rewardPaid the amount of rewards(WETH) that have been claimed\n     * @param lastUpdatePeriodIndex the index of the last period_ that the user has updated their rewards for\n     */\n    struct StakeInfo {\n        uint8 lastUpdatePeriodIndex;\n        uint88 amountStaked;\n        uint88 rewardDebt_USA_1;\n        uint88 rewardPaid_USA_1;\n        uint88 rewardDebt_WETH_2;\n        uint88 rewardPaid_WETH_2;\n        uint88 rewardDebt_Stable_3;\n        uint88 rewardPaid_Stable_3;\n    }\n\n    enum ContractState {\n        NONE, // 0\n        ACTIVE_LOCKED, // 1\n        UNLOCKED_REDEEMABLE, // 2\n        FRESH_PERIOD, // 3\n        CONTRACT_UNLOCKED_INACTIVE // 4\n    }\n\n    /* ========== VIEW FUNCTIONS ========== */\n\n    function returnPeriodIndexCounter() external view returns (uint256);\n\n    function isActivePeriodFinalized() external view returns (bool);\n\n    function isPreviousPeriodFinalized() external view returns (bool);\n\n    function returnContractStateInContract()\n        external\n        view\n        returns (ContractState);\n\n    function returnActivePeriodInContract() external view returns (uint256);\n\n    function returnLockPeriod() external view returns (uint256);\n\n    function returnStandardWindowDuration() external view returns (uint256);\n\n    function returnNextPeriod() external view returns (uint256);\n\n    function returnPeriodRewardPerStakedToken(\n        uint256 _periodIndex\n    ) external view returns (uint256, uint256, uint256);\n\n    function totalTokensLocked() external view returns (uint256);\n\n    function returnTotalRewardsDistributed()\n        external\n        view\n        returns (\n            uint256 totalRewardsDistributed_USA_1,\n            uint256 totalRewardsDistributed_WETH_2,\n            uint256 totalRewardsDistributed_Stable_3\n        );\n\n    /**\n     * @notice Calculates the amount of reward USA token each locked token is entitled to for a given period\n     * @param _periodIndex The index of the period for which to calculate the reward per token\n     * @return The calculated reward amount per token as a fixed point number with 18 decimals\n     */\n    function rewardPerToken_USA_1(\n        uint256 _periodIndex\n    ) external view returns (uint256);\n\n    /**\n     * @notice Calculates the amount of reward WETH token each locked token is entitled to for a given period\n     * @param _periodIndex The index of the period for which to calculate the reward per token\n     * @return The calculated reward amount per token as a fixed point number with 18 decimals\n     */\n    function rewardPerToken_WETH_2(\n        uint256 _periodIndex\n    ) external view returns (uint256);\n\n    /**\n     * @notice Calculates the amount of reward Stable token each locked token is entitled to for a given period\n     * @param _periodIndex The index of the period for which to calculate the reward per token\n     * @return The calculated reward amount per token as a fixed point number with 18 decimals\n     */\n    function rewardPerToken_Stable_3(\n        uint256 _periodIndex\n    ) external view returns (uint256);\n\n    /**\n     * @notice Returns the amount of tokens staked by a specific user and how much historically user has been issued and claimed\n     * @param _user The address of the user for whom to return the stake information\n     * @return lastUpdatePeriodIndex The index of the last period that the user has updated their rewards for\n     * @return amountStaked The amount of tokens staked by the user\n     * @return rewardDebt_USA_1 The amount of USA the user has earned historically (up only value, accumulated)\n     * @return rewardPaid_USA_1 The amount of USA the user has claimed historically (up only value, accumulated)\n     * @return rewardDebt_WETH_2 The amount of WETH the user has earned historically (up only value, accumulated)\n     * @return rewardPaid_WETH_2 The amount of WETH the user has claimed historically (up only value, accumulated)\n     * @return rewardDebt_Stable_3 The amount of Stable the user has earned historically (up only value, accumulated)\n     * @return rewardPaid_Stable_3 The amount of Stable the user has claimed historically (up only value, accumulated)\n     */\n    function returnUserStakeInfo(\n        address _user\n    )\n        external\n        view\n        returns (\n            uint8 lastUpdatePeriodIndex,\n            uint88 amountStaked,\n            uint88 rewardDebt_USA_1,\n            uint88 rewardPaid_USA_1,\n            uint88 rewardDebt_WETH_2,\n            uint88 rewardPaid_WETH_2,\n            uint88 rewardDebt_Stable_3,\n            uint88 rewardPaid_Stable_3\n        );\n\n    /**\n     * @notice Returns the claimable reward amount of a specific user\n     * @param _user The address of the user for whom to return the claimable reward\n     * @return The total amount of rewards that the user can claim\n     */\n    function returnRewardClaimableUser(\n        address _user\n    ) external view returns (uint256, uint256, uint256);\n\n    /**\n     * @notice Returns detailed information about a specific period by index.\n     * @dev This function provides granular details about a period, including its finalization status, total tokens locked, rewards distributed across different tokens, and its start and end timestamps. This information is crucial for understanding the state and history of rewards and staking for a given period.\n     * @param _periodIndex The index of the period for which to retrieve information.\n     * @return isFinalized Indicates whether the period has been finalized (1) or not (0).\n     * @return totalLockedInPeriod The total amount of tokens locked during the specified period.\n     * @return totalRewardedInPeriod_USA_1 The total amount of USA_1 token rewards distributed during the specified period.\n     * @return timestampPeriodStart The start timestamp of the period.\n     * @return totalRewardedInPeriod_WETH_2 The total amount of WETH_2 token rewards distributed during the specified period.\n     * @return totalRewardedInPeriod_Stable_3 The total amount of Stable_3 token rewards distributed during the specified period.\n     * @return timestampPeriodEnd The end timestamp of the period.\n     */\n    function returnPeriodInfo(\n        uint256 _periodIndex\n    )\n        external\n        view\n        returns (\n            uint8 isFinalized,\n            uint88 totalLockedInPeriod,\n            uint88 totalRewardedInPeriod_USA_1,\n            uint32 timestampPeriodStart,\n            uint88 totalRewardedInPeriod_WETH_2,\n            uint88 totalRewardedInPeriod_Stable_3,\n            uint32 timestampPeriodEnd\n        );\n\n    function returnPeriodInfoTime()\n        external\n        view\n        returns (\n            uint256 currentPeriodStart_,\n            uint256 currentPeriodEnd_,\n            uint256 nextPeriodStart_,\n            uint256 nextPeriodEnd_\n        );\n\n    /**\n     * @notice Returns a struct containing detailed information about a specific period by index.\n     * @dev This function is an alternative to `returnPeriodInfo` that returns a struct, making it easier to interact with in some scenarios. It provides the same information in a structured format, which can be particularly useful when the caller needs to process multiple pieces of period data at once.\n     * @param _periodIndex The index of the period for which to retrieve information.\n     * @return A `PeriodInfo` struct containing all relevant details about the period, including its finalization status, total tokens locked, rewards distributed across different tokens, and its start and end timestamps.\n     */\n    function returnPeriodInfoStruct(\n        uint256 _periodIndex\n    ) external view returns (PeriodInfo memory);\n\n    /**\n     * @notice Returns the balance of staked tokens for a specific account\n     * @param _account The address of the account for which to return the staked token balance\n     * @return The total amount of tokens staked by the specified account\n     */\n    function amountLocked(address _account) external view returns (uint256);\n\n    /* ========== WRITE FUNCTIONS ========== */\n\n    function distributeRewardsForLatestPeriod(\n        uint256 _amountReward_1,\n        uint256 _amountReward_2,\n        uint256 _amountReward_3\n    ) external;\n\n    function pause() external;\n\n    function unpause() external;\n\n    /**\n     * @notice Sets the duration of the standard window for the staking period\n     * @param _standardWindowDuration The duration in seconds for the standard window\n     */\n    function setStandardWindowDuration(uint32 _standardWindowDuration) external;\n\n    /**\n     * @notice set the rewards distribution contract address that can call notifyRewardAmount()\n     * @param _rewardsDistribution The address of the rewardsDistribution contract\n     */\n    function setRewardsDistribution(address _rewardsDistribution) external;\n\n    /**\n     * @notice Sets the lock period for the next period\n     * This function can be used to set the lock period for the next period\n     * @param _lockPeriodNextPeriod The lock period for the next period\n     */\n    function setLockPeriodNextPeriod(uint256 _lockPeriodNextPeriod) external;\n\n    /**\n     * @notice Updates all information for a specific period\n     * @dev This function allows updating the period information including its start and end timestamps,\n     * the total amount locked during the period, and the total rewards distributed in the period for each token type.\n     * This function can only be called by the contract owner or another authorized entity.\n     * @param _periodIndex The index of the period to update\n     * @param _isFinalized The finalization status of the period (0 = not finalized, 1 = finalized)\n     * @param _timestampPeriodStart The start timestamp of the period\n     * @param _timestampPeriodEnd The end timestamp of the period\n     * @param _totalLockedInPeriod The total amount of tokens locked during the period\n     * @param _totalRewardedInPeriod_USA_1 The total amount of USA token rewards distributed during the period\n     * @param _totalRewardedInPeriod_WETH_2 The total amount of WETH token rewards distributed during the period\n     * @param _totalRewardedInPeriod_Stable_3 The total amount of Stable token rewards distributed during the period\n     */\n    function setPeriodAllInfo(\n        uint256 _periodIndex,\n        uint8 _isFinalized,\n        uint32 _timestampPeriodStart,\n        uint32 _timestampPeriodEnd,\n        uint88 _totalLockedInPeriod,\n        uint88 _totalRewardedInPeriod_USA_1,\n        uint88 _totalRewardedInPeriod_WETH_2,\n        uint88 _totalRewardedInPeriod_Stable_3\n    ) external;\n\n    /**\n     * @notice Updates the total amount of tokens locked for a specific period\n     * @dev This function allows updating the total amount of tokens that have been locked during a specified period.\n     * It can only be called by the contract owner or another authorized entity. This is crucial for accurately tracking\n     * the total locked tokens which can affect reward calculations and period finalizations.\n     * @param _periodIndex The index of the period for which to update the total locked amount\n     * @param _totalLockedInPeriod The new total amount of tokens locked in the specified period\n     */\n    function setTotalLockedInPeriod(\n        uint256 _periodIndex,\n        uint88 _totalLockedInPeriod\n    ) external;\n\n    /**\n     * @notice Marks a specific period as finalized\n     * @dev This function sets the finalization status of a specified period to finalized (1).\n     * It can only be called by the contract owner or another authorized entity. Finalizing a period\n     * is an important step in the rewards distribution process as it prevents any further changes\n     * to the period's data, ensuring the integrity of the rewards calculation.\n     * @param _periodIndex The index of the period to be finalized\n     */\n    function setPeriodFinalized(uint256 _periodIndex) external;\n\n    function unfinalizePeriod(uint256 _periodIndex) external;\n\n    /**\n     * @notice Manually triggers the update of the contract state\n     * @dev This function is designed to manually trigger the internal mechanism that updates the contract's state based on the current time and the state of periods. It is intended to be used in scenarios where the automatic state transition needs to be enforced immediately. This function can only be called by the contract owner or another authorized entity.\n     */\n    function updateManual() external;\n\n    /**\n     * @notice Sets the current state of the pool\n     * @dev This function allows updating the current state of the pool to reflect its operational status accurately.\n     * The state can be one of several predefined states, such as ACTIVE_LOCKED, UNLOCKED_REDEEMABLE, or FRESH_PERIOD,\n     * each representing a different phase in the pool's lifecycle. Changing the pool state is a critical action that\n     * can affect the pool's behavior and how users interact with it. Therefore, this function can only be called by\n     * the contract owner or another authorized entity to ensure that state transitions are controlled and intentional.\n     * @param _poolState The new state to set for the pool\n     */\n    function setPoolState(ContractState _poolState) external;\n\n    /**\n     * @notice Configures the first period of the lock pool\n     * @dev This function sets the start time and lock duration for the first period of the lock pool.\n     * It can only be called by the contract owner or another authorized entity. This is a critical setup step\n     * that initializes the first period, enabling users to start locking tokens. The lock duration determines\n     * how long the tokens will be locked before they can be unlocked or before rewards can be claimed.\n     * @param _startFirstPeriod The start time of the first period\n     * @param _lockDurationNextPeriod The lock duration for the first period\n     */\n    function configureFirstPeriod(\n        uint32 _startFirstPeriod,\n        uint256 _lockDurationNextPeriod\n    ) external;\n\n    /**\n     * @notice Transfers staked tokens to a multisig address\n     * @dev This function is designed for emergency scenarios or contract migrations. It allows the transfer of staked tokens to a multisig address. This function can only be called by the multisig address set in the contract, ensuring that only authorized parties can execute it.\n     * @param _to The address to which the tokens will be transferred.\n     * @param _amount The amount of tokens to be transferred.\n     */\n    function transferStakedTokensToMultisig(\n        address _to,\n        uint256 _amount\n    ) external;\n\n    /**\n     * @notice Allows the emergency withdrawal of tokens\n     * @dev This function is an emergency mechanism to withdraw tokens from the contract. It can be used in scenarios such as contract migration or if there's a need to recover tokens mistakenly sent to the contract. This function can only be called by the contract owner.\n     * @param _token The address of the token to be withdrawn.\n     * @param _to The address to which the tokens will be sent.\n     * @param _amount The amount of tokens to be withdrawn.\n     */\n    function emergencyWithdrawToken(\n        address _token,\n        address _to,\n        uint256 _amount\n    ) external;\n\n    /**\n     * @notice Sets the migrator contract address\n     * @dev This function allows setting the address of the migrator contract, which is authorized to call `migrateLockERC20TokensToNewLockContract`. This is a security measure to ensure that only a trusted migrator can perform migrations. This function can only be called by the multisig address.\n     * @param _migratorContract The address of the migrator contract.\n     */\n    function setMigratorContract(address _migratorContract) external;\n\n    /* ========== EVENTS ========== */\n\n    event TokensStaked(\n        address indexed user,\n        uint256 amount,\n        uint256 periodIndexCounter_\n    );\n\n    event StopNextPeriod(bool stopNextPeriod);\n\n    event RewardDistributed(uint256 indexed periodIndex, uint256 amount);\n\n    event NewPeriodStarted(\n        uint256 indexed periodIndex,\n        uint256 startTime,\n        uint256 endTime\n    );\n\n    event RewardsClaimed(\n        address indexed user,\n        uint256 amountClaimedUSA,\n        uint256 amountClaimedWETH,\n        uint256 amountClaimedStable\n    );\n\n    event RewardsDurationUpdated(uint256 newDuration);\n\n    event LockPeriodNextPeriodUpdated(uint256 lockPeriodNextPeriod);\n\n    event RewardsDistributionUpdated(address newRewardsDistribution);\n\n    event StandardWindowDurationUpdated(uint32 standardWindowDuration);\n\n    event UnstakeTokens(address indexed user, uint256 amount);\n\n    event DistributeRewardsForLatestPeriod(\n        uint256 periodIndex,\n        uint256 amountReward_usa_1,\n        uint256 amountReward_weth_2,\n        uint256 amountReward_stable_3,\n        uint88 totalLockedInPeriod\n    );\n\n    event NewLockPeriodConfigured(\n        uint256 indexed periodIndex,\n        uint32 timestampPeriodStart,\n        uint256 lockDurationNextPeriod\n    );\n\n    event PoolStateManualSet(ContractState _poolState);\n\n    event LockActiveUpdated(bool _isLockActive);\n\n    event ContractStateChanged(\n        ContractState _contractState,\n        uint256 periodIndex\n    );\n\n    event NewPeriodCreated(\n        uint256 indexed periodIndex,\n        uint32 timestampPeriodStart,\n        uint32 timestampPeriodEnd\n    );\n\n    event TimeoutByUnfinalizedPeriods(uint256 activePeriodIndex);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Enumerable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721} from \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Enumerable is IERC721 {\n    /**\n     * @dev Returns the total amount of tokens stored by the contract.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n     */\n    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);\n\n    /**\n     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n     * Use along with {totalSupply} to enumerate all tokens.\n     */\n    function tokenByIndex(uint256 index) external view returns (uint256);\n}\n"
      },
      "lib/openzeppelin-contracts/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 ERC-165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[ERC].\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[ERC 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"
      },
      "lib/openzeppelin-contracts/contracts/utils/Errors.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of common custom errors used in multiple contracts\n *\n * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.\n * It is recommended to avoid relying on the error API for critical functionality.\n */\nlibrary Errors {\n    /**\n     * @dev The ETH balance of the account is not enough to perform the operation.\n     */\n    error InsufficientBalance(uint256 balance, uint256 needed);\n\n    /**\n     * @dev A call to an address target failed. The target may have reverted.\n     */\n    error FailedCall();\n\n    /**\n     * @dev The deployment failed.\n     */\n    error FailedDeployment();\n}\n"
      },
      "lib/openzeppelin-contracts/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"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC-721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC-721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\n     *   {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721\n     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n     * understand this adds an external call which potentially creates a reentrancy vulnerability.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the address zero.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
        "forge-std/=lib/forge-std/src/",
        "@delta/=lib/ERC1155Delta/contracts/",
        "solady/=lib/solady/",
        "@chainlink/=lib/ERC1155Delta/node_modules/@chainlink/",
        "@ensdomains/=lib/ERC1155Delta/node_modules/@ensdomains/",
        "@eth-optimism/=lib/ERC1155Delta/node_modules/@eth-optimism/contracts/",
        "ERC1155Delta/=lib/ERC1155Delta/contracts/",
        "closedsea/=lib/ERC1155Delta/node_modules/closedsea/src/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
        "erc721a/=lib/ERC1155Delta/node_modules/erc721a/contracts/",
        "erc721psi/=lib/ERC1155Delta/node_modules/erc721psi/contracts/",
        "eth-gas-reporter/=lib/ERC1155Delta/node_modules/eth-gas-reporter/",
        "hardhat/=lib/ERC1155Delta/node_modules/hardhat/",
        "openzeppelin-contracts/=lib/openzeppelin-contracts/",
        "solidity-bits/=lib/ERC1155Delta/node_modules/solidity-bits/contracts/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs",
        "appendCBOR": true
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "paris",
      "viaIR": false,
      "libraries": {}
    }
  }}