Skip to main content

NodesManager

Git Source ↗

Inherits: Ownable2StepUpgradeable ↗, EIP712Upgradeable ↗, UUPSUpgradeable ↗, ReentrancyGuardUpgradeable ↗, Multicall, INodesManager

State Variables

_validatorChangeClaimDelay

uint256 private constant _validatorChangeClaimDelay = 2

_wad

uint256 private constant _wad = 1e18

_maxPercent

uint256 private constant _maxPercent = 10_000

_validatorV2DepositLength

uint256 private constant _validatorV2DepositLength = 184

_signatureLength

uint256 private constant _signatureLength = 65

_fundValidatorsTypeHash

bytes32 private constant _fundValidatorsTypeHash =
keccak256("FundValidators(address operator,uint256 nonce,address vault,bytes validators)")

_registerValidatorsTypeHash

bytes32 private constant _registerValidatorsTypeHash =
keccak256("RegisterValidators(address operator,uint256 nonce,address vault,bytes validators)")

_updateStateTypeHash

bytes32 private constant _updateStateTypeHash =
keccak256("UpdateState(bytes32 stateRoot,string stateIpfsHash,uint64 updateTimestamp,uint256 nonce)")

_keeper

IKeeper private immutable _keeper

vault

The address of the vault the NodesManager is attached to

address public immutable override vault

operatorStates

mapping(address operator => OperatorState state) public override operatorStates

stateData

The state data of the nodes manager

StateData public override stateData

minDepositAssets

The minimum assets required for a deposit request

uint256 public override minDepositAssets

withdrawalsManager

The address of the withdrawals manager

address public override withdrawalsManager

minBalancePercent

The minimum balance percent in BPS (10000 = 100%)

uint16 public override minBalancePercent

operatorNonces

mapping(address operator => mapping(OperatorNonceType nonceType => uint256 nonce)) public override operatorNonces

pendingPenaltyAssets

mapping(address operator => uint256 penaltyAssets) public override pendingPenaltyAssets

validatorsManagers

mapping(address operator => address manager) public override validatorsManagers

_exitPositions

mapping(uint256 positionTicket => address operator) private _exitPositions

__gap

This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain. See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps

uint256[50] private __gap

Functions

onlyWithdrawalsManager

Modifier to restrict access to the withdrawals manager

modifier onlyWithdrawalsManager() ;

constructor

Constructor sets the immutables

constructor(address vault_, address keeper_) ;

Parameters

NameTypeDescription
vault_addressThe address of the vault
keeper_addressThe address of the Keeper contract

__NodesManager_init

Initializes the NodesManager contract

function __NodesManager_init(
address _owner,
uint256 _minDepositAssets,
uint16 _minBalancePercent,
uint256 _stateUpdateDelay
) internal onlyInitializing;

Parameters

NameTypeDescription
_owneraddressThe address of the contract owner
_minDepositAssetsuint256The minimum assets required for a deposit request
_minBalancePercentuint16The minimum balance percent in BPS
_stateUpdateDelayuint256The delay in seconds between state updates

setMinDepositAssets

Updates the minimum deposit assets. Can only be called by the owner.

function setMinDepositAssets(uint256 newMinDepositAssets) external override onlyOwner;

Parameters

NameTypeDescription
newMinDepositAssetsuint256The new minimum deposit assets

setMinBalancePercent

Updates the minimum balance percent. Can only be called by the owner.

function setMinBalancePercent(uint16 newMinBalancePercent) external override onlyOwner;

Parameters

NameTypeDescription
newMinBalancePercentuint16The new minimum balance percent

setWithdrawalsManager

Updates the withdrawals manager address. Can only be called by the owner.

function setWithdrawalsManager(address newWithdrawalsManager) external override onlyOwner;

Parameters

NameTypeDescription
newWithdrawalsManageraddressThe new withdrawals manager address

setValidatorsManager

Sets the validators manager address for the calling operator

function setValidatorsManager(address validatorsManager) external override;

Parameters

NameTypeDescription
validatorsManageraddressThe new validators manager address

canUpdateState

Checks whether state can be updated

function canUpdateState() external view override returns (bool);

Returns

NameTypeDescription
<none>booltrue if state can be updated, false otherwise

updateState

Update state data

function updateState(StateUpdateParams calldata params) external override;

Parameters

NameTypeDescription
paramsStateUpdateParamsThe struct containing state update parameters

setStateUpdateDelay

Updates the state update delay. Can only be called by the owner.

function setStateUpdateDelay(uint256 newStateUpdateDelay) external override onlyOwner;

Parameters

NameTypeDescription
newStateUpdateDelayuint256The new state update delay in seconds

updateVaultState

Updates the vault state by harvesting rewards

function updateVaultState(IKeeperRewards.HarvestParams calldata harvestParams) external override;

Parameters

NameTypeDescription
harvestParamsIKeeperRewards.HarvestParamsThe parameters for harvesting Keeper rewards

updateOperatorState

Updates the operator state by verifying a merkle proof against the current state root

function updateOperatorState(address operator, OperatorStateUpdateParams calldata params) external override;

Parameters

