Skip to content

Latest commit

 

History

History
548 lines (454 loc) · 16.7 KB

File metadata and controls

548 lines (454 loc) · 16.7 KB

Staking Admin Module. (StakingAdminModule.sol)

View Source: contracts/governance/Staking/modules/StakingAdminModule.sol

↗ Extends: IFunctionsList, StakingShared

StakingAdminModule contract

Implements administrative functionality pause, freeze and setting addresses and parameters related to staking

Events

event AdminAdded(address  admin);
event AdminRemoved(address  admin);
event PauserAddedOrRemoved(address indexed pauser, bool indexed added);
event StakingPaused(bool indexed setPaused);
event StakingFrozen(bool indexed setFrozen);

Functions


addAdmin

Add account to Admins ACL.

function addAdmin(address _admin) external nonpayable onlyOwner whenNotFrozen 

Arguments

Name Type Description
_admin address The addresses of the account to grant permissions.
Source Code
function addAdmin(address _admin) external onlyOwner whenNotFrozen {
        require(_admin != address(0), "cannot add the zero address as an admin");
        admins[_admin] = true;
        emit AdminAdded(_admin);
    }

removeAdmin

Remove account from Admins ACL.

function removeAdmin(address _admin) external nonpayable onlyOwner whenNotFrozen 

Arguments

Name Type Description
_admin address The addresses of the account to revoke permissions.
Source Code
function removeAdmin(address _admin) external onlyOwner whenNotFrozen {
        require(admins[_admin], "address is not an admin");
        admins[_admin] = false;
        emit AdminRemoved(_admin);
    }

addPauser

Add account to pausers ACL.

function addPauser(address _pauser) external nonpayable onlyOwner whenNotFrozen 

Arguments

Name Type Description
_pauser address The address to grant pauser permissions.
Source Code
function addPauser(address _pauser) external onlyOwner whenNotFrozen {
        require(_pauser != address(0), "cannot add the zero address as a pauser");
        pausers[_pauser] = true;
        emit PauserAddedOrRemoved(_pauser, true);
    }

removePauser

Remove account from pausers ACL.

function removePauser(address _pauser) external nonpayable onlyOwner whenNotFrozen 

Arguments

Name Type Description
_pauser address The address to grant pauser permissions.
Source Code
function removePauser(address _pauser) external onlyOwner whenNotFrozen {
        require(pausers[_pauser], "address is not a pauser");
        delete pausers[_pauser];
        emit PauserAddedOrRemoved(_pauser, false);
    }

pauseUnpause

Pause/unpause contract

function pauseUnpause(bool _pause) public nonpayable onlyPauserOrOwner whenNotFrozen 

Arguments

Name Type Description
_pause bool true when pausing, false when unpausing
Source Code
function pauseUnpause(bool _pause) public onlyPauserOrOwner whenNotFrozen {
        paused = _pause;
        emit StakingPaused(_pause);
    }

freezeUnfreeze

Freeze contract - disable all functions

function freezeUnfreeze(bool _freeze) external nonpayable onlyPauserOrOwner 

Arguments

Name Type Description
_freeze bool true when freezing, false when unfreezing
Source Code
function freezeUnfreeze(bool _freeze) external onlyPauserOrOwner {
        require(_freeze != frozen, "Cannot freeze/unfreeze to the same state"); // WS25
        if (_freeze) pauseUnpause(true);
        frozen = _freeze;
        emit StakingFrozen(_freeze);
    }

setFeeSharing

Allow the owner to set a fee sharing proxy contract. We need it for unstaking with slashing.

function setFeeSharing(address _feeSharing) external nonpayable onlyOwner whenNotFrozen 

Arguments

Name Type Description
_feeSharing address The address of FeeSharingCollectorProxy contract.
Source Code
function setFeeSharing(address _feeSharing) external onlyOwner whenNotFrozen {
        require(_feeSharing != address(0), "FeeSharing address shouldn't be 0"); // S17
        feeSharing = IFeeSharingCollector(_feeSharing);
    }

setWeightScaling

Allow the owner to set weight scaling. We need it for unstaking with slashing.

function setWeightScaling(uint96 _weightScaling) external nonpayable onlyOwner whenNotFrozen 

Arguments

Name Type Description
_weightScaling uint96 The weight scaling.
Source Code
function setWeightScaling(uint96 _weightScaling) external onlyOwner whenNotFrozen {
        require(
            MIN_WEIGHT_SCALING <= _weightScaling && _weightScaling <= MAX_WEIGHT_SCALING,
            "scaling doesn't belong to range [1, 9]" // S18
        );
        weightScaling = _weightScaling;
    }

setNewStakingContract

Allow the owner to set a new staking contract. As a consequence it allows the stakers to migrate their positions to the new contract.

function setNewStakingContract(address _newStakingContract) external nonpayable onlyOwner whenNotFrozen 

Arguments

Name Type Description
_newStakingContract address The address of the new staking contract.
Source Code
function setNewStakingContract(address _newStakingContract) external onlyOwner whenNotFrozen {
        require(_newStakingContract != address(0), "can't reset the new staking contract to 0"); // S16
        newStakingContract = _newStakingContract;
    }

migrateToNewStakingContract

Allow a staker to migrate his positions to the new staking contract.

function migrateToNewStakingContract() external nonpayable whenNotFrozen 
Source Code
function migrateToNewStakingContract() external whenNotFrozen {
        require(newStakingContract != address(0), "there is no new staking contract set"); // S19
        revert("not implemented");
        /// @dev implementation:
        /// @dev Iterate over all possible lock dates from now until now + MAX_DURATION.
        /// @dev Read the stake & delegate of the msg.sender
        /// @dev If stake > 0, stake it at the new contract until the lock date with the current delegate.
    }

getFunctionsList

undefined

function getFunctionsList() external pure
returns(bytes4[])
Source Code
function getFunctionsList() external pure returns (bytes4[] memory) {
        bytes4[] memory functionsList = new bytes4[](13);
        functionsList[0] = this.addAdmin.selector;
        functionsList[1] = this.removeAdmin.selector;
        functionsList[2] = this.addPauser.selector;
        functionsList[3] = this.removePauser.selector;
        functionsList[4] = this.pauseUnpause.selector;
        functionsList[5] = this.freezeUnfreeze.selector;
        functionsList[6] = this.setFeeSharing.selector;
        functionsList[7] = this.setWeightScaling.selector;
        functionsList[8] = this.setNewStakingContract.selector;
        functionsList[9] = this.owner.selector;
        functionsList[10] = this.isOwner.selector;
        functionsList[11] = this.transferOwnership.selector;
        functionsList[12] = this.migrateToNewStakingContract.selector;
        return functionsList;
    }

Contracts