Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions docs/based-applications/developers/BA-SDK/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,17 @@ const walletClient = createWalletClient({
transport,
})

const sdk = new BasedAppsSDK({
beaconchainUrl: 'https://example.com/beacon',
publicClient,
walletClient,
extendedConfig: {
subgraph: {
apiKey: "<YOUR_SUBGRAPH_API_KEY>"
const sdk = new SSVSDK({
publicClient: publicClient as any,
walletClient: walletClient as any,
beaconchainUrl: 'https://example.com/beacon',
extendedConfig: {
subgraph: {
apiKey: process.env.SUBGRAPH_API,
endpoint: process.env.SUBGRAPH_ENDPOINT,
}
}
}
})
})

async function main(): Promise<void> {

Expand Down
23 changes: 18 additions & 5 deletions docs/developers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,15 @@ const walletClient = createWalletClient({

// Initialize SDK with viem clients
const sdk = new SSVSDK({
publicClient,
walletClient,
})
publicClient: publicClient as any,
walletClient: walletClient as any,
extendedConfig: {
subgraph: {
apiKey: process.env.SUBGRAPH_API,
endpoint: process.env.SUBGRAPH_ENDPOINT,
}
}
});
```

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

// Initialize SDK with viem clients
const sdk = new SSVSDK({
publicClient,
walletClient,
publicClient: publicClient as any,
walletClient: walletClient as any,
extendedConfig: {
subgraph: {
apiKey: process.env.SUBGRAPH_API,
endpoint: process.env.SUBGRAPH_ENDPOINT,
}
}
})


const directoryPath = process.env.KEYSTORE_FILE_DIRECTORY;
let keystoresArray: { name: string; keystore: any }[];
try {
Expand Down
29 changes: 19 additions & 10 deletions docs/developers/SSV-SDK/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ To install the SDK, run:
npm i @ssv-labs/ssv-sdk
```

:::info ⚠️ Testnet Version ⚠️
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:
```bash
npm i --force --ignore-scripts github:ssvlabs/ssv-sdk#v.1.0.0
```
:::

## Initialization

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.
Expand Down Expand Up @@ -52,25 +59,27 @@ const walletClient = createWalletClient({

// Initialize SDK with viem clients
const sdk = new SSVSDK({
publicClient,
walletClient,
extendedConfig: {
subgraph: {
apiKey: "<YOUR_SUBGRAPH_API_KEY>"
publicClient: publicClient as any,
walletClient: walletClient as any,
extendedConfig: {
subgraph: {
apiKey: process.env.SUBGRAPH_API,
endpoint: process.env.SUBGRAPH_ENDPOINT,
}
}
}
})
});
```

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](../tools/ssv-subgraph/README.md).
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).

### Initialization Parameters

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

## Usage

Expand Down
2 changes: 1 addition & 1 deletion docs/developers/SSV-SDK/module-reference/api-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const clusterID = createClusterId(ownerAddress, operatorIds)
Example output:

```bash
1179fed483c8c1b0327c8667521162015fa8cbe1a1b047a26baf0f0971a81929
0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8
```

### `getClusterBalance(clusterId, daoAddress, operatorIds)`
Expand Down
28 changes: 14 additions & 14 deletions docs/developers/SSV-SDK/module-reference/cluster-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ Converts an SSV-based cluster (legacy) to ETH-based cluster. Accepts cluster ID

| Input parameter | Input type | Description | Example input |
|----------------|------------|-------------|---------------|
| `cluster_Id` | string | A `cluster_id` in its computed ID form. | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
| cluster_Id | string | A cluster_id in its computed ID form. Has to have the **owner address in lowercase 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 |
| amount | bigint | Amount of ETH to deposit to fund the cluster | 0.1234 |

#### Example:

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

| Input parameter | Input type | Description | Example input |
|----------------|------------|-------------|---------------|
| id | string | Cluster ID | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
| id | string | A cluster id in its computed ID form. Has to have the **owner address in lowercase 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 |
| amount | bigint | Amount of ETH to deposit to cluster | 0.1234 |

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

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

| Input parameter | Input type | Description | Example input |
|----------------|------------|-------------|---------------|
| id | string | Cluster ID | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
| id | string | A cluster id in its computed ID form. Has to have the **owner address in lowercase 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 |

#### Example:

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

| Input parameter | Input type | Description | Example input |
|----------------|------------|-------------|---------------|
| id | string | Cluster ID | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
| id | string | A cluster id in its computed ID form. Has to have the **owner address in lowercase 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 |

#### Example:

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

| Input parameter | Input type | Description | Example input |
|----------------|------------|-------------|---------------|
| id | string | Cluster ID | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
| id | string | A cluster id in its computed ID form. Has to have the **owner address in lowercase 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 |
| amount | bigint | Amount of ETH to withdraw from the cluster | 0.1234 |

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

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

| Input parameter | Input type | Description | Example input |
|----------------|------------|-------------|---------------|
| id | string | Cluster ID | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
| id | string | A cluster id in its computed ID form. Has to have the **owner address in lowercase 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 |
| amount | bigint | Amount of ETH to deposit to cluster | 0.1234 |

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

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

| Input parameter | Input type | Description | Example input |
|----------------|------------|-------------|---------------|
| id | string | Cluster ID | 0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8 |
| id | string | A cluster id in its computed ID form. Has to have the **owner address in lowercase 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 |
| publicKeys | Hex[] | Array of validator public keys to remove | ["0x820fd0519c75f74c8be9f21f185406919721dad0c624464538e2eaa323d77d3eb3ef27a039e8779de6cfa649a5484e86", "0x820fd0519c75f74c8be9f21f185406919721dad0c624464538e2eaa323d77d3eb3ef27a039e8779de6cfa649a5484e87"] |

#### Example:

```typescript
txn_receipt = await sdk.clusters.removeValidators({
args: {
id: "0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8",
id: "0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8",
publicKeys: ["0x820fd0519c75f74c8be9f21f185406919721dad0c624464538e2eaa323d77d3eb3ef27a039e8779de6cfa649a5484e86", "0x820fd0519c75f74c8be9f21f185406919721dad0c624464538e2eaa323d77d3eb3ef27a039e8779de6cfa649a5484e87"],
},
}).then(tx => tx.wait())
Expand Down
8 changes: 4 additions & 4 deletions docs/developers/SSV-SDK/module-reference/utils-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ Accepts a cluster ID to identify the cluster, for which the balance needs to be

| Input parameter | Input type | Description | Example input |
|----------------|------------|-------------|---------------|
| cluster_Id | string | A cluster_id in its computed ID form. | “0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8” |
| cluster_Id | string | A cluster_id in its computed ID form. Has to have the **owner address in lowercase 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” |

#### Example:

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

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

| Input parameter | Input type | Description | Example input |
|----------------|------------|-------------|---------------|
| cluster_Id | string | A cluster_id in its computed ID form. | “0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8” |
| cluster_Id | string | A cluster_id in its computed ID form. Has to have the **owner address in lowercase 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” |
| runway | number | Desired Runway length, measured in number of days. | 45 |


#### Example:

```typescript
const result = await sdk.utils.calcDepositFromRunway({
cluster_Id: “0xf69A08B652f0CEBb685c2fFE043cfB767b66544A-5-6-7-8”,
cluster_Id: “0xf69a08b652f0cebb685c2ffe043cfb767b66544a-5-6-7-8”,
runway: 45,
});
```
Expand Down
Loading