Contract 0x53D698d543BE1d8E5c73a2406c209E26095f2284

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xfb38e593266fc09a34206a5ec5d8d612cfa75d42078ce98e998e6a636a864ffe0x60a0604045811742022-01-12 8:24:3616 days 3 hrs ago0x52b50644a9fef330ffc7a93d92a4b7591d5a3903 IN  Create: RewardDelegators0 ETH0.119755686468 ETH
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RewardDelegators

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 10000 runs

Other Settings:
default evmVersion
File 1 of 19 : RewardDelegators.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "./IClusterRewards.sol";
import "./IClusterRegistry.sol";


contract RewardDelegators is
    Initializable,  // initializer
    ContextUpgradeable,  // _msgSender, _msgData
    ERC165Upgradeable,  // supportsInterface
    AccessControlUpgradeable,  // RBAC
    AccessControlEnumerableUpgradeable,  // RBAC enumeration
    ERC1967UpgradeUpgradeable,  // delegate slots, proxy admin, private upgrade
    UUPSUpgradeable  // public upgrade
{
    // in case we add more contracts in the inheritance chain
    uint256[500] private __gap0;

    /// @custom:oz-upgrades-unsafe-allow constructor
    // initializes the logic contract without any admins
    // safeguard against takeover of the logic contract
    constructor() initializer {}

    modifier onlyAdmin() {
        require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()));
        _;
    }

//-------------------------------- Overrides start --------------------------------//

    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, AccessControlUpgradeable, AccessControlEnumerableUpgradeable) returns (bool) {
        return super.supportsInterface(interfaceId);
    }

    function _grantRole(bytes32 role, address account) internal virtual override(AccessControlUpgradeable, AccessControlEnumerableUpgradeable) {
        super._grantRole(role, account);
    }

    function _revokeRole(bytes32 role, address account) internal virtual override(AccessControlUpgradeable, AccessControlEnumerableUpgradeable) {
        super._revokeRole(role, account);

        // protect against accidentally removing all admins
        require(getRoleMemberCount(DEFAULT_ADMIN_ROLE) != 0);
    }

    function _authorizeUpgrade(address /*account*/) onlyAdmin internal view override {}

//-------------------------------- Overrides end --------------------------------//

//-------------------------------- Initializer start --------------------------------//

    uint256[50] private __gap1;

    function initialize(
        address _stakeAddress,
        address _clusterRewardsAddress,
        address _clusterRegistry,
        address _PONDAddress,
        bytes32[] memory _tokenIds,
        uint256[] memory _rewardFactors
    )
        initializer
        public
    {
        require(
            _tokenIds.length == _rewardFactors.length,
            "RD:I-Each TokenId should have a corresponding Reward Factor and vice versa"
        );

        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
        __AccessControlEnumerable_init_unchained();
        __ERC1967Upgrade_init_unchained();
        __UUPSUpgradeable_init_unchained();

        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());

        stakeAddress = _stakeAddress;
        emit StakeAddressUpdated(_stakeAddress);

        clusterRegistry = IClusterRegistry(_clusterRegistry);
        emit ClusterRegistryUpdated(_clusterRegistry);

        clusterRewards = IClusterRewards(_clusterRewardsAddress);
        emit ClusterRewardsAddressUpdated(_clusterRewardsAddress);

        PONDToken = IERC20Upgradeable(_PONDAddress);
        emit PONDAddressUpdated(_PONDAddress);

        for(uint256 i=0; i < _tokenIds.length; i++) {
            rewardFactor[_tokenIds[i]] = _rewardFactors[i];
            tokenIndex[_tokenIds[i]] = tokenList.length;
            tokenList.push(_tokenIds[i]);
            emit AddReward(_tokenIds[i], _rewardFactors[i]);
        }
    }

