Skip to main content

Cluster Balance Calculation

The script below calculates the balance of a cluster on SSV Network. You can integrate it into your own monitoring or automation tools.

Details on the formulas used can be found in the documentation page related to Cluster Balance.

Prerequisites

Before using this example, make sure you have:

note

The ownerAddress parameter is optional if the SDK is initialized with a walletClient that includes an account address.

Calculate Cluster Balance

Use sdk.utils.getClusterBalance to retrieve the cluster balance and estimated operational runway.

try {
const { balance, operationalRunway } = await sdk.utils.getClusterBalance({
operatorIds: [1, 2, 3, 4],
ownerAddress: '0xA4831B989972605A62141a667578d742927Cbef9',
})
console.log('Cluster balance result:', {
balance: balance.toString(),
operationalRunway: operationalRunway.toString(),
});
} catch (error) {
console.error('Failed to get cluster balance:', error);
}