Skip to main content

VettedGate

VettedGate.sol is a supplementary contract that enables Node Operator creation for the vetted addresses, which serves as an entry point to CSModule.sol. Alongside Node Operator creation, a contract can assign a custom Node Operator type (bondCurveId) in CSAccounting.sol. Deployed using VettedGateFactory.sol to allow plugging of the new instances later without additional code security audits. The list of the vetted participants is upgradable for each instance of the VettedGate.sol individually.

Upgradability

The contract uses OssifiableProxy for upgradability.

State Variables

PAUSE_ROLE

bytes32 public constant PAUSE_ROLE = keccak256("PAUSE_ROLE");

RESUME_ROLE

bytes32 public constant RESUME_ROLE = keccak256("RESUME_ROLE");

RECOVERER_ROLE

bytes32 public constant RECOVERER_ROLE = keccak256("RECOVERER_ROLE");

SET_TREE_ROLE

bytes32 public constant SET_TREE_ROLE = keccak256("SET_TREE_ROLE");

START_REFERRAL_SEASON_ROLE

bytes32 public constant START_REFERRAL_SEASON_ROLE = keccak256("START_REFERRAL_SEASON_ROLE");

END_REFERRAL_SEASON_ROLE

bytes32 public constant END_REFERRAL_SEASON_ROLE = keccak256("END_REFERRAL_SEASON_ROLE");

MODULE

Address of the Staking Module

ICSModule public immutable MODULE;

ACCOUNTING

Address of the CS Accounting

ICSAccounting public immutable ACCOUNTING;

curveId

Id of the bond curve to be assigned for the eligible members

uint256 public curveId;

treeRoot

Root of the eligible members Merkle Tree

bytes32 public treeRoot;

treeCid

CID of the eligible members Merkle Tree

string public treeCid;

isReferralProgramSeasonActive

Optional referral program ///

bool public isReferralProgramSeasonActive;

referralProgramSeasonNumber

uint256 public referralProgramSeasonNumber;

referralCurveId

Id of the bond curve for referral program

uint256 public referralCurveId;

referralsThreshold

Number of referrals required for bond curve claim

uint256 public referralsThreshold;

Functions

resume

Resume the contract

function resume() external onlyRole(RESUME_ROLE);

pauseFor

Pause the contract for a given duration Pausing the contract prevent creating new node operators using VettedGate and claiming beneficial curve for the existing ones

function pauseFor(uint256 duration) external onlyRole(PAUSE_ROLE);

Parameters

NameTypeDescription
durationuint256Duration of the pause

startNewReferralProgramSeason

Start referral program season

function startNewReferralProgramSeason(uint256 _referralCurveId, uint256 _referralsThreshold)
external
onlyRole(START_REFERRAL_SEASON_ROLE)
returns (uint256 season);

Parameters

NameTypeDescription
_referralCurveIduint256Curve Id for the referral curve
_referralsThresholduint256Minimum number of referrals to be eligible to claim the curve

Returns

NameTypeDescription
seasonuint256Id of the started season

endCurrentReferralProgramSeason

End referral program season

function endCurrentReferralProgramSeason() external onlyRole(END_REFERRAL_SEASON_ROLE);

addNodeOperatorETH

Add a new Node Operator using ETH as a bond. At least one deposit data and corresponding bond should be provided

function addNodeOperatorETH(
uint256 keysCount,
bytes calldata publicKeys,
bytes calldata signatures,
NodeOperatorManagementProperties calldata managementProperties,
bytes32[] calldata proof,
address referrer
) external payable whenResumed returns (uint256 nodeOperatorId);

Parameters

NameTypeDescription
keysCountuint256Signing keys count
publicKeysbytesPublic keys to submit
signaturesbytesSignatures of (deposit_message_root, domain) tuples https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#signingdata
managementPropertiesNodeOperatorManagementPropertiesOptional. Management properties to be used for the Node Operator. managerAddress: Used as managerAddress for the Node Operator. If not passed msg.sender will be used. rewardAddress: Used as rewardAddress for the Node Operator. If not passed msg.sender will be used. extendedManagerPermissions: Flag indicating that managerAddress will be able to change rewardAddress. If set to true resetNodeOperatorManagerAddress method will be disabled
proofbytes32[]Merkle proof of the sender being eligible to join via the gate
referreraddressOptional. Referrer address. Should be passed when Node Operator is created using partners integration

Returns

NameTypeDescription
nodeOperatorIduint256Id of the created Node Operator

addNodeOperatorStETH

Add a new Node Operator using stETH as a bond. At least one deposit data and corresponding bond should be provided

function addNodeOperatorStETH(
uint256 keysCount,
bytes calldata publicKeys,
bytes calldata signatures,
NodeOperatorManagementProperties calldata managementProperties,
ICSAccounting.PermitInput calldata permit,
bytes32[] calldata proof,
address referrer
) external whenResumed returns (uint256 nodeOperatorId);

Parameters

NameTypeDescription
keysCountuint256Signing keys count
publicKeysbytesPublic keys to submit
signaturesbytesSignatures of (deposit_message_root, domain) tuples https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#signingdata
managementPropertiesNodeOperatorManagementPropertiesOptional. Management properties to be used for the Node Operator. managerAddress: Used as managerAddress for the Node Operator. If not passed msg.sender will be used. rewardAddress: Used as rewardAddress for the Node Operator. If not passed msg.sender will be used. extendedManagerPermissions: Flag indicating that managerAddress will be able to change rewardAddress. If set to true resetNodeOperatorManagerAddress method will be disabled
permitICSAccounting.PermitInputOptional. Permit to use stETH as bond
proofbytes32[]Merkle proof of the sender being eligible to join via the gate
referreraddressOptional. Referrer address. Should be passed when Node Operator is created using partners integration

