Skip to main content

Cluster Module

This is a library which contains all the cluster functions you need for working with SSV, such as registering a validator

After instantiating the SDK, you can call any of the functions in the utils library like so:

sdk.clusters.registerValidators()

Function List

registerValidators()

Accepts all parameters necessary to compute the keyshares, does this in the background using ssv-keys library, returns the keyshares as an object or saves it to file.

Input:

Input parameterInput typeDescriptionExample input
keysharesKeySharesItem[] | KeySharesPayload[]Keyshare or transaction payloadSee output of generateKeyShares()
depositAmountbigintAmount of SSV to deposit to cluster4

Example:

txn_receipt = await sdk.clusters.registerValidators({ 
args: {
keyshares: keysharesPayload,
depositAmount: parseEther('30')
},
}).then(tx => tx.wait())

deposit()

Executes the contract call to the SSV smart contract to deposit SSV to the cluster.

Input:

Input parameterInput typeDescriptionExample input
idstringCluster IDee8881d3c979203025996773ef8a13cb4aac57076e22638dd6ed9b17adcdabfc
amountbigintAmount of SSV to deposit to cluster4
approveboolWhether to execute out the SSV ERC20 approve transaction or nottrue

Example:

import { parseEther } from 'viem'

txn_receipt = await sdk.clusters.deposit({
args: {
id: "ee8881d3c979203025996773ef8a13cb4aac57076e22638dd6ed9b17adcdabfc",
amount: parseEther('30')
},
{
approve: true, // Automatically triggers token approval transaction if the allowance is lower than the deposit amount
},
}).then(tx => tx.wait())

liquidateCluster()

Liquidates a cluster sends their balances to the msg.sender (the Liquidator), will fail if the cluster is not liquidatable.

Input:

Input parameterInput typeDescriptionExample input
idstringCluster IDee8881d3c979203025996773ef8a13cb4aac57076e22638dd6ed9b17adcdabfc

Example:

txn_receipt = await sdk.clusters.liquidateCluster({ 
args: {
id: "ee8881d3c979203025996773ef8a13cb4aac57076e22638dd6ed9b17adcdabfc",
},
}).then(tx => tx.wait())

withdraw()

Withdraw a specified amount of SSV from a cluster.

Input:

Input parameterInput typeDescriptionExample input
idstringCluster IDee8881d3c979203025996773ef8a13cb4aac57076e22638dd6ed9b17adcdabfc
amountbigintAmount of SSV to withdraw to cluster4

Example:

import { parseEther } from 'viem'

txn_receipt = await sdk.clusters.withdraw({
args: {
id: "ee8881d3c979203025996773ef8a13cb4aac57076e22638dd6ed9b17adcdabfc",
amount: parseEther('30')
},
}).then(tx => tx.wait())

reactivateCluster()

Reactivates a liquidated cluster, will fail if insufficient SSV tokens to cover the cluster's liquidation collateral have been deposited.

Input:

Input parameterInput typeDescriptionExample input
idstringCluster IDee8881d3c979203025996773ef8a13cb4aac57076e22638dd6ed9b17adcdabfc
amountbigintAmount of SSV to withdraw to cluster4

Example input:

import { parseEther } from 'viem'

txn_receipt = await sdk.clusters.reactivateCluster({
args: {
id: "ee8881d3c979203025996773ef8a13cb4aac57076e22638dd6ed9b17adcdabfc",
amount: parseEther('30')
},
}).then(tx => tx.wait())

removeValidators()

Accepts all parameters necessary to compute the keyshares, does this in the background using ssv-keys library, returns the keyshares as an object or saves it to file.

Input:

Input parameterInput typeDescriptionExample input
idstringCluster IDee8881d3c979203025996773ef8a13cb4aac57076e22638dd6ed9b17adcdabfc
publicKeysHex[]Array of validator public keys to remove["0x820fd0519c75f74c8be9f21f185406919721dad0c624464538e2eaa323d77d3eb3ef27a039e8779de6cfa649a5484e86", "0x820fd0519c75f74c8be9f21f185406919721dad0c624464538e2eaa323d77d3eb3ef27a039e8779de6cfa649a5484e87"]

Example:

txn_receipt = await sdk.clusters.removeValidators({ 
args: {
id: "ee8881d3c979203025996773ef8a13cb4aac57076e22638dd6ed9b17adcdabfc",
depositAmount: ["0x820fd0519c75f74c8be9f21f185406919721dad0c624464538e2eaa323d77d3eb3ef27a039e8779de6cfa649a5484e86", "0x820fd0519c75f74c8be9f21f185406919721dad0c624464538e2eaa323d77d3eb3ef27a039e8779de6cfa649a5484e87"],
},
}).then(tx => tx.wait())

setFeeRecipient()

Sets a fee recipient address to receive tips from user transactions (part block proposal rewards). This address will be set for all the account's validators (all clusters).

Input:

Input parameterInput typeDescriptionExample input
recipientAddressValid Ethereum address0xA4831B989972605A62141a667578d742927Cbef9

Example:

txn_receipt = await sdk.clusters.setFeeRecipient({ 
args: {
recipient: "0xA4831B989972605A62141a667578d742927Cbef9",
},
}).then(tx => tx.wait())

exitValidators()

Prompts SSV nodes to sign a voluntary exit of the validator.

Input:

Input parameterInput typeDescriptionExample input
publicKeysHex[]Public keys of the validators to be exited["0xA4831B989972605A62141a667578d742927Cbef9","0xA4831B989972605A62141a667578d742927Cbef8"]
operatorIdsbigint[]IDs of the operators[1,2,3,4]

Example input:

txn_receipt = await sdk.clusters.exitValidators({ 
args: {
publicKeys: ["0xA4831B989972605A62141a667578d742927Cbef9","0xA4831B989972605A62141a667578d742927Cbef8"],
operatorIds: [1,2,3,4]
},
}).then(tx => tx.wait())

validateSharesPostRegistration()

Accepts a transaction hash of the validator registration contract call.

Input:

Input parameterInput typeDescriptionExample input
txHashHexHash of the register validator transaction"0xd9095893dba18b101c01973069922db2d81c45e814003851ccc586d60ae28e5b"

Example input:

const result = await validateSharesPostRegistration( { txHash: '0x123' as Hex })

Example output:

{
isValid,
validations,
invalids,
ownerNonceAtBlock: Number(ownerNonce),
block: Number(receipt.blockNumber)
}