NameTypeDescription
operatoraddressThe address of the operator to update
paramsOperatorStateUpdateParamsThe parameters for updating the operator state

registerValidators

Registers validators with oracle-approved signatures. Can only be called by the operator's validators manager.

function registerValidators(
address operator,
IKeeperValidators.ApprovalParams calldata keeperParams,
bytes calldata signatures
) external override;

Parameters

NameTypeDescription
operatoraddressThe address of the operator
keeperParamsIKeeperValidators.ApprovalParamsThe keeper approval parameters containing validator data
signaturesbytesThe concatenation of the oracles' signatures

fundValidators

Funds validators with oracle-approved signatures. Can only be called by the operator's validators manager.

function fundValidators(address operator, bytes calldata validators, bytes calldata signatures) external override;

Parameters

NameTypeDescription
operatoraddressThe address of the operator
validatorsbytesThe concatenation of the validators' data
signaturesbytesThe concatenation of the oracles' signatures approving the funding

withdrawValidators

Submits validator withdrawals. Can only be called by the withdrawals manager.

function withdrawValidators(bytes calldata validators)
external
payable
override
nonReentrant
onlyWithdrawalsManager;

Parameters

NameTypeDescription
validatorsbytesThe concatenation of the validators' data

enterExitQueue

Enters the exit queue by locking operator shares in the vault's exit queue

function enterExitQueue(uint256 shares) external override nonReentrant returns (uint256 positionTicket);

Parameters

NameTypeDescription
sharesuint256The number of shares to lock in the exit queue

Returns

NameTypeDescription
positionTicketuint256The position ticket of the exit queue

claimExitedAssets

Claims exited assets from the vault's exit queue for the operator

function claimExitedAssets(uint256 positionTicket, uint256 timestamp, uint256 exitQueueIndex)
external
override
nonReentrant;

Parameters

NameTypeDescription
positionTicketuint256The exit queue ticket received after the enterExitQueue call
timestampuint256The timestamp when the shares entered the exit queue
exitQueueIndexuint256The exit queue index at which the shares were burned

_deposit

Internal function to deposit assets to the vault and update the operator's shares balance

function _deposit(uint256 assets) internal returns (uint256 addedShares);

Parameters

NameTypeDescription
assetsuint256The amount of assets to deposit

Returns

NameTypeDescription
addedSharesuint256The amount of shares received with penalty applied if any

_setMinDepositAssets

Internal function for updating the minimum deposit assets

function _setMinDepositAssets(uint256 newMinDepositAssets) private;

Parameters

NameTypeDescription
newMinDepositAssetsuint256The new minimum deposit assets

_setStateUpdateDelay

Internal function for updating the state update delay

function _setStateUpdateDelay(uint256 newStateUpdateDelay) private;

Parameters

NameTypeDescription
newStateUpdateDelayuint256The new state update delay in seconds

_setMinBalancePercent

Internal function for updating the minimum balance percent

function _setMinBalancePercent(uint16 newMinBalancePercent) private;

Parameters

NameTypeDescription
newMinBalancePercentuint16The new minimum balance percent

_useOperatorNonce

Returns the current nonce for an operator and nonce type, then increments it

function _useOperatorNonce(address operator, OperatorNonceType nonceType) private returns (uint256 nonce);

Parameters

NameTypeDescription
operatoraddressThe address of the operator
nonceTypeOperatorNonceTypeThe type of nonce to use

Returns

NameTypeDescription
nonceuint256The current nonce before incrementing

_verifySignatures

Verifies that oracles have approved the action by checking their signatures

function _verifySignatures(bytes32 digest, bytes calldata signatures) private view;

Parameters

NameTypeDescription
digestbytes32The EIP-712 typed data hash to verify signatures against
signaturesbytesThe concatenation of the oracles' signatures

_getValidatorsPublicKeys

Internal function to extract the validators' public keys from the concatenated validators data

function _getValidatorsPublicKeys(bytes calldata validators) internal pure returns (bytes memory publicKeys);

Parameters

NameTypeDescription
validatorsbytesThe concatenation of the validators' data

Returns

NameTypeDescription
publicKeysbytesThe concatenation of the validators' public keys extracted from the validators data

_authorizeUpgrade

Function that should revert when msg.sender is not authorized to upgrade the contract. Called by upgradeToAndCall. Normally, this function will use an access control modifier such as Ownable-onlyOwner.

function _authorizeUpgrade(address) internal onlyOwner {}
function _authorizeUpgrade(address) internal override onlyOwner;

_depositToVault

Deposits assets to the vault and returns the shares received. Must be implemented by network-specific contracts.

function _depositToVault(uint256 assets) internal virtual returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256The amount of assets to deposit

Returns

NameTypeDescription
sharesuint256The vault shares received

_transferAssets

Transfers assets to the receiver. Must be implemented by network-specific contracts.

function _transferAssets(address receiver, uint256 assets) internal virtual;

Parameters

NameTypeDescription
receiveraddressThe address to transfer assets to
assetsuint256The amount of assets to transfer

_donateAssets

Donates assets back to the vault. Must be implemented by network-specific contracts.

function _donateAssets(uint256 assets) internal virtual;

Parameters

NameTypeDescription
assetsuint256The amount of assets to donate