Returns

NameTypeDescription
nodeOperatorIduint256Id of the created Node Operator

addNodeOperatorWstETH

Add a new Node Operator using wstETH as a bond. At least one deposit data and corresponding bond should be provided

function addNodeOperatorWstETH(
uint256 keysCount,
bytes calldata publicKeys,
bytes calldata signatures,
NodeOperatorManagementProperties calldata managementProperties,
ICSAccounting.PermitInput calldata permit,
bytes32[] calldata proof,
address referrer
) external whenResumed returns (uint256 nodeOperatorId);

Parameters

NameTypeDescription
keysCountuint256Signing keys count
publicKeysbytesPublic keys to submit
signaturesbytesSignatures of (deposit_message_root, domain) tuples https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#signingdata
managementPropertiesNodeOperatorManagementPropertiesOptional. Management properties to be used for the Node Operator. managerAddress: Used as managerAddress for the Node Operator. If not passed msg.sender will be used. rewardAddress: Used as rewardAddress for the Node Operator. If not passed msg.sender will be used. extendedManagerPermissions: Flag indicating that managerAddress will be able to change rewardAddress. If set to true resetNodeOperatorManagerAddress method will be disabled
permitICSAccounting.PermitInputOptional. Permit to use wstETH as bond
proofbytes32[]Merkle proof of the sender being eligible to join via the gate
referreraddressOptional. Referrer address. Should be passed when Node Operator is created using partners integration

Returns

NameTypeDescription
nodeOperatorIduint256Id of the created Node Operator

claimBondCurve

Claim the bond curve for the eligible Node Operator

Should be called by the reward address of the Node Operator In case of the extended manager permissions, should be called by the manager address

function claimBondCurve(uint256 nodeOperatorId, bytes32[] calldata proof) external whenResumed;

Parameters

NameTypeDescription
nodeOperatorIduint256Id of the Node Operator
proofbytes32[]Merkle proof of the sender being eligible to join via the gate

claimReferrerBondCurve

Claim the referral program bond curve for the eligible Node Operator

function claimReferrerBondCurve(uint256 nodeOperatorId, bytes32[] calldata proof) external whenResumed;

Parameters

NameTypeDescription
nodeOperatorIduint256Id of the Node Operator
proofbytes32[]Merkle proof of the sender being eligible to join via the gate

setTreeParams

Set the root of the eligible members Merkle Tree

function setTreeParams(bytes32 _treeRoot, string calldata _treeCid) external onlyRole(SET_TREE_ROLE);

Parameters

NameTypeDescription
_treeRootbytes32New root of the Merkle Tree
_treeCidstringNew CID of the Merkle Tree

getReferralsCount

Get the number of referrals for the given referrer in the current or last season

function getReferralsCount(address referrer) external view returns (uint256);

Parameters

NameTypeDescription
referreraddressReferrer address

Returns

NameTypeDescription
<none>uint256Number of referrals for the given referrer in the current or last season

getReferralsCount

Get the number of referrals for the given referrer in the current or last season

function getReferralsCount(address referrer, uint256 season) external view returns (uint256);

Parameters

NameTypeDescription
referreraddressReferrer address
seasonuint256

Returns

NameTypeDescription
<none>uint256Number of referrals for the given referrer in the current or last season

getInitializedVersion

Returns the initialized version of the contract

function getInitializedVersion() external view returns (uint64);

isReferrerConsumed

Check if the address has already consumed referral program bond curve

function isReferrerConsumed(address referrer) external view returns (bool);

Parameters

NameTypeDescription
referreraddressAddress to check

Returns

NameTypeDescription
<none>boolConsumed flag

isConsumed

Check if the address has already consumed the curve

function isConsumed(address member) public view returns (bool);

Parameters

NameTypeDescription
memberaddressAddress to check

Returns

NameTypeDescription
<none>boolConsumed flag

verifyProof

Check is the address is eligible to consume beneficial curve

function verifyProof(address member, bytes32[] calldata proof) public view returns (bool);

Parameters

NameTypeDescription
memberaddressAddress to check
proofbytes32[]Merkle proof of the beneficial curve eligibility

Returns

NameTypeDescription
<none>boolBoolean flag if the proof is valid or not

hashLeaf

Get a hash of a leaf in the Merkle tree

Double hash the leaf to prevent second preimage attacks

function hashLeaf(address member) public pure returns (bytes32);

Parameters

NameTypeDescription
memberaddresseligible member address

Returns

NameTypeDescription
<none>bytes32Hash of the leaf

Events

TreeSet

event TreeSet(bytes32 indexed treeRoot, string treeCid);

Consumed

event Consumed(address indexed member);

ReferrerConsumed

event ReferrerConsumed(address indexed referrer, uint256 indexed season);

ReferralProgramSeasonStarted

event ReferralProgramSeasonStarted(uint256 indexed season, uint256 referralCurveId, uint256 referralsThreshold);

ReferralProgramSeasonEnded

event ReferralProgramSeasonEnded(uint256 indexed season);

ReferralRecorded

event ReferralRecorded(address indexed referrer, uint256 indexed season, uint256 indexed referralNodeOperatorId);