DxPoolStakingFeePoolV2

Description:

Proxy contract enabling upgradeable smart contract patterns. Delegates calls to an implementation contract.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "artifacts/contracts/DxpoolSSVFeePoolV2.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.20;\r
\r
import "@openzeppelin/contracts/utils/Address.sol";\r
import "@openzeppelin/contracts/utils/StorageSlot.sol";\r
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";\r
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";\r
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";\r
import "./interfaces/IDxpoolStakingFeePoolV2.sol";\r
import "./storage/DxpoolStakingFeePoolStorage.sol";\r
import "./storage/DxpoolStakingFeePoolStorageV2.sol";\r
\r
/**                                                                                  \r
        ,--.          ,--.                 ,--.                               ,--. \r
 ,---.,-'  '-. ,--,--.|  |,-. ,---.      ,-|  |,--.  ,--. ,---.  ,---.  ,---. |  | \r
(  .-''-.  .-'' ,-.  ||     /| .-. :    ' .-. | \  `'  / | .-. || .-. || .-. ||  | \r
.-'  `) |  |  \ '-'  ||  \  \\   --..--.\ `-' | /  /.  \ | '-' '' '-' '' '-' '|  | \r
`----'  `--'   `--`--'`--'`--'`----''--' `---' '--'  '--'|  |-'  `---'  `---' `--' \r
                                                         `--'                      \r
**/\r
\r
contract DxPoolStakingFeePoolV2 is\r
    IDxpoolStakingFeePoolV2,\r
    DxpoolStakingFeePoolStorage,\r
    Initializable,\r
    UUPSUpgradeable,\r
    ReentrancyGuard,\r
    DxpoolStakingFeePoolStorageV2\r
{\r
    using Address for address payable;\r
\r
    uint64 constant SHARE_FRACTAL = 32e9;\r
\r
    uint256 constant PRECISION_FACTOR = 1e32;\r
\r
    uint256 constant COMMISSION_RATE_MAX = 1e4;\r
   \r
    constructor() initializer {}\r
    \r
    // initialize\r
    function initialize(address operatorAddress_, address adminAddress_) initializer external {\r
        require(operatorAddress_ != address(0));\r
        require(adminAddress_ != address(0));\r
        adminAddress = adminAddress_;\r
        operatorAddress = operatorAddress_;\r
        totalShares = 0;\r
        stakeCommissionFeeRate = 0;\r
        isOpenForWithdrawal = true;\r
\r
        accRewardPerShare = 0;\r
        accTotalStakeCommissionFee = 0;\r
        totalTransferredToColdWallet = 0;\r
        totalTransferredFromSSV = 0;\r
        lastRewardBlock  = block.number;\r
        lastPeriodReward = getTotalRewards();\r
    }\r
\r
    function initialize_version_2() adminOnly external reinitializer(2) {\r
        accRewardPerShare *= 1e26;\r
\r
        accRewardPerShare /= SHARE_FRACTAL;\r
\r
        accTotalStakeCommissionFee *= 1e26;\r
    }\r
\r
    function migrateValidatorsFromV1(bytes[] calldata validatorPubKeys) external nonReentrant operatorOnly {\r
        // require(isOpenForWithdrawal == false, "Pool must be closed");\r
\r
        for (uint256 i = 0; i < validatorPubKeys.length; i++) {\r
            bytes memory pubKey = validatorPubKeys[i];\r
\r
            (address depositor, ,uint32 joinTime) = decodeValidatorInfo(DEPRECATED_validatorOwnerAndJoinTime[pubKey]);\r
            require(depositor != address(0), "Validator not in pool");\r
\r
            bytes32 hashedPubKey = hashValidatorPublicKey(pubKey);\r
            validatorHashedPubkeyToInfo[hashedPubKey] = encodeValidatorInfo(depositor, SHARE_FRACTAL, joinTime);\r
\r
            // delete old data\r
            delete DEPRECATED_validatorOwnerAndJoinTime[pubKey];\r
        }\r
    }\r
\r
    function migrateUsersFromV1(address[] calldata userList) external nonReentrant operatorOnly {\r
        // require(isOpenForWithdrawal == false, "Pool must be closed");\r
        for (uint256 i = 0; i < userList.length; i++) {\r
            address userAddress = userList[i];\r
\r
            // confirm exist user\r
            require(\r
                DEPRECATED_users[userAddress].validatorCount > 0 ||\r
                DEPRECATED_users[userAddress].totalReward > 0 ||\r
                DEPRECATED_users[userAddress].debit > 0 ||\r
                DEPRECATED_users[userAddress].claimedReward > 0,\r
                "User does not exist"\r
            );\r
\r
            // Copy user data\r
            users[userAddress].validatorShares = DEPRECATED_users[userAddress].validatorCount;\r
            users[userAddress].totalReward = DEPRECATED_users[userAddress].totalReward;\r
            users[userAddress].debit = DEPRECATED_users[userAddress].debit;\r
            users[userAddress].claimedReward = DEPRECATED_users[userAddress].claimedReward;\r
\r
            // initialize user lastCheckpoint\r
            users[userAddress].lastCheckpoint = uint32(block.timestamp);\r
\r
            totalShares -= users[userAddress].validatorShares;\r
            users[userAddress].validatorShares *= SHARE_FRACTAL;\r
            totalShares += users[userAddress].validatorShares;\r
\r
            // delete old user data\r
            delete DEPRECATED_users[userAddress];\r
        }\r
    }\r
\r
    function migrateFromV1Complete() external nonReentrant operatorOnly {\r
        // finally update\r
        updatePool();\r
    }\r
\r
    // Only admin can update contract\r
    function _authorizeUpgrade(address) internal override adminOnly {}\r
\r
    // decode or encode validator information\r
    function decodeValidatorInfo(uint256 data) public pure returns (address, uint64, uint32) {\r
        address ownerAddress = address(uint160(data));\r
        uint64 shares = uint64((data >> 160) & ((1 << 64) - 1));\r
        uint32 joinPoolTimestamp = uint32(data >> 224);\r
        return (ownerAddress, shares, joinPoolTimestamp);\r
    }\r
\r
    function encodeValidatorInfo(address ownerAddress, uint64 shares, uint32 joinPoolTimestamp) public pure returns (uint256) {\r
        return uint256(uint160(ownerAddress)) | (uint256(shares) << 160) | uint256(joinPoolTimestamp) << 224;\r
    }\r
\r
    // get total rewards since contract created\r
    function getTotalRewards() public view returns (uint256) {\r
        return address(this).balance\r
            + totalTransferredToColdWallet\r
            + totalPaidToUserRewards\r
            + totalClaimedStakeCommissionFee\r
            - totalTransferredFromSSV;\r
    }\r
\r
    // get commission have earned\r
    function getAccStakeCommissionFee() public view returns (uint256) {\r
        uint256 currentPeriodReward = getTotalRewards();\r
\r
        return (\r
            accTotalStakeCommissionFee + PRECISION_FACTOR * (currentPeriodReward - lastPeriodReward)\r
        * stakeCommissionFeeRate / COMMISSION_RATE_MAX\r
        ) / PRECISION_FACTOR;\r
    }\r
    \r
    // compute a Reward by adding pending reward to user totalRewards\r
    function computeReward(address depositor) internal {\r
        uint256 userValidatorShares = users[depositor].validatorShares;\r
        if (userValidatorShares > 0) {\r
            uint256 pending = userValidatorShares * accRewardPerShare / PRECISION_FACTOR - users[depositor].debit;\r
            users[depositor].totalReward += uint128(pending);\r
        }\r
    }\r
\r
    // compute a ssv remaing reward by adding ssv remaingingEth to user totalRewards\r
    function computeRewardWithSSVRemaingEth(address depositor, uint256 ssvRemainingEth) internal {\r
        uint256 userValidatorShares = users[depositor].validatorShares;\r
        if (userValidatorShares > 0) {\r
            uint256 pending = userValidatorShares * accRewardPerShare / PRECISION_FACTOR - users[depositor].debit;\r
            users[depositor].totalReward += uint128(pending);\r
        }\r
        users[depositor].totalReward += uint128(ssvRemainingEth);\r
    }\r
    \r
    function updatePool() internal {\r
        if (block.number <= lastRewardBlock || totalShares == 0) {\r
            return;\r
        }\r
\r
        uint256 currentPeriodReward = getTotalRewards();\r
\r
        accRewardPerShare += PRECISION_FACTOR * (currentPeriodReward - lastPeriodReward) / totalShares\r
            * (COMMISSION_RATE_MAX - stakeCommissionFeeRate) / COMMISSION_RATE_MAX;\r
\r
        accTotalStakeCommissionFee += PRECISION_FACTOR\r
            * (currentPeriodReward - lastPeriodReward) * stakeCommissionFeeRate / COMMISSION_RATE_MAX;\r
\r
        lastRewardBlock = block.number;\r
\r
        lastPeriodReward = currentPeriodReward;\r
    }\r
\r
    /**\r
       Operator Functions\r
       Those methods Reference: https://github.com/pancakeswap/pancake-smart-contracts/blob/master/projects/farms-pools/contracts/MasterChef.sol\r
    */\r
    function enterPool(bytes calldata validatorPubKey, address depositor, uint256 effectiveBalance) external nonReentrant operatorOnly {\r
        // One validator joined, the previous time period ends.\r
        bytes32 hashedValidatorPubKey = hashValidatorPublicKey(validatorPubKey);\r
\r
        updatePool();\r
        _enterPool(hashedValidatorPubKey, depositor, effectiveBalance);\r
        emit ValidatorEntered(validatorPubKey, depositor, block.timestamp);\r
    }\r
    \r
    function _enterPool(bytes32 hashedValidatorPubKey, address depositor, uint256 effectiveBalance) internal {\r
        require(validatorHashedPubkeyToInfo[hashedValidatorPubKey] == 0, "validator already in pool");\r
        require(depositor != address(0), "depositorAddress not be empty");\r
        require(effectiveBalance >= 32e9 && effectiveBalance <= 2048e9, "Effective balance must be between 32 and 2048 ether");\r
\r
        // compute reward\r
        computeReward(depositor);\r
\r
        users[depositor].validatorShares += uint64(effectiveBalance);\r
        totalShares += effectiveBalance;\r
        validatorHashedPubkeyToInfo[hashedValidatorPubKey] = encodeValidatorInfo(depositor, uint64(effectiveBalance), uint32(block.timestamp));\r
        users[depositor].debit = uint128(users[depositor].validatorShares * accRewardPerShare / PRECISION_FACTOR);\r
\r
        users[depositor].lastCheckpoint = uint32(block.timestamp);\r
    }\r
\r
    function leavePool(\r
        bytes calldata validatorPubKey,\r
        uint256 ssvRemainingEth\r
    ) external nonReentrant operatorOnly {\r
        bytes32 hashedValidatorPubKey = hashValidatorPublicKey(validatorPubKey);\r
\r
        updatePool();\r
        address depositor = _leavePool(hashedValidatorPubKey, ssvRemainingEth);\r
        emit ValidatorLeft(validatorPubKey, depositor, block.timestamp);\r
    }\r
\r
    function _leavePool(\r
        bytes32 hashedValidatorPubKey,\r
        uint256 ssvRemainingEth\r
    ) internal returns (address depositorAddress) {\r
        (address depositor, uint64 shares, ) = decodeValidatorInfo(validatorHashedPubkeyToInfo[hashedValidatorPubKey]);\r
        require(depositor != address(0), "Validator not in pool");\r
\r
        computeRewardWithSSVRemaingEth(depositor, ssvRemainingEth);\r
\r
        totalShares -= shares;\r
        totalSSVRemainingEth += ssvRemainingEth;\r
        users[depositor].validatorShares -= shares;\r
        users[depositor].debit = uint128(users[depositor].validatorShares * accRewardPerShare / PRECISION_FACTOR);\r
\r
        delete validatorHashedPubkeyToInfo[hashedValidatorPubKey];\r
\r
        return depositor;\r
    }\r
\r
    function batchLeavePool(\r
        bytes calldata validatorPubkeyArray,\r
        uint256[] calldata ssvRemainingEthArray\r
    ) external nonReentrant operatorOnly {\r
        require(validatorPubkeyArray.length % 48 == 0, "pubKeyArray length not multiple of 48");\r
        uint256 validatorCount = validatorPubkeyArray.length / 48;\r
        require(validatorCount == ssvRemainingEthArray.length, "validatorPubkeys byte array length incorrect");\r
        updatePool();\r
\r
        for(uint256 i = 0; i < validatorCount; i++) {\r
            bytes32 hashedPubKey = hashValidatorPublicKey(validatorPubkeyArray[i*48:(i+1)*48]);\r
            address depositor = _leavePool(hashedPubKey, ssvRemainingEthArray[i]);\r
            emit ValidatorLeft(validatorPubkeyArray[i*48:(i+1)*48], depositor, block.timestamp);\r
        }\r
    }\r
    \r
    function batchEnterPool(\r
        bytes calldata validatorPubkeyArray,\r
        address[] calldata depositorAddresses,\r
        uint256[] calldata effectiveBalances\r
\r
    ) external nonReentrant operatorOnly {\r
        require(depositorAddresses.length == 1 || depositorAddresses.length * 48 == validatorPubkeyArray.length, "Invalid depositorAddresses length");\r
\r
        updatePool();\r
        uint256 validatorCount = validatorPubkeyArray.length / 48;\r
        bytes32 hashedPubKey;\r
\r
        if (depositorAddresses.length == 1) {\r
            for(uint256 i = 0; i < validatorCount; i++) {\r
                hashedPubKey = hashValidatorPublicKey(validatorPubkeyArray[i*48:(i+1)*48]);\r
                _enterPool(hashedPubKey, depositorAddresses[0], effectiveBalances[i]);\r
                emit ValidatorEntered(validatorPubkeyArray[i*48:(i+1)*48], depositorAddresses[0], block.timestamp);\r
            }\r
        } else {\r
            for(uint256 i = 0; i < validatorCount; i++) {\r
                hashedPubKey = hashValidatorPublicKey(validatorPubkeyArray[i*48:(i+1)*48]);\r
                _enterPool(hashedPubKey, depositorAddresses[i], effectiveBalances[i]);\r
                emit ValidatorEntered(validatorPubkeyArray[i*48:(i+1)*48], depositorAddresses[i], block.timestamp);\r
            }\r
        }\r
    }\r
\r
    function updateValidatorShares(\r
        bytes[] calldata validatorPubKeys,\r
        uint128[] calldata effectiveBalances\r
    ) external nonReentrant operatorOnly {\r
        require(validatorPubKeys.length == effectiveBalances.length, "Validator array length mismatch");\r
\r
        updatePool();\r
\r
        for (uint32 i = 0; i < validatorPubKeys.length; i++) {\r
            bytes32 hashedValidatorPubKey = hashValidatorPublicKey(validatorPubKeys[i]);\r
            _processValidatorShares(hashedValidatorPubKey, effectiveBalances[i]);\r
        }\r
    }\r
\r
    function _processValidatorShares(\r
        bytes32 hashedValidatorPubKey,\r
        uint128 effectiveBalance\r
    ) internal {\r
        (address depositor, uint64 currentShares, uint32 joinTime) = decodeValidatorInfo(validatorHashedPubkeyToInfo[hashedValidatorPubKey]);\r
        require(depositor != address(0), "PubKey does not exist");\r
        require(effectiveBalance >= 32e9 && effectiveBalance <= 2048e9, "Invalid effective balance");\r
\r
        validatorHashedPubkeyToInfo[hashedValidatorPubKey] = encodeValidatorInfo(depositor, uint64(effectiveBalance), joinTime);\r
\r
        computeReward(depositor);\r
\r
        totalShares = totalShares - currentShares + effectiveBalance;\r
\r
        users[depositor].validatorShares = users[depositor].validatorShares - currentShares + uint128(effectiveBalance);\r
        users[depositor].debit = uint128(users[depositor].validatorShares * accRewardPerShare / PRECISION_FACTOR);\r
    }\r
\r
\r
    // @returns totalRewards, unclaimedRewards, claimedRewards\r
    function computeRewards(address depositor) internal view returns (uint256, uint256, uint256) {\r
        uint256 accRewardPerShareWithCurPeriod = accRewardPerShare;\r
        if (block.number > lastRewardBlock && totalShares > 0) {\r
            uint256 currentPeriodReward = getTotalRewards();\r
            accRewardPerShareWithCurPeriod +=\r
                PRECISION_FACTOR * (currentPeriodReward - lastPeriodReward) / totalShares * (COMMISSION_RATE_MAX - stakeCommissionFeeRate) / COMMISSION_RATE_MAX;\r
        }\r
\r
        uint256 totalReward =\r
            users[depositor].validatorShares * accRewardPerShareWithCurPeriod / PRECISION_FACTOR\r
                + users[depositor].totalReward - users[depositor].debit;\r
\r
        if (totalReward > users[depositor].claimedReward) {\r
            return (totalReward, totalReward - users[depositor].claimedReward, users[depositor].claimedReward);\r
        } else {\r
            return (users[depositor].claimedReward, 0, users[depositor].claimedReward);\r
        }\r
    }\r
\r
    // This function estimates user totalRewards, unclaimedRewards, claimedRewards based on latest timestamp.\r
    function getUserRewardInfo(address depositor) external view returns (uint256, uint256, uint256) {\r
        require(depositor != address(0), "depositorAddress not be empty");\r
        return computeRewards(depositor);\r
    }\r
\r
    function _claimReward(\r
        address depositor,\r
        address payable withdrawAddress,\r
        uint256 amount\r
    ) internal {\r
        if (withdrawAddress == address(0)) {\r
            withdrawAddress = payable(depositor);\r
        }\r
\r
        computeReward(depositor);\r
        users[depositor].debit = uint128(users[depositor].validatorShares * accRewardPerShare / PRECISION_FACTOR);\r
\r
        uint256 unClaimedReward = users[depositor].totalReward - users[depositor].claimedReward;\r
        if (amount == 0) {\r
            users[depositor].claimedReward += uint128(unClaimedReward);\r
            totalPaidToUserRewards += unClaimedReward;\r
            emit ValidatorRewardClaimed(depositor, withdrawAddress, unClaimedReward);\r
            require(unClaimedReward <= address(this).balance, "Please Contact stake.dxpool.com to fix");\r
            withdrawAddress.sendValue(unClaimedReward);\r
        } else {\r
            require(amount <= unClaimedReward, "Not enough unClaimed rewards");\r
            users[depositor].claimedReward += uint128(amount);\r
            totalPaidToUserRewards += amount;\r
            emit ValidatorRewardClaimed(depositor, withdrawAddress, amount);\r
            require(amount <= address(this).balance, "Please Contact stake.dxpool.com to fix");\r
            withdrawAddress.sendValue(amount);\r
        }\r
    }\r
\r
    // claim rewards from the fee pool\r
    function claimReward(address payable withdrawAddress, uint256 amount) external nonReentrant {\r
        require(isOpenForWithdrawal, "Pool is not open for withdrawal");\r
        updatePool();\r
        _claimReward(msg.sender, withdrawAddress, amount);\r
    }\r
    \r
    /**\r
     * Admin Functions\r
     */\r
    function setStakeCommissionFeeRate(uint256 commissionFeeRate) external nonReentrant adminOnly {\r
        updatePool();\r
        stakeCommissionFeeRate = commissionFeeRate;\r
        emit CommissionFeeRateChanged(stakeCommissionFeeRate);\r
    }\r
\r
    // Claim accumulated commission fees\r
    function claimStakeCommissionFee(address payable withdrawAddress, uint256 amount)\r
        external\r
        nonReentrant\r
        adminOnly\r
    {\r
        updatePool();\r
        uint256 totalCommissionFee = accTotalStakeCommissionFee / PRECISION_FACTOR;\r
        uint256 unclaimedCommissionFee = totalCommissionFee - totalClaimedStakeCommissionFee;\r
        if (amount == 0) {\r
            totalClaimedStakeCommissionFee += unclaimedCommissionFee;\r
            emit CommissionClaimed(withdrawAddress, unclaimedCommissionFee);\r
            withdrawAddress.sendValue(unclaimedCommissionFee);\r
        } else {\r
            require(amount <= unclaimedCommissionFee, "Not enough unclaimed commission fee");\r
            totalClaimedStakeCommissionFee += amount;\r
            emit CommissionClaimed(withdrawAddress, amount);\r
            withdrawAddress.sendValue(amount);\r
        }\r
    }\r
\r
    function _transferValidator(bytes calldata validatorPubKey, address to, uint256 ssvRemainingEth) internal {\r
        bytes32 hashedValidatorPubKey = hashValidatorPublicKey(validatorPubKey);\r
        (address validatorOwner, uint64 shares, ) = decodeValidatorInfo(validatorHashedPubkeyToInfo[hashedValidatorPubKey]);\r
\r
        require(validatorOwner != address(0), "Validator not in pool");\r
        require(to != address(0), "to address must be set to nonzero");\r
        require(to != validatorOwner, "cannot transfer validator owner to oneself");\r
\r
        _leavePool(hashedValidatorPubKey, ssvRemainingEth);\r
        _enterPool(hashedValidatorPubKey, to, shares);\r
\r
        emit ValidatorTransferred(validatorPubKey, validatorOwner, to, block.timestamp);\r
    }\r
\r
    function transferValidatorByAdmin(bytes calldata validatorPubkeys, address[] calldata toAddresses, uint256[] calldata ssvRemainingEthArray) external nonReentrant adminOnly {\r
        require(validatorPubkeys.length == toAddresses.length * 48 && validatorPubkeys.length == ssvRemainingEthArray.length * 48, "validatorPubkeys byte array length incorrect");\r
        for (uint256 i = 0; i < toAddresses.length; i++) {\r
            _transferValidator(\r
                validatorPubkeys[i * 48 : (i + 1) * 48],\r
                toAddresses[i],\r
                ssvRemainingEthArray[i]\r
            );\r
        }\r
    }\r
\r
    // Admin handle emergency situations where we want to temporarily pause all withdrawals.\r
    function closePoolForWithdrawal() external nonReentrant adminOnly {\r
        require(isOpenForWithdrawal, "Pool is already closed for withdrawal");\r
        isOpenForWithdrawal = false;\r
    }\r
\r
    function openPoolForWithdrawal() external nonReentrant adminOnly {\r
        require(!isOpenForWithdrawal, "Pool is already open for withdrawal");\r
        isOpenForWithdrawal = true;\r
    }\r
\r
    function changeOperator(address newOperatorAddress) external nonReentrant adminOnly {\r
        require(newOperatorAddress != address(0));\r
        operatorAddress = newOperatorAddress;\r
        emit OperatorChanged(operatorAddress);\r
    }\r
\r
    function emergencyWithdraw (address[] calldata depositor, address[] calldata withdrawAddress, uint256 maxAmount)\r
        external\r
        nonReentrant\r
        adminOnly\r
    {\r
        require(withdrawAddress.length == depositor.length || withdrawAddress.length == 1, "withdrawAddress length incorrect");\r
        updatePool();\r
        if (withdrawAddress.length == 1) {\r
            for (uint256 i = 0; i < depositor.length; i++) {\r
                _claimReward(depositor[i], payable(withdrawAddress[0]), maxAmount);\r
            }\r
        } else {\r
            for (uint256 i = 0; i < depositor.length; i++) {\r
                _claimReward(depositor[i], payable(withdrawAddress[i]), maxAmount);\r
            }\r
        }\r
    }\r
\r
    function increaseTotalTransferredFromSSV() external payable nonReentrant adminOnly {\r
        totalTransferredFromSSV += msg.value;\r
    }\r
\r
\r
    function saveToColdWallet(address wallet, uint256 amount) external nonReentrant adminOnly {\r
        require(amount <= address(this).balance, "Not enough balance");\r
        totalTransferredToColdWallet += amount;\r
        payable(wallet).sendValue(amount);\r
    }\r
\r
    function loadFromColdWallet() external payable nonReentrant adminOnly {\r
        require(msg.value <= totalTransferredToColdWallet, "Too much transferred from cold wallet");\r
        totalTransferredToColdWallet -= msg.value;\r
    }\r
\r
    function getTotalShares() external view returns (uint256) {\r
        return totalShares;\r
    }\r
\r
    function getPoolInfo() external view returns (uint256, uint256, uint256, uint256, uint256, uint256, bool) {\r
        return (\r
            lastRewardBlock,\r
            accRewardPerShare / PRECISION_FACTOR,\r
            totalShares,\r
            totalClaimedStakeCommissionFee,\r
            totalPaidToUserRewards,\r
            totalTransferredToColdWallet,\r
            isOpenForWithdrawal\r
        );\r
    }\r
    \r
    function getUserInfo(address user) external view returns (uint256, uint256, uint256, uint256, uint256) {\r
        return (\r
            users[user].validatorShares,\r
            users[user].totalReward,\r
            users[user].debit,\r
            users[user].claimedReward,\r
            users[user].lastCheckpoint\r
        );\r
    }\r
    \r
    function getStakeCommissionFeeInfo() external view returns (uint256, uint256, uint256) {\r
        uint256 totalCommissionFee = getAccStakeCommissionFee();\r
        uint256 unclaimedCommissionFee = totalCommissionFee - totalClaimedStakeCommissionFee;\r
        return (\r
            totalCommissionFee,\r
            unclaimedCommissionFee,\r
            totalClaimedStakeCommissionFee\r
        );\r
    }\r
\r
    function justifyValidatorInPool(bytes calldata validatorPubKey) external view returns (bool, uint64, uint256) {\r
        bytes32 hashedValidatorPubKey = hashValidatorPublicKey(validatorPubKey);\r
        if (validatorHashedPubkeyToInfo[hashedValidatorPubKey] == 0) {\r
            return (false, 0, 0);\r
        } else {\r
            (, uint64 shares, uint256 timestamp) = decodeValidatorInfo(validatorHashedPubkeyToInfo[hashedValidatorPubKey]);\r
            return (true, shares, timestamp);\r
        }\r
    }\r
\r
    function justifyEnoughTransferredFromSSV() external view returns (bool) {\r
        if (totalTransferredFromSSV >= totalSSVRemainingEth) {\r
            return true;\r
        }\r
        return false;\r
    }\r
    \r
    function hashValidatorPublicKey(bytes memory validatorPubKey) public pure returns (bytes32) {\r
        require(validatorPubKey.length == 48, "pubkey must be 48 bytes");\r
        return sha256(abi.encodePacked(validatorPubKey, bytes16(0)));\r
    }\r
\r
    /**\r
     * Modifiers\r
    */\r
\r
    modifier operatorOnly() {\r
        require(msg.sender == operatorAddress, "Only Dxpool staking operator allowed");\r
        _;\r
    }\r
\r
    modifier adminOnly() {\r
        require(msg.sender == adminAddress, "Only Dxpool staking admin allowed");\r
        _;\r
    }\r
}"
    },
    "artifacts/contracts/storage/DxpoolStakingFeePoolStorageV2.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.20;\r
