Skip to content

Commit

Permalink
Merge pull request #29 from lidofinance/set-reward-address
Browse files Browse the repository at this point in the history
CS-79 feat: set reward address
  • Loading branch information
skhomuti authored Oct 27, 2023
2 parents d2e0c25 + 0a9619f commit 8049c0d
Show file tree
Hide file tree
Showing 10 changed files with 465 additions and 304 deletions.
53 changes: 25 additions & 28 deletions src/CSAccounting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,11 @@ contract CSAccounting is CSAccountingBase, AccessControlEnumerable {
uint256 cumulativeFeeShares,
uint256 stETHAmount
) external {
address rewardAddress = _getNodeOperatorRewardAddress(nodeOperatorId);
_isSenderEligableToClaim(rewardAddress);
(
address managerAddress,
address rewardAddress
) = _getNodeOperatorAddresses(nodeOperatorId);
_isSenderEligibleToClaim(managerAddress);
uint256 claimableShares = _pullFeeRewards(
rewardsProof,
nodeOperatorId,
Expand Down Expand Up @@ -521,8 +524,11 @@ contract CSAccounting is CSAccountingBase, AccessControlEnumerable {
uint256 cumulativeFeeShares,
uint256 wstETHAmount
) external {
address rewardAddress = _getNodeOperatorRewardAddress(nodeOperatorId);
_isSenderEligableToClaim(rewardAddress);
(
address managerAddress,
address rewardAddress
) = _getNodeOperatorAddresses(nodeOperatorId);
_isSenderEligibleToClaim(managerAddress);
uint256 claimableShares = _pullFeeRewards(
rewardsProof,
nodeOperatorId,
Expand Down Expand Up @@ -572,33 +578,24 @@ contract CSAccounting is CSAccountingBase, AccessControlEnumerable {
function _getNodeOperatorActiveKeys(
uint256 nodeOperatorId
) internal view returns (uint256) {
(
,
,
,
,
,
uint256 totalWithdrawnValidators,
uint256 totalAddedValidators,

) = CSM.getNodeOperator({
_nodeOperatorId: nodeOperatorId,
_fullInfo: false
});
return totalAddedValidators - totalWithdrawnValidators;
}

function _getNodeOperatorRewardAddress(
ICSModule.NodeOperatorInfo memory nodeOperator = CSM.getNodeOperator(
nodeOperatorId
);
return
nodeOperator.totalAddedValidators -
nodeOperator.totalWithdrawnValidators;
}

function _getNodeOperatorAddresses(
uint256 nodeOperatorId
) internal view returns (address) {
(, , address rewardAddress, , , , , ) = CSM.getNodeOperator({
_nodeOperatorId: nodeOperatorId,
_fullInfo: false
});
return rewardAddress;
) internal view returns (address, address) {
ICSModule.NodeOperatorInfo memory nodeOperator = CSM.getNodeOperator(
nodeOperatorId
);
return (nodeOperator.managerAddress, nodeOperator.rewardAddress);
}

function _isSenderEligableToClaim(address rewardAddress) internal view {
function _isSenderEligibleToClaim(address rewardAddress) internal view {
if (msg.sender != rewardAddress) {
revert NotOwnerToClaim(msg.sender, rewardAddress);
}
Expand Down
Loading

0 comments on commit 8049c0d

Please sign in to comment.