//-------------------------------- Initializer end --------------------------------//


    struct Cluster {
        mapping(bytes32 => uint256) totalDelegations;
        mapping(address => mapping(bytes32 => uint256)) delegators;
        mapping(address => mapping(bytes32 => uint256)) rewardDebt;
        mapping(bytes32 => uint256) accRewardPerShare;
    }

    mapping(address => Cluster) clusters;

    address public stakeAddress;
    mapping(bytes32 => uint256) public rewardFactor;
    mapping(bytes32 => uint256) public tokenIndex;
    bytes32[] public tokenList;
    IClusterRewards public clusterRewards;
    IClusterRegistry public clusterRegistry;
    IERC20Upgradeable public PONDToken;

    event AddReward(bytes32 tokenId, uint256 rewardFactor);
    event RemoveReward(bytes32 tokenId);
    event RewardsUpdated(bytes32 tokenId, uint256 rewardFactor);
    event ClusterRewardDistributed(address cluster);
    event RewardsWithdrawn(address cluster, address delegator, bytes32[] tokenIds, uint256 rewards);
    event StakeAddressUpdated(address _updatedStakeAddress);
    event ClusterRewardsAddressUpdated(address _updatedClusterRewards);
    event ClusterRegistryUpdated(address _updatedClusterRegistry);
    event PONDAddressUpdated(address _updatedPOND);

    modifier onlyStake() {
        require(_msgSender() == stakeAddress, "RD:OS-only stake contract can invoke");
        _;
    }

    function addRewardFactor(bytes32 _tokenId, uint256 _rewardFactor) external onlyAdmin {
        require(rewardFactor[_tokenId] == 0, "RD:AR-Reward already exists");
        require(_rewardFactor != 0, "RD:AR-Reward cant be 0");
        rewardFactor[_tokenId] = _rewardFactor;
        tokenIndex[_tokenId] = tokenList.length;
        tokenList.push(_tokenId);
        emit AddReward(_tokenId, _rewardFactor);
    }

    function removeRewardFactor(bytes32 _tokenId) external onlyAdmin {
        require(rewardFactor[_tokenId] != 0, "RD:RR-Reward doesnt exist");
        bytes32 tokenToReplace = tokenList[tokenList.length - 1];
        uint256 originalTokenIndex = tokenIndex[_tokenId];
        tokenList[originalTokenIndex] = tokenToReplace;
        tokenIndex[tokenToReplace] = originalTokenIndex;
        tokenList.pop();
        delete rewardFactor[_tokenId];
        delete tokenIndex[_tokenId];
        emit RemoveReward(_tokenId);
    }

    function updateRewardFactor(bytes32 _tokenId, uint256 _updatedRewardFactor) external onlyAdmin {
        require(rewardFactor[_tokenId] != 0, "RD:UR-Cant update reward that doesnt exist");
        require(_updatedRewardFactor != 0, "RD:UR-Reward cant be 0");
        rewardFactor[_tokenId] = _updatedRewardFactor;
        emit RewardsUpdated(_tokenId, _updatedRewardFactor);
    }

    function _updateRewards(address _cluster) public {
        uint256 reward = clusterRewards.claimReward(_cluster);
        if(reward == 0) {
            return;
        }

        (uint256 _commission, address _rewardAddress) = clusterRegistry.getRewardInfo(_cluster);

        uint256 commissionReward = (reward * _commission) / 100;
        uint256 delegatorReward = reward - commissionReward;
        bytes32[] memory tokens = tokenList;
        uint256[] memory delegations = new uint256[](tokens.length);
        uint256 delegatedTokens = 0;
        for(uint i=0; i < tokens.length; i++) {
            delegations[i] = clusters[_cluster].totalDelegations[tokens[i]];
            if(delegations[i] != 0) {
                delegatedTokens++;
            }
        }
        for(uint i=0; i < tokens.length; i++) {
            // clusters[_cluster].accRewardPerShare[tokens[i]] = clusters[_cluster].accRewardPerShare[tokens[i]].add(
            //                                                         delegatorReward
            //                                                         .mul(rewardFactor[tokens[i]])
            //                                                         .mul(10**30)
            //                                                         .div(weightedStake)
            //                                                     );
            if(delegations[i] != 0) {
                clusters[_cluster].accRewardPerShare[tokens[i]] = clusters[_cluster].accRewardPerShare[tokens[i]] +
                                                                   (((delegatorReward * (10**30)) / delegatedTokens) / delegations[i]);

            }
        }
        if(commissionReward != 0) {
            transferRewards(_rewardAddress, commissionReward);
        }
        emit ClusterRewardDistributed(_cluster);
    }

    function delegate(
        address _delegator,
        address _cluster,
        bytes32[] memory _tokens,
        uint256[] memory _amounts
    ) public onlyStake {
        _updateTokens(_delegator, _cluster, _tokens, _amounts, true);
    }

    function _updateTokens(
        address _delegator,
        address _cluster,
        bytes32[] memory _tokens,
        uint256[] memory _amounts,
        bool _isDelegation
    ) internal returns(uint256 _aggregateReward) {
        _updateRewards(_cluster);

        for(uint256 i = 0; i < _tokens.length; i++) {
            bytes32 _tokenId = _tokens[i];
            uint256 _amount = _amounts[i];

            (uint256 _oldBalance, uint256 _newBalance) = _updateBalances(
                _cluster,
                _delegator,
                _tokenId,
                _amount,
                _isDelegation
            );

            uint256 _reward = _updateDelegatorRewards(
                _cluster,
                _delegator,
                _tokenId,
                _oldBalance,
                _newBalance
            );

            _aggregateReward = _aggregateReward + _reward;
        }

        if(_aggregateReward != 0) {
            transferRewards(_delegator, _aggregateReward);
            emit RewardsWithdrawn(_cluster, _delegator, _tokens, _aggregateReward);
        }
    }

    function _updateBalances(
        address _cluster,
        address _delegator,
        bytes32 _tokenId,
        uint256 _amount,
        bool _isDelegation
    ) internal returns(uint256 _oldBalance, uint256 _newBalance) {
        _oldBalance = clusters[_cluster].delegators[_delegator][_tokenId];

        // short circuit
        if(_amount == 0) {
            _newBalance = _oldBalance;
            return (_oldBalance, _newBalance);
        }

        // update balances
        if(_isDelegation) {
            _newBalance =  _oldBalance + _amount;
            clusters[_cluster].totalDelegations[_tokenId] = clusters[_cluster].totalDelegations[_tokenId]
                                                             + _amount;
        } else {
            _newBalance =  _oldBalance - _amount;
            clusters[_cluster].totalDelegations[_tokenId] = clusters[_cluster].totalDelegations[_tokenId]
                                                             - _amount;
        }
        clusters[_cluster].delegators[_delegator][_tokenId] = _newBalance;
    }

    function _updateDelegatorRewards(
        address _cluster,
        address _delegator,
        bytes32 _tokenId,
        uint256 _oldBalance,
        uint256 _newBalance
    ) internal returns(uint256 _reward) {
        uint256 _accRewardPerShare = clusters[_cluster].accRewardPerShare[_tokenId];
        uint256 _rewardDebt = clusters[_cluster].rewardDebt[_delegator][_tokenId];

        // pending rewards
        uint256 _tokenPendingRewards = (_accRewardPerShare * _oldBalance) / (10**30);

        // calculating pending rewards for the delegator if any
        _reward = _tokenPendingRewards - _rewardDebt;

        // short circuit
        if(_oldBalance == _newBalance && _reward == 0) {
            return _reward;
        }

        // update the debt for next reward calculation
        clusters[_cluster].rewardDebt[_delegator][_tokenId] = (_accRewardPerShare * _newBalance) / (10**30);
    }

    function undelegate(
        address _delegator,
        address _cluster,
        bytes32[] memory _tokens,
        uint256[] memory _amounts
    ) public onlyStake {
        _updateTokens(_delegator, _cluster, _tokens, _amounts, false);
    }

    function withdrawRewards(address _delegator, address _cluster) public returns(uint256) {
        return _updateTokens(_delegator, _cluster, tokenList, new uint256[](tokenList.length), true);
    }

    function withdrawRewards(address _delegator, address[] calldata _clusters) external {
        for(uint256 i=0; i < _clusters.length; i++) {
            withdrawRewards(_delegator, _clusters[i]);
        }
    }

    function transferRewards(address _to, uint256 _amount) internal {
        PONDToken.transfer(_to, _amount);
    }

    function getClusterDelegation(address _cluster, bytes32 _tokenId)
        external
        view
        returns(uint256)
    {
        return clusters[_cluster].totalDelegations[_tokenId];
    }

    function getDelegation(address _cluster, address _delegator, bytes32 _tokenId)
        external
        view
        returns(uint256)
    {
        return clusters[_cluster].delegators[_delegator][_tokenId];
    }

    function updateStakeAddress(address _updatedStakeAddress) external onlyAdmin {
        require(
            _updatedStakeAddress != address(0),
            "RD:USA-Stake contract address cant be 0"
        );
        stakeAddress = _updatedStakeAddress;
        emit StakeAddressUpdated(_updatedStakeAddress);
    }

    function updateClusterRewards(
        address _updatedClusterRewards
    ) external onlyAdmin {
        require(
            _updatedClusterRewards != address(0),
            "RD:UCR-ClusterRewards address cant be 0"
        );
        clusterRewards = IClusterRewards(_updatedClusterRewards);
        emit ClusterRewardsAddressUpdated(_updatedClusterRewards);
    }

    function updateClusterRegistry(
        address _updatedClusterRegistry
    ) external onlyAdmin {
        require(
            _updatedClusterRegistry != address(0),
            "RD:UCR-Cluster Registry address cant be 0"
        );
        clusterRegistry = IClusterRegistry(_updatedClusterRegistry);
        emit ClusterRegistryUpdated(_updatedClusterRegistry);
    }

    function updatePONDAddress(address _updatedPOND) external onlyAdmin {
        require(
            _updatedPOND != address(0),
            "RD:UPA-Updated POND token address cant be 0"
        );
        PONDToken = IERC20Upgradeable(_updatedPOND);
        emit PONDAddressUpdated(_updatedPOND);
    }

    function getAccRewardPerShare(address _cluster, bytes32 _tokenId) external view returns(uint256) {
        return clusters[_cluster].accRewardPerShare[_tokenId];
    }

    function applyDiffs(
        address[] calldata _delegators,
        address[] calldata _clusters,
        bytes32[] calldata _tokens,
        uint256[] calldata _allAmounts,
        bool[] calldata _isDelegations
    ) external onlyAdmin {
        require(_delegators.length == _clusters.length);
        require(_delegators.length * _tokens.length == _allAmounts.length);
        require(_delegators.length == _isDelegations.length);

        for(uint256 _idx = 0; _idx < _delegators.length; _idx++) {
            address _delegator = _delegators[_idx];
            address _cluster = _clusters[_idx];
            uint256[] memory _amounts = _allAmounts[(_idx*_tokens.length):((_idx+1)*_tokens.length)];
            bool _isDelegation = _isDelegations[_idx];

            for(uint256 _tidx = 0; _tidx < _tokens.length; _tidx++) {
                _updateBalances(_cluster, _delegator, _tokens[_tidx], _amounts[_tidx], _isDelegation);
            }
        }
    }
}