\r
// Storage Message\r
contract DxpoolStakingFeePoolStorageV2 {\r
        struct UserInfo {\r
        uint128 validatorShares;\r
        uint128 totalReward;\r
        uint128 debit;\r
        uint128 claimedReward;\r
        uint32  lastCheckpoint;\r
    }\r
\r
    mapping(address => UserInfo) internal users;\r
\r
    mapping(bytes32 => uint256) internal validatorHashedPubkeyToInfo;\r
}"
    },
    "artifacts/contracts/storage/DxpoolStakingFeePoolStorage.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.20;\r
\r
// Storage Message\r
contract DxpoolStakingFeePoolStorage {\r
    // user struct\r
    struct DEPRECATED_UserInfo {\r
        uint128 validatorCount;\r
        uint128 totalReward;\r
        uint128 debit;\r
        uint128 claimedReward;\r
    }\r
\r
    // admin, operator address\r
    address internal adminAddress;\r
    address internal operatorAddress;\r
\r
    uint256 public totalClaimedStakeCommissionFee;\r
    uint256 public totalPaidToUserRewards;\r
    uint256 public totalTransferredToColdWallet;\r
\r
    uint256 internal totalShares;\r
    uint256 public   stakeCommissionFeeRate;\r
\r
    bool public isOpenForWithdrawal;\r
\r
    mapping(address => DEPRECATED_UserInfo) internal DEPRECATED_users;\r
    mapping(bytes => uint256) internal DEPRECATED_validatorOwnerAndJoinTime;\r
\r
    uint256 internal accRewardPerShare;\r
    uint256 internal accTotalStakeCommissionFee;\r
\r
    uint256 internal lastRewardBlock;\r
    uint256 internal lastPeriodReward;\r
    \r
    uint256 public totalTransferredFromSSV;\r
    uint256 public totalSSVRemainingEth;\r
}"
    },
    "artifacts/contracts/interfaces/IDxpoolStakingFeePoolV2.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.20;\r
