@obolnetwork/obol-sdk 2.11.4 → 2.11.5-rc.0
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/dist/cjs/src/index.js +17457 -382
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/esm/src/index.js +17424 -361
- package/dist/esm/src/index.js.map +1 -0
- package/dist/types/src/constants.d.ts +1 -2
- package/dist/types/src/eoa/eoaHelpers.d.ts +1 -1
- package/dist/types/src/exits/verificationHelpers.d.ts +0 -2
- package/dist/types/src/incentives/incentiveHelpers.d.ts +1 -1
- package/dist/types/src/splits/splitHelpers.d.ts +3 -3
- package/dist/types/src/utils.d.ts +2 -2
- package/dist/types/src/verification/common.d.ts +0 -2
- package/dist/types/src/verification/signature-validator.d.ts +4 -4
- package/dist/types/src/verification/v1.10.0.d.ts +1 -1
- package/dist/types/src/verification/v1.6.0.d.ts +1 -1
- package/dist/types/src/verification/v1.7.0.d.ts +1 -1
- package/dist/types/src/verification/v1.8.0.d.ts +1 -1
- package/dist/types/test/client/methods.spec.d.ts +17 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -0
- package/dist/types/tsup.config.d.ts +2 -0
- package/package.json +79 -54
- package/dist/cjs/package.json +0 -139
- package/dist/cjs/src/abi/BatchDeposit.js +0 -120
- package/dist/cjs/src/abi/MerkleDistributorWithDeadline.js +0 -73
- package/dist/cjs/src/abi/Multicall3.js +0 -253
- package/dist/cjs/src/abi/OVM.js +0 -627
- package/dist/cjs/src/abi/OWR.js +0 -304
- package/dist/cjs/src/abi/SplitMain.js +0 -929
- package/dist/cjs/src/abi/splitV2FactoryAbi.js +0 -420
- package/dist/cjs/src/ajv.js +0 -136
- package/dist/cjs/src/base.js +0 -42
- package/dist/cjs/src/bytecodes.js +0 -19
- package/dist/cjs/src/constants.js +0 -272
- package/dist/cjs/src/eoa/eoa.js +0 -132
- package/dist/cjs/src/eoa/eoaHelpers.js +0 -82
- package/dist/cjs/src/errors.js +0 -11
- package/dist/cjs/src/exits/ethUtils.js +0 -57
- package/dist/cjs/src/exits/exit.js +0 -502
- package/dist/cjs/src/exits/verificationHelpers.js +0 -86
- package/dist/cjs/src/incentives/incentiveHelpers.js +0 -39
- package/dist/cjs/src/incentives/incentives.js +0 -119
- package/dist/cjs/src/schema.js +0 -352
- package/dist/cjs/src/services.js +0 -33
- package/dist/cjs/src/splits/splitHelpers.js +0 -571
- package/dist/cjs/src/splits/splits.js +0 -366
- package/dist/cjs/src/types.js +0 -29
- package/dist/cjs/src/utils.js +0 -77
- package/dist/cjs/src/verification/common.js +0 -355
- package/dist/cjs/src/verification/signature-validator.js +0 -73
- package/dist/cjs/src/verification/sszTypes.js +0 -69
- package/dist/cjs/src/verification/termsAndConditions.js +0 -40
- package/dist/cjs/src/verification/v1.10.0.js +0 -146
- package/dist/cjs/src/verification/v1.6.0.js +0 -149
- package/dist/cjs/src/verification/v1.7.0.js +0 -173
- package/dist/cjs/src/verification/v1.8.0.js +0 -196
- package/dist/cjs/test/client/ajv.spec.js +0 -320
- package/dist/cjs/test/client/methods.spec.js +0 -418
- package/dist/cjs/test/eoa/eoa.spec.js +0 -176
- package/dist/cjs/test/exit/ethUtils.spec.js +0 -83
- package/dist/cjs/test/exit/exit.spec.js +0 -399
- package/dist/cjs/test/exit/verificationHelpers.spec.js +0 -68
- package/dist/cjs/test/fixtures.js +0 -896
- package/dist/cjs/test/incentives/incentives.spec.js +0 -202
- package/dist/cjs/test/splits/splits.spec.js +0 -402
- package/dist/esm/package.json +0 -139
- package/dist/esm/src/abi/BatchDeposit.js +0 -117
- package/dist/esm/src/abi/MerkleDistributorWithDeadline.js +0 -70
- package/dist/esm/src/abi/Multicall3.js +0 -250
- package/dist/esm/src/abi/OVM.js +0 -624
- package/dist/esm/src/abi/OWR.js +0 -301
- package/dist/esm/src/abi/SplitMain.js +0 -926
- package/dist/esm/src/abi/splitV2FactoryAbi.js +0 -417
- package/dist/esm/src/ajv.js +0 -129
- package/dist/esm/src/base.js +0 -38
- package/dist/esm/src/bytecodes.js +0 -16
- package/dist/esm/src/constants.js +0 -238
- package/dist/esm/src/eoa/eoa.js +0 -128
- package/dist/esm/src/eoa/eoaHelpers.js +0 -77
- package/dist/esm/src/errors.js +0 -7
- package/dist/esm/src/exits/ethUtils.js +0 -52
- package/dist/esm/src/exits/exit.js +0 -475
- package/dist/esm/src/exits/verificationHelpers.js +0 -81
- package/dist/esm/src/incentives/incentiveHelpers.js +0 -34
- package/dist/esm/src/incentives/incentives.js +0 -115
- package/dist/esm/src/schema.js +0 -349
- package/dist/esm/src/services.js +0 -29
- package/dist/esm/src/splits/splitHelpers.js +0 -554
- package/dist/esm/src/splits/splits.js +0 -362
- package/dist/esm/src/types.js +0 -26
- package/dist/esm/src/utils.js +0 -68
- package/dist/esm/src/verification/common.js +0 -319
- package/dist/esm/src/verification/signature-validator.js +0 -64
- package/dist/esm/src/verification/sszTypes.js +0 -64
- package/dist/esm/src/verification/termsAndConditions.js +0 -33
- package/dist/esm/src/verification/v1.10.0.js +0 -140
- package/dist/esm/src/verification/v1.6.0.js +0 -142
- package/dist/esm/src/verification/v1.7.0.js +0 -166
- package/dist/esm/src/verification/v1.8.0.js +0 -189
- package/dist/esm/test/client/ajv.spec.js +0 -318
- package/dist/esm/test/client/methods.spec.js +0 -393
- package/dist/esm/test/eoa/eoa.spec.js +0 -174
- package/dist/esm/test/exit/ethUtils.spec.js +0 -81
- package/dist/esm/test/exit/exit.spec.js +0 -374
- package/dist/esm/test/exit/verificationHelpers.spec.js +0 -66
- package/dist/esm/test/fixtures.js +0 -893
- package/dist/esm/test/incentives/incentives.spec.js +0 -177
- package/dist/esm/test/splits/splits.spec.js +0 -400
- package/src/abi/BatchDeposit.ts +0 -117
- package/src/abi/MerkleDistributorWithDeadline.ts +0 -70
- package/src/abi/Multicall3.ts +0 -250
- package/src/abi/OVM.ts +0 -624
- package/src/abi/OWR.ts +0 -302
- package/src/abi/SplitMain.ts +0 -927
- package/src/abi/splitV2FactoryAbi.ts +0 -417
- package/src/ajv.ts +0 -191
- package/src/base.ts +0 -54
- package/src/bytecodes.ts +0 -32
- package/src/constants.ts +0 -309
- package/src/eoa/eoa.ts +0 -153
- package/src/eoa/eoaHelpers.ts +0 -112
- package/src/errors.ts +0 -8
- package/src/exits/ethUtils.ts +0 -49
- package/src/exits/exit.ts +0 -661
- package/src/exits/verificationHelpers.ts +0 -110
- package/src/incentives/incentiveHelpers.ts +0 -55
- package/src/incentives/incentives.ts +0 -153
- package/src/index.ts +0 -614
- package/src/schema.ts +0 -376
- package/src/services.ts +0 -24
- package/src/splits/splitHelpers.ts +0 -1032
- package/src/splits/splits.ts +0 -504
- package/src/types.ts +0 -687
- package/src/utils.ts +0 -88
- package/src/verification/common.ts +0 -532
- package/src/verification/signature-validator.ts +0 -103
- package/src/verification/sszTypes.ts +0 -88
- package/src/verification/termsAndConditions.ts +0 -32
- package/src/verification/v1.10.0.ts +0 -245
- package/src/verification/v1.6.0.ts +0 -256
- package/src/verification/v1.7.0.ts +0 -309
- package/src/verification/v1.8.0.ts +0 -340
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ObolSplits = void 0;
|
|
13
|
-
const splitHelpers_1 = require("./splitHelpers");
|
|
14
|
-
const constants_1 = require("../constants");
|
|
15
|
-
const schema_1 = require("../schema");
|
|
16
|
-
const ajv_1 = require("../ajv");
|
|
17
|
-
const utils_1 = require("../utils");
|
|
18
|
-
/**
|
|
19
|
-
* ObolSplits can be used for creating and managing Obol splits.
|
|
20
|
-
* @class
|
|
21
|
-
* @internal Access it through Client.splits.
|
|
22
|
-
* @example
|
|
23
|
-
* const obolClient = new Client(config);
|
|
24
|
-
* await obolClient.splits.createValidatorManagerAndRewardsSplit(OVMRewardsSplitPayload);
|
|
25
|
-
*/
|
|
26
|
-
class ObolSplits {
|
|
27
|
-
constructor(signer, chainId, provider) {
|
|
28
|
-
this.signer = signer;
|
|
29
|
-
this.chainId = chainId;
|
|
30
|
-
this.provider = provider;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Creates an Obol OVM and Pull split configuration for rewards-only scenario.
|
|
34
|
-
*
|
|
35
|
-
* This method deploys OVM and SplitV2 contracts for managing validator rewards only.
|
|
36
|
-
* Principal is handled by a single address, while rewards are split among recipients.
|
|
37
|
-
*
|
|
38
|
-
* @remarks
|
|
39
|
-
* **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
|
|
40
|
-
* and not pushed to version control.
|
|
41
|
-
*
|
|
42
|
-
* @param {OVMRewardsSplitPayload} payload - Data needed to deploy OVM and SplitV2
|
|
43
|
-
* @returns {Promise<ClusterValidator>} OVM address as withdrawal address and splitter as fee recipient
|
|
44
|
-
* @throws Will throw an error if the splitter configuration is not supported or deployment fails
|
|
45
|
-
*
|
|
46
|
-
* An example of how to use createValidatorManagerAndRewardsSplit:
|
|
47
|
-
* [createValidatorManagerAndRewardsSplit](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L333)
|
|
48
|
-
*/
|
|
49
|
-
createValidatorManagerAndRewardsSplit(payload) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
const salt = constants_1.SPLITS_V2_SALT;
|
|
52
|
-
if (!this.signer) {
|
|
53
|
-
throw new Error('Signer is required in createValidatorManagerAndRewardsSplit');
|
|
54
|
-
}
|
|
55
|
-
const validatedPayload = (0, ajv_1.validatePayload)(payload, schema_1.ovmRewardsSplitPayloadSchema);
|
|
56
|
-
if (!(0, constants_1.isChainSupportedForSplitters)(this.chainId)) {
|
|
57
|
-
throw new Error(`Splitter configuration is not supported on ${this.chainId} chain`);
|
|
58
|
-
}
|
|
59
|
-
const chainConfig = constants_1.CHAIN_CONFIGURATION[this.chainId];
|
|
60
|
-
if (!(chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.OVM_FACTORY_CONTRACT)) {
|
|
61
|
-
throw new Error(`OVM contract factory is not configured for chain ${this.chainId}`);
|
|
62
|
-
}
|
|
63
|
-
if (!this.provider) {
|
|
64
|
-
throw new Error('Provider is required to check OVM factory contract availability');
|
|
65
|
-
}
|
|
66
|
-
const ovmFactoryConfig = chainConfig.OVM_FACTORY_CONTRACT;
|
|
67
|
-
const splitV2FactoryConfig = chainConfig.SPLIT_V2_FACTORY_CONTRACT;
|
|
68
|
-
const multiCall3Config = chainConfig.MULTICALL3_CONTRACT;
|
|
69
|
-
if (!(ovmFactoryConfig === null || ovmFactoryConfig === void 0 ? void 0 : ovmFactoryConfig.address) ||
|
|
70
|
-
!(ovmFactoryConfig === null || ovmFactoryConfig === void 0 ? void 0 : ovmFactoryConfig.bytecode) ||
|
|
71
|
-
!(splitV2FactoryConfig === null || splitV2FactoryConfig === void 0 ? void 0 : splitV2FactoryConfig.address) ||
|
|
72
|
-
!(splitV2FactoryConfig === null || splitV2FactoryConfig === void 0 ? void 0 : splitV2FactoryConfig.bytecode) ||
|
|
73
|
-
!(multiCall3Config === null || multiCall3Config === void 0 ? void 0 : multiCall3Config.address) ||
|
|
74
|
-
!(multiCall3Config === null || multiCall3Config === void 0 ? void 0 : multiCall3Config.bytecode)) {
|
|
75
|
-
throw new Error(`Contracts configuration is incomplete for chain ${this.chainId}`);
|
|
76
|
-
}
|
|
77
|
-
const checkOVMFactoryContract = yield (0, utils_1.isContractAvailable)(ovmFactoryConfig.address, this.provider, ovmFactoryConfig.bytecode);
|
|
78
|
-
const checkSplitV2FactoryContract = yield (0, utils_1.isContractAvailable)(splitV2FactoryConfig.address, this.provider, splitV2FactoryConfig.bytecode);
|
|
79
|
-
const checkMultiCall3Contract = yield (0, utils_1.isContractAvailable)(multiCall3Config.address, this.provider, multiCall3Config.bytecode);
|
|
80
|
-
if (!checkOVMFactoryContract ||
|
|
81
|
-
!checkSplitV2FactoryContract ||
|
|
82
|
-
!checkMultiCall3Contract) {
|
|
83
|
-
throw new Error(`Splitter contract is not deployed or available on chain ${this.chainId}`);
|
|
84
|
-
}
|
|
85
|
-
const retroActiveFundingRecipient = {
|
|
86
|
-
address: chainConfig.RETROACTIVE_FUNDING_CONTRACT.address,
|
|
87
|
-
percentAllocation: constants_1.DEFAULT_RETROACTIVE_FUNDING_REWARDS_ONLY_SPLIT,
|
|
88
|
-
};
|
|
89
|
-
const copiedRewardsSplitRecipients = [
|
|
90
|
-
...validatedPayload.rewardSplitRecipients,
|
|
91
|
-
];
|
|
92
|
-
copiedRewardsSplitRecipients.push(retroActiveFundingRecipient);
|
|
93
|
-
// Format recipients for SplitV2
|
|
94
|
-
const rewardRecipients = (0, splitHelpers_1.formatRecipientsForSplitV2)(copiedRewardsSplitRecipients);
|
|
95
|
-
const predictedSplitAddress = yield (0, splitHelpers_1.predictSplitV2Address)({
|
|
96
|
-
splitOwnerAddress: validatedPayload.splitOwnerAddress,
|
|
97
|
-
recipients: rewardRecipients,
|
|
98
|
-
distributorFeePercent: validatedPayload.distributorFeePercent,
|
|
99
|
-
salt,
|
|
100
|
-
signer: this.signer,
|
|
101
|
-
chainId: this.chainId,
|
|
102
|
-
});
|
|
103
|
-
const isRewardSplitterDeployed = yield (0, splitHelpers_1.isSplitV2Deployed)({
|
|
104
|
-
splitOwnerAddress: validatedPayload.splitOwnerAddress,
|
|
105
|
-
recipients: rewardRecipients,
|
|
106
|
-
distributorFeePercent: validatedPayload.distributorFeePercent,
|
|
107
|
-
salt,
|
|
108
|
-
signer: this.signer,
|
|
109
|
-
chainId: this.chainId,
|
|
110
|
-
});
|
|
111
|
-
if (isRewardSplitterDeployed) {
|
|
112
|
-
const ovmAddress = yield (0, splitHelpers_1.deployOVMContract)({
|
|
113
|
-
OVMOwnerAddress: validatedPayload.OVMOwnerAddress,
|
|
114
|
-
principalRecipient: validatedPayload.principalRecipient,
|
|
115
|
-
rewardRecipient: predictedSplitAddress,
|
|
116
|
-
principalThreshold: validatedPayload.principalThreshold,
|
|
117
|
-
signer: this.signer,
|
|
118
|
-
chainId: this.chainId,
|
|
119
|
-
});
|
|
120
|
-
return {
|
|
121
|
-
withdrawal_address: ovmAddress,
|
|
122
|
-
fee_recipient_address: predictedSplitAddress,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
const ovmAddress = yield (0, splitHelpers_1.deployOVMAndSplitV2)({
|
|
127
|
-
ovmArgs: {
|
|
128
|
-
OVMOwnerAddress: validatedPayload.OVMOwnerAddress,
|
|
129
|
-
rewardRecipient: predictedSplitAddress,
|
|
130
|
-
principalRecipient: validatedPayload.principalRecipient,
|
|
131
|
-
principalThreshold: validatedPayload.principalThreshold,
|
|
132
|
-
},
|
|
133
|
-
rewardRecipients,
|
|
134
|
-
isRewardsSplitterDeployed: isRewardSplitterDeployed,
|
|
135
|
-
distributorFeePercent: validatedPayload.distributorFeePercent,
|
|
136
|
-
salt,
|
|
137
|
-
signer: this.signer,
|
|
138
|
-
chainId: this.chainId,
|
|
139
|
-
splitOwnerAddress: validatedPayload.splitOwnerAddress,
|
|
140
|
-
});
|
|
141
|
-
return {
|
|
142
|
-
withdrawal_address: ovmAddress,
|
|
143
|
-
fee_recipient_address: predictedSplitAddress,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Creates an Obol OVM and Total split configuration for total split scenario.
|
|
150
|
-
*
|
|
151
|
-
* This method deploys OVM and SplitV2 contracts for managing both validator rewards and principal.
|
|
152
|
-
* Both rewards and principal are split among recipients, with rewards including RAF recipient.
|
|
153
|
-
*
|
|
154
|
-
* @remarks
|
|
155
|
-
* **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
|
|
156
|
-
* and not pushed to version control.
|
|
157
|
-
*
|
|
158
|
-
* @param {OVMTotalSplitPayload} payload - Data needed to deploy OVM and SplitV2
|
|
159
|
-
* @returns {Promise<ClusterValidator>} OVM address as withdrawal address and splitter as fee recipient
|
|
160
|
-
* @throws Will throw an error if the splitter configuration is not supported or deployment fails
|
|
161
|
-
*
|
|
162
|
-
* An example of how to use createValidatorManagerAndTotalSplit:
|
|
163
|
-
* [createValidatorManagerAndTotalSplit](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#340)
|
|
164
|
-
*/
|
|
165
|
-
createValidatorManagerAndTotalSplit(payload) {
|
|
166
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
const salt = constants_1.SPLITS_V2_SALT;
|
|
168
|
-
if (!this.signer) {
|
|
169
|
-
throw new Error('Signer is required in createValidatorManagerAndTotalSplit');
|
|
170
|
-
}
|
|
171
|
-
const validatedPayload = (0, ajv_1.validatePayload)(payload, schema_1.ovmTotalSplitPayloadSchema);
|
|
172
|
-
if (!(0, constants_1.isChainSupportedForSplitters)(this.chainId)) {
|
|
173
|
-
throw new Error(`Splitter configuration is not supported on ${this.chainId} chain`);
|
|
174
|
-
}
|
|
175
|
-
const chainConfig = constants_1.CHAIN_CONFIGURATION[this.chainId];
|
|
176
|
-
if (!(chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.OVM_FACTORY_CONTRACT)) {
|
|
177
|
-
throw new Error(`OVM contract factory is not configured for chain ${this.chainId}`);
|
|
178
|
-
}
|
|
179
|
-
if (!this.provider) {
|
|
180
|
-
throw new Error('Provider is required to check OVM factory contract availability');
|
|
181
|
-
}
|
|
182
|
-
const ovmFactoryConfig = chainConfig.OVM_FACTORY_CONTRACT;
|
|
183
|
-
const splitV2FactoryConfig = chainConfig.SPLIT_V2_FACTORY_CONTRACT;
|
|
184
|
-
const multiCall3Config = chainConfig.MULTICALL3_CONTRACT;
|
|
185
|
-
if (!(ovmFactoryConfig === null || ovmFactoryConfig === void 0 ? void 0 : ovmFactoryConfig.address) ||
|
|
186
|
-
!(ovmFactoryConfig === null || ovmFactoryConfig === void 0 ? void 0 : ovmFactoryConfig.bytecode) ||
|
|
187
|
-
!(splitV2FactoryConfig === null || splitV2FactoryConfig === void 0 ? void 0 : splitV2FactoryConfig.address) ||
|
|
188
|
-
!(splitV2FactoryConfig === null || splitV2FactoryConfig === void 0 ? void 0 : splitV2FactoryConfig.bytecode) ||
|
|
189
|
-
!(multiCall3Config === null || multiCall3Config === void 0 ? void 0 : multiCall3Config.address) ||
|
|
190
|
-
!(multiCall3Config === null || multiCall3Config === void 0 ? void 0 : multiCall3Config.bytecode)) {
|
|
191
|
-
throw new Error(`Contracts configuration is incomplete for chain ${this.chainId}`);
|
|
192
|
-
}
|
|
193
|
-
const checkOVMFactoryContract = yield (0, utils_1.isContractAvailable)(ovmFactoryConfig.address, this.provider, ovmFactoryConfig.bytecode);
|
|
194
|
-
const checkSplitV2FactoryContract = yield (0, utils_1.isContractAvailable)(splitV2FactoryConfig.address, this.provider, splitV2FactoryConfig.bytecode);
|
|
195
|
-
const checkMultiCall3Contract = yield (0, utils_1.isContractAvailable)(multiCall3Config.address, this.provider, multiCall3Config.bytecode);
|
|
196
|
-
if (!checkOVMFactoryContract ||
|
|
197
|
-
!checkSplitV2FactoryContract ||
|
|
198
|
-
!checkMultiCall3Contract) {
|
|
199
|
-
throw new Error(`Splitter contract is not deployed or available on chain ${this.chainId}`);
|
|
200
|
-
}
|
|
201
|
-
const retroActiveFundingRecipient = {
|
|
202
|
-
address: chainConfig.RETROACTIVE_FUNDING_CONTRACT.address,
|
|
203
|
-
percentAllocation: constants_1.DEFAULT_RETROACTIVE_FUNDING_REWARDS_ONLY_SPLIT,
|
|
204
|
-
};
|
|
205
|
-
const copiedRewardsSplitRecipients = [
|
|
206
|
-
...validatedPayload.rewardSplitRecipients,
|
|
207
|
-
];
|
|
208
|
-
copiedRewardsSplitRecipients.push(retroActiveFundingRecipient);
|
|
209
|
-
const rewardsRecipients = (0, splitHelpers_1.formatRecipientsForSplitV2)(copiedRewardsSplitRecipients);
|
|
210
|
-
const principalSplitRecipients = (0, splitHelpers_1.formatRecipientsForSplitV2)(validatedPayload.principalSplitRecipients);
|
|
211
|
-
const predictedRewardsSplitAddress = yield (0, splitHelpers_1.predictSplitV2Address)({
|
|
212
|
-
splitOwnerAddress: validatedPayload.splitOwnerAddress,
|
|
213
|
-
recipients: rewardsRecipients,
|
|
214
|
-
distributorFeePercent: validatedPayload.distributorFeePercent,
|
|
215
|
-
salt,
|
|
216
|
-
signer: this.signer,
|
|
217
|
-
chainId: this.chainId,
|
|
218
|
-
});
|
|
219
|
-
const predictedPrincipalSplitAddress = yield (0, splitHelpers_1.predictSplitV2Address)({
|
|
220
|
-
splitOwnerAddress: validatedPayload.splitOwnerAddress,
|
|
221
|
-
recipients: principalSplitRecipients,
|
|
222
|
-
distributorFeePercent: validatedPayload.distributorFeePercent,
|
|
223
|
-
salt,
|
|
224
|
-
signer: this.signer,
|
|
225
|
-
chainId: this.chainId,
|
|
226
|
-
});
|
|
227
|
-
const isRewardsSplitterDeployed = yield (0, splitHelpers_1.isSplitV2Deployed)({
|
|
228
|
-
splitOwnerAddress: validatedPayload.splitOwnerAddress,
|
|
229
|
-
recipients: rewardsRecipients,
|
|
230
|
-
distributorFeePercent: validatedPayload.distributorFeePercent,
|
|
231
|
-
salt,
|
|
232
|
-
signer: this.signer,
|
|
233
|
-
chainId: this.chainId,
|
|
234
|
-
});
|
|
235
|
-
const isPrincipalSplitterDeployed = yield (0, splitHelpers_1.isSplitV2Deployed)({
|
|
236
|
-
splitOwnerAddress: validatedPayload.splitOwnerAddress,
|
|
237
|
-
recipients: principalSplitRecipients,
|
|
238
|
-
distributorFeePercent: validatedPayload.distributorFeePercent,
|
|
239
|
-
salt,
|
|
240
|
-
signer: this.signer,
|
|
241
|
-
chainId: this.chainId,
|
|
242
|
-
});
|
|
243
|
-
if (isRewardsSplitterDeployed && isPrincipalSplitterDeployed) {
|
|
244
|
-
const ovmAddress = yield (0, splitHelpers_1.deployOVMContract)({
|
|
245
|
-
OVMOwnerAddress: validatedPayload.OVMOwnerAddress,
|
|
246
|
-
principalRecipient: predictedPrincipalSplitAddress,
|
|
247
|
-
rewardRecipient: predictedRewardsSplitAddress,
|
|
248
|
-
principalThreshold: validatedPayload.principalThreshold,
|
|
249
|
-
signer: this.signer,
|
|
250
|
-
chainId: this.chainId,
|
|
251
|
-
});
|
|
252
|
-
return {
|
|
253
|
-
withdrawal_address: ovmAddress,
|
|
254
|
-
fee_recipient_address: predictedRewardsSplitAddress,
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
// Use multicall3 to deploy any contracts that aren't deployed
|
|
259
|
-
const ovmAddress = yield (0, splitHelpers_1.deployOVMAndSplitV2)({
|
|
260
|
-
ovmArgs: {
|
|
261
|
-
OVMOwnerAddress: validatedPayload.OVMOwnerAddress,
|
|
262
|
-
rewardRecipient: predictedRewardsSplitAddress,
|
|
263
|
-
principalRecipient: predictedPrincipalSplitAddress,
|
|
264
|
-
principalThreshold: validatedPayload.principalThreshold,
|
|
265
|
-
},
|
|
266
|
-
rewardRecipients: rewardsRecipients,
|
|
267
|
-
distributorFeePercent: validatedPayload.distributorFeePercent,
|
|
268
|
-
salt,
|
|
269
|
-
signer: this.signer,
|
|
270
|
-
chainId: this.chainId,
|
|
271
|
-
principalSplitRecipients,
|
|
272
|
-
isPrincipalSplitDeployed: isPrincipalSplitterDeployed,
|
|
273
|
-
splitOwnerAddress: validatedPayload.splitOwnerAddress,
|
|
274
|
-
});
|
|
275
|
-
return {
|
|
276
|
-
withdrawal_address: ovmAddress,
|
|
277
|
-
fee_recipient_address: predictedRewardsSplitAddress,
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Requests withdrawal from an OVM contract.
|
|
284
|
-
*
|
|
285
|
-
* This method allows requesting withdrawal of validator funds from an OVM contract.
|
|
286
|
-
* The withdrawal request includes OVM address, validator public keys and corresponding withdrawal amounts.
|
|
287
|
-
*
|
|
288
|
-
* @remarks
|
|
289
|
-
* **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
|
|
290
|
-
* and not pushed to version control.
|
|
291
|
-
*
|
|
292
|
-
* @param {OVMRequestWithdrawalPayload} payload - Data needed to request withdrawal
|
|
293
|
-
* @returns {Promise<{txHash: string}>} Transaction hash of the withdrawal request
|
|
294
|
-
* @throws Will throw an error if the signer is not provided, OVM address is invalid, or the request fails
|
|
295
|
-
*
|
|
296
|
-
* An example of how to use requestWithdrawal:
|
|
297
|
-
* ```typescript
|
|
298
|
-
* const result = await client.splits.requestWithdrawal({
|
|
299
|
-
* ovmAddress: '0x1234567890123456789012345678901234567890',
|
|
300
|
-
* pubKeys: ['0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456'],
|
|
301
|
-
* amounts: ['32000000000'] // 32 ETH in gwei
|
|
302
|
-
* });
|
|
303
|
-
* console.log('Withdrawal requested:', result.txHash);
|
|
304
|
-
* ```
|
|
305
|
-
*/
|
|
306
|
-
requestWithdrawal(payload) {
|
|
307
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
308
|
-
if (!this.signer) {
|
|
309
|
-
throw new Error('Signer is required in requestWithdrawal');
|
|
310
|
-
}
|
|
311
|
-
// [TBD] need to move ovm verification to sdk method and use it here
|
|
312
|
-
const validatedPayload = (0, ajv_1.validatePayload)(payload, schema_1.ovmRequestWithdrawalPayloadSchema);
|
|
313
|
-
return yield (0, splitHelpers_1.requestWithdrawalFromOVM)({
|
|
314
|
-
ovmAddress: validatedPayload.ovmAddress,
|
|
315
|
-
pubKeys: validatedPayload.pubKeys,
|
|
316
|
-
amounts: validatedPayload.amounts,
|
|
317
|
-
withdrawalFees: validatedPayload.withdrawalFees,
|
|
318
|
-
signer: this.signer,
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Deposits to OVM contract using multicall3 for batch operations.
|
|
324
|
-
*
|
|
325
|
-
* This method allows depositing to an OVM contract using multicall3 for efficient batch processing.
|
|
326
|
-
* Each deposit includes validator public key, withdrawal credentials, signature, deposit data root, and amount.
|
|
327
|
-
*
|
|
328
|
-
* @remarks
|
|
329
|
-
* **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
|
|
330
|
-
* and not pushed to version control.
|
|
331
|
-
*
|
|
332
|
-
* @param {OVMDepositPayload} payload - Data needed to deposit to OVM
|
|
333
|
-
* @returns {Promise<{txHashes: string[]}>} Array of transaction hashes for all batches
|
|
334
|
-
* @throws Will throw an error if the signer is not provided, OVM address is invalid, or the deposit fails
|
|
335
|
-
*
|
|
336
|
-
* An example of how to use deposit:
|
|
337
|
-
* ```typescript
|
|
338
|
-
* const result = await client.splits.deposit({
|
|
339
|
-
* ovmAddress: '0x1234567890123456789012345678901234567890',
|
|
340
|
-
* deposits: [{
|
|
341
|
-
* pubkey: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
|
|
342
|
-
* withdrawal_credentials: '0x1234567890123456789012345678901234567890',
|
|
343
|
-
* signature: '0x123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456',
|
|
344
|
-
* deposit_data_root: '0x1234567890123456789012345678901234567890123456789012345678901234',
|
|
345
|
-
* amount: '32000000000000000000' // 32 ETH in wei
|
|
346
|
-
* }]
|
|
347
|
-
* });
|
|
348
|
-
* console.log('Deposits completed:', result.txHashes);
|
|
349
|
-
* ```
|
|
350
|
-
*/
|
|
351
|
-
deposit(payload) {
|
|
352
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
353
|
-
if (!this.signer) {
|
|
354
|
-
throw new Error('Signer is required in deposit');
|
|
355
|
-
}
|
|
356
|
-
const validatedPayload = (0, ajv_1.validatePayload)(payload, schema_1.ovmDepositPayloadSchema);
|
|
357
|
-
return yield (0, splitHelpers_1.depositWithMulticall3)({
|
|
358
|
-
ovmAddress: validatedPayload.ovmAddress,
|
|
359
|
-
deposits: validatedPayload.deposits,
|
|
360
|
-
signer: this.signer,
|
|
361
|
-
chainId: this.chainId,
|
|
362
|
-
});
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
exports.ObolSplits = ObolSplits;
|
package/dist/cjs/src/types.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FORK_NAMES = exports.FORK_MAPPING = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Permitted ChainID's
|
|
6
|
-
*/
|
|
7
|
-
var FORK_MAPPING;
|
|
8
|
-
(function (FORK_MAPPING) {
|
|
9
|
-
/** Mainnet. */
|
|
10
|
-
FORK_MAPPING[FORK_MAPPING["0x00000000"] = 1] = "0x00000000";
|
|
11
|
-
/** Goerli/Prater. */
|
|
12
|
-
FORK_MAPPING[FORK_MAPPING["0x00001020"] = 5] = "0x00001020";
|
|
13
|
-
/** Gnosis Chain. */
|
|
14
|
-
FORK_MAPPING[FORK_MAPPING["0x00000064"] = 100] = "0x00000064";
|
|
15
|
-
/** Holesky. */
|
|
16
|
-
FORK_MAPPING[FORK_MAPPING["0x01017000"] = 17000] = "0x01017000";
|
|
17
|
-
/** Sepolia. */
|
|
18
|
-
FORK_MAPPING[FORK_MAPPING["0x90000069"] = 11155111] = "0x90000069";
|
|
19
|
-
/** Hoodi Chain. */
|
|
20
|
-
FORK_MAPPING[FORK_MAPPING["0x10000910"] = 560048] = "0x10000910";
|
|
21
|
-
})(FORK_MAPPING || (exports.FORK_MAPPING = FORK_MAPPING = {}));
|
|
22
|
-
exports.FORK_NAMES = {
|
|
23
|
-
[FORK_MAPPING['0x00000000']]: 'mainnet',
|
|
24
|
-
[FORK_MAPPING['0x00001020']]: 'goerli',
|
|
25
|
-
[FORK_MAPPING['0x00000064']]: 'gnosis',
|
|
26
|
-
[FORK_MAPPING['0x01017000']]: 'holesky',
|
|
27
|
-
[FORK_MAPPING['0x90000069']]: 'sepolia',
|
|
28
|
-
[FORK_MAPPING['0x10000910']]: 'hoodi',
|
|
29
|
-
};
|
package/dist/cjs/src/utils.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getProvider = exports.isContractAvailable = exports.findDeployedBytecode = exports.definitionFlow = exports.strToUint8Array = exports.hexWithout0x = void 0;
|
|
13
|
-
const ethers_1 = require("ethers");
|
|
14
|
-
const constants_1 = require("./constants");
|
|
15
|
-
const types_1 = require("./types");
|
|
16
|
-
const hexWithout0x = (hex) => {
|
|
17
|
-
return hex.slice(2, hex.length);
|
|
18
|
-
};
|
|
19
|
-
exports.hexWithout0x = hexWithout0x;
|
|
20
|
-
const strToUint8Array = (str) => {
|
|
21
|
-
return new TextEncoder().encode(str);
|
|
22
|
-
};
|
|
23
|
-
exports.strToUint8Array = strToUint8Array;
|
|
24
|
-
const definitionFlow = (clusterDefinition) => {
|
|
25
|
-
if (clusterDefinition.creator.address &&
|
|
26
|
-
clusterDefinition.creator.config_signature &&
|
|
27
|
-
clusterDefinition.operators.every(operator => {
|
|
28
|
-
return (operator.address &&
|
|
29
|
-
operator.config_signature &&
|
|
30
|
-
operator.enr &&
|
|
31
|
-
operator.enr_signature);
|
|
32
|
-
})) {
|
|
33
|
-
return constants_1.DefinitionFlow.Group;
|
|
34
|
-
}
|
|
35
|
-
else if (clusterDefinition.creator.address &&
|
|
36
|
-
clusterDefinition.creator.config_signature &&
|
|
37
|
-
clusterDefinition.operators.every(operator => {
|
|
38
|
-
return (!operator.address &&
|
|
39
|
-
!operator.config_signature &&
|
|
40
|
-
operator.enr &&
|
|
41
|
-
!operator.enr_signature);
|
|
42
|
-
})) {
|
|
43
|
-
return constants_1.DefinitionFlow.Solo;
|
|
44
|
-
}
|
|
45
|
-
else if (!clusterDefinition.creator.address &&
|
|
46
|
-
!clusterDefinition.creator.config_signature &&
|
|
47
|
-
clusterDefinition.operators.every(operator => {
|
|
48
|
-
return (!operator.address &&
|
|
49
|
-
!operator.config_signature &&
|
|
50
|
-
operator.enr &&
|
|
51
|
-
!operator.enr_signature);
|
|
52
|
-
})) {
|
|
53
|
-
return constants_1.DefinitionFlow.Charon;
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
};
|
|
57
|
-
exports.definitionFlow = definitionFlow;
|
|
58
|
-
const findDeployedBytecode = (contractAddress, provider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
-
return yield (provider === null || provider === void 0 ? void 0 : provider.getCode(contractAddress));
|
|
60
|
-
});
|
|
61
|
-
exports.findDeployedBytecode = findDeployedBytecode;
|
|
62
|
-
const isContractAvailable = (contractAddress, provider, bytecode) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
const code = yield (0, exports.findDeployedBytecode)(contractAddress, provider);
|
|
64
|
-
if (bytecode) {
|
|
65
|
-
return !!code && code === bytecode;
|
|
66
|
-
}
|
|
67
|
-
return !!code && code !== '0x' && code !== '0x0';
|
|
68
|
-
});
|
|
69
|
-
exports.isContractAvailable = isContractAvailable;
|
|
70
|
-
const getProvider = (chainId, rpcUrl) => {
|
|
71
|
-
const resolvedRpcUrl = rpcUrl !== null && rpcUrl !== void 0 ? rpcUrl : constants_1.PROVIDER_MAP[chainId];
|
|
72
|
-
if (chainId && (!resolvedRpcUrl || resolvedRpcUrl === 'undefined')) {
|
|
73
|
-
throw new Error(`No provider configured for ${types_1.FORK_NAMES[chainId]}`);
|
|
74
|
-
}
|
|
75
|
-
return new ethers_1.ethers.JsonRpcProvider(resolvedRpcUrl);
|
|
76
|
-
};
|
|
77
|
-
exports.getProvider = getProvider;
|