@ssv-labs/ssv-sdk 0.1.3 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.html +4 -7
- package/README.md +56 -29
- package/dist/{KeyShares-B_4l2THg.js → KeyShares-Bk9uzOlK.js} +194 -51
- package/dist/{KeyShares-ClzHwMUy.mjs → KeyShares-Dlp4Pa3b.mjs} +198 -55
- package/dist/abi/mainnet/v4/getter.d.ts +699 -74
- package/dist/abi/mainnet/v4/setter.d.ts +939 -59
- package/dist/api/subgraph/index.d.ts +50 -48
- package/dist/config/create.d.ts +2 -2
- package/dist/config/globals.d.ts +3 -0
- package/dist/{globals-CDOcDUnk.mjs → config-BdEJjnYA.mjs} +107 -79
- package/dist/{globals-DsaKgq3v.js → config-ClGS9Tic.js} +73 -45
- package/dist/contract-interactions/create.d.ts +1 -1
- package/dist/contract-interactions/types.d.ts +9 -3
- package/dist/graphql/graphql.d.ts +4799 -921
- package/dist/keys.js +1 -1
- package/dist/keys.mjs +5 -5
- package/dist/libs/api/index.d.ts +1 -0
- package/dist/libs/cluster/index.d.ts +3 -1
- package/dist/libs/cluster/methods/deposit.d.ts +150 -4
- package/dist/libs/cluster/methods/exit-validators.d.ts +149 -0
- package/dist/libs/cluster/methods/index.d.ts +3 -1
- package/dist/libs/cluster/methods/liquidate-cluster.d.ts +149 -0
- package/dist/libs/cluster/methods/liquidate-ssv.d.ts +430 -0
- package/dist/libs/cluster/methods/migrate-cluster-to-eth.d.ts +431 -0
- package/dist/libs/cluster/methods/reactivate-cluster.d.ts +149 -0
- package/dist/libs/cluster/methods/register-validators.d.ts +2222 -309
- package/dist/libs/cluster/methods/remove-validators.d.ts +149 -0
- package/dist/libs/cluster/methods/set-fee-recipient.d.ts +149 -0
- package/dist/libs/cluster/methods/withdraw.d.ts +149 -0
- package/dist/libs/dao/index.d.ts +8 -0
- package/dist/libs/dao/methods/commit-root.d.ts +432 -0
- package/dist/libs/dao/methods/index.d.ts +3 -0
- package/dist/libs/dao/methods/update-network-fee-ssv.d.ts +430 -0
- package/dist/libs/dao/methods/withdraw-network-ssv-earnings.d.ts +430 -0
- package/dist/libs/operator/index.d.ts +1525 -32
- package/dist/libs/operator/methods.d.ts +1732 -3
- package/dist/libs/ssv-keys/Encryption/__test__/RsaKeys.d.ts +1 -1
- package/dist/libs/ssv-keys/KeyShares/KeySharesItem.d.ts +1 -1
- package/dist/libs/ssv-keys/SSVKeys.d.ts +1 -1
- package/dist/libs/ssv-keys/exceptions/index.d.ts +1 -1
- package/dist/libs/ssv-keys/index.d.ts +1 -1
- package/dist/libs/ssv-keys/interfaces/index.d.ts +2 -2
- package/dist/libs/utils/index.d.ts +8 -4
- package/dist/libs/utils/methods/calc-deposit-from-runway.d.ts +11 -0
- package/dist/libs/utils/methods/get-cluster-balance.d.ts +4 -1
- package/dist/libs/utils/methods/index.d.ts +1 -0
- package/dist/libs/utils/methods/keyshares.d.ts +4 -2
- package/dist/libs/utils/methods/keystores.d.ts +4 -4
- package/dist/libs/utils/methods/write-keyshares-file.d.ts +16 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +2970 -733
- package/dist/main.mjs +2961 -746
- package/dist/sdk.d.ts +8 -4
- package/dist/types/contract-interactions.d.ts +11 -0
- package/dist/types/methods.d.ts +4 -3
- package/dist/utils/cluster.d.ts +3 -3
- package/dist/utils/funding.d.ts +29 -0
- package/dist/utils/zod/config.d.ts +1 -1
- package/dist/utils.js +38 -38
- package/dist/utils.mjs +34 -34
- package/package.json +18 -6
package/dist/sdk.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { createClusterManager } from './libs/cluster';
|
|
2
|
+
import { createDaoManager } from './libs/dao';
|
|
2
3
|
import { createOperatorManager } from './libs/operator';
|
|
3
4
|
import { createUtils } from './libs/utils';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { WalletClient } from 'viem';
|
|
6
|
+
import { ConfigReturnType } from './config';
|
|
7
|
+
import { ConfigArgs } from './utils';
|
|
6
8
|
export declare class SSVSDK {
|
|
7
9
|
readonly config: ConfigReturnType;
|
|
8
10
|
readonly clusters: ReturnType<typeof createClusterManager>;
|
|
9
|
-
readonly
|
|
11
|
+
readonly dao: ReturnType<typeof createDaoManager>;
|
|
12
|
+
operators: ReturnType<typeof createOperatorManager>;
|
|
10
13
|
readonly api: ConfigReturnType['api'];
|
|
11
|
-
|
|
14
|
+
contract: ConfigReturnType['contract'];
|
|
12
15
|
readonly utils: ReturnType<typeof createUtils>;
|
|
13
16
|
constructor(props: ConfigArgs | ConfigReturnType);
|
|
17
|
+
connectWallet(walletClient: WalletClient): this;
|
|
14
18
|
}
|
|
@@ -14,6 +14,17 @@ export type ClusterSnapshot = AbiParameterToPrimitiveType<Extract<DepositFN['inp
|
|
|
14
14
|
export type AbiInputsToParams<T extends readonly AbiParameter[]> = {
|
|
15
15
|
[K in T[number] as K['name'] extends string ? K['name'] : never]: AbiParameterToPrimitiveType<K>;
|
|
16
16
|
};
|
|
17
|
+
export declare class MissingAbiParameterError extends Error {
|
|
18
|
+
readonly code = "MISSING_ABI_PARAMETER";
|
|
19
|
+
readonly functionName: string;
|
|
20
|
+
readonly parameterName: string;
|
|
21
|
+
readonly parameterIndex: number;
|
|
22
|
+
constructor({ functionName, parameterName, parameterIndex, }: {
|
|
23
|
+
functionName: string;
|
|
24
|
+
parameterName: string;
|
|
25
|
+
parameterIndex: number;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
17
28
|
export declare const paramsToArray: <Fn extends AbiFunction, Params extends Record<string, AbiTypeToPrimitiveType<AbiType>>>({ params, abiFunction, }: {
|
|
18
29
|
params: Params;
|
|
19
30
|
abiFunction: Fn;
|
package/dist/types/methods.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export type RemoveConfigArg<T extends (...args: any[]) => any> = (
|
|
3
|
-
export type RemoveClientArg<T extends (...args: any[]) => any> = (
|
|
1
|
+
type Tail<T extends any[]> = T extends [any, ...infer R] ? R : never;
|
|
2
|
+
export type RemoveConfigArg<T extends (...args: any[]) => any> = (...args: Tail<Parameters<T>>) => ReturnType<T>;
|
|
3
|
+
export type RemoveClientArg<T extends (...args: any[]) => any> = (...args: Tail<Parameters<T>>) => ReturnType<T>;
|
|
4
|
+
export {};
|
package/dist/utils/cluster.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { GetClusterQuery } from '../graphql/graphql';
|
|
2
|
-
import { ClusterSnapshot } from '../types/contract-interactions';
|
|
2
|
+
import { ClusterSnapshot as SolidityCluster } from '../types/contract-interactions';
|
|
3
3
|
import { Hex } from 'viem';
|
|
4
4
|
export declare const createClusterId: (ownerAddress: string, operatorIds: number[]) => string;
|
|
5
5
|
export declare const isClusterId: (clusterId: string) => boolean;
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const createEmptyCluster: (cluster?: Partial<
|
|
6
|
+
export declare const toSolidityCluster: (cluster: Pick<NonNullable<GetClusterQuery["cluster"]>, "active" | "balance" | "index" | "networkFeeIndex" | "validatorCount">) => SolidityCluster;
|
|
7
|
+
export declare const createEmptyCluster: (cluster?: Partial<SolidityCluster>) => SolidityCluster;
|
|
8
8
|
export declare const add0x: (value: string | Hex) => Hex;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Prettify } from '../types/utils';
|
|
2
|
+
export declare const computeDailyAmount: (value: bigint, days: number) => bigint;
|
|
3
|
+
type LiquidationCollateralCostArgs = {
|
|
4
|
+
networkFee: bigint;
|
|
5
|
+
operatorsFee: bigint;
|
|
6
|
+
liquidationCollateralPeriod: bigint;
|
|
7
|
+
minimumLiquidationCollateral: bigint;
|
|
8
|
+
effectiveBalance: bigint;
|
|
9
|
+
};
|
|
10
|
+
export declare const computeLiquidationCollateralCostPerValidator: ({ networkFee, operatorsFee, liquidationCollateralPeriod, minimumLiquidationCollateral, effectiveBalance, }: LiquidationCollateralCostArgs) => bigint;
|
|
11
|
+
type ComputeFundingCostArgs = Prettify<{
|
|
12
|
+
fundingDays: number;
|
|
13
|
+
effectiveBalance?: bigint;
|
|
14
|
+
} & LiquidationCollateralCostArgs>;
|
|
15
|
+
export declare const computeFundingCost: (args: ComputeFundingCostArgs) => {
|
|
16
|
+
perValidator: {
|
|
17
|
+
networkCost: bigint;
|
|
18
|
+
operatorsCost: bigint;
|
|
19
|
+
liquidationCollateral: bigint;
|
|
20
|
+
};
|
|
21
|
+
subtotal: {
|
|
22
|
+
networkCost: bigint;
|
|
23
|
+
operatorsCost: bigint;
|
|
24
|
+
liquidationCollateral: bigint;
|
|
25
|
+
};
|
|
26
|
+
total: bigint;
|
|
27
|
+
effectiveBalance: bigint;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import { Address, PublicClient, WalletClient } from 'viem';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export declare const configArgsSchema: z.ZodType<ConfigArgs>;
|
|
4
4
|
export type ConfigArgs = {
|
|
5
|
-
walletClient
|
|
5
|
+
walletClient?: WalletClient;
|
|
6
6
|
publicClient: PublicClient;
|
|
7
7
|
extendedConfig?: {
|
|
8
8
|
subgraph?: {
|
package/dist/utils.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const waitForTransaction = async (
|
|
3
|
+
const config = require("./config-ClGS9Tic.js");
|
|
4
|
+
const waitForTransaction = async (config2, fn) => {
|
|
5
5
|
const hash = await fn;
|
|
6
|
-
return
|
|
6
|
+
return config2.publicClient.waitForTransactionReceipt({ hash });
|
|
7
7
|
};
|
|
8
|
-
exports.KeysharesValidationError =
|
|
9
|
-
exports.KeysharesValidationErrors =
|
|
10
|
-
exports.KeysharesValidationErrorsMessages =
|
|
11
|
-
exports._percentageFormatter =
|
|
12
|
-
exports.add0x =
|
|
13
|
-
exports.bigintAbs =
|
|
14
|
-
exports.bigintFloor =
|
|
15
|
-
exports.bigintFormatter =
|
|
16
|
-
exports.bigintMax =
|
|
17
|
-
exports.bigintMin =
|
|
18
|
-
exports.bigintRound =
|
|
19
|
-
exports.bigintifyNumbers =
|
|
20
|
-
exports.configArgsSchema =
|
|
21
|
-
exports.createClusterId =
|
|
22
|
-
exports.createEmptyCluster =
|
|
23
|
-
exports.decodeOperatorPublicKey =
|
|
24
|
-
exports.ensureNoKeysharesErrors =
|
|
25
|
-
exports.ensureValidatorsUniqueness =
|
|
26
|
-
exports.ethFormatter =
|
|
27
|
-
exports.formatBigintInput =
|
|
28
|
-
exports.formatSSV =
|
|
29
|
-
exports.
|
|
30
|
-
exports.
|
|
31
|
-
exports.
|
|
32
|
-
exports.
|
|
33
|
-
exports.
|
|
34
|
-
exports.
|
|
35
|
-
exports.
|
|
36
|
-
exports.
|
|
37
|
-
exports.
|
|
38
|
-
exports.
|
|
39
|
-
exports.
|
|
40
|
-
exports.tryCatch =
|
|
41
|
-
exports.validateConsistentOperatorIds =
|
|
42
|
-
exports.validateConsistentOperatorPublicKeys =
|
|
8
|
+
exports.KeysharesValidationError = config.KeysharesValidationError;
|
|
9
|
+
exports.KeysharesValidationErrors = config.KeysharesValidationErrors;
|
|
10
|
+
exports.KeysharesValidationErrorsMessages = config.KeysharesValidationErrorsMessages;
|
|
11
|
+
exports._percentageFormatter = config._percentageFormatter;
|
|
12
|
+
exports.add0x = config.add0x;
|
|
13
|
+
exports.bigintAbs = config.bigintAbs;
|
|
14
|
+
exports.bigintFloor = config.bigintFloor;
|
|
15
|
+
exports.bigintFormatter = config.bigintFormatter;
|
|
16
|
+
exports.bigintMax = config.bigintMax;
|
|
17
|
+
exports.bigintMin = config.bigintMin;
|
|
18
|
+
exports.bigintRound = config.bigintRound;
|
|
19
|
+
exports.bigintifyNumbers = config.bigintifyNumbers;
|
|
20
|
+
exports.configArgsSchema = config.configArgsSchema;
|
|
21
|
+
exports.createClusterId = config.createClusterId;
|
|
22
|
+
exports.createEmptyCluster = config.createEmptyCluster;
|
|
23
|
+
exports.decodeOperatorPublicKey = config.decodeOperatorPublicKey;
|
|
24
|
+
exports.ensureNoKeysharesErrors = config.ensureNoKeysharesErrors;
|
|
25
|
+
exports.ensureValidatorsUniqueness = config.ensureValidatorsUniqueness;
|
|
26
|
+
exports.ethFormatter = config.ethFormatter;
|
|
27
|
+
exports.formatBigintInput = config.formatBigintInput;
|
|
28
|
+
exports.formatSSV = config.formatSSV;
|
|
29
|
+
exports.getOperatorIds = config.getOperatorIds;
|
|
30
|
+
exports.isBigIntChanged = config.isBigIntChanged;
|
|
31
|
+
exports.isClusterId = config.isClusterId;
|
|
32
|
+
exports.isKeySharesItem = config.isKeySharesItem;
|
|
33
|
+
exports.ms = config.ms;
|
|
34
|
+
exports.numberFormatter = config.numberFormatter;
|
|
35
|
+
exports.percentageFormatter = config.percentageFormatter;
|
|
36
|
+
exports.roundOperatorFee = config.roundOperatorFee;
|
|
37
|
+
exports.sortNumbers = config.sortNumbers;
|
|
38
|
+
exports.stringifyBigints = config.stringifyBigints;
|
|
39
|
+
exports.toSolidityCluster = config.toSolidityCluster;
|
|
40
|
+
exports.tryCatch = config.tryCatch;
|
|
41
|
+
exports.validateConsistentOperatorIds = config.validateConsistentOperatorIds;
|
|
42
|
+
exports.validateConsistentOperatorPublicKeys = config.validateConsistentOperatorPublicKeys;
|
|
43
43
|
exports.waitForTransaction = waitForTransaction;
|
package/dist/utils.mjs
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { K, a, b, _, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G } from "./config-BdEJjnYA.mjs";
|
|
2
2
|
const waitForTransaction = async (config, fn) => {
|
|
3
3
|
const hash = await fn;
|
|
4
4
|
return config.publicClient.waitForTransactionReceipt({ hash });
|
|
5
5
|
};
|
|
6
6
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
K as KeysharesValidationError,
|
|
8
|
+
a as KeysharesValidationErrors,
|
|
9
|
+
b as KeysharesValidationErrorsMessages,
|
|
10
10
|
_ as _percentageFormatter,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
c as add0x,
|
|
12
|
+
d as bigintAbs,
|
|
13
|
+
e as bigintFloor,
|
|
14
|
+
f as bigintFormatter,
|
|
15
|
+
g as bigintMax,
|
|
16
|
+
h as bigintMin,
|
|
17
|
+
i as bigintRound,
|
|
18
|
+
j as bigintifyNumbers,
|
|
19
|
+
k as configArgsSchema,
|
|
20
|
+
l as createClusterId,
|
|
21
|
+
m as createEmptyCluster,
|
|
22
|
+
n as decodeOperatorPublicKey,
|
|
23
|
+
o as ensureNoKeysharesErrors,
|
|
24
24
|
p as ensureValidatorsUniqueness,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
C as
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
q as ethFormatter,
|
|
26
|
+
r as formatBigintInput,
|
|
27
|
+
s as formatSSV,
|
|
28
|
+
t as getOperatorIds,
|
|
29
|
+
u as isBigIntChanged,
|
|
30
|
+
v as isClusterId,
|
|
31
|
+
w as isKeySharesItem,
|
|
32
|
+
x as ms,
|
|
33
|
+
y as numberFormatter,
|
|
34
|
+
z as percentageFormatter,
|
|
35
|
+
A as roundOperatorFee,
|
|
36
|
+
B as sortNumbers,
|
|
37
|
+
C as stringifyBigints,
|
|
38
|
+
D as toSolidityCluster,
|
|
39
|
+
E as tryCatch,
|
|
40
|
+
F as validateConsistentOperatorIds,
|
|
41
|
+
G as validateConsistentOperatorPublicKeys,
|
|
42
42
|
waitForTransaction
|
|
43
43
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssv-labs/ssv-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"author": "SSV.Labs",
|
|
5
5
|
"description": "ssv labs sdk",
|
|
6
6
|
"keywords": [
|
|
@@ -65,7 +65,6 @@
|
|
|
65
65
|
"@graphql-codegen/typescript": "4.1.6",
|
|
66
66
|
"@graphql-codegen/typescript-graphql-request": "6.3.0",
|
|
67
67
|
"@graphql-codegen/typescript-operations": "4.6.1",
|
|
68
|
-
"@nomicfoundation/hardhat-toolbox": "6.0.0",
|
|
69
68
|
"@nomicfoundation/hardhat-viem": "2.0.6",
|
|
70
69
|
"@openzeppelin/contracts": "4.9.6",
|
|
71
70
|
"@openzeppelin/contracts-upgradeable": "4.9.6",
|
|
@@ -94,12 +93,13 @@
|
|
|
94
93
|
"eslint-config-prettier": "9.1.2",
|
|
95
94
|
"eslint-plugin-prettier": "5.5.4",
|
|
96
95
|
"eslint-plugin-unused-imports": "4.1.4",
|
|
96
|
+
"dotenv": "^16.4.5",
|
|
97
97
|
"hardhat": "2.27.2",
|
|
98
98
|
"husky": "9.1.7",
|
|
99
99
|
"lint-staged": "15.5.2",
|
|
100
100
|
"prettier": "3.6.2",
|
|
101
101
|
"release-it": "19.0.6",
|
|
102
|
-
"rollup": "4.
|
|
102
|
+
"rollup": "4.59.0",
|
|
103
103
|
"rollup-plugin-delete": "2.2.0",
|
|
104
104
|
"rollup-plugin-dts": "6.3.0",
|
|
105
105
|
"rollup-plugin-tsconfig-paths": "1.5.2",
|
|
@@ -110,7 +110,6 @@
|
|
|
110
110
|
"vite": "5.4.21",
|
|
111
111
|
"vite-plugin-dts": "4.5.4",
|
|
112
112
|
"vite-plugin-glob": "0.3.2",
|
|
113
|
-
"vite-plugin-node-polyfills": "0.24.0",
|
|
114
113
|
"vitest": "1.6.1"
|
|
115
114
|
},
|
|
116
115
|
"config": {
|
|
@@ -118,6 +117,20 @@
|
|
|
118
117
|
"path": "node_modules/cz-git"
|
|
119
118
|
}
|
|
120
119
|
},
|
|
120
|
+
"pnpm": {
|
|
121
|
+
"overrides": {
|
|
122
|
+
"ajv@>=7.0.0 <8.18.0": "8.18.0",
|
|
123
|
+
"cookie@<0.7.0": "0.7.0",
|
|
124
|
+
"esbuild@<=0.24.2": "0.25.0",
|
|
125
|
+
"fast-xml-parser@>=5.0.0 <5.3.8": "5.3.8",
|
|
126
|
+
"immutable@<3.8.3": "3.8.3",
|
|
127
|
+
"lodash@<4.17.23": "4.17.23",
|
|
128
|
+
"minimatch@>=10.0.0 <10.2.3": "10.2.3",
|
|
129
|
+
"serialize-javascript@<=7.0.2": "7.0.3",
|
|
130
|
+
"tmp@<=0.2.3": "0.2.4",
|
|
131
|
+
"undici@<6.23.0": "6.23.0"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
121
134
|
"engines": {
|
|
122
135
|
"node": ">=22"
|
|
123
136
|
},
|
|
@@ -127,9 +140,8 @@
|
|
|
127
140
|
"abitype": "^1.0.6",
|
|
128
141
|
"bls-eth-wasm": "^1.4.0",
|
|
129
142
|
"class-validator": "0.14.3",
|
|
130
|
-
"dotenv": "^16.4.5",
|
|
131
143
|
"graphql-request": "7.3.5",
|
|
132
|
-
"lodash-es": "^4.17.
|
|
144
|
+
"lodash-es": "^4.17.23",
|
|
133
145
|
"node-forge": "1.3.3",
|
|
134
146
|
"scrypt-js": "^3.0.1",
|
|
135
147
|
"tslib": "^2.8.1",
|