\r
interface IDxpoolStakingFeePoolV2 {\r
    event ValidatorEntered(bytes validatorPubkey, address depositorAddress, uint256 ts);\r
    event ValidatorLeft(bytes validatorPubkey, address depositorAddress, uint256 ts);\r
    event ValidatorRewardClaimed(address depositorAddress, address withdrawAddress, uint256 rewardAmount);\r
    event ValidatorTransferred(bytes indexed validatorPubkey, address indexed from, address indexed to, uint256 ts);\r
    event OperatorChanged(address newOperator);\r
    event CommissionFeeRateChanged(uint256 newFeeRate);\r
    event CommissionClaimed(address withdrawAddress, uint256 collectedAmount);\r
\r
    // Only operator can do those operations\r
\r
    /**\r
     * @notice Add a validator to the pool\r
     * @dev operatorOnly.\r
     */\r
    function enterPool(bytes calldata validatorPubKey, address depositorAddress, uint256 effectiveBalance) external;\r
\r
    /**\r
     * @notice Remove a validator from the pool\r
     * @dev operatorOnly.\r
     */\r
    function leavePool(bytes calldata validatorPubKey, uint256 ssvRemainingEth) external;\r
\r
    /**\r
     * @notice Add many validators to the pool\r
     * @dev operatorOnly.\r
     */\r
    function batchEnterPool(bytes calldata validatorPubKeys, address[] calldata depositorAddresses, uint256[] calldata effectiveBalances) external;\r
\r
    /**\r
     * @notice Remove many validators from the pool\r
     * @dev operatorOnly.\r
     */\r
    function batchLeavePool(bytes calldata validatorPubKeys, uint256[] calldata ssvRemaingEthArray) external;\r
\r
    /**\r
     * @notice Update validator shares\r
     * @dev operatorOnly.\r
     */\r
    function updateValidatorShares(bytes[] calldata validatorPubKeys, uint128[] calldata effectiveBalances) external;\r
\r
\r
    // Only admin can do those operations\r
\r
    /**\r
     * @notice Set the contract commission fee rate\r
     * @dev adminOnly.\r
     */\r
    function setStakeCommissionFeeRate(uint256 stakeCommissionFeeRate) external;\r
\r
    /**\r
     * @notice Claim commission fees up to `amount`.\r
     * @dev adminOnly.\r
     */\r
\r
    function claimStakeCommissionFee(address payable withdrawAddress, uint256 amount) external;\r
\r
    /**\r
     * @notice Change the contract operator\r
     * @dev adminOnly.\r
     */\r
    function changeOperator(address newOperator) external;\r
\r
    /**\r
     * @notice Disable withdrawal permission\r
     * @dev adminOnly.\r
     */\r
    function closePoolForWithdrawal() external;\r
\r
    /**\r
     * @notice Enable withdrawal permission\r
     * @dev adminOnly.\r
     */\r
    function openPoolForWithdrawal() external;\r
\r
    /**\r
     * @notice Transfer one or more validators to new fee pool owners.\r
     * @dev adminOnly.\r
     */\r
    function transferValidatorByAdmin(bytes calldata validatorPubKeys, address[] calldata toAddresses, uint256[] calldata ssvLeftTimeRewardArray) external;\r
\r
    /**\r
     * @notice Admin function to help users recover funds from a lost or stolen wallet\r
     * @dev adminOnly.\r
     */\r
    function emergencyWithdraw(address[] calldata depositor, address[] calldata withdrawAddress, uint256 amount) external;\r
\r
\r
    /**\r
     * @notice Admin function to transfer balance into a cold wallet for safe.\r
     * @dev adminOnly.\r
     */\r
    function saveToColdWallet(address wallet, uint256 amount) external;\r
\r
    /**\r
     * @notice Admin function to transfer balance back from a cold wallet.\r
     * @dev adminOnly.\r
     */\r
    function loadFromColdWallet() external payable;\r
\r
    // EveryOne can use those functions\r
\r
    /**\r
     * @notice The amount of rewards a depositor can withdraw, and all rewards they have ever withdrawn\r
     */\r
    function getUserRewardInfo(address depositor) external view returns (uint256 totalRewards, uint256 unclaimedRewards, uint256 claimedRewards);\r
\r
    /**\r
     * @notice Allow a depositor (`msg.sender`) to collect their tip rewards from the pool.\r
     * @dev Emits an {ValidatorRewardCollected} event.\r
     */\r
    function claimReward(address payable withdrawAddress, uint256 amount) external;\r
\r
    /**\r
     * @notice A summary of the pool's current state\r
     */\r
    function getPoolInfo() external view returns (\r
        uint256 lastRewardBlock,\r
        uint256 accRewardPerValidator,\r
        uint256 totalValidatorsCount,\r
        uint256 totalClaimedStakeCommissionFee,\r
        uint256 totalPaidToUserRewards,\r
        uint256 totalTransferredToColdWallet,\r
        bool isPoolOpenForWithdrawal\r
    );\r
\r
    /**\r
     * @notice A summary of the depositor's activity in the pool\r
     * @param user The depositor's address\r
     */\r
    function getUserInfo(address user) external view returns (\r
        uint256 validatorShares,\r
        uint256 totalReward,\r
        uint256 debit,\r
        uint256 claimedReward,\r
        uint256 lastCheckpoint\r
    );\r
\r
    /**\r
     * @notice A summary of pool stake commission fee\r
     */\r
    function getStakeCommissionFeeInfo() external view returns (\r
         uint256 totalStakeCommissionFee,\r
         uint256 unclaimedStakeCommissionFee,\r
         uint256 claimedStakeCommissionFee\r
    );\r
     \r
    /**\r
     * @notice Justify whether a validator in pool\r
     * @param validatorPubkey a validator publicKey\r
     */\r
    function justifyValidatorInPool(bytes calldata validatorPubkey) external view returns (\r
        bool inPool,\r
        uint64 shares,\r
        uint256 timestamp\r
    );\r
}"
    },
    "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.22;

