@obolnetwork/obol-sdk 2.8.0 → 2.8.1

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.
@@ -142,76 +142,84 @@ const isChainSupportedForSplitters = (chainId) => {
142
142
  exports.isChainSupportedForSplitters = isChainSupportedForSplitters;
143
143
  exports.CHAIN_CONFIGURATION = {
144
144
  [types_1.FORK_MAPPING['0x00000000']]: {
145
- SPLITMAIN_ADDRESS: {
145
+ SPLITMAIN_CONTRACT: {
146
146
  address: '0x2ed6c4B5dA6378c7897AC67Ba9e43102Feb694EE',
147
147
  bytecode: bytecodes_1.MAINNET_SPLITMAIN_BYTECODE,
148
148
  },
149
- MULTICALL_ADDRESS: {
149
+ MULTICALL_CONTRACT: {
150
150
  address: '0xeefba1e63905ef1d7acba5a8513c70307c1ce441',
151
151
  bytecode: bytecodes_1.MAINNET_MULTICALL_BYTECODE,
152
152
  },
153
- OWR_FACTORY_ADDRESS: {
153
+ OWR_FACTORY_CONTRACT: {
154
154
  address: '0x119acd7844cbdd5fc09b1c6a4408f490c8f7f522',
155
155
  bytecode: bytecodes_1.MAINNET_OWR_FACTORY_BYTECODE,
156
156
  },
157
- RETROACTIVE_FUNDING_ADDRESS: {
157
+ RETROACTIVE_FUNDING_CONTRACT: {
158
158
  address: '0xDe5aE4De36c966747Ea7DF13BD9589642e2B1D0d',
159
159
  bytecode: '',
160
160
  },
161
161
  // OVM and SplitV2 Contract Addresses
162
- OVM_FACTORY_ADDRESS: {
162
+ OVM_FACTORY_CONTRACT: {
163
163
  address: '0xdfe2d8b26806583cf03b3cb623b0752f8670e93e',
164
164
  bytecode: bytecodes_1.MAINNET_OVM_FACTORY_BYTECODE,
165
165
  },
166
- WAREHOUSE_ADDRESS: {
166
+ WAREHOUSE_CONTRACT: {
167
167
  address: '0x8fb66F38cF86A3d5e8768f8F1754A24A6c661Fb8',
168
168
  bytecode: bytecodes_1.MAINNET_WAREHOUSE_BYTECODE,
169
169
  },
170
+ SPLIT_V2_FACTORY_CONTRACT: {
171
+ address: '0x5cbA88D55Cec83caD5A105Ad40C8c9aF20bE21d1',
172
+ bytecode: bytecodes_1.MAINNET_SPLIT_V2_FACTORY_BYTECODE,
173
+ },
170
174
  },
171
175
  [types_1.FORK_MAPPING['0x01017000']]: {
172
- SPLITMAIN_ADDRESS: {
176
+ SPLITMAIN_CONTRACT: {
173
177
  address: '0xfC8a305728051367797DADE6Aa0344E0987f5286',
174
178
  bytecode: bytecodes_1.HOLESKY_SPLITMAIN_BYTECODE,
175
179
  },
176
- MULTICALL_ADDRESS: {
180
+ MULTICALL_CONTRACT: {
177
181
  address: '0xcA11bde05977b3631167028862bE2a173976CA11',
178
182
  bytecode: bytecodes_1.HOLESKY_MULTICALL_BYTECODE,
179
183
  },
180
- OWR_FACTORY_ADDRESS: {
184
+ OWR_FACTORY_CONTRACT: {
181
185
  address: '0xc0961353fcc43a99e3041db07ac646720e116256',
182
186
  bytecode: bytecodes_1.HOLESKY_OWR_FACTORY_BYTECODE,
183
187
  },
184
- RETROACTIVE_FUNDING_ADDRESS: {
188
+ RETROACTIVE_FUNDING_CONTRACT: {
185
189
  address: '0x43F641fA70e09f0326ac66b4Ef0C416EaEcBC6f5',
186
190
  bytecode: '',
187
191
  },
188
192
  },
189
193
  [types_1.FORK_MAPPING['0x10000910']]: {
190
- SPLITMAIN_ADDRESS: {
194
+ SPLITMAIN_CONTRACT: {
191
195
  address: '0xc05ae267291705ac16F75283572294ed2a91CBc7',
192
196
  bytecode: bytecodes_1.HOODI_SPLITMAIN_BYTECODE,
193
197
  },
194
- MULTICALL_ADDRESS: {
198
+ MULTICALL_CONTRACT: {
195
199
  address: '0xcA11bde05977b3631167028862bE2a173976CA11',
196
200
  bytecode: bytecodes_1.HOODI_MULTICALL_BYTECODE,
197
201
  },
198
- OWR_FACTORY_ADDRESS: {
202
+ OWR_FACTORY_CONTRACT: {
199
203
  address: '0x9ff0c649d0bf5fe7efa4d72e94bed7302ed5c8d7',
200
204
  bytecode: bytecodes_1.HOODI_OWR_FACTORY_BYTECODE,
201
205
  },
202
- RETROACTIVE_FUNDING_ADDRESS: {
206
+ RETROACTIVE_FUNDING_CONTRACT: {
203
207
  address: '0x43F641fA70e09f0326ac66b4Ef0C416EaEcBC6f5',
204
208
  bytecode: '',
205
209
  },
206
210
  // OVM and SplitV2 Contract Addresses
207
- OVM_FACTORY_ADDRESS: {
211
+ OVM_FACTORY_CONTRACT: {
208
212
  address: '0x6F13d929C783a420AE4DC71C1dcc27A02038Ed09',
209
213
  bytecode: bytecodes_1.HOODI_OVM_FACTORY_BYTECODE,
210
214
  },
211
- WAREHOUSE_ADDRESS: {
215
+ WAREHOUSE_CONTRACT: {
212
216
  address: '0x8fb66F38cF86A3d5e8768f8F1754A24A6c661Fb8',
213
217
  bytecode: bytecodes_1.HOODI_WAREHOUSE_BYTECODE,
214
218
  },
219
+ SPLIT_V2_FACTORY_CONTRACT: {
220
+ address: '0x5cbA88D55Cec83caD5A105Ad40C8c9aF20bE21d1',
221
+ bytecode: bytecodes_1.HOODI_SPLIT_V2_FACTORY_BYTECODE,
222
+ },
215
223
  },
216
224
  };
217
225
  exports.DEFAULT_RETROACTIVE_FUNDING_REWARDS_ONLY_SPLIT = 1;
@@ -148,19 +148,19 @@ class Client extends base_js_1.Base {
148
148
  throw new Error(`Splitter configuration is not supported on ${this.chainId} chain`);
149
149
  }
150
150
  const chainConfig = constants_js_1.CHAIN_CONFIGURATION[this.chainId];
151
- if (!(chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.SPLITMAIN_ADDRESS)) {
152
- throw new Error(`SPLITMAIN_ADDRESS is not configured for chain ${this.chainId}`);
151
+ if (!(chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.SPLITMAIN_CONTRACT)) {
152
+ throw new Error(`SPLITMAIN_CONTRACT is not configured for chain ${this.chainId}`);
153
153
  }
154
- const checkSplitMainAddress = yield (0, utils_js_1.isContractAvailable)(chainConfig.SPLITMAIN_ADDRESS.address, this.signer.provider, chainConfig.SPLITMAIN_ADDRESS.bytecode);
155
- const checkMulticallAddress = yield (0, utils_js_1.isContractAvailable)(chainConfig.MULTICALL_ADDRESS.address, this.signer.provider, chainConfig.MULTICALL_ADDRESS.bytecode);
156
- const checkOWRFactoryAddress = yield (0, utils_js_1.isContractAvailable)(chainConfig.OWR_FACTORY_ADDRESS.address, this.signer.provider, chainConfig.OWR_FACTORY_ADDRESS.bytecode);
154
+ const checkSplitMainAddress = yield (0, utils_js_1.isContractAvailable)(chainConfig.SPLITMAIN_CONTRACT.address, this.signer.provider, chainConfig.SPLITMAIN_CONTRACT.bytecode);
155
+ const checkMulticallAddress = yield (0, utils_js_1.isContractAvailable)(chainConfig.MULTICALL_CONTRACT.address, this.signer.provider, chainConfig.MULTICALL_CONTRACT.bytecode);
156
+ const checkOWRFactoryAddress = yield (0, utils_js_1.isContractAvailable)(chainConfig.OWR_FACTORY_CONTRACT.address, this.signer.provider, chainConfig.OWR_FACTORY_CONTRACT.bytecode);
157
157
  if (!checkMulticallAddress ||
158
158
  !checkSplitMainAddress ||
159
159
  !checkOWRFactoryAddress) {
160
160
  throw new Error(`Something isn not working as expected, check this issue with obol-sdk team on ${constants_js_1.OBOL_SDK_EMAIL}`);
161
161
  }
162
162
  const retroActiveFundingRecipient = {
163
- account: chainConfig.RETROACTIVE_FUNDING_ADDRESS.address,
163
+ account: chainConfig.RETROACTIVE_FUNDING_CONTRACT.address,
164
164
  percentAllocation: validatedPayload.ObolRAFSplit,
165
165
  };
166
166
  const copiedSplitRecipients = [...validatedPayload.splitRecipients];
@@ -222,15 +222,15 @@ class Client extends base_js_1.Base {
222
222
  throw new Error(`Splitter configuration is not supported on ${this.chainId} chain`);
223
223
  }
224
224
  const chainConfig = constants_js_1.CHAIN_CONFIGURATION[this.chainId];
225
- if (!(chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.SPLITMAIN_ADDRESS)) {
226
- throw new Error(`SPLITMAIN_ADDRESS is not configured for chain ${this.chainId}`);
225
+ if (!(chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.SPLITMAIN_CONTRACT)) {
226
+ throw new Error(`SPLITMAIN_CONTRACT is not configured for chain ${this.chainId}`);
227
227
  }
228
- const checkSplitMainAddress = yield (0, utils_js_1.isContractAvailable)(chainConfig.SPLITMAIN_ADDRESS.address, this.signer.provider, chainConfig.SPLITMAIN_ADDRESS.bytecode);
228
+ const checkSplitMainAddress = yield (0, utils_js_1.isContractAvailable)(chainConfig.SPLITMAIN_CONTRACT.address, this.signer.provider, chainConfig.SPLITMAIN_CONTRACT.bytecode);
229
229
  if (!checkSplitMainAddress) {
230
230
  throw new Error(`Something isn not working as expected, check this issue with obol-sdk team on ${constants_js_1.OBOL_SDK_EMAIL}`);
231
231
  }
232
232
  const retroActiveFundingRecipient = {
233
- account: chainConfig.RETROACTIVE_FUNDING_ADDRESS.address,
233
+ account: chainConfig.RETROACTIVE_FUNDING_CONTRACT.address,
234
234
  percentAllocation: validatedPayload.ObolRAFSplit,
235
235
  };
236
236
  const copiedSplitRecipients = [...validatedPayload.splitRecipients];
@@ -4,7 +4,6 @@ exports.ovmTotalSplitPayloadSchema = exports.ovmRewardsSplitPayloadSchema = expo
4
4
  const ethers_1 = require("ethers");
5
5
  const constants_1 = require("./constants");
6
6
  const ajv_1 = require("./ajv");
7
- const viem_1 = require("viem");
8
7
  exports.operatorPayloadSchema = {
9
8
  type: 'object',
10
9
  properties: {
@@ -163,7 +162,7 @@ exports.ovmBaseSplitPayload = {
163
162
  splitOwnerAddress: {
164
163
  type: 'string',
165
164
  pattern: '^0x[a-fA-F0-9]{40}$',
166
- default: viem_1.zeroAddress,
165
+ default: ethers_1.ZeroAddress,
167
166
  },
168
167
  principalThreshold: {
169
168
  type: 'number',
@@ -9,20 +9,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.deployOVMAndSplitV2 = exports.deployOVMContract = exports.isSplitV2Deployed = exports.predictSplitV2Address = exports.createSplitsClient = exports.formatRecipientsForSplitV2 = exports.multicall = exports.getOWRTranches = exports.deploySplitterAndOWRContracts = exports.deploySplitterContract = exports.handleDeployOWRAndSplitter = exports.predictSplitterAddress = exports.formatSplitRecipients = void 0;
12
+ exports.deployOVMAndSplitV2 = exports.deployOVMContract = exports.isSplitV2Deployed = exports.predictSplitV2Address = exports.formatRecipientsForSplitV2 = exports.multicall = exports.getOWRTranches = exports.deploySplitterAndOWRContracts = exports.deploySplitterContract = exports.handleDeployOWRAndSplitter = exports.predictSplitterAddress = exports.formatSplitRecipients = void 0;
13
13
  const ethers_1 = require("ethers");
14
14
  const OWR_1 = require("../abi/OWR");
15
15
  const OVMFactory_1 = require("../abi/OVMFactory");
16
16
  const SplitMain_1 = require("../abi/SplitMain");
17
17
  const Multicall_1 = require("../abi/Multicall");
18
18
  const constants_1 = require("../constants");
19
- const splits_sdk_1 = require("@0xsplits/splits-sdk");
20
- const viem_1 = require("viem");
21
- const chains_1 = require("viem/chains");
22
- const accounts_1 = require("viem/accounts");
19
+ const splitV2FactoryAbi_1 = require("../abi/splitV2FactoryAbi");
23
20
  const splitMainContractInterface = new ethers_1.Interface(SplitMain_1.splitMainEthereumAbi);
24
21
  const owrFactoryContractInterface = new ethers_1.Interface(OWR_1.OWRFactoryContract.abi);
25
22
  const ovmFactoryContractInterface = new ethers_1.Interface(OVMFactory_1.OVMFactoryContract.abi);
23
+ const splitV2FactoryInterface = new ethers_1.Interface(splitV2FactoryAbi_1.splitV2FactoryAbi);
26
24
  // Helper function to extract common recipient formatting logic
27
25
  const formatRecipientsCommon = (recipients) => {
28
26
  const copiedRecipients = [...recipients];
@@ -50,7 +48,7 @@ exports.formatSplitRecipients = formatSplitRecipients;
50
48
  const predictSplitterAddress = ({ signer, accounts, percentAllocations, chainId, distributorFee, controllerAddress, }) => __awaiter(void 0, void 0, void 0, function* () {
51
49
  var _a, _b, _c;
52
50
  try {
53
- const splitMainContractInstance = new ethers_1.Contract(getChainConfig(chainId).SPLITMAIN_ADDRESS.address, SplitMain_1.splitMainEthereumAbi, signer);
51
+ const splitMainContractInstance = new ethers_1.Contract(getChainConfig(chainId).SPLITMAIN_CONTRACT.address, SplitMain_1.splitMainEthereumAbi, signer);
54
52
  let predictedSplitterAddress;
55
53
  if (controllerAddress === ethers_1.ZeroAddress) {
56
54
  try {
@@ -153,7 +151,7 @@ exports.handleDeployOWRAndSplitter = handleDeployOWRAndSplitter;
153
151
  const createOWRContract = ({ owrArgs, signer, chainId, }) => __awaiter(void 0, void 0, void 0, function* () {
154
152
  var _g, _h, _j, _k, _l;
155
153
  try {
156
- const OWRFactoryInstance = new ethers_1.Contract(getChainConfig(chainId).OWR_FACTORY_ADDRESS.address, OWR_1.OWRFactoryContract.abi, signer);
154
+ const OWRFactoryInstance = new ethers_1.Contract(getChainConfig(chainId).OWR_FACTORY_CONTRACT.address, OWR_1.OWRFactoryContract.abi, signer);
157
155
  let tx;
158
156
  try {
159
157
  tx = yield OWRFactoryInstance.createOWRecipient(owrArgs.recoveryAddress, owrArgs.principalRecipient, owrArgs.predictedSplitterAddress, (0, ethers_1.parseEther)(owrArgs.amountOfPrincipalStake.toString()));
@@ -197,7 +195,7 @@ const createOWRContract = ({ owrArgs, signer, chainId, }) => __awaiter(void 0, v
197
195
  const deploySplitterContract = ({ signer, accounts, percentAllocations, chainId, distributorFee, controllerAddress, }) => __awaiter(void 0, void 0, void 0, function* () {
198
196
  var _m, _o, _p, _q, _r;
199
197
  try {
200
- const splitMainContractInstance = new ethers_1.Contract(getChainConfig(chainId).SPLITMAIN_ADDRESS.address, SplitMain_1.splitMainEthereumAbi, signer);
198
+ const splitMainContractInstance = new ethers_1.Contract(getChainConfig(chainId).SPLITMAIN_CONTRACT.address, SplitMain_1.splitMainEthereumAbi, signer);
201
199
  let tx;
202
200
  try {
203
201
  tx = yield splitMainContractInstance.createSplit(accounts, percentAllocations, distributorFee, controllerAddress);
@@ -245,14 +243,13 @@ const deploySplitterAndOWRContracts = ({ owrArgs, splitterArgs, signer, chainId,
245
243
  const splitTxData = encodeCreateSplitTxData(splitterArgs.accounts, splitterArgs.percentAllocations, splitterArgs.distributorFee, splitterArgs.controllerAddress);
246
244
  const owrTxData = encodeCreateOWRecipientTxData(owrArgs.recoveryAddress, owrArgs.principalRecipient, owrArgs.predictedSplitterAddress, owrArgs.amountOfPrincipalStake);
247
245
  executeCalls.push({
248
- target: getChainConfig(chainId).SPLITMAIN_ADDRESS.address,
246
+ target: getChainConfig(chainId).SPLITMAIN_CONTRACT.address,
249
247
  callData: splitTxData,
250
248
  }, {
251
- target: getChainConfig(chainId).OWR_FACTORY_ADDRESS.address,
249
+ target: getChainConfig(chainId).OWR_FACTORY_CONTRACT.address,
252
250
  callData: owrTxData,
253
251
  });
254
- const multicallAddess = getChainConfig(chainId).MULTICALL_ADDRESS.address;
255
- const executeMultiCalls = yield (0, exports.multicall)(executeCalls, signer, multicallAddess);
252
+ const executeMultiCalls = yield (0, exports.multicall)(executeCalls, signer, chainId);
256
253
  const splitAddressData = (_s = executeMultiCalls === null || executeMultiCalls === void 0 ? void 0 : executeMultiCalls.logs[0]) === null || _s === void 0 ? void 0 : _s.topics[1];
257
254
  const formattedSplitterAddress = '0x' + (splitAddressData === null || splitAddressData === void 0 ? void 0 : splitAddressData.slice(26, 66));
258
255
  const owrAddressData = (_t = executeMultiCalls === null || executeMultiCalls === void 0 ? void 0 : executeMultiCalls.logs[1]) === null || _t === void 0 ? void 0 : _t.topics[1];
@@ -294,9 +291,11 @@ const getOWRTranches = ({ owrAddress, signer, }) => __awaiter(void 0, void 0, vo
294
291
  }
295
292
  });
296
293
  exports.getOWRTranches = getOWRTranches;
297
- const multicall = (calls, signer, multicallAddress) => __awaiter(void 0, void 0, void 0, function* () {
294
+ const multicall = (calls, signer, chainId) => __awaiter(void 0, void 0, void 0, function* () {
298
295
  var _w, _x, _y;
299
296
  try {
297
+ const chainConfig = getChainConfig(chainId);
298
+ const multicallAddress = chainConfig.MULTICALL_CONTRACT.address;
300
299
  const multiCallContractInstance = new ethers_1.Contract(multicallAddress, Multicall_1.MultiCallContract.abi, signer);
301
300
  let tx;
302
301
  try {
@@ -356,79 +355,46 @@ const formatRecipientsForSplitV2 = (splitRecipients) => {
356
355
  }));
357
356
  };
358
357
  exports.formatRecipientsForSplitV2 = formatRecipientsForSplitV2;
359
- const createSplitsClient = (signer, chainId) => __awaiter(void 0, void 0, void 0, function* () {
360
- const chain = chainId === 1 ? chains_1.mainnet : chains_1.hoodi;
361
- const client = (0, viem_1.createPublicClient)({
362
- chain,
363
- transport: (0, viem_1.http)(constants_1.CHAIN_PUBLIC_RPC_URL[chainId]),
364
- });
365
- // convert signer to walletClient
366
- if (typeof window !== 'undefined' &&
367
- signer.provider instanceof ethers_1.BrowserProvider) {
368
- // For browser environment
369
- const address = yield signer.getAddress();
370
- const viemWalletClient = (0, viem_1.createWalletClient)({
371
- account: address,
372
- chain,
373
- transport: (0, viem_1.custom)(window.ethereum),
374
- });
375
- return new splits_sdk_1.SplitsClient({
376
- publicClient: client,
377
- walletClient: viemWalletClient,
378
- chainId,
379
- });
380
- }
381
- else {
382
- // For non-browser environment, extract private key from signer
383
- const signerPrivateKey = signer === null || signer === void 0 ? void 0 : signer.privateKey;
384
- if (!signerPrivateKey) {
385
- throw new Error('Signer private key not available');
386
- }
387
- const privateKey = signerPrivateKey.startsWith('0x')
388
- ? signerPrivateKey
389
- : `0x${signerPrivateKey}`;
390
- const scriptAccount = (0, accounts_1.privateKeyToAccount)(privateKey);
391
- const account = scriptAccount;
392
- const viemWalletClient = (0, viem_1.createWalletClient)({
393
- account,
394
- chain,
395
- transport: (0, viem_1.http)(constants_1.CHAIN_PUBLIC_RPC_URL[chainId]),
396
- });
397
- return new splits_sdk_1.SplitsClient({
398
- publicClient: client,
399
- walletClient: viemWalletClient,
400
- chainId,
401
- });
402
- }
403
- });
404
- exports.createSplitsClient = createSplitsClient;
358
+ // Helper function to create SplitV2 parameters
359
+ const createSplitV2Params = (recipients, distributorFeePercent) => {
360
+ const addresses = recipients.map(r => r.address);
361
+ const allocations = recipients.map(r => Math.floor(r.percentAllocation * 1e4)); // Convert to basis points
362
+ const totalAllocation = allocations.reduce((sum, allocation) => sum + allocation, 0);
363
+ return {
364
+ recipients: addresses,
365
+ allocations,
366
+ totalAllocation,
367
+ distributionIncentive: distributorFeePercent,
368
+ };
369
+ };
405
370
  const predictSplitV2Address = ({ splitOwnerAddress, recipients, distributorFeePercent, salt, signer, chainId, }) => __awaiter(void 0, void 0, void 0, function* () {
406
- var _z;
371
+ var _z, _0;
407
372
  try {
408
- const splitsClient = yield (0, exports.createSplitsClient)(signer, chainId);
409
- const response = yield splitsClient.splitV2.predictDeterministicAddress({
410
- ownerAddress: splitOwnerAddress,
411
- recipients,
412
- distributorFeePercent,
413
- salt,
414
- });
415
- return response.splitAddress;
373
+ const chainConfig = getChainConfig(chainId);
374
+ if (!((_z = chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.SPLIT_V2_FACTORY_CONTRACT) === null || _z === void 0 ? void 0 : _z.address)) {
375
+ throw new Error(`SplitV2 Factory not configured for chain ${chainId}`);
376
+ }
377
+ const splitV2FactoryContract = new ethers_1.Contract(chainConfig.SPLIT_V2_FACTORY_CONTRACT.address, splitV2FactoryAbi_1.splitV2FactoryAbi, signer);
378
+ const splitParams = createSplitV2Params(recipients, distributorFeePercent);
379
+ const predictedAddress = yield splitV2FactoryContract['predictDeterministicAddress((address[],uint256[],uint256,uint16),address,bytes32)'](splitParams, splitOwnerAddress, salt);
380
+ return predictedAddress;
416
381
  }
417
382
  catch (error) {
418
- throw new Error(`Failed to predict SplitV2 address: ${(_z = error.message) !== null && _z !== void 0 ? _z : 'SplitV2 SDK call failed'}`);
383
+ throw new Error(`Failed to predict SplitV2 address: ${(_0 = error.message) !== null && _0 !== void 0 ? _0 : 'SplitV2 contract call failed'}`);
419
384
  }
420
385
  });
421
386
  exports.predictSplitV2Address = predictSplitV2Address;
422
387
  const isSplitV2Deployed = ({ splitOwnerAddress, recipients, distributorFeePercent, salt, signer, chainId, }) => __awaiter(void 0, void 0, void 0, function* () {
388
+ var _1;
423
389
  try {
424
- const splitsClient = yield (0, exports.createSplitsClient)(signer, chainId);
425
- const response = yield splitsClient.splitV2.isDeployed({
426
- ownerAddress: splitOwnerAddress,
427
- recipients,
428
- distributorFeePercent,
429
- salt,
430
- });
431
- return response.deployed;
390
+ const chainConfig = getChainConfig(chainId);
391
+ if (!((_1 = chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.SPLIT_V2_FACTORY_CONTRACT) === null || _1 === void 0 ? void 0 : _1.address)) {
392
+ throw new Error(`SplitV2 Factory not configured for chain ${chainId}`);
393
+ }
394
+ const splitV2FactoryContract = new ethers_1.Contract(chainConfig.SPLIT_V2_FACTORY_CONTRACT.address, splitV2FactoryAbi_1.splitV2FactoryAbi, signer);
395
+ const splitParams = createSplitV2Params(recipients, distributorFeePercent);
396
+ const [, exists] = yield splitV2FactoryContract.isDeployed(splitParams, splitOwnerAddress, salt);
397
+ return exists;
432
398
  }
433
399
  catch (error) {
434
400
  // If the check fails, assume it's not deployed
@@ -437,17 +403,17 @@ const isSplitV2Deployed = ({ splitOwnerAddress, recipients, distributorFeePercen
437
403
  });
438
404
  exports.isSplitV2Deployed = isSplitV2Deployed;
439
405
  const deployOVMContract = ({ OVMOwnerAddress, principalRecipient, rewardRecipient, principalThreshold, signer, chainId, }) => __awaiter(void 0, void 0, void 0, function* () {
440
- var _0, _1, _2;
406
+ var _2, _3, _4;
441
407
  try {
442
408
  const chainConfig = getChainConfig(chainId);
443
- if (!((_0 = chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.OVM_FACTORY_ADDRESS) === null || _0 === void 0 ? void 0 : _0.address)) {
409
+ if (!((_2 = chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.OVM_FACTORY_CONTRACT) === null || _2 === void 0 ? void 0 : _2.address)) {
444
410
  throw new Error(`OVM Factory not configured for chain ${chainId}`);
445
411
  }
446
- const ovmFactoryContract = new ethers_1.Contract(chainConfig.OVM_FACTORY_ADDRESS.address, OVMFactory_1.OVMFactoryContract.abi, signer);
412
+ const ovmFactoryContract = new ethers_1.Contract(chainConfig.OVM_FACTORY_CONTRACT.address, OVMFactory_1.OVMFactoryContract.abi, signer);
447
413
  const tx = yield ovmFactoryContract.createObolValidatorManager(OVMOwnerAddress, principalRecipient, rewardRecipient, principalThreshold);
448
414
  const receipt = yield tx.wait();
449
415
  // Extract OVM address from logs
450
- const ovmAddressLog = (_1 = receipt === null || receipt === void 0 ? void 0 : receipt.logs[1]) === null || _1 === void 0 ? void 0 : _1.topics[1];
416
+ const ovmAddressLog = (_3 = receipt === null || receipt === void 0 ? void 0 : receipt.logs[1]) === null || _3 === void 0 ? void 0 : _3.topics[1];
451
417
  if (!ovmAddressLog) {
452
418
  throw new Error('Failed to extract OVM address from transaction logs');
453
419
  }
@@ -455,60 +421,58 @@ const deployOVMContract = ({ OVMOwnerAddress, principalRecipient, rewardRecipien
455
421
  return ovmAddress;
456
422
  }
457
423
  catch (error) {
458
- throw new Error(`Failed to deploy OVM contract: ${(_2 = error.message) !== null && _2 !== void 0 ? _2 : 'OVM deployment failed'}`);
424
+ throw new Error(`Failed to deploy OVM contract: ${(_4 = error.message) !== null && _4 !== void 0 ? _4 : 'OVM deployment failed'}`);
459
425
  }
460
426
  });
461
427
  exports.deployOVMContract = deployOVMContract;
462
428
  const deployOVMAndSplitV2 = ({ ovmArgs, rewardRecipients, isRewardsSplitterDeployed, distributorFeePercent, salt, signer, chainId, principalSplitRecipients, isPrincipalSplitDeployed, splitOwnerAddress, }) => __awaiter(void 0, void 0, void 0, function* () {
463
- var _3, _4, _5, _6, _7;
429
+ var _5, _6, _7, _8, _9, _10, _11, _12, _13, _14;
464
430
  try {
465
431
  const chainConfig = getChainConfig(chainId);
466
- if (!((_3 = chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.OVM_FACTORY_ADDRESS) === null || _3 === void 0 ? void 0 : _3.address)) {
432
+ if (!((_5 = chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.OVM_FACTORY_CONTRACT) === null || _5 === void 0 ? void 0 : _5.address)) {
467
433
  throw new Error(`OVM Factory not configured for chain ${chainId}`);
468
434
  }
469
- const splitsClient = yield (0, exports.createSplitsClient)(signer, chainId);
435
+ if (!((_6 = chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.SPLIT_V2_FACTORY_CONTRACT) === null || _6 === void 0 ? void 0 : _6.address)) {
436
+ throw new Error(`SplitV2 Factory not configured for chain ${chainId}`);
437
+ }
470
438
  const executeCalls = [];
471
439
  if (rewardRecipients && !isRewardsSplitterDeployed) {
472
440
  // Create rewards split call data
473
- const rewardsSplitTxData = yield splitsClient.splitV2.callData.createSplit({
474
- recipients: rewardRecipients,
475
- distributorFeePercent,
476
- ownerAddress: splitOwnerAddress,
477
- salt,
441
+ const splitParams = createSplitV2Params(rewardRecipients, distributorFeePercent);
442
+ const rewardsSplitTxData = encodeCreateSplitV2DeterministicTxData(splitParams, splitOwnerAddress, salt);
443
+ executeCalls.push({
444
+ target: chainConfig.SPLIT_V2_FACTORY_CONTRACT.address,
445
+ callData: rewardsSplitTxData,
478
446
  });
479
- executeCalls.push(rewardsSplitTxData);
480
447
  }
481
448
  // Create principal split call data if needed (for total split scenario)
482
449
  if (principalSplitRecipients && !isPrincipalSplitDeployed) {
483
- const principalSplitTxData = yield splitsClient.splitV2.callData.createSplit({
484
- recipients: principalSplitRecipients,
485
- distributorFeePercent,
486
- salt,
487
- ownerAddress: splitOwnerAddress,
450
+ const principalSplitParams = createSplitV2Params(principalSplitRecipients, distributorFeePercent);
451
+ const principalSplitTxData = encodeCreateSplitV2DeterministicTxData(principalSplitParams, splitOwnerAddress, salt);
452
+ executeCalls.push({
453
+ target: chainConfig.SPLIT_V2_FACTORY_CONTRACT.address,
454
+ callData: principalSplitTxData,
488
455
  });
489
- executeCalls.push(principalSplitTxData);
490
456
  }
491
457
  // Create OVM call data
492
458
  const ovmTxData = encodeCreateOVMTxData(ovmArgs.OVMOwnerAddress, ovmArgs.principalRecipient, ovmArgs.rewardRecipient, ovmArgs.principalThreshold);
493
459
  executeCalls.push({
494
- address: chainConfig.OVM_FACTORY_ADDRESS.address,
495
- data: ovmTxData,
460
+ target: chainConfig.OVM_FACTORY_CONTRACT.address,
461
+ callData: ovmTxData,
496
462
  });
497
463
  // Execute multicall
498
- const executeMultiCalls = yield splitsClient.splitV2.multicall({
499
- calls: executeCalls,
500
- });
464
+ const executeMultiCalls = yield (0, exports.multicall)(executeCalls, signer, chainId);
501
465
  // Extract addresses from events
502
466
  let ovmAddress;
503
- const eventCount = executeMultiCalls === null || executeMultiCalls === void 0 ? void 0 : executeMultiCalls.events.length;
504
- if (eventCount === 2) {
505
- ovmAddress = (_4 = executeMultiCalls === null || executeMultiCalls === void 0 ? void 0 : executeMultiCalls.events[0]) === null || _4 === void 0 ? void 0 : _4.address;
467
+ const logsCount = ((_7 = executeMultiCalls === null || executeMultiCalls === void 0 ? void 0 : executeMultiCalls.logs) === null || _7 === void 0 ? void 0 : _7.length) || 0;
468
+ if (logsCount === 2) {
469
+ ovmAddress = '0x' + ((_9 = (_8 = executeMultiCalls === null || executeMultiCalls === void 0 ? void 0 : executeMultiCalls.logs[1]) === null || _8 === void 0 ? void 0 : _8.topics[1]) === null || _9 === void 0 ? void 0 : _9.slice(26, 66));
506
470
  }
507
- else if (eventCount === 5) {
508
- ovmAddress = (_5 = executeMultiCalls === null || executeMultiCalls === void 0 ? void 0 : executeMultiCalls.events[3]) === null || _5 === void 0 ? void 0 : _5.address;
471
+ else if (logsCount === 5) {
472
+ ovmAddress = '0x' + ((_11 = (_10 = executeMultiCalls === null || executeMultiCalls === void 0 ? void 0 : executeMultiCalls.logs[4]) === null || _10 === void 0 ? void 0 : _10.topics[1]) === null || _11 === void 0 ? void 0 : _11.slice(26, 66));
509
473
  }
510
474
  else {
511
- ovmAddress = (_6 = executeMultiCalls === null || executeMultiCalls === void 0 ? void 0 : executeMultiCalls.events[6]) === null || _6 === void 0 ? void 0 : _6.address;
475
+ ovmAddress = '0x' + ((_13 = (_12 = executeMultiCalls === null || executeMultiCalls === void 0 ? void 0 : executeMultiCalls.logs[7]) === null || _12 === void 0 ? void 0 : _12.topics[1]) === null || _13 === void 0 ? void 0 : _13.slice(26, 66));
512
476
  }
513
477
  if (!ovmAddress) {
514
478
  throw new Error('Failed to extract contract addresses from multicall events');
@@ -516,13 +480,17 @@ const deployOVMAndSplitV2 = ({ ovmArgs, rewardRecipients, isRewardsSplitterDeplo
516
480
  return ovmAddress;
517
481
  }
518
482
  catch (error) {
519
- throw new Error(`Failed to deploy OVM and SplitV2: ${(_7 = error.message) !== null && _7 !== void 0 ? _7 : 'Deployment failed'}`);
483
+ throw new Error(`Failed to deploy OVM and SplitV2: ${(_14 = error.message) !== null && _14 !== void 0 ? _14 : 'Deployment failed'}`);
520
484
  }
521
485
  });
522
486
  exports.deployOVMAndSplitV2 = deployOVMAndSplitV2;
523
487
  const encodeCreateOVMTxData = (OVMOwnerAddress, principalRecipient, rewardRecipient, principalThreshold) => {
524
488
  return ovmFactoryContractInterface.encodeFunctionData('createObolValidatorManager', [OVMOwnerAddress, principalRecipient, rewardRecipient, principalThreshold]);
525
489
  };
490
+ const encodeCreateSplitV2DeterministicTxData = (splitParams, splitOwnerAddress, salt) => {
491
+ // creatorAddress can be kept as default https://docs.splits.org/sdk/splits-v2#createsplit
492
+ return splitV2FactoryInterface.encodeFunctionData('createSplitDeterministic', [splitParams, splitOwnerAddress, ethers_1.ZeroAddress, salt]);
493
+ };
526
494
  // Helper function to safely get chain configuration
527
495
  const getChainConfig = (chainId) => {
528
496
  const config = constants_1.CHAIN_CONFIGURATION[chainId];
@@ -57,22 +57,33 @@ class ObolSplits {
57
57
  throw new Error(`Splitter configuration is not supported on ${this.chainId} chain`);
58
58
  }
59
59
  const chainConfig = constants_1.CHAIN_CONFIGURATION[this.chainId];
60
- if (!(chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.OVM_FACTORY_ADDRESS)) {
60
+ if (!(chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.OVM_FACTORY_CONTRACT)) {
61
61
  throw new Error(`OVM contract factory is not configured for chain ${this.chainId}`);
62
62
  }
63
63
  if (!this.provider) {
64
64
  throw new Error('Provider is required to check OVM factory contract availability');
65
65
  }
66
- const ovmFactoryConfig = chainConfig.OVM_FACTORY_ADDRESS;
67
- if (!(ovmFactoryConfig === null || ovmFactoryConfig === void 0 ? void 0 : ovmFactoryConfig.address) || !(ovmFactoryConfig === null || ovmFactoryConfig === void 0 ? void 0 : ovmFactoryConfig.bytecode)) {
68
- throw new Error(`OVM factory contract configuration is incomplete for chain ${this.chainId}`);
66
+ const ovmFactoryConfig = chainConfig.OVM_FACTORY_CONTRACT;
67
+ const splitV2FactoryConfig = chainConfig.SPLIT_V2_FACTORY_CONTRACT;
68
+ const multiCallConfig = chainConfig.MULTICALL_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
+ !(multiCallConfig === null || multiCallConfig === void 0 ? void 0 : multiCallConfig.address) ||
74
+ !(multiCallConfig === null || multiCallConfig === void 0 ? void 0 : multiCallConfig.bytecode)) {
75
+ throw new Error(`Contracts configuration is incomplete for chain ${this.chainId}`);
69
76
  }
70
- const checkOVMFactoryAddress = yield (0, utils_1.isContractAvailable)(ovmFactoryConfig.address, this.provider, ovmFactoryConfig.bytecode);
71
- if (!checkOVMFactoryAddress) {
72
- throw new Error(`OVM factory contract is not deployed or available on chain ${this.chainId}`);
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 checkMultiCallContract = yield (0, utils_1.isContractAvailable)(multiCallConfig.address, this.provider, multiCallConfig.bytecode);
80
+ if (!checkOVMFactoryContract ||
81
+ !checkSplitV2FactoryContract ||
82
+ !checkMultiCallContract) {
83
+ throw new Error(`Splitter contract is not deployed or available on chain ${this.chainId}`);
73
84
  }
74
85
  const retroActiveFundingRecipient = {
75
- address: chainConfig.RETROACTIVE_FUNDING_ADDRESS.address,
86
+ address: chainConfig.RETROACTIVE_FUNDING_CONTRACT.address,
76
87
  percentAllocation: constants_1.DEFAULT_RETROACTIVE_FUNDING_REWARDS_ONLY_SPLIT,
77
88
  };
78
89
  const copiedRewardsSplitRecipients = [
@@ -162,22 +173,33 @@ class ObolSplits {
162
173
  throw new Error(`Splitter configuration is not supported on ${this.chainId} chain`);
163
174
  }
164
175
  const chainConfig = constants_1.CHAIN_CONFIGURATION[this.chainId];
165
- if (!(chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.OVM_FACTORY_ADDRESS)) {
176
+ if (!(chainConfig === null || chainConfig === void 0 ? void 0 : chainConfig.OVM_FACTORY_CONTRACT)) {
166
177
  throw new Error(`OVM contract factory is not configured for chain ${this.chainId}`);
167
178
  }
168
179
  if (!this.provider) {
169
180
  throw new Error('Provider is required to check OVM factory contract availability');
170
181
  }
171
- const ovmFactoryConfig = chainConfig.OVM_FACTORY_ADDRESS;
172
- if (!(ovmFactoryConfig === null || ovmFactoryConfig === void 0 ? void 0 : ovmFactoryConfig.address) || !(ovmFactoryConfig === null || ovmFactoryConfig === void 0 ? void 0 : ovmFactoryConfig.bytecode)) {
173
- throw new Error(`OVM factory contract configuration is incomplete for chain ${this.chainId}`);
182
+ const ovmFactoryConfig = chainConfig.OVM_FACTORY_CONTRACT;
183
+ const splitV2FactoryConfig = chainConfig.SPLIT_V2_FACTORY_CONTRACT;
184
+ const multiCallConfig = chainConfig.MULTICALL_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
+ !(multiCallConfig === null || multiCallConfig === void 0 ? void 0 : multiCallConfig.address) ||
190
+ !(multiCallConfig === null || multiCallConfig === void 0 ? void 0 : multiCallConfig.bytecode)) {
191
+ throw new Error(`Contracts configuration is incomplete for chain ${this.chainId}`);
174
192
  }
175
- const checkOVMFactoryAddress = yield (0, utils_1.isContractAvailable)(ovmFactoryConfig.address, this.provider, ovmFactoryConfig.bytecode);
176
- if (!checkOVMFactoryAddress) {
177
- throw new Error(`OVM factory contract is not deployed or available on chain ${this.chainId}`);
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 checkMultiCallContract = yield (0, utils_1.isContractAvailable)(multiCallConfig.address, this.provider, multiCallConfig.bytecode);
196
+ if (!checkOVMFactoryContract ||
197
+ !checkSplitV2FactoryContract ||
198
+ !checkMultiCallContract) {
199
+ throw new Error(`Splitter contract is not deployed or available on chain ${this.chainId}`);
178
200
  }
179
201
  const retroActiveFundingRecipient = {
180
- address: chainConfig.RETROACTIVE_FUNDING_ADDRESS.address,
202
+ address: chainConfig.RETROACTIVE_FUNDING_CONTRACT.address,
181
203
  percentAllocation: constants_1.DEFAULT_RETROACTIVE_FUNDING_REWARDS_ONLY_SPLIT,
182
204
  };
183
205
  const copiedRewardsSplitRecipients = [
@@ -104,9 +104,9 @@ describe('ObolSplits', () => {
104
104
  it('should throw error when OVM factory is not configured', () => __awaiter(void 0, void 0, void 0, function* () {
105
105
  // Mock chain configuration without OVM factory
106
106
  const originalConfig = constants_1.CHAIN_CONFIGURATION[1];
107
- // Create a new config object without OVM_FACTORY_ADDRESS
107
+ // Create a new config object without OVM_FACTORY_CONTRACT
108
108
  const configWithoutOVM = Object.assign({}, originalConfig);
109
- delete configWithoutOVM.OVM_FACTORY_ADDRESS;
109
+ delete configWithoutOVM.OVM_FACTORY_CONTRACT;
110
110
  constants_1.CHAIN_CONFIGURATION[1] = configWithoutOVM;
111
111
  yield expect(client.splits.createValidatorManagerAndRewardsSplit(mockRewardsSplitPayload)).rejects.toThrow('OVM contract factory is not configured for chain 1');
112
112
  // Restore original config
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "description": "A package for creating Distributed Validators using the Obol API.",
5
5
  "bugs": {
6
6
  "url": "https://github.com/obolnetwork/obol-sdk/issues"
@@ -40,7 +40,6 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@0xsplits/splits-sdk": "^5.1.0",
44
43
  "@chainsafe/bls": "6.0.3",
45
44
  "@chainsafe/blst": "^0.2.9",
46
45
  "@chainsafe/discv5": "^0.5.1",
@@ -64,8 +63,7 @@
64
63
  "pdf-parse": "^1.1.1",
65
64
  "semver": "^7.6.0",
66
65
  "typescript-eslint": "^7.1.0",
67
- "uuid": "^9.0.0",
68
- "viem": "^2.31.4"
66
+ "uuid": "^9.0.0"
69
67
  },
70
68
  "devDependencies": {
71
69
  "@release-it/conventional-changelog": "^8.0.1",