Skip to content

Commit b93255e

Browse files
committed
SDK v1.0.0 and fixes
1 parent 68735e0 commit b93255e

6 files changed

Lines changed: 66 additions & 43 deletions

File tree

docs/based-applications/developers/BA-SDK/README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,17 @@ const walletClient = createWalletClient({
6363
transport,
6464
})
6565

66-
const sdk = new BasedAppsSDK({
67-
beaconchainUrl: 'https://example.com/beacon',
68-
publicClient,
69-
walletClient,
70-
extendedConfig: {
71-
subgraph: {
72-
apiKey: "<YOUR_SUBGRAPH_API_KEY>"
66+
const sdk = new SSVSDK({
67+
publicClient: publicClient as any,
68+
walletClient: walletClient as any,
69+
beaconchainUrl: 'https://example.com/beacon',
70+
extendedConfig: {
71+
subgraph: {
72+
apiKey: process.env.SUBGRAPH_API,
73+
endpoint: process.env.SUBGRAPH_ENDPOINT,
74+
}
7375
}
74-
}
75-
})
76+
})
7677

7778
async function main(): Promise<void> {
7879

docs/developers/README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,15 @@ const walletClient = createWalletClient({
8080

8181
// Initialize SDK with viem clients
8282
const sdk = new SSVSDK({
83-
publicClient,
84-
walletClient,
85-
})
83+
publicClient: publicClient as any,
84+
walletClient: walletClient as any,
85+
extendedConfig: {
86+
subgraph: {
87+
apiKey: process.env.SUBGRAPH_API,
88+
endpoint: process.env.SUBGRAPH_ENDPOINT,
89+
}
90+
}
91+
});
8692
```
8793

8894
### **2. Select operators and collect their data**
@@ -278,10 +284,17 @@ async function main(): Promise<void> {
278284

279285
// Initialize SDK with viem clients
280286
const sdk = new SSVSDK({
281-
publicClient,
282-
walletClient,
287+
publicClient: publicClient as any,
288+
walletClient: walletClient as any,
289+
extendedConfig: {
290+
subgraph: {
291+
apiKey: process.env.SUBGRAPH_API,
292+
endpoint: process.env.SUBGRAPH_ENDPOINT,
293+
}
294+
}
283295
})
284296

297+
285298
const directoryPath = process.env.KEYSTORE_FILE_DIRECTORY;
286299
let keystoresArray: { name: string; keystore: any }[];
287300
try {

docs/developers/SSV-SDK/README.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ To install the SDK, run:
2525
npm i @ssv-labs/ssv-sdk
2626
```
2727

28+
:::info ⚠️ Testnet Version ⚠️
29+
The latest Hoodi-compatible version was not released to npmjs. To install it, download it from [the github release](https://github.com/ssvlabs/ssv-sdk/releases/tag/v.1.0.0) or via the command below:
30+
```bash
31+
npm i --force --ignore-scripts github:ssvlabs/ssv-sdk#v.1.0.0
32+
```
33+
:::
34+
2835
## Initialization
2936

3037
The SDK requires specific parameters for initialization. Two that are not optional are the chain and the account. The `viem` library can be used to create an account object based off of a wallet's private key, and pass it into the SDK to instantiate it.
@@ -52,25 +59,27 @@ const walletClient = createWalletClient({
5259

5360
// Initialize SDK with viem clients
5461
const sdk = new SSVSDK({
55-
publicClient,
56-
walletClient,
57-
extendedConfig: {
58-
subgraph: {
59-
apiKey: "<YOUR_SUBGRAPH_API_KEY>"
62+
publicClient: publicClient as any,
63+
walletClient: walletClient as any,
64+
extendedConfig: {
65+
subgraph: {
66+
apiKey: process.env.SUBGRAPH_API,
67+
endpoint: process.env.SUBGRAPH_ENDPOINT,
68+
}
6069
}
61-
}
62-
})
70+
});
6371
```
6472

65-
The `extendedConfig` parameter is optional, if not provided, the SDK will use the development endpoint. Bear in mind that this is rate limited, though, so it is strongly advised to use an API key with the free plan.
66-
For more information regarding your subgraph API key, please refer to the [dedicated Subgraph page](../tools/ssv-subgraph/README.md).
73+
The `extendedConfig` parameter is optional, if not provided, the SDK will use the development endpoint. Bear in mind that this is rate limited, though, so it is strongly advised to use an API key with the free plan. For more information regarding your subgraph API key, please refer to the [dedicated Subgraph page](/developers/tools/ssv-subgraph/README.md).
6774

6875
### Initialization Parameters
6976

7077
| Input name | Input type | Optional |
7178
|------------|------------|----------|
72-
| public_client | [Viem public client](https://viem.sh/docs/clients/public.html) | No |
79+
| public_client | [Viem public client](https://viem.sh/docs/clients/public) | No |
7380
| wallet_client | [Viem wallet client](https://viem.sh/docs/clients/wallet) | No |
81+
| SUBGRAPH_API | API Key retrived from [The Graph account](https://thegraph.com/studio/apikeys/) | Yes, strongly recommended |
82+
| SUBGRAPH_ENDPOINT | Subgraph Endpoint retrieved from [Mainnet or Testnet subgraph page](/developers/tools/ssv-subgraph/#querying-ssv-protocol-smart-contract-data) | Yes, strongly recommended |
7483

7584
## Usage
7685

docs/developers/SSV-SDK/module-reference/api-module.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const clusterID = createClusterId(ownerAddress, operatorIds)
7575
Example output:
7676

7777
```bash
78-
1179fed483c8c1b0327c8667521162015fa8cbe1a1b047a26baf0f0971a81929
78+
0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8
7979
```
8080

8181
### `getClusterBalance(clusterId, daoAddress, operatorIds)`

docs/developers/SSV-SDK/module-reference/cluster-module.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ Converts an SSV-based cluster (legacy) to ETH-based cluster. Accepts cluster ID
1919

2020
| Input parameter | Input type | Description | Example input |
2121
|----------------|------------|-------------|---------------|
22-
| `cluster_Id` | string | A `cluster_id` in its computed ID form. | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
22+
| cluster_Id | string | A cluster_id in its computed ID form. Has to have the **owner address in lower case letters**. It is advised to use the [`createClusterID`](/developers/SSV-SDK/module-reference/api-module#getclusteridowner_address-operator_ids) function to get the cluster ID in the correct format | “0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8 |
2323
| amount | bigint | Amount of ETH to deposit to fund the cluster | 0.1234 |
2424

2525
#### Example:
2626

2727
```typescript
2828
txn_receipt = await sdk.clusters.migrateClusterToETH({
2929
args: {
30-
cluster_Id: "0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8",
30+
cluster_Id: "0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8",
3131
amount: parseEther('0.1234')
3232
},
3333
}).then(tx => tx.wait())
@@ -59,7 +59,7 @@ Executes the contract call to to deposit ETH to the cluster balance.
5959

6060
| Input parameter | Input type | Description | Example input |
6161
|----------------|------------|-------------|---------------|
62-
| id | string | Cluster ID | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
62+
| id | string | A cluster id in its computed ID form. Has to have the **owner address in lower case letters**. It is advised to use the [`createClusterID`](/developers/SSV-SDK/module-reference/api-module#getclusteridowner_address-operator_ids) function to get the cluster ID in the correct format | “0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8 |
6363
| amount | bigint | Amount of ETH to deposit to cluster | 0.1234 |
6464

6565
#### Example:
@@ -69,7 +69,7 @@ import { parseEther } from 'viem'
6969

7070
txn_receipt = await sdk.clusters.deposit({
7171
args: {
72-
id: "0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8",
72+
id: "0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8",
7373
amount: parseEther('0.1234')
7474
},
7575
}).then(tx => tx.wait())
@@ -81,14 +81,14 @@ Liquidates a cluster sends their balance to the msg.sender (the Liquidator). **W
8181

8282
| Input parameter | Input type | Description | Example input |
8383
|----------------|------------|-------------|---------------|
84-
| id | string | Cluster ID | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
84+
| id | string | A cluster id in its computed ID form. Has to have the **owner address in lower case letters**. It is advised to use the [`createClusterID`](/developers/SSV-SDK/module-reference/api-module#getclusteridowner_address-operator_ids) function to get the cluster ID in the correct format | “0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8 |
8585

8686
#### Example:
8787

8888
```typescript
8989
txn_receipt = await sdk.clusters.liquidateCluster({
9090
args: {
91-
id: "0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8",
91+
id: "0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8",
9292
},
9393
}).then(tx => tx.wait())
9494
```
@@ -99,14 +99,14 @@ Liquidates a legacy (SSV-based) cluster sends their balance to the msg.sender (t
9999

100100
| Input parameter | Input type | Description | Example input |
101101
|----------------|------------|-------------|---------------|
102-
| id | string | Cluster ID | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
102+
| id | string | A cluster id in its computed ID form. Has to have the **owner address in lower case letters**. It is advised to use the [`createClusterID`](/developers/SSV-SDK/module-reference/api-module#getclusteridowner_address-operator_ids) function to get the cluster ID in the correct format | “0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8 |
103103

104104
#### Example:
105105

106106
```typescript
107107
txn_receipt = await sdk.clusters.liquidateSSV({
108108
args: {
109-
id: "0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8",
109+
id: "0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8",
110110
},
111111
}).then(tx => tx.wait())
112112
```
@@ -122,7 +122,7 @@ Withdraw a specified amount of ETH from a cluster.
122122

123123
| Input parameter | Input type | Description | Example input |
124124
|----------------|------------|-------------|---------------|
125-
| id | string | Cluster ID | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
125+
| id | string | A cluster id in its computed ID form. Has to have the **owner address in lower case letters**. It is advised to use the [`createClusterID`](/developers/SSV-SDK/module-reference/api-module#getclusteridowner_address-operator_ids) function to get the cluster ID in the correct format | “0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8 |
126126
| amount | bigint | Amount of ETH to withdraw from the cluster | 0.1234 |
127127

128128
#### Example:
@@ -132,7 +132,7 @@ import { parseEther } from 'viem'
132132

133133
txn_receipt = await sdk.clusters.withdraw({
134134
args: {
135-
id: "0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8",
135+
id: "0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8",
136136
amount: parseEther('0.1234')
137137
},
138138
}).then(tx => tx.wait())
@@ -148,7 +148,7 @@ Reactivates a liquidated cluster.
148148

149149
| Input parameter | Input type | Description | Example input |
150150
|----------------|------------|-------------|---------------|
151-
| id | string | Cluster ID | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
151+
| id | string | A cluster id in its computed ID form. Has to have the **owner address in lower case letters**. It is advised to use the [`createClusterID`](/developers/SSV-SDK/module-reference/api-module#getclusteridowner_address-operator_ids) function to get the cluster ID in the correct format | “0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8 |
152152
| amount | bigint | Amount of ETH to deposit to cluster | 0.1234 |
153153

154154
#### Example:
@@ -158,7 +158,7 @@ import { parseEther } from 'viem'
158158

159159
txn_receipt = await sdk.clusters.reactivateCluster({
160160
args: {
161-
id: "0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8",
161+
id: "0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8",
162162
amount: parseEther('0.1234')
163163
},
164164
}).then(tx => tx.wait())
@@ -174,15 +174,15 @@ Accepts all parameters necessary to remove the validators. Removes all the valid
174174

175175
| Input parameter | Input type | Description | Example input |
176176
|----------------|------------|-------------|---------------|
177-
| id | string | Cluster ID | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
177+
| id | string | A cluster id in its computed ID form. Has to have the **owner address in lower case letters**. It is advised to use the [`createClusterID`](/developers/SSV-SDK/module-reference/api-module#getclusteridowner_address-operator_ids) function to get the cluster ID in the correct format | “0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8 |
178178
| publicKeys | Hex[] | Array of validator public keys to remove | ["0x820fd0519c75f74c8be9f21f185406919721dad0c624464538e2eaa323d77d3eb3ef27a039e8779de6cfa649a5484e86", "0x820fd0519c75f74c8be9f21f185406919721dad0c624464538e2eaa323d77d3eb3ef27a039e8779de6cfa649a5484e87"] |
179179

180180
#### Example:
181181

182182
```typescript
183183
txn_receipt = await sdk.clusters.removeValidators({
184184
args: {
185-
id: "0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8",
185+
id: "0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8",
186186
publicKeys: ["0x820fd0519c75f74c8be9f21f185406919721dad0c624464538e2eaa323d77d3eb3ef27a039e8779de6cfa649a5484e86", "0x820fd0519c75f74c8be9f21f185406919721dad0c624464538e2eaa323d77d3eb3ef27a039e8779de6cfa649a5484e87"],
187187
},
188188
}).then(tx => tx.wait())

docs/developers/SSV-SDK/module-reference/utils-module.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ Accepts a cluster ID to identify the cluster, for which the balance needs to be
177177

178178
| Input parameter | Input type | Description | Example input |
179179
|----------------|------------|-------------|---------------|
180-
| cluster_Id | string | A cluster_id in its computed ID form. |0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8” |
180+
| cluster_Id | string | A cluster_id in its computed ID form. Has to have the **owner address in lower case letters**. It is advised to use the [`createClusterID`](/developers/SSV-SDK/module-reference/api-module#getclusteridowner_address-operator_ids) function to get the cluster ID in the correct format |0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8” |
181181

182182
#### Example:
183183

184184
```typescript
185-
const result = await sdk.utils.getClusterBalance(“0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8”)
185+
const result = await sdk.utils.getClusterBalance(“0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8”)
186186
```
187187

188188
Example output:
@@ -202,15 +202,15 @@ The function fetches the cluster snapshot using the provided ID, calculate the B
202202

203203
| Input parameter | Input type | Description | Example input |
204204
|----------------|------------|-------------|---------------|
205-
| cluster_Id | string | A cluster_id in its computed ID form. |0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8” |
205+
| cluster_Id | string | A cluster_id in its computed ID form. Has to have the **owner address in lower case letters**. It is advised to use the [`createClusterID`](/developers/SSV-SDK/module-reference/api-module#getclusteridowner_address-operator_ids) function to get the cluster ID in the correct format |0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8” |
206206
| runway | number | Desired Runway length, measured in number of days. | 45 |
207207

208208

209209
#### Example:
210210

211211
```typescript
212212
const result = await sdk.utils.calcDepositFromRunway({
213-
cluster_Id: “0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8”,
213+
cluster_Id: “0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8”,
214214
runway: 45,
215215
});
216216
```

0 commit comments

Comments
 (0)