File 2 of 19 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "../../utils/AddressUpgradeable.sol";

/**
 * @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 a proxied contract can't have 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.
 *
 * 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 initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 3 of 19 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
        __Context_init_unchained();
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 4 of 19 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
        __ERC165_init_unchained();
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }
    uint256[50] private __gap;
}

File 5 of 19 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal onlyInitializing {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        StringsUpgradeable.toHexString(uint160(account), 20),
                        " is missing role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
    uint256[49] private __gap;
}

File 6 of 19 : AccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/AccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlEnumerableUpgradeable.sol";
import "./AccessControlUpgradeable.sol";
import "../utils/structs/EnumerableSetUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable {
    function __AccessControlEnumerable_init() internal onlyInitializing {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
        __AccessControlEnumerable_init_unchained();
    }

    function __AccessControlEnumerable_init_unchained() internal onlyInitializing {
    }
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {_grantRole} to track enumerable memberships
     */
    function _grantRole(bytes32 role, address account) internal virtual override {
        super._grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {_revokeRole} to track enumerable memberships
     */
    function _revokeRole(bytes32 role, address account) internal virtual override {
        super._revokeRole(role, account);
        _roleMembers[role].remove(account);
    }
    uint256[49] private __gap;
}

File 7 of 19 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.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.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
        __ERC1967Upgrade_init_unchained();
        __UUPSUpgradeable_init_unchained();
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @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 ERC1967) 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 ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallSecure(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallSecure(newImplementation, data, true);
    }

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

File 8 of 19 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 9 of 19 : IClusterRewards.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IClusterRewards {
    function clusterRewards(address _cluster) external returns(uint256);
    function rewardWeight(bytes32 _networkId) external returns(uint256);
    function totalRewardsPerEpoch() external returns(uint256);
    function feeder() external returns(address);
    function rewardDistributionWaitTime() external returns(uint256);
    function changeFeeder(address _newFeeder) external;
    function addNetwork(bytes32 _networkId, uint256 _rewardWeight) external;
    function removeNetwork(bytes32 _networkId) external;
    function changeNetworkReward(bytes32 _networkId, uint256 _updatedRewardWeight) external;
    function feed(bytes32 _networkId, address[] calldata _clusters, uint256[] calldata _payouts, uint256 _epoch) external;
    function getRewardPerEpoch(bytes32 _networkId) external view returns(uint256);
    function claimReward(address _cluster) external returns(uint256);
    function transferRewardsToRewardDelegators() external returns(bool);
    function updateRewardDelegatorAddress(address _updatedRewardDelegator) external;
    function updatePONDAddress(address _updatedPOND) external;
    function changeRewardPerEpoch(uint256 _updatedRewardPerEpoch) external;
    function changePayoutDenomination(uint256 _updatedPayoutDenomination) external;
    function updateRewardDistributionWaitTime(uint256 _updatedRewardDistributionWaitTime) external;
}

