@@ -21,7 +21,7 @@ import {StakeManagerStorage} from "./StakeManagerStorage.sol";
2121import {StakeManagerStorageExtension} from "./StakeManagerStorageExtension.sol " ;
2222import {IGovernance} from "../../common/governance/IGovernance.sol " ;
2323import {Initializable} from "../../common/mixin/Initializable.sol " ;
24- import {ValidatorAuction } from "./ValidatorAuction .sol " ;
24+ import {StakeManagerExtension } from "./StakeManagerExtension .sol " ;
2525
2626contract StakeManager is
2727 StakeManagerStorage ,
@@ -78,10 +78,10 @@ contract StakeManager is
7878 address _validatorShareFactory ,
7979 address _governance ,
8080 address _owner ,
81- address _auctionImplementation
81+ address _extensionCode
8282 ) external initializer {
83- require (isContract (_auctionImplementation ), "auction impl incorrect " );
84- auctionImplementation = _auctionImplementation ;
83+ require (isContract (_extensionCode ), "auction impl incorrect " );
84+ extensionCode = _extensionCode ;
8585 governance = IGovernance (_governance);
8686 registry = _registry;
8787 rootChain = _rootchain;
@@ -209,7 +209,7 @@ contract StakeManager is
209209 }
210210
211211 function updateCheckPointBlockInterval (uint256 _blocks ) public onlyGovernance {
212- require (_blocks != 0 , " incorrect value " );
212+ require (_blocks != 0 );
213213 checkPointBlockInterval = _blocks;
214214 }
215215
@@ -221,29 +221,31 @@ contract StakeManager is
221221
222222 function updateCheckpointRewardParams (
223223 uint256 _rewardDecreasePerCheckpoint ,
224- uint256 _maxSkippedCheckpoints ,
224+ uint256 _maxRewardedCheckpoints ,
225225 uint256 _checkpointRewardDelta
226226 ) public onlyGovernance {
227- require (_maxSkippedCheckpoints.mul (_rewardDecreasePerCheckpoint) <= CHK_REWARD_PRECISION);
228- require (_checkpointRewardDelta <= CHK_REWARD_PRECISION);
229-
230- rewardDecreasePerCheckpoint = _rewardDecreasePerCheckpoint;
231- maxSkippedCheckpoints = _maxSkippedCheckpoints;
232- checkpointRewardDelta = _checkpointRewardDelta;
227+ delegatedFwd (
228+ extensionCode,
229+ abi.encodeWithSelector (
230+ StakeManagerExtension (extensionCode).updateCheckpointRewardParams.selector ,
231+ _rewardDecreasePerCheckpoint,
232+ _maxRewardedCheckpoints,
233+ _checkpointRewardDelta
234+ )
235+ );
233236 }
234237
235238 // New implementation upgrade
236239
237240 function migrateValidatorsData (uint256 validatorIdFrom , uint256 validatorIdTo ) public onlyOwner {
238- for (uint256 i = validatorIdFrom; i < validatorIdTo; ++ i) {
239- ValidatorShare contractAddress = ValidatorShare (validators[i].contractAddress);
240- if (contractAddress != ValidatorShare (0 )) {
241- validators[i].delegatorsReward = contractAddress.validatorRewards_deprecated ().add (INITIALIZED_AMOUNT);
242- validators[i].delegatedAmount = contractAddress.activeAmount_deprecated ();
243- validators[i].commissionRate = contractAddress.commissionRate_deprecated ();
244- validators[i].reward = validators[i].reward.add (INITIALIZED_AMOUNT);
245- }
246- }
241+ delegatedFwd (
242+ extensionCode,
243+ abi.encodeWithSelector (
244+ StakeManagerExtension (extensionCode).migrateValidatorsData.selector ,
245+ validatorIdFrom,
246+ validatorIdTo
247+ )
248+ );
247249 }
248250
249251 function insertSigners (address [] memory _signers ) public onlyOwner {
@@ -254,7 +256,7 @@ contract StakeManager is
254256 @dev Users must exit before this update or all funds may get lost
255257 */
256258 function updateValidatorContractAddress (uint256 validatorId , address newContractAddress ) public onlyGovernance {
257- require (IValidatorShare (newContractAddress).owner () == address (this ), " Not stakeManager " );
259+ require (IValidatorShare (newContractAddress).owner () == address (this ));
258260 validators[validatorId].contractAddress = newContractAddress;
259261 }
260262
@@ -294,7 +296,7 @@ contract StakeManager is
294296 uint256 amount
295297 ) external onlyGovernance {
296298 address contractAddr = validators[validatorId].contractAddress;
297- require (contractAddr != address (0x0 ), " not validator " );
299+ require (contractAddr != address (0x0 ));
298300 IValidatorShare (contractAddr).drain (tokenAddr, destination, amount);
299301 }
300302
@@ -306,10 +308,10 @@ contract StakeManager is
306308 address _NFTContract ,
307309 address _stakingLogger ,
308310 address _validatorShareFactory ,
309- address _auctionImplementation
311+ address _extensionCode
310312 ) external onlyGovernance {
311- require (isContract (_auctionImplementation), " auction impl incorrect " );
312- auctionImplementation = _auctionImplementation ;
313+ require (isContract (_extensionCode) );
314+ extensionCode = _extensionCode ;
313315 NFTContract = StakingNFT (_NFTContract);
314316 logger = StakingInfo (_stakingLogger);
315317 validatorShareFactory = ValidatorShareFactory (_validatorShareFactory);
@@ -353,9 +355,9 @@ contract StakeManager is
353355 bytes calldata _signerPubkey
354356 ) external onlyWhenUnlocked {
355357 delegatedFwd (
356- auctionImplementation ,
358+ extensionCode ,
357359 abi.encodeWithSelector (
358- ValidatorAuction (auctionImplementation ).startAuction.selector ,
360+ StakeManagerExtension (extensionCode ).startAuction.selector ,
359361 validatorId,
360362 amount,
361363 _acceptDelegation,
@@ -369,9 +371,9 @@ contract StakeManager is
369371 uint256 heimdallFee /** for new validator */
370372 ) external onlyWhenUnlocked {
371373 delegatedFwd (
372- auctionImplementation ,
374+ extensionCode ,
373375 abi.encodeWithSelector (
374- ValidatorAuction (auctionImplementation ).confirmAuctionBid.selector ,
376+ StakeManagerExtension (extensionCode ).confirmAuctionBid.selector ,
375377 validatorId,
376378 heimdallFee,
377379 address (this )
@@ -397,7 +399,7 @@ contract StakeManager is
397399 }
398400
399401 function unstake (uint256 validatorId ) external onlyStaker (validatorId) {
400- require (validatorAuction[validatorId].amount == 0 , " Wait for auction completion " );
402+ require (validatorAuction[validatorId].amount == 0 );
401403
402404 Status status = validators[validatorId].status;
403405 require (
@@ -786,7 +788,7 @@ contract StakeManager is
786788 uint256 amount ,
787789 uint256 deactivationEpoch ,
788790 uint256 _currentEpoch
789- ) private view returns (bool ) {
791+ ) private pure returns (bool ) {
790792 return (amount > 0 && (deactivationEpoch == 0 || deactivationEpoch > _currentEpoch) && status == Status.Active);
791793 }
792794
@@ -819,7 +821,7 @@ contract StakeManager is
819821
820822 uint256 targetBlockInterval = checkPointBlockInterval;
821823 uint256 ckpReward = CHECKPOINT_REWARD;
822- uint256 fullIntervals = Math.min (blockInterval / targetBlockInterval, maxSkippedCheckpoints );
824+ uint256 fullIntervals = Math.min (blockInterval / targetBlockInterval, maxRewardedCheckpoints );
823825
824826 // only apply to full checkpoints
825827 if (fullIntervals > 0 && fullIntervals != prevBlockInterval) {
@@ -963,7 +965,7 @@ contract StakeManager is
963965 uint256 validatorStakePower ,
964966 uint256 currentRewardPerStake ,
965967 uint256 initialRewardPerStake
966- ) private returns (uint256 ) {
968+ ) private pure returns (uint256 ) {
967969 uint256 eligibleReward = currentRewardPerStake - initialRewardPerStake;
968970 return eligibleReward.mul (validatorStakePower).div (REWARD_PRECISION);
969971 }
0 commit comments