import {IERC1822Proxiable} from "../../interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 */
abstract contract UUPSUpgradeable is IERC1822Proxiable {
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    address private immutable __self = address(this);

    /**
     * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
     * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
     * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
     * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
     * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
     * during an upgrade.
     */
    string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";

    /**
     * @dev The call is from an unauthorized context.
     */
    error UUPSUnauthorizedCallContext();

    /**
     * @dev The storage `slot` is unsupported as a UUID.
     */
    error UUPSUnsupportedProxiableUUID(bytes32 slot);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        _checkProxy();
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        _checkNotDelegated();
        _;
    }

    /**
     * @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual notDelegated returns (bytes32) {
        return ERC1967Utils.IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data);
    }

    /**
     * @dev Reverts if the execution is not performed via delegatecall or the execution
     * context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
     */
    function _checkProxy() internal view virtual {
        if (
            address(this) == __self || // Must be called through delegatecall
            ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
        ) {
            revert UUPSUnauthorizedCallContext();
        }
    }

    /**
     * @dev Reverts if the execution is performed via delegatecall.
     * See {notDelegated}.
     */
    function _checkNotDelegated() internal view virtual {
        if (address(this) != __self) {
            // Must not be called through delegatecall
            revert UUPSUnauthorizedCallContext();
        }
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
     *
     * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
     * is expected to be the implementation slot in ERC-1967.
     *
     * Emits an {IERC1967-Upgraded} event.
     */
    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
        try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
            if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
                revert UUPSUnsupportedProxiableUUID(slot);
            }
            ERC1967Utils.upgradeToAndCall(newImplementation, data);
        } catch {
            // The implementation is not UUPS
            revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
        }
    }
}
"
    },
    "@openzeppelin/contracts/proxy/utils/Initializable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Storage of the initializable contract.
     *
     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
     * when using with upgradeable contracts.
     *
     * @custom:storage-location erc7201:openzeppelin.storage.Initializable
     */
    struct InitializableStorage {
        /**
         * @dev Indicates that the contract has been initialized.
         */
        uint64 _initialized;
        /**
         * @dev Indicates that the contract is in the process of being initialized.
         */
        bool _initializing;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint64 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reinitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._initialized = 1;
        if (isTopLevelCall) {
            $._initializing = true;
        }
        _;
        if (isTopLevelCall) {
            $._initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._initialized = version;
        $._initializing = true;
        _;
        $._initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint64) {
        return _getInitializableStorage()._initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _getInitializableStorage()._initializing;
    }

    /**
     * @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.
     *
     * NOTE: Consider following the ERC-7201 formula to derive storage locations.
     */
    function _initializableStorageSlot() internal pure virtual returns (bytes32) {
        return INITIALIZABLE_STORAGE;
    }

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        bytes32 slot = _initializableStorageSlot();
        assembly {
            $.slot := slot
        }
    }
}
"
    },
    "@openzeppelin/contracts/utils/ReentrancyGuard.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}
"
    },
    "@openzeppelin/contracts/utils/StorageSlot.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC-1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * TIP: Consider using this library along with {SlotDerivation}.
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct Int256Slot {
        int256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Int256Slot` with member `value` located at `slot`.
     */
    function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns a `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }
}
"
    },
    "@openzeppelin/contracts/utils/Address.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (utils/Address.sol)

pragma solidity ^0.8.20;

import {Errors} from "./Errors.sol";

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert Errors.InsufficientBalance(address(this).balance, amount);
        }

        (bool success, bytes memory returndata) = recipient.call{value: amount}("");
        if (!success) {
            _revert(returndata);
        }
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {Errors.FailedCall} error.
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert Errors.InsufficientBalance(address(this).balance, value);
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
     * of an unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {Errors.FailedCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            assembly ("memory-safe") {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert Errors.FailedCall();
        }
    }
}
"
    },
    "@openzeppelin/contracts/utils/Errors.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of common custom errors used in multiple contracts
 *
 * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
 * It is recommended to avoid relying on the error API for critical functionality.
 *
 * _Available since v5.1._
 */
library Errors {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error InsufficientBalance(uint256 balance, uint256 needed);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedCall();

    /**
     * @dev The deployment failed.
     */
    error FailedDeployment();

    /**
     * @dev A necessary precompile is missing.
     */
    error MissingPrecompile(address);
}
"
    },
    "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (las

Tags:
Proxy, Staking, Upgradeable, Factory|addr:0x52ef4e0f4cb45ee8111a3f6255f8915e6e684ebd|verified:true|block:23393875|tx:0xa04916262902af9967249edf22e7a6343b29d308b59bad205d5fd7fe9d9166e0|first_check:1758276303

Submitted on: 2025-09-19 12:05:05

Comments

Log in to comment.

No comments yet.