Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-vball committed Sep 18, 2024
1 parent 8a791c1 commit 13e210b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

22 changes: 16 additions & 6 deletions contracts/staking/PoSValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ abstract contract PoSValidatorManager is
IRewardCalculator _rewardCalculator;
/// @notice Maps the validation ID to its requirements.
mapping(bytes32 validationID => PoSValidatorRequirements) _validatorRequirements;
/// @notice Maps the delegationID to the delegator information.
/// @notice Maps the delegation ID to the delegator information.
mapping(bytes32 delegationID => Delegator) _delegatorStakes;
/// @notice Maps the delegationID to its pending staking rewards.
/// @notice Maps the delegation ID to its pending staking rewards.
mapping(bytes32 delegationID => uint256) _redeemableDelegatorRewards;
/// @notice Maps the validator owner address to its pending staking rewards.
/// @notice Maps the validation ID to its pending staking rewards.
mapping(bytes32 validationID => uint256) _redeemableValidatorRewards;
/// @notice Saves the uptime of a pending completed or completed validation period so that delegators can collect rewards.
mapping(bytes32 validationID => uint64) _completedValidationUptimeSeconds;
Expand Down Expand Up @@ -145,7 +145,11 @@ abstract contract PoSValidatorManager is

Validator memory validator = _initializeEndValidation(validationID);

// Check that minimum stake duration has passed
if (!_isPoSValidator(validationID)) {
return;
}

// Check that minimum stake duration has passed.
require(
validator.endedAt
>= validator.startedAt + $._validatorRequirements[validationID].minStakeDuration,
Expand Down Expand Up @@ -483,10 +487,16 @@ abstract contract PoSValidatorManager is
// Update the delegator status
$._delegatorStakes[delegationID].status = DelegatorStatus.Completed;

_reward(delegator.owner, $._redeemableDelegatorRewards[delegationID]);
uint256 rewards = $._redeemableDelegatorRewards[delegationID];
delete $._redeemableDelegatorRewards[delegationID];

uint256 validatorFees =
rewards * $._validatorRequirements[validationID].delegationFeeBips / 10000;
$._redeemableValidatorRewards[validationID] += validatorFees;

_reward(delegator.owner, rewards - validatorFees);
_unlock(delegator.owner, weightToValue(delegator.weight));
// TODO can we remove the delegation from _delegatorStakes here?
delete $._delegatorStakes[delegationID];

emit DelegationEnded(delegationID, validationID, nonce);
}
Expand Down

0 comments on commit 13e210b

Please sign in to comment.