File 10 of 19 : IClusterRegistry.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IClusterRegistry {
    function locks(bytes32 _lockId) external returns(uint256, uint256);
    function lockWaitTime(bytes32 _selectorId) external returns(uint256);
    function updateLockWaitTime(bytes32 _selector, uint256 _updatedWaitTime) external;
    function register(
        bytes32 _networkId,
        uint256 _commission,
        address _rewardAddress,
        address _clientKey
    ) external;
    function updateCluster(
        uint256 _commission,
        bytes32 _networkId,
        address _rewardAddress,
        address _clientKey
    ) external;
    function updateCommission(uint256 _commission) external;
    function switchNetwork(bytes32 _networkId) external;
    function updateRewardAddress(address _rewardAddress) external;
    function updateClientKey(address _clientKey) external;
    function unregister() external;
    function isClusterValid(address _cluster) external returns(bool);
    function getCommission(address _cluster) external returns(uint256);
    function getNetwork(address _cluster) external returns(bytes32);
    function getRewardAddress(address _cluster) external view returns(address);
    function getClientKey(address _cluster) external view returns(address);
    function getCluster(address _cluster) external;
    function getRewardInfo(address _cluster) external returns(uint256, address);
    function addClientKeys(address[] calldata _clusters) external;
}

File 11 of 19 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @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, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * 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.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @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`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // 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 {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 12 of 19 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 13 of 19 : IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 14 of 19 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 15 of 19 : IAccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable {
    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

File 16 of 19 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSetUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastvalue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastvalue;
                // Update the index for the moved value
                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly {
            result := store
        }

        return result;
    }
}

File 17 of 19 : ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
        __ERC1967Upgrade_init_unchained();
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallSecure(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        address oldImplementation = _getImplementation();

        // Initial upgrade and setup call
        _setImplementation(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }

        // Perform rollback test if not already in progress
        StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT);
        if (!rollbackTesting.value) {
            // Trigger rollback using upgradeTo from the new implementation
            rollbackTesting.value = true;
            _functionDelegateCall(
                newImplementation,
                abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
            );
            rollbackTesting.value = false;
            // Check rollback was effective
            require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
            // Finally reset to the new implementation and log the upgrade
            _upgradeTo(newImplementation);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }
    uint256[50] private __gap;
}

File 18 of 19 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

File 19 of 19 : StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @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 ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

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

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

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

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

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 10000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"tokenId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"rewardFactor","type":"uint256"}],"name":"AddReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_updatedClusterRegistry","type":"address"}],"name":"ClusterRegistryUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"cluster","type":"address"}],"name":"ClusterRewardDistributed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_updatedClusterRewards","type":"address"}],"name":"ClusterRewardsAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_updatedPOND","type":"address"}],"name":"PONDAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"tokenId","type":"bytes32"}],"name":"RemoveReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"tokenId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"rewardFactor","type":"uint256"}],"name":"RewardsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"cluster","type":"address"},{"indexed":false,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"bytes32[]","name":"tokenIds","type":"bytes32[]"},{"indexed":false,"internalType":"uint256","name":"rewards","type":"uint256"}],"name":"RewardsWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_updatedStakeAddress","type":"address"}],"name":"StakeAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PONDToken","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_cluster","type":"address"}],"name":"_updateRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_tokenId","type":"bytes32"},{"internalType":"uint256","name":"_rewardFactor","type":"uint256"}],"name":"addRewardFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_delegators","type":"address[]"},{"internalType":"address[]","name":"_clusters","type":"address[]"},{"internalType":"bytes32[]","name":"_tokens","type":"bytes32[]"},{"internalType":"uint256[]","name":"_allAmounts","type":"uint256[]"},{"internalType":"bool[]","name":"_isDelegations","type":"bool[]"}],"name":"applyDiffs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"clusterRegistry","outputs":[{"internalType":"contract IClusterRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"clusterRewards","outputs":[{"internalType":"contract IClusterRewards","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"address","name":"_cluster","type":"address"},{"internalType":"bytes32[]","name":"_tokens","type":"bytes32[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_cluster","type":"address"},{"internalType":"bytes32","name":"_tokenId","type":"bytes32"}],"name":"getAccRewardPerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_cluster","type":"address"},{"internalType":"bytes32","name":"_tokenId","type":"bytes32"}],"name":"getClusterDelegation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_cluster","type":"address"},{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"bytes32","name":"_tokenId","type":"bytes32"}],"name":"getDelegation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_stakeAddress","type":"address"},{"internalType":"address","name":"_clusterRewardsAddress","type":"address"},{"internalType":"address","name":"_clusterRegistry","type":"address"},{"internalType":"address","name":"_PONDAddress","type":"address"},{"internalType":"bytes32[]","name":"_tokenIds","type":"bytes32[]"},{"internalType":"uint256[]","name":"_rewardFactors","type":"uint256[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_tokenId","type":"bytes32"}],"name":"removeRewardFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"rewardFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakeAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"tokenIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenList","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"address","name":"_cluster","type":"address"},{"internalType":"bytes32[]","name":"_tokens","type":"bytes32[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"undelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_updatedClusterRegistry","type":"address"}],"name":"updateClusterRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_updatedClusterRewards","type":"address"}],"name":"updateClusterRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_updatedPOND","type":"address"}],"name":"updatePONDAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_tokenId","type":"bytes32"},{"internalType":"uint256","name":"_updatedRewardFactor","type":"uint256"}],"name":"updateRewardFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_updatedStakeAddress","type":"address"}],"name":"updateStakeAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"address[]","name":"_clusters","type":"address[]"}],"name":"withdrawRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegator","type":"address"},{"internalType":"address","name":"_cluster","type":"address"}],"name":"withdrawRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

60a0604052306080523480156200001557600080fd5b50600054610100900460ff16620000335760005460ff16156200003d565b6200003d620000e2565b620000a55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b600054610100900460ff16158015620000c8576000805461ffff19166101011790555b8015620000db576000805461ff00191690555b5062000106565b6000620000fa306200010060201b620020fc1760201c565b15905090565b3b151590565b608051613b3462000137600039600081816110e80152818161117e0152818161153301526115c90152613b346000f3fe6080604052600436106102345760003560e01c80637b22790a11610138578063afe3b8d9116100b0578063ca7e6a081161007f578063dd62c94411610064578063dd62c94414610700578063e20981ca14610720578063ec57002b1461074057600080fd5b8063ca7e6a08146106bf578063d547741f146106e057600080fd5b8063afe3b8d91461063e578063b66206d41461065f578063c4b07bcc1461067f578063ca15c8731461069f57600080fd5b806391d14854116101075780639ead7222116100ec5780639ead7222146105c5578063a217fddf146105e5578063a702730e146105fa57600080fd5b806391d148541461055f5780639a943e00146105a557600080fd5b80637b22790a146104c557806385107367146104fe5780638609ab5b1461051f5780639010d07c1461053f57600080fd5b806334638031116101cb57806339bc83da1161019a5780634f1ef2861161017f5780634f1ef2861461043c5780635d3e91d81461044f578063762c03961461047d57600080fd5b806339bc83da146103fc57806345431d651461041c57600080fd5b8063346380311461037c578063360dfd221461039c57806336568abe146103bc5780633659cfe6146103dc57600080fd5b80632bc51f6d116102075780632bc51f6d146102ee5780632f2ff15d1461030e57806331b600861461032e57806332be8d7f1461035c57600080fd5b806301ffc9a7146102395780631efd41061461026e578063242ae35814610290578063248a9ca3146102b0575b600080fd5b34801561024557600080fd5b506102596102543660046130f6565b610760565b60405190151581526020015b60405180910390f35b34801561027a57600080fd5b5061028e61028936600461314d565b610771565b005b34801561029c57600080fd5b5061028e6102ab366004613268565b610874565b3480156102bc57600080fd5b506102e06102cb3660046132f1565b60009081526065602052604090206001015490565b604051908152602001610265565b3480156102fa57600080fd5b5061028e61030936600461314d565b610912565b34801561031a57600080fd5b5061028e61032936600461330a565b610d67565b34801561033a57600080fd5b506102e06103493660046132f1565b6103566020526000908152604090205481565b34801561036857600080fd5b5061028e6103773660046132f1565b610d92565b34801561038857600080fd5b5061028e61039736600461314d565b610f1f565b3480156103a857600080fd5b506102e06103b736600461333a565b611016565b3480156103c857600080fd5b5061028e6103d736600461330a565b611051565b3480156103e857600080fd5b5061028e6103f736600461314d565b6110dd565b34801561040857600080fd5b5061028e61041736600461314d565b61127b565b34801561042857600080fd5b5061028e6104373660046133c7565b611372565b61028e61044a3660046134b8565b611528565b34801561045b57600080fd5b506102e061046a3660046132f1565b6103556020526000908152604090205481565b34801561048957600080fd5b506102e061049836600461357e565b6001600160a01b039190911660009081526103536020908152604080832093835260039093019052205490565b3480156104d157600080fd5b50610358546104e6906001600160a01b031681565b6040516001600160a01b039091168152602001610265565b34801561050a57600080fd5b50610354546104e6906001600160a01b031681565b34801561052b57600080fd5b5061028e61053a3660046135aa565b6116b3565b34801561054b57600080fd5b506104e661055a366004613657565b611b88565b34801561056b57600080fd5b5061025961057a36600461330a565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156105b157600080fd5b5061028e6105c0366004613268565b611ba0565b3480156105d157600080fd5b506102e06105e03660046132f1565b611c37565b3480156105f157600080fd5b506102e0600081565b34801561060657600080fd5b506102e061061536600461357e565b6001600160a01b0391909116600090815261035360209081526040808320938352929052205490565b34801561064a57600080fd5b50610359546104e6906001600160a01b031681565b34801561066b57600080fd5b5061028e61067a366004613679565b611c59565b34801561068b57600080fd5b5061028e61069a36600461314d565b611ca8565b3480156106ab57600080fd5b506102e06106ba3660046132f1565b611d9f565b3480156106cb57600080fd5b5061035a546104e6906001600160a01b031681565b3480156106ec57600080fd5b5061028e6106fb36600461330a565b611db6565b34801561070c57600080fd5b5061028e61071b366004613657565b611ddc565b34801561072c57600080fd5b506102e061073b3660046136ce565b611f10565b34801561074c57600080fd5b5061028e61075b366004613657565b611fb7565b600061076b82612102565b92915050565b61077c60003361057a565b61078557600080fd5b6001600160a01b0381166108065760405162461bcd60e51b815260206004820152602960248201527f52443a5543522d436c757374657220526567697374727920616464726573732060448201527f63616e742062652030000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61035980547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527f4351260b1696230c4813cbc69203806934609b506e3a438dd911d22e6965ed39906020015b60405180910390a150565b610354546001600160a01b0316336001600160a01b0316146108fd5760405162461bcd60e51b8152602060048201526024808201527f52443a4f532d6f6e6c79207374616b6520636f6e74726163742063616e20696e60448201527f766f6b650000000000000000000000000000000000000000000000000000000060648201526084016107fd565b61090b848484846001612158565b5050505050565b610358546040517fd279c1910000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152600092169063d279c19190602401602060405180830381600087803b15801561097457600080fd5b505af1158015610988573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ac91906136fc565b9050806109b7575050565b610359546040517f06032d740000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260009283929116906306032d74906024016040805180830381600087803b158015610a1b57600080fd5b505af1158015610a2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a539190613715565b909250905060006064610a668486613769565b610a7091906137a6565b90506000610a7e82866137e1565b90506000610357805480602002602001604051908101604052809291908181526020018280548015610acf57602002820191906000526020600020905b815481526020019060010190808311610abb575b505050505090506000815167ffffffffffffffff811115610af257610af261316a565b604051908082528060200260200182016040528015610b1b578160200160208202803683370190505b5090506000805b8351811015610bd1576001600160a01b038a166000908152610353602052604081208551909190869084908110610b5b57610b5b6137f8565b6020026020010151815260200190815260200160002054838281518110610b8457610b846137f8565b602002602001018181525050828181518110610ba257610ba26137f8565b6020026020010151600014610bbf5781610bbb81613827565b9250505b80610bc981613827565b915050610b22565b5060005b8351811015610d0f57828181518110610bf057610bf06137f8565b6020026020010151600014610cfd57828181518110610c1157610c116137f8565b602002602001015182866c0c9f2c9cd04674edea40000000610c339190613769565b610c3d91906137a6565b610c4791906137a6565b61035360008c6001600160a01b03166001600160a01b031681526020019081526020016000206003016000868481518110610c8457610c846137f8565b6020026020010151815260200190815260200160002054610ca59190613860565b61035360008c6001600160a01b03166001600160a01b031681526020019081526020016000206003016000868481518110610ce257610ce26137f8565b60200260200101518152602001908152602001600020819055505b80610d0781613827565b915050610bd5565b508415610d2057610d20868661224c565b6040516001600160a01b038a1681527f643d0f768d20758fe82686d7de201866faaee92f36542c9b1ea68fe26217dc909060200160405180910390a1505050505050505050565b600082815260656020526040902060010154610d8381336122ec565b610d8d838361238a565b505050565b610d9d60003361057a565b610da657600080fd5b60008181526103556020526040902054610e025760405162461bcd60e51b815260206004820152601960248201527f52443a52522d52657761726420646f65736e742065786973740000000000000060448201526064016107fd565b610357805460009190610e17906001906137e1565b81548110610e2757610e276137f8565b9060005260206000200154905060006103566000848152602001908152602001600020549050816103578281548110610e6257610e626137f8565b600091825260208083209091019290925583815261035690915260409020819055610357805480610e9557610e95613878565b600082815260208082207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90840181018390559092019092558482526103558152604080832083905561035682528083209290925590518481527fc21f2202b563765aa875aa0a6a2fde3881f4c11badde30a726d5608eb1afa109910160405180910390a1505050565b610f2a60003361057a565b610f3357600080fd5b6001600160a01b038116610faf5760405162461bcd60e51b815260206004820152602b60248201527f52443a5550412d5570646174656420504f4e4420746f6b656e2061646472657360448201527f732063616e74206265203000000000000000000000000000000000000000000060648201526084016107fd565b61035a80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527f7c5c83d102d6ea0acddb82e57f9c4b34d02eff8d010a0634dc65378f16eb032390602001610869565b6001600160a01b03808416600090815261035360209081526040808320938616835260019093018152828220848352905220545b9392505050565b6001600160a01b03811633146110cf5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016107fd565b6110d98282612394565b5050565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561117c5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c000000000000000000000000000000000000000060648201526084016107fd565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166111d77f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146112535760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f7879000000000000000000000000000000000000000060648201526084016107fd565b61125c816123b1565b60408051600080825260208201909252611278918391906123c5565b50565b61128660003361057a565b61128f57600080fd5b6001600160a01b03811661130b5760405162461bcd60e51b815260206004820152602760248201527f52443a5543522d436c757374657252657761726473206164647265737320636160448201527f6e7420626520300000000000000000000000000000000000000000000000000060648201526084016107fd565b61035880547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527fdc995512cdbd25ea12dfdeb157d3c8e916bab71a2237322efa834846db5262bf90602001610869565b61137d60003361057a565b61138657600080fd5b88871461139257600080fd5b8261139d868b613769565b146113a757600080fd5b8881146113b357600080fd5b60005b8981101561151b5760008b8b838181106113d2576113d26137f8565b90506020020160208101906113e7919061314d565b905060008a8a848181106113fd576113fd6137f8565b9050602002016020810190611412919061314d565b9050600087876114228b87613769565b908b61142f886001613860565b6114399190613769565b92611446939291906138a7565b80806020026020016040519081016040528093929190818152602001838360200280828437600092018290525093945089925088915087905081811061148e5761148e6137f8565b90506020020160208101906114a391906138e3565b905060005b8a811015611503576114ee84868e8e858181106114c7576114c76137f8565b905060200201358685815181106114e0576114e06137f8565b6020026020010151866125dc565b505080806114fb90613827565b9150506114a8565b5050505050808061151390613827565b9150506113b6565b5050505050505050505050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156115c75760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c000000000000000000000000000000000000000060648201526084016107fd565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166116227f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b03161461169e5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f7879000000000000000000000000000000000000000060648201526084016107fd565b6116a7826123b1565b6110d9828260016123c5565b600054610100900460ff166116ce5760005460ff16156116d2565b303b155b6117445760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016107fd565b600054610100900460ff1615801561178357600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000166101011790555b81518351146118205760405162461bcd60e51b815260206004820152604a60248201527f52443a492d4561636820546f6b656e49642073686f756c64206861766520612060448201527f636f72726573706f6e64696e672052657761726420466163746f7220616e642060648201527f7669636520766572736100000000000000000000000000000000000000000000608482015260a4016107fd565b61182861272e565b61183061272e565b61183861272e565b61184061272e565b61184861272e565b61185061272e565b61185b6000336127ad565b61035480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0389169081179091556040519081527faea47bea602f2b18a4721cdacf1aafd7e3962d8574680ee8e15714cc7739e4549060200160405180910390a161035980547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0387169081179091556040519081527f4351260b1696230c4813cbc69203806934609b506e3a438dd911d22e6965ed399060200160405180910390a161035880547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0388169081179091556040519081527fdc995512cdbd25ea12dfdeb157d3c8e916bab71a2237322efa834846db5262bf9060200160405180910390a161035a80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0386169081179091556040519081527f7c5c83d102d6ea0acddb82e57f9c4b34d02eff8d010a0634dc65378f16eb03239060200160405180910390a160005b8351811015611b4f57828181518110611a2157611a216137f8565b60200260200101516103556000868481518110611a4057611a406137f8565b6020026020010151815260200190815260200160002081905550610357805490506103566000868481518110611a7857611a786137f8565b6020026020010151815260200190815260200160002081905550610357848281518110611aa757611aa76137f8565b6020908102919091018101518254600181018455600093845291909220015583517faf18f84b562d534f966cd12a369a21eb5e9264df24b55799ac5950deace3a7e390859083908110611afc57611afc6137f8565b6020026020010151848381518110611b1657611b166137f8565b6020026020010151604051611b35929190918252602082015260400190565b60405180910390a180611b4781613827565b915050611a06565b508015611b7f57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1690555b50505050505050565b600082815260976020526040812061104a90836127b7565b610354546001600160a01b0316336001600160a01b031614611c295760405162461bcd60e51b8152602060048201526024808201527f52443a4f532d6f6e6c79207374616b6520636f6e74726163742063616e20696e60448201527f766f6b650000000000000000000000000000000000000000000000000000000060648201526084016107fd565b61090b848484846000612158565b6103578181548110611c4857600080fd5b600091825260209091200154905081565b60005b81811015611ca257611c8f84848484818110611c7a57611c7a6137f8565b905060200201602081019061073b919061314d565b5080611c9a81613827565b915050611c5c565b50505050565b611cb360003361057a565b611cbc57600080fd5b6001600160a01b038116611d385760405162461bcd60e51b815260206004820152602760248201527f52443a5553412d5374616b6520636f6e7472616374206164647265737320636160448201527f6e7420626520300000000000000000000000000000000000000000000000000060648201526084016107fd565b61035480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527faea47bea602f2b18a4721cdacf1aafd7e3962d8574680ee8e15714cc7739e45490602001610869565b600081815260976020526040812061076b906127c3565b600082815260656020526040902060010154611dd281336122ec565b610d8d8383612394565b611de760003361057a565b611df057600080fd5b60008281526103556020526040902054611e725760405162461bcd60e51b815260206004820152602a60248201527f52443a55522d43616e742075706461746520726577617264207468617420646f60448201527f65736e742065786973740000000000000000000000000000000000000000000060648201526084016107fd565b80611ebf5760405162461bcd60e51b815260206004820152601660248201527f52443a55522d5265776172642063616e7420626520300000000000000000000060448201526064016107fd565b6000828152610355602090815260409182902083905581518481529081018390527f724ced771231b28817afaf7ec57ee9b21a844ac261955fbca7ee727ce8826e6691015b60405180910390a15050565b600061104a8383610357805480602002602001604051908101604052809291908181526020018280548015611f6457602002820191906000526020600020905b815481526020019060010190808311611f50575b5050610357549250505067ffffffffffffffff811115611f8657611f8661316a565b604051908082528060200260200182016040528015611faf578160200160208202803683370190505b506001612158565b611fc260003361057a565b611fcb57600080fd5b60008281526103556020526040902054156120285760405162461bcd60e51b815260206004820152601b60248201527f52443a41522d52657761726420616c726561647920657869737473000000000060448201526064016107fd565b806120755760405162461bcd60e51b815260206004820152601660248201527f52443a41522d5265776172642063616e7420626520300000000000000000000060448201526064016107fd565b6000828152610355602090815260408083208490556103578054610356845282852081905560018101825593527f867007ff0c9c91c963bfa60bcb8e814dfc261843d6b3506fffede331f2d4717690920184905581518481529081018390527faf18f84b562d534f966cd12a369a21eb5e9264df24b55799ac5950deace3a7e39101611f04565b3b151590565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f5a05180f00000000000000000000000000000000000000000000000000000000148061076b575061076b826127cd565b600061216385610912565b60005b84518110156121f4576000858281518110612183576121836137f8565b6020026020010151905060008583815181106121a1576121a16137f8565b602002602001015190506000806121bb8a8c86868b6125dc565b9150915060006121ce8b8d878686612864565b90506121da8188613860565b9650505050505080806121ec90613827565b915050612166565b50801561224357612205868261224c565b7f54e8f034636217314f27bfc2c4e0aec174ceab3a2b1196d2e00f8bae09ac52fd8587868460405161223a9493929190613900565b60405180910390a15b95945050505050565b61035a546040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b038481166004830152602482018490529091169063a9059cbb90604401602060405180830381600087803b1580156122b457600080fd5b505af11580156122c8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8d919061396b565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff166110d95761232a816001600160a01b03166014612953565b612335836020612953565b6040516020016123469291906139b4565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262461bcd60e51b82526107fd91600401613a35565b6110d98282612b7c565b61239e8282612b9e565b6123a86000611d9f565b6110d957600080fd5b6123bc60003361057a565b61127857600080fd5b60006123f87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905061240384612bc0565b6000835111806124105750815b156124215761241f8484612c8d565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff1661090b5780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011781556040516001600160a01b038316602482015261250a908690604401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f3659cfe600000000000000000000000000000000000000000000000000000000179052612c8d565b5080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001681557f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b038381169116146125d35760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201527f757274686572207570677261646573000000000000000000000000000000000060648201526084016107fd565b61090b85612d86565b6001600160a01b03808616600090815261035360209081526040808320938816835260019093018152828220868352905290812054908361261e575080612724565b821561268b5761262e8483613860565b6001600160a01b038816600090815261035360209081526040808320898452909152902054909150612661908590613860565b6001600160a01b0388166000908152610353602090815260408083208984529091529020556126ee565b61269584836137e1565b6001600160a01b0388166000908152610353602090815260408083208984529091529020549091506126c89085906137e1565b6001600160a01b0388166000908152610353602090815260408083208984529091529020555b6001600160a01b03808816600090815261035360209081526040808320938a168352600190930181528282208883529052208190555b9550959350505050565b600054610100900460ff166127ab5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e6700000000000000000000000000000000000000000060648201526084016107fd565b565b6110d9828261238a565b600061104a8383612dc6565b600061076b825490565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061076b57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461076b565b6001600160a01b038086166000908152610353602090815260408083208784526003810183528184205494891684526002018252808320878452909152812054909190826c0c9f2c9cd04674edea400000006128c08785613769565b6128ca91906137a6565b90506128d682826137e1565b935084861480156128e5575083155b156128f257505050612243565b6c0c9f2c9cd04674edea4000000061290a8685613769565b61291491906137a6565b6001600160a01b03808b16600090815261035360209081526040808320938d168352600290930181528282208b83529052205550505095945050505050565b60606000612962836002613769565b61296d906002613860565b67ffffffffffffffff8111156129855761298561316a565b6040519080825280601f01601f1916602001820160405280156129af576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106129e6576129e66137f8565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110612a4957612a496137f8565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000612a85846002613769565b612a90906001613860565b90505b6001811115612b2d577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110612ad157612ad16137f8565b1a60f81b828281518110612ae757612ae76137f8565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93612b2681613a86565b9050612a93565b50831561104a5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107fd565b612b868282612df0565b6000828152609760205260409020610d8d9082612eb0565b612ba88282612ec5565b6000828152609760205260409020610d8d9082612f66565b803b612c345760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016107fd565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6060823b612d035760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016107fd565b600080846001600160a01b031684604051612d1e9190613abb565b600060405180830381855af49150503d8060008114612d59576040519150601f19603f3d011682016040523d82523d6000602084013e612d5e565b606091505b50915091506122438282604051806060016040528060278152602001613ad860279139612f7b565b612d8f81612bc0565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6000826000018281548110612ddd57612ddd6137f8565b9060005260206000200154905092915050565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff166110d95760008281526065602090815260408083206001600160a01b0385168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055612e6c3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600061104a836001600160a01b038416612fb4565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16156110d95760008281526065602090815260408083206001600160a01b038516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600061104a836001600160a01b038416613003565b60608315612f8a57508161104a565b825115612f9a5782518084602001fd5b8160405162461bcd60e51b81526004016107fd9190613a35565b6000818152600183016020526040812054612ffb5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561076b565b50600061076b565b600081815260018301602052604081205480156130ec5760006130276001836137e1565b855490915060009061303b906001906137e1565b90508181146130a057600086600001828154811061305b5761305b6137f8565b906000526020600020015490508087600001848154811061307e5761307e6137f8565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806130b1576130b1613878565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061076b565b600091505061076b565b60006020828403121561310857600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461104a57600080fd5b6001600160a01b038116811461127857600080fd5b60006020828403121561315f57600080fd5b813561104a81613138565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156131e0576131e061316a565b604052919050565b600082601f8301126131f957600080fd5b8135602067ffffffffffffffff8211156132155761321561316a565b8160051b613224828201613199565b928352848101820192828101908785111561323e57600080fd5b83870192505b8483101561325d57823582529183019190830190613244565b979650505050505050565b6000806000806080858703121561327e57600080fd5b843561328981613138565b9350602085013561329981613138565b9250604085013567ffffffffffffffff808211156132b657600080fd5b6132c2888389016131e8565b935060608701359150808211156132d857600080fd5b506132e5878288016131e8565b91505092959194509250565b60006020828403121561330357600080fd5b5035919050565b6000806040838503121561331d57600080fd5b82359150602083013561332f81613138565b809150509250929050565b60008060006060848603121561334f57600080fd5b833561335a81613138565b9250602084013561336a81613138565b929592945050506040919091013590565b60008083601f84011261338d57600080fd5b50813567ffffffffffffffff8111156133a557600080fd5b6020830191508360208260051b85010111156133c057600080fd5b9250929050565b60008060008060008060008060008060a08b8d0312156133e657600080fd5b8a3567ffffffffffffffff808211156133fe57600080fd5b61340a8e838f0161337b565b909c509a5060208d013591508082111561342357600080fd5b61342f8e838f0161337b565b909a50985060408d013591508082111561344857600080fd5b6134548e838f0161337b565b909850965060608d013591508082111561346d57600080fd5b6134798e838f0161337b565b909650945060808d013591508082111561349257600080fd5b5061349f8d828e0161337b565b915080935050809150509295989b9194979a5092959850565b600080604083850312156134cb57600080fd5b82356134d681613138565b915060208381013567ffffffffffffffff808211156134f457600080fd5b818601915086601f83011261350857600080fd5b81358181111561351a5761351a61316a565b61354a847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601613199565b9150808252878482850101111561356057600080fd5b80848401858401376000848284010152508093505050509250929050565b6000806040838503121561359157600080fd5b823561359c81613138565b946020939093013593505050565b60008060008060008060c087890312156135c357600080fd5b86356135ce81613138565b955060208701356135de81613138565b945060408701356135ee81613138565b935060608701356135fe81613138565b9250608087013567ffffffffffffffff8082111561361b57600080fd5b6136278a838b016131e8565b935060a089013591508082111561363d57600080fd5b5061364a89828a016131e8565b9150509295509295509295565b6000806040838503121561366a57600080fd5b50508035926020909101359150565b60008060006040848603121561368e57600080fd5b833561369981613138565b9250602084013567ffffffffffffffff8111156136b557600080fd5b6136c18682870161337b565b9497909650939450505050565b600080604083850312156136e157600080fd5b82356136ec81613138565b9150602083013561332f81613138565b60006020828403121561370e57600080fd5b5051919050565b6000806040838503121561372857600080fd5b82519150602083015161332f81613138565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156137a1576137a161373a565b500290565b6000826137dc577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000828210156137f3576137f361373a565b500390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156138595761385961373a565b5060010190565b600082198211156138735761387361373a565b500190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b600080858511156138b757600080fd5b838611156138c457600080fd5b5050600583901b0193919092039150565b801515811461127857600080fd5b6000602082840312156138f557600080fd5b813561104a816138d5565b6000608082016001600160a01b03808816845260208188168186015260806040860152829150865180845260a086019250818801935060005b8181101561395557845184529382019392820192600101613939565b5050506060939093019390935250949350505050565b60006020828403121561397d57600080fd5b815161104a816138d5565b60005b838110156139a357818101518382015260200161398b565b83811115611ca25750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516139ec816017850160208801613988565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613a29816028840160208801613988565b01602801949350505050565b6020815260008251806020840152613a54816040850160208701613988565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b600081613a9557613a9561373a565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b60008251613acd818460208701613988565b919091019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212204311e4925e3d8403870822ada9780a006204be47bd3ec10f5b61950c72a840d664736f6c63430008090033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.