@obolnetwork/obol-sdk 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/abi/OWR.js +172 -1
- package/dist/cjs/src/index.js +21 -0
- package/dist/cjs/src/splitHelpers.js +11 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/src/abi/OWR.js +171 -0
- package/dist/esm/src/index.js +22 -1
- package/dist/esm/src/splitHelpers.js +10 -1
- package/dist/types/src/abi/OWR.d.ts +44 -0
- package/dist/types/src/index.d.ts +13 -1
- package/dist/types/src/splitHelpers.d.ts +5 -1
- package/dist/types/src/types.d.ts +11 -0
- package/package.json +1 -1
- package/src/abi/OWR.ts +172 -0
- package/src/index.ts +24 -0
- package/src/splitHelpers.ts +20 -1
- package/src/types.ts +14 -0
package/dist/cjs/package.json
CHANGED
package/dist/cjs/src/abi/OWR.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OWRFactoryContract = void 0;
|
|
3
|
+
exports.OWRContract = exports.OWRFactoryContract = void 0;
|
|
4
4
|
exports.OWRFactoryContract = {
|
|
5
5
|
abi: [
|
|
6
6
|
{
|
|
@@ -131,3 +131,174 @@ exports.OWRFactoryContract = {
|
|
|
131
131
|
},
|
|
132
132
|
],
|
|
133
133
|
};
|
|
134
|
+
exports.OWRContract = {
|
|
135
|
+
abi: [
|
|
136
|
+
{ inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
|
|
137
|
+
{ inputs: [], name: 'InvalidDistribution_TooLarge', type: 'error' },
|
|
138
|
+
{
|
|
139
|
+
inputs: [],
|
|
140
|
+
name: 'InvalidTokenRecovery_InvalidRecipient',
|
|
141
|
+
type: 'error',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
anonymous: false,
|
|
145
|
+
inputs: [
|
|
146
|
+
{
|
|
147
|
+
indexed: false,
|
|
148
|
+
internalType: 'uint256',
|
|
149
|
+
name: 'principalPayout',
|
|
150
|
+
type: 'uint256',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
indexed: false,
|
|
154
|
+
internalType: 'uint256',
|
|
155
|
+
name: 'rewardPayout',
|
|
156
|
+
type: 'uint256',
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
indexed: false,
|
|
160
|
+
internalType: 'uint256',
|
|
161
|
+
name: 'pullFlowFlag',
|
|
162
|
+
type: 'uint256',
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
name: 'DistributeFunds',
|
|
166
|
+
type: 'event',
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
anonymous: false,
|
|
170
|
+
inputs: [
|
|
171
|
+
{
|
|
172
|
+
indexed: false,
|
|
173
|
+
internalType: 'uint256',
|
|
174
|
+
name: 'amount',
|
|
175
|
+
type: 'uint256',
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
name: 'ReceiveETH',
|
|
179
|
+
type: 'event',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
anonymous: false,
|
|
183
|
+
inputs: [
|
|
184
|
+
{
|
|
185
|
+
indexed: false,
|
|
186
|
+
internalType: 'address',
|
|
187
|
+
name: 'recoveryAddressToken',
|
|
188
|
+
type: 'address',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
indexed: false,
|
|
192
|
+
internalType: 'address',
|
|
193
|
+
name: 'recipient',
|
|
194
|
+
type: 'address',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
indexed: false,
|
|
198
|
+
internalType: 'uint256',
|
|
199
|
+
name: 'amount',
|
|
200
|
+
type: 'uint256',
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
name: 'RecoverNonOWRecipientFunds',
|
|
204
|
+
type: 'event',
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
anonymous: false,
|
|
208
|
+
inputs: [
|
|
209
|
+
{
|
|
210
|
+
indexed: false,
|
|
211
|
+
internalType: 'address',
|
|
212
|
+
name: 'account',
|
|
213
|
+
type: 'address',
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
indexed: false,
|
|
217
|
+
internalType: 'uint256',
|
|
218
|
+
name: 'amount',
|
|
219
|
+
type: 'uint256',
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
name: 'Withdrawal',
|
|
223
|
+
type: 'event',
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
inputs: [],
|
|
227
|
+
name: 'claimedPrincipalFunds',
|
|
228
|
+
outputs: [{ internalType: 'uint128', name: '', type: 'uint128' }],
|
|
229
|
+
stateMutability: 'view',
|
|
230
|
+
type: 'function',
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
inputs: [],
|
|
234
|
+
name: 'distributeFunds',
|
|
235
|
+
outputs: [],
|
|
236
|
+
stateMutability: 'payable',
|
|
237
|
+
type: 'function',
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
inputs: [],
|
|
241
|
+
name: 'distributeFundsPull',
|
|
242
|
+
outputs: [],
|
|
243
|
+
stateMutability: 'payable',
|
|
244
|
+
type: 'function',
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
inputs: [],
|
|
248
|
+
name: 'fundsPendingWithdrawal',
|
|
249
|
+
outputs: [{ internalType: 'uint128', name: '', type: 'uint128' }],
|
|
250
|
+
stateMutability: 'view',
|
|
251
|
+
type: 'function',
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
|
|
255
|
+
name: 'getPullBalance',
|
|
256
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
257
|
+
stateMutability: 'view',
|
|
258
|
+
type: 'function',
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
inputs: [],
|
|
262
|
+
name: 'getTranches',
|
|
263
|
+
outputs: [
|
|
264
|
+
{
|
|
265
|
+
internalType: 'address',
|
|
266
|
+
name: 'principalRecipient',
|
|
267
|
+
type: 'address',
|
|
268
|
+
},
|
|
269
|
+
{ internalType: 'address', name: 'rewardRecipient', type: 'address' },
|
|
270
|
+
{
|
|
271
|
+
internalType: 'uint256',
|
|
272
|
+
name: 'amountOfPrincipalStake',
|
|
273
|
+
type: 'uint256',
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
stateMutability: 'pure',
|
|
277
|
+
type: 'function',
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
inputs: [
|
|
281
|
+
{ internalType: 'address', name: 'nonOWRToken', type: 'address' },
|
|
282
|
+
{ internalType: 'address', name: 'recipient', type: 'address' },
|
|
283
|
+
],
|
|
284
|
+
name: 'recoverFunds',
|
|
285
|
+
outputs: [],
|
|
286
|
+
stateMutability: 'payable',
|
|
287
|
+
type: 'function',
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
inputs: [],
|
|
291
|
+
name: 'recoveryAddress',
|
|
292
|
+
outputs: [{ internalType: 'address', name: '', type: 'address' }],
|
|
293
|
+
stateMutability: 'pure',
|
|
294
|
+
type: 'function',
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
|
|
298
|
+
name: 'withdraw',
|
|
299
|
+
outputs: [],
|
|
300
|
+
stateMutability: 'nonpayable',
|
|
301
|
+
type: 'function',
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
};
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -74,6 +74,7 @@ class Client extends base_js_1.Base {
|
|
|
74
74
|
address,
|
|
75
75
|
version: constants_js_1.TERMS_AND_CONDITIONS_VERSION,
|
|
76
76
|
terms_and_conditions_hash: termsAndConditionsHash,
|
|
77
|
+
fork_version: this.fork_version,
|
|
77
78
|
};
|
|
78
79
|
const termsAndConditionsSignature = yield this.signer.signTypedData((0, constants_js_1.Domain)(), constants_js_1.TermsAndConditionsSigningTypes, {
|
|
79
80
|
terms_and_conditions_hash: termsAndConditionsHash,
|
|
@@ -239,6 +240,26 @@ class Client extends base_js_1.Base {
|
|
|
239
240
|
};
|
|
240
241
|
});
|
|
241
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Read OWR Tranches.
|
|
245
|
+
*
|
|
246
|
+
* @remarks
|
|
247
|
+
* **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
|
|
248
|
+
* and not pushed to version control.
|
|
249
|
+
*
|
|
250
|
+
* @param {ETH_ADDRESS} owrAddress - Address of the Deployed OWR Contract
|
|
251
|
+
* @returns {Promise<OWRTranches>} owr tranch information about principal and reward reciepient, as well as the principal amount
|
|
252
|
+
*
|
|
253
|
+
*/
|
|
254
|
+
getOWRTranches(owrAddress) {
|
|
255
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
256
|
+
if (!this.signer) {
|
|
257
|
+
throw new Error('Signer is required in getOWRTranches');
|
|
258
|
+
}
|
|
259
|
+
const signer = this.signer;
|
|
260
|
+
return yield (0, splitHelpers_js_1.getOWRTranches)({ owrAddress, signer });
|
|
261
|
+
});
|
|
262
|
+
}
|
|
242
263
|
/**
|
|
243
264
|
* Creates a cluster definition which contains cluster configuration.
|
|
244
265
|
* @param {ClusterPayload} newCluster - The new unique cluster.
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.multicall = exports.deploySplitterAndOWRContracts = exports.deploySplitterContract = exports.handleDeployOWRAndSplitter = exports.predictSplitterAddress = exports.formatSplitRecipients = void 0;
|
|
12
|
+
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 SplitMain_1 = require("./abi/SplitMain");
|
|
@@ -152,6 +152,16 @@ const deploySplitterAndOWRContracts = ({ owrArgs, splitterArgs, signer, chainId,
|
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
154
|
exports.deploySplitterAndOWRContracts = deploySplitterAndOWRContracts;
|
|
155
|
+
const getOWRTranches = ({ owrAddress, signer, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
+
const owrContract = new ethers_1.Contract(owrAddress, OWR_1.OWRContract.abi, signer);
|
|
157
|
+
const res = yield owrContract.getTranches();
|
|
158
|
+
return {
|
|
159
|
+
principalRecipient: res.principalRecipient,
|
|
160
|
+
rewardRecipient: res.rewardRecipient,
|
|
161
|
+
amountOfPrincipalStake: res.amountOfPrincipalStake,
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
exports.getOWRTranches = getOWRTranches;
|
|
155
165
|
const multicall = (calls, signer, multicallAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
166
|
const multiCallContractInstance = new ethers_1.Contract(multicallAddress, Multicall_1.MultiCallContract.abi, signer);
|
|
157
167
|
const tx = yield multiCallContractInstance.aggregate(calls);
|
package/dist/esm/package.json
CHANGED
package/dist/esm/src/abi/OWR.js
CHANGED
|
@@ -128,3 +128,174 @@ export const OWRFactoryContract = {
|
|
|
128
128
|
},
|
|
129
129
|
],
|
|
130
130
|
};
|
|
131
|
+
export const OWRContract = {
|
|
132
|
+
abi: [
|
|
133
|
+
{ inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
|
|
134
|
+
{ inputs: [], name: 'InvalidDistribution_TooLarge', type: 'error' },
|
|
135
|
+
{
|
|
136
|
+
inputs: [],
|
|
137
|
+
name: 'InvalidTokenRecovery_InvalidRecipient',
|
|
138
|
+
type: 'error',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
anonymous: false,
|
|
142
|
+
inputs: [
|
|
143
|
+
{
|
|
144
|
+
indexed: false,
|
|
145
|
+
internalType: 'uint256',
|
|
146
|
+
name: 'principalPayout',
|
|
147
|
+
type: 'uint256',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
indexed: false,
|
|
151
|
+
internalType: 'uint256',
|
|
152
|
+
name: 'rewardPayout',
|
|
153
|
+
type: 'uint256',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
indexed: false,
|
|
157
|
+
internalType: 'uint256',
|
|
158
|
+
name: 'pullFlowFlag',
|
|
159
|
+
type: 'uint256',
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
name: 'DistributeFunds',
|
|
163
|
+
type: 'event',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
anonymous: false,
|
|
167
|
+
inputs: [
|
|
168
|
+
{
|
|
169
|
+
indexed: false,
|
|
170
|
+
internalType: 'uint256',
|
|
171
|
+
name: 'amount',
|
|
172
|
+
type: 'uint256',
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
name: 'ReceiveETH',
|
|
176
|
+
type: 'event',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
anonymous: false,
|
|
180
|
+
inputs: [
|
|
181
|
+
{
|
|
182
|
+
indexed: false,
|
|
183
|
+
internalType: 'address',
|
|
184
|
+
name: 'recoveryAddressToken',
|
|
185
|
+
type: 'address',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
indexed: false,
|
|
189
|
+
internalType: 'address',
|
|
190
|
+
name: 'recipient',
|
|
191
|
+
type: 'address',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
indexed: false,
|
|
195
|
+
internalType: 'uint256',
|
|
196
|
+
name: 'amount',
|
|
197
|
+
type: 'uint256',
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
name: 'RecoverNonOWRecipientFunds',
|
|
201
|
+
type: 'event',
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
anonymous: false,
|
|
205
|
+
inputs: [
|
|
206
|
+
{
|
|
207
|
+
indexed: false,
|
|
208
|
+
internalType: 'address',
|
|
209
|
+
name: 'account',
|
|
210
|
+
type: 'address',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
indexed: false,
|
|
214
|
+
internalType: 'uint256',
|
|
215
|
+
name: 'amount',
|
|
216
|
+
type: 'uint256',
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
name: 'Withdrawal',
|
|
220
|
+
type: 'event',
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
inputs: [],
|
|
224
|
+
name: 'claimedPrincipalFunds',
|
|
225
|
+
outputs: [{ internalType: 'uint128', name: '', type: 'uint128' }],
|
|
226
|
+
stateMutability: 'view',
|
|
227
|
+
type: 'function',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
inputs: [],
|
|
231
|
+
name: 'distributeFunds',
|
|
232
|
+
outputs: [],
|
|
233
|
+
stateMutability: 'payable',
|
|
234
|
+
type: 'function',
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
inputs: [],
|
|
238
|
+
name: 'distributeFundsPull',
|
|
239
|
+
outputs: [],
|
|
240
|
+
stateMutability: 'payable',
|
|
241
|
+
type: 'function',
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
inputs: [],
|
|
245
|
+
name: 'fundsPendingWithdrawal',
|
|
246
|
+
outputs: [{ internalType: 'uint128', name: '', type: 'uint128' }],
|
|
247
|
+
stateMutability: 'view',
|
|
248
|
+
type: 'function',
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
|
|
252
|
+
name: 'getPullBalance',
|
|
253
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
254
|
+
stateMutability: 'view',
|
|
255
|
+
type: 'function',
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
inputs: [],
|
|
259
|
+
name: 'getTranches',
|
|
260
|
+
outputs: [
|
|
261
|
+
{
|
|
262
|
+
internalType: 'address',
|
|
263
|
+
name: 'principalRecipient',
|
|
264
|
+
type: 'address',
|
|
265
|
+
},
|
|
266
|
+
{ internalType: 'address', name: 'rewardRecipient', type: 'address' },
|
|
267
|
+
{
|
|
268
|
+
internalType: 'uint256',
|
|
269
|
+
name: 'amountOfPrincipalStake',
|
|
270
|
+
type: 'uint256',
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
stateMutability: 'pure',
|
|
274
|
+
type: 'function',
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
inputs: [
|
|
278
|
+
{ internalType: 'address', name: 'nonOWRToken', type: 'address' },
|
|
279
|
+
{ internalType: 'address', name: 'recipient', type: 'address' },
|
|
280
|
+
],
|
|
281
|
+
name: 'recoverFunds',
|
|
282
|
+
outputs: [],
|
|
283
|
+
stateMutability: 'payable',
|
|
284
|
+
type: 'function',
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
inputs: [],
|
|
288
|
+
name: 'recoveryAddress',
|
|
289
|
+
outputs: [{ internalType: 'address', name: '', type: 'address' }],
|
|
290
|
+
stateMutability: 'pure',
|
|
291
|
+
type: 'function',
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
|
|
295
|
+
name: 'withdraw',
|
|
296
|
+
outputs: [],
|
|
297
|
+
stateMutability: 'nonpayable',
|
|
298
|
+
type: 'function',
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
};
|
package/dist/esm/src/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { ConflictError } from './errors.js';
|
|
|
15
15
|
import { clusterConfigOrDefinitionHash } from './verification/common.js';
|
|
16
16
|
import { validatePayload } from './ajv.js';
|
|
17
17
|
import { definitionSchema, operatorPayloadSchema, rewardsSplitterPayloadSchema, totalSplitterPayloadSchema, } from './schema.js';
|
|
18
|
-
import { deploySplitterContract, formatSplitRecipients, handleDeployOWRAndSplitter, predictSplitterAddress, } from './splitHelpers.js';
|
|
18
|
+
import { deploySplitterContract, formatSplitRecipients, handleDeployOWRAndSplitter, predictSplitterAddress, getOWRTranches, } from './splitHelpers.js';
|
|
19
19
|
import { isContractAvailable } from './utils.js';
|
|
20
20
|
export * from './types.js';
|
|
21
21
|
export * from './services.js';
|
|
@@ -57,6 +57,7 @@ export class Client extends Base {
|
|
|
57
57
|
address,
|
|
58
58
|
version: TERMS_AND_CONDITIONS_VERSION,
|
|
59
59
|
terms_and_conditions_hash: termsAndConditionsHash,
|
|
60
|
+
fork_version: this.fork_version,
|
|
60
61
|
};
|
|
61
62
|
const termsAndConditionsSignature = yield this.signer.signTypedData(Domain(), TermsAndConditionsSigningTypes, {
|
|
62
63
|
terms_and_conditions_hash: termsAndConditionsHash,
|
|
@@ -222,6 +223,26 @@ export class Client extends Base {
|
|
|
222
223
|
};
|
|
223
224
|
});
|
|
224
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Read OWR Tranches.
|
|
228
|
+
*
|
|
229
|
+
* @remarks
|
|
230
|
+
* **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
|
|
231
|
+
* and not pushed to version control.
|
|
232
|
+
*
|
|
233
|
+
* @param {ETH_ADDRESS} owrAddress - Address of the Deployed OWR Contract
|
|
234
|
+
* @returns {Promise<OWRTranches>} owr tranch information about principal and reward reciepient, as well as the principal amount
|
|
235
|
+
*
|
|
236
|
+
*/
|
|
237
|
+
getOWRTranches(owrAddress) {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
+
if (!this.signer) {
|
|
240
|
+
throw new Error('Signer is required in getOWRTranches');
|
|
241
|
+
}
|
|
242
|
+
const signer = this.signer;
|
|
243
|
+
return yield getOWRTranches({ owrAddress, signer });
|
|
244
|
+
});
|
|
245
|
+
}
|
|
225
246
|
/**
|
|
226
247
|
* Creates a cluster definition which contains cluster configuration.
|
|
227
248
|
* @param {ClusterPayload} newCluster - The new unique cluster.
|
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { Contract, Interface, parseEther, ZeroAddress, } from 'ethers';
|
|
11
|
-
import { OWRFactoryContract } from './abi/OWR';
|
|
11
|
+
import { OWRContract, OWRFactoryContract } from './abi/OWR';
|
|
12
12
|
import { splitMainEthereumAbi } from './abi/SplitMain';
|
|
13
13
|
import { MultiCallContract } from './abi/Multicall';
|
|
14
14
|
import { CHAIN_CONFIGURATION } from './constants';
|
|
@@ -144,6 +144,15 @@ export const deploySplitterAndOWRContracts = ({ owrArgs, splitterArgs, signer, c
|
|
|
144
144
|
throw e;
|
|
145
145
|
}
|
|
146
146
|
});
|
|
147
|
+
export const getOWRTranches = ({ owrAddress, signer, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
148
|
+
const owrContract = new Contract(owrAddress, OWRContract.abi, signer);
|
|
149
|
+
const res = yield owrContract.getTranches();
|
|
150
|
+
return {
|
|
151
|
+
principalRecipient: res.principalRecipient,
|
|
152
|
+
rewardRecipient: res.rewardRecipient,
|
|
153
|
+
amountOfPrincipalStake: res.amountOfPrincipalStake,
|
|
154
|
+
};
|
|
155
|
+
});
|
|
147
156
|
export const multicall = (calls, signer, multicallAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
148
157
|
const multiCallContractInstance = new Contract(multicallAddress, MultiCallContract.abi, signer);
|
|
149
158
|
const tx = yield multiCallContractInstance.aggregate(calls);
|
|
@@ -50,3 +50,47 @@ export declare const OWRFactoryContract: {
|
|
|
50
50
|
anonymous?: undefined;
|
|
51
51
|
})[];
|
|
52
52
|
};
|
|
53
|
+
export declare const OWRContract: {
|
|
54
|
+
abi: ({
|
|
55
|
+
inputs: never[];
|
|
56
|
+
stateMutability: string;
|
|
57
|
+
type: string;
|
|
58
|
+
name?: undefined;
|
|
59
|
+
anonymous?: undefined;
|
|
60
|
+
outputs?: undefined;
|
|
61
|
+
} | {
|
|
62
|
+
inputs: never[];
|
|
63
|
+
name: string;
|
|
64
|
+
type: string;
|
|
65
|
+
stateMutability?: undefined;
|
|
66
|
+
anonymous?: undefined;
|
|
67
|
+
outputs?: undefined;
|
|
68
|
+
} | {
|
|
69
|
+
anonymous: boolean;
|
|
70
|
+
inputs: {
|
|
71
|
+
indexed: boolean;
|
|
72
|
+
internalType: string;
|
|
73
|
+
name: string;
|
|
74
|
+
type: string;
|
|
75
|
+
}[];
|
|
76
|
+
name: string;
|
|
77
|
+
type: string;
|
|
78
|
+
stateMutability?: undefined;
|
|
79
|
+
outputs?: undefined;
|
|
80
|
+
} | {
|
|
81
|
+
inputs: {
|
|
82
|
+
internalType: string;
|
|
83
|
+
name: string;
|
|
84
|
+
type: string;
|
|
85
|
+
}[];
|
|
86
|
+
name: string;
|
|
87
|
+
outputs: {
|
|
88
|
+
internalType: string;
|
|
89
|
+
name: string;
|
|
90
|
+
type: string;
|
|
91
|
+
}[];
|
|
92
|
+
stateMutability: string;
|
|
93
|
+
type: string;
|
|
94
|
+
anonymous?: undefined;
|
|
95
|
+
})[];
|
|
96
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Signer } from 'ethers';
|
|
2
2
|
import { Base } from './base.js';
|
|
3
|
-
import { type RewardsSplitPayload, type ClusterDefinition, type ClusterLock, type ClusterPayload, type OperatorPayload, type TotalSplitPayload, type ClusterValidator } from './types.js';
|
|
3
|
+
import { type RewardsSplitPayload, type ClusterDefinition, type ClusterLock, type ClusterPayload, type OperatorPayload, type TotalSplitPayload, type ClusterValidator, type ETH_ADDRESS, type OWRTranches } from './types.js';
|
|
4
4
|
export * from './types.js';
|
|
5
5
|
export * from './services.js';
|
|
6
6
|
/**
|
|
@@ -59,6 +59,18 @@ export declare class Client extends Base {
|
|
|
59
59
|
* [createObolTotalSplit](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L168)
|
|
60
60
|
*/
|
|
61
61
|
createObolTotalSplit({ splitRecipients, ObolRAFSplit, distributorFee, controllerAddress, }: TotalSplitPayload): Promise<ClusterValidator>;
|
|
62
|
+
/**
|
|
63
|
+
* Read OWR Tranches.
|
|
64
|
+
*
|
|
65
|
+
* @remarks
|
|
66
|
+
* **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
|
|
67
|
+
* and not pushed to version control.
|
|
68
|
+
*
|
|
69
|
+
* @param {ETH_ADDRESS} owrAddress - Address of the Deployed OWR Contract
|
|
70
|
+
* @returns {Promise<OWRTranches>} owr tranch information about principal and reward reciepient, as well as the principal amount
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
getOWRTranches(owrAddress: ETH_ADDRESS): Promise<OWRTranches>;
|
|
62
74
|
/**
|
|
63
75
|
* Creates a cluster definition which contains cluster configuration.
|
|
64
76
|
* @param {ClusterPayload} newCluster - The new unique cluster.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ClusterValidator, type ETH_ADDRESS, type SplitRecipient } from './types';
|
|
1
|
+
import { type OWRTranches, type ClusterValidator, type ETH_ADDRESS, type SplitRecipient } from './types';
|
|
2
2
|
import { type Signer } from 'ethers';
|
|
3
3
|
type Call = {
|
|
4
4
|
target: ETH_ADDRESS;
|
|
@@ -58,5 +58,9 @@ export declare const deploySplitterAndOWRContracts: ({ owrArgs, splitterArgs, si
|
|
|
58
58
|
owrAddress: ETH_ADDRESS;
|
|
59
59
|
splitterAddress: ETH_ADDRESS;
|
|
60
60
|
}>;
|
|
61
|
+
export declare const getOWRTranches: ({ owrAddress, signer, }: {
|
|
62
|
+
owrAddress: ETH_ADDRESS;
|
|
63
|
+
signer: Signer;
|
|
64
|
+
}) => Promise<OWRTranches>;
|
|
61
65
|
export declare const multicall: (calls: Call[], signer: Signer, multicallAddress: string) => Promise<any>;
|
|
62
66
|
export {};
|
|
@@ -121,6 +121,17 @@ export interface RewardsSplitPayload extends TotalSplitPayload {
|
|
|
121
121
|
/** Address that can control where the owr erc-20 tokens can be pushed, if set to zero it goes to splitter or principal address. */
|
|
122
122
|
recoveryAddress?: string;
|
|
123
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* OWR Tranches
|
|
126
|
+
*/
|
|
127
|
+
export type OWRTranches = {
|
|
128
|
+
/** Address that will reclaim validator principal after exit. */
|
|
129
|
+
principalRecipient: ETH_ADDRESS;
|
|
130
|
+
/** Address that will reclaim validator rewards during operation. */
|
|
131
|
+
rewardRecipient: ETH_ADDRESS;
|
|
132
|
+
/** Amount of principal staked. */
|
|
133
|
+
amountOfPrincipalStake: number;
|
|
134
|
+
};
|
|
124
135
|
/**
|
|
125
136
|
* Unsigned DV Builder Registration Message
|
|
126
137
|
*/
|
package/package.json
CHANGED
package/src/abi/OWR.ts
CHANGED
|
@@ -128,3 +128,175 @@ export const OWRFactoryContract = {
|
|
|
128
128
|
},
|
|
129
129
|
],
|
|
130
130
|
};
|
|
131
|
+
|
|
132
|
+
export const OWRContract = {
|
|
133
|
+
abi: [
|
|
134
|
+
{ inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
|
|
135
|
+
{ inputs: [], name: 'InvalidDistribution_TooLarge', type: 'error' },
|
|
136
|
+
{
|
|
137
|
+
inputs: [],
|
|
138
|
+
name: 'InvalidTokenRecovery_InvalidRecipient',
|
|
139
|
+
type: 'error',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
anonymous: false,
|
|
143
|
+
inputs: [
|
|
144
|
+
{
|
|
145
|
+
indexed: false,
|
|
146
|
+
internalType: 'uint256',
|
|
147
|
+
name: 'principalPayout',
|
|
148
|
+
type: 'uint256',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
indexed: false,
|
|
152
|
+
internalType: 'uint256',
|
|
153
|
+
name: 'rewardPayout',
|
|
154
|
+
type: 'uint256',
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
indexed: false,
|
|
158
|
+
internalType: 'uint256',
|
|
159
|
+
name: 'pullFlowFlag',
|
|
160
|
+
type: 'uint256',
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
name: 'DistributeFunds',
|
|
164
|
+
type: 'event',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
anonymous: false,
|
|
168
|
+
inputs: [
|
|
169
|
+
{
|
|
170
|
+
indexed: false,
|
|
171
|
+
internalType: 'uint256',
|
|
172
|
+
name: 'amount',
|
|
173
|
+
type: 'uint256',
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
name: 'ReceiveETH',
|
|
177
|
+
type: 'event',
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
anonymous: false,
|
|
181
|
+
inputs: [
|
|
182
|
+
{
|
|
183
|
+
indexed: false,
|
|
184
|
+
internalType: 'address',
|
|
185
|
+
name: 'recoveryAddressToken',
|
|
186
|
+
type: 'address',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
indexed: false,
|
|
190
|
+
internalType: 'address',
|
|
191
|
+
name: 'recipient',
|
|
192
|
+
type: 'address',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
indexed: false,
|
|
196
|
+
internalType: 'uint256',
|
|
197
|
+
name: 'amount',
|
|
198
|
+
type: 'uint256',
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
name: 'RecoverNonOWRecipientFunds',
|
|
202
|
+
type: 'event',
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
anonymous: false,
|
|
206
|
+
inputs: [
|
|
207
|
+
{
|
|
208
|
+
indexed: false,
|
|
209
|
+
internalType: 'address',
|
|
210
|
+
name: 'account',
|
|
211
|
+
type: 'address',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
indexed: false,
|
|
215
|
+
internalType: 'uint256',
|
|
216
|
+
name: 'amount',
|
|
217
|
+
type: 'uint256',
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
name: 'Withdrawal',
|
|
221
|
+
type: 'event',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
inputs: [],
|
|
225
|
+
name: 'claimedPrincipalFunds',
|
|
226
|
+
outputs: [{ internalType: 'uint128', name: '', type: 'uint128' }],
|
|
227
|
+
stateMutability: 'view',
|
|
228
|
+
type: 'function',
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
inputs: [],
|
|
232
|
+
name: 'distributeFunds',
|
|
233
|
+
outputs: [],
|
|
234
|
+
stateMutability: 'payable',
|
|
235
|
+
type: 'function',
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
inputs: [],
|
|
239
|
+
name: 'distributeFundsPull',
|
|
240
|
+
outputs: [],
|
|
241
|
+
stateMutability: 'payable',
|
|
242
|
+
type: 'function',
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
inputs: [],
|
|
246
|
+
name: 'fundsPendingWithdrawal',
|
|
247
|
+
outputs: [{ internalType: 'uint128', name: '', type: 'uint128' }],
|
|
248
|
+
stateMutability: 'view',
|
|
249
|
+
type: 'function',
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
|
|
253
|
+
name: 'getPullBalance',
|
|
254
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
255
|
+
stateMutability: 'view',
|
|
256
|
+
type: 'function',
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
inputs: [],
|
|
260
|
+
name: 'getTranches',
|
|
261
|
+
outputs: [
|
|
262
|
+
{
|
|
263
|
+
internalType: 'address',
|
|
264
|
+
name: 'principalRecipient',
|
|
265
|
+
type: 'address',
|
|
266
|
+
},
|
|
267
|
+
{ internalType: 'address', name: 'rewardRecipient', type: 'address' },
|
|
268
|
+
{
|
|
269
|
+
internalType: 'uint256',
|
|
270
|
+
name: 'amountOfPrincipalStake',
|
|
271
|
+
type: 'uint256',
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
stateMutability: 'pure',
|
|
275
|
+
type: 'function',
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
inputs: [
|
|
279
|
+
{ internalType: 'address', name: 'nonOWRToken', type: 'address' },
|
|
280
|
+
{ internalType: 'address', name: 'recipient', type: 'address' },
|
|
281
|
+
],
|
|
282
|
+
name: 'recoverFunds',
|
|
283
|
+
outputs: [],
|
|
284
|
+
stateMutability: 'payable',
|
|
285
|
+
type: 'function',
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
inputs: [],
|
|
289
|
+
name: 'recoveryAddress',
|
|
290
|
+
outputs: [{ internalType: 'address', name: '', type: 'address' }],
|
|
291
|
+
stateMutability: 'pure',
|
|
292
|
+
type: 'function',
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
|
|
296
|
+
name: 'withdraw',
|
|
297
|
+
outputs: [],
|
|
298
|
+
stateMutability: 'nonpayable',
|
|
299
|
+
type: 'function',
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -28,6 +28,8 @@ import {
|
|
|
28
28
|
type OperatorPayload,
|
|
29
29
|
type TotalSplitPayload,
|
|
30
30
|
type ClusterValidator,
|
|
31
|
+
type ETH_ADDRESS,
|
|
32
|
+
type OWRTranches,
|
|
31
33
|
} from './types.js';
|
|
32
34
|
import { clusterConfigOrDefinitionHash } from './verification/common.js';
|
|
33
35
|
import { validatePayload } from './ajv.js';
|
|
@@ -42,6 +44,7 @@ import {
|
|
|
42
44
|
formatSplitRecipients,
|
|
43
45
|
handleDeployOWRAndSplitter,
|
|
44
46
|
predictSplitterAddress,
|
|
47
|
+
getOWRTranches,
|
|
45
48
|
} from './splitHelpers.js';
|
|
46
49
|
import { isContractAvailable } from './utils.js';
|
|
47
50
|
export * from './types.js';
|
|
@@ -88,6 +91,7 @@ export class Client extends Base {
|
|
|
88
91
|
address,
|
|
89
92
|
version: TERMS_AND_CONDITIONS_VERSION,
|
|
90
93
|
terms_and_conditions_hash: termsAndConditionsHash,
|
|
94
|
+
fork_version: this.fork_version,
|
|
91
95
|
};
|
|
92
96
|
|
|
93
97
|
const termsAndConditionsSignature = await this.signer.signTypedData(
|
|
@@ -338,6 +342,26 @@ export class Client extends Base {
|
|
|
338
342
|
};
|
|
339
343
|
}
|
|
340
344
|
|
|
345
|
+
/**
|
|
346
|
+
* Read OWR Tranches.
|
|
347
|
+
*
|
|
348
|
+
* @remarks
|
|
349
|
+
* **⚠️ Important:** If you're storing the private key in an `.env` file, ensure it is securely managed
|
|
350
|
+
* and not pushed to version control.
|
|
351
|
+
*
|
|
352
|
+
* @param {ETH_ADDRESS} owrAddress - Address of the Deployed OWR Contract
|
|
353
|
+
* @returns {Promise<OWRTranches>} owr tranch information about principal and reward reciepient, as well as the principal amount
|
|
354
|
+
*
|
|
355
|
+
*/
|
|
356
|
+
async getOWRTranches(owrAddress: ETH_ADDRESS): Promise<OWRTranches> {
|
|
357
|
+
if (!this.signer) {
|
|
358
|
+
throw new Error('Signer is required in getOWRTranches');
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const signer = this.signer;
|
|
362
|
+
return await getOWRTranches({ owrAddress, signer });
|
|
363
|
+
}
|
|
364
|
+
|
|
341
365
|
/**
|
|
342
366
|
* Creates a cluster definition which contains cluster configuration.
|
|
343
367
|
* @param {ClusterPayload} newCluster - The new unique cluster.
|
package/src/splitHelpers.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type OWRTranches,
|
|
2
3
|
type ClusterValidator,
|
|
3
4
|
type ETH_ADDRESS,
|
|
4
5
|
type SplitRecipient,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
ZeroAddress,
|
|
11
12
|
type Signer,
|
|
12
13
|
} from 'ethers';
|
|
13
|
-
import { OWRFactoryContract } from './abi/OWR';
|
|
14
|
+
import { OWRContract, OWRFactoryContract } from './abi/OWR';
|
|
14
15
|
import { splitMainEthereumAbi } from './abi/SplitMain';
|
|
15
16
|
import { MultiCallContract } from './abi/Multicall';
|
|
16
17
|
import { CHAIN_CONFIGURATION } from './constants';
|
|
@@ -237,6 +238,7 @@ export const deploySplitterContract = async ({
|
|
|
237
238
|
throw e;
|
|
238
239
|
}
|
|
239
240
|
};
|
|
241
|
+
|
|
240
242
|
export const deploySplitterAndOWRContracts = async ({
|
|
241
243
|
owrArgs,
|
|
242
244
|
splitterArgs,
|
|
@@ -297,6 +299,23 @@ export const deploySplitterAndOWRContracts = async ({
|
|
|
297
299
|
}
|
|
298
300
|
};
|
|
299
301
|
|
|
302
|
+
export const getOWRTranches = async ({
|
|
303
|
+
owrAddress,
|
|
304
|
+
signer,
|
|
305
|
+
}: {
|
|
306
|
+
owrAddress: ETH_ADDRESS;
|
|
307
|
+
signer: Signer;
|
|
308
|
+
}): Promise<OWRTranches> => {
|
|
309
|
+
const owrContract = new Contract(owrAddress, OWRContract.abi, signer);
|
|
310
|
+
const res = await owrContract.getTranches();
|
|
311
|
+
|
|
312
|
+
return {
|
|
313
|
+
principalRecipient: res.principalRecipient,
|
|
314
|
+
rewardRecipient: res.rewardRecipient,
|
|
315
|
+
amountOfPrincipalStake: res.amountOfPrincipalStake,
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
|
|
300
319
|
export const multicall = async (
|
|
301
320
|
calls: Call[],
|
|
302
321
|
signer: Signer,
|
package/src/types.ts
CHANGED
|
@@ -159,6 +159,20 @@ export interface RewardsSplitPayload extends TotalSplitPayload {
|
|
|
159
159
|
recoveryAddress?: string;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
/**
|
|
163
|
+
* OWR Tranches
|
|
164
|
+
*/
|
|
165
|
+
export type OWRTranches = {
|
|
166
|
+
/** Address that will reclaim validator principal after exit. */
|
|
167
|
+
principalRecipient: ETH_ADDRESS;
|
|
168
|
+
|
|
169
|
+
/** Address that will reclaim validator rewards during operation. */
|
|
170
|
+
rewardRecipient: ETH_ADDRESS;
|
|
171
|
+
|
|
172
|
+
/** Amount of principal staked. */
|
|
173
|
+
amountOfPrincipalStake: number;
|
|
174
|
+
};
|
|
175
|
+
|
|
162
176
|
/**
|
|
163
177
|
* Unsigned DV Builder Registration Message
|
|
164
178
|
*/
|