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