@gearbox-protocol/sdk 10.9.0 → 10.10.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.
@@ -22,12 +22,476 @@ __export(iTreasurySplitter_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(iTreasurySplitter_exports);
24
24
  const ITreasurySplitterAbi = [
25
+ {
26
+ type: "function",
27
+ name: "activeProposals",
28
+ inputs: [],
29
+ outputs: [
30
+ {
31
+ name: "",
32
+ type: "tuple[]",
33
+ internalType: "struct TwoAdminProposal[]",
34
+ components: [
35
+ {
36
+ name: "callData",
37
+ type: "bytes",
38
+ internalType: "bytes"
39
+ },
40
+ {
41
+ name: "confirmedByAdmin",
42
+ type: "bool",
43
+ internalType: "bool"
44
+ },
45
+ {
46
+ name: "confirmedByTreasuryProxy",
47
+ type: "bool",
48
+ internalType: "bool"
49
+ }
50
+ ]
51
+ }
52
+ ],
53
+ stateMutability: "view"
54
+ },
55
+ {
56
+ type: "function",
57
+ name: "admin",
58
+ inputs: [],
59
+ outputs: [
60
+ {
61
+ name: "",
62
+ type: "address",
63
+ internalType: "address"
64
+ }
65
+ ],
66
+ stateMutability: "view"
67
+ },
68
+ {
69
+ type: "function",
70
+ name: "cancelConfigure",
71
+ inputs: [
72
+ {
73
+ name: "callData",
74
+ type: "bytes",
75
+ internalType: "bytes"
76
+ }
77
+ ],
78
+ outputs: [],
79
+ stateMutability: "nonpayable"
80
+ },
81
+ {
82
+ type: "function",
83
+ name: "configure",
84
+ inputs: [
85
+ {
86
+ name: "callData",
87
+ type: "bytes",
88
+ internalType: "bytes"
89
+ }
90
+ ],
91
+ outputs: [],
92
+ stateMutability: "nonpayable"
93
+ },
94
+ {
95
+ type: "function",
96
+ name: "contractType",
97
+ inputs: [],
98
+ outputs: [
99
+ {
100
+ name: "",
101
+ type: "bytes32",
102
+ internalType: "bytes32"
103
+ }
104
+ ],
105
+ stateMutability: "view"
106
+ },
107
+ {
108
+ type: "function",
109
+ name: "defaultSplit",
110
+ inputs: [],
111
+ outputs: [
112
+ {
113
+ name: "",
114
+ type: "tuple",
115
+ internalType: "struct Split",
116
+ components: [
117
+ {
118
+ name: "initialized",
119
+ type: "bool",
120
+ internalType: "bool"
121
+ },
122
+ {
123
+ name: "receivers",
124
+ type: "address[]",
125
+ internalType: "address[]"
126
+ },
127
+ {
128
+ name: "proportions",
129
+ type: "uint16[]",
130
+ internalType: "uint16[]"
131
+ }
132
+ ]
133
+ }
134
+ ],
135
+ stateMutability: "view"
136
+ },
25
137
  {
26
138
  type: "function",
27
139
  name: "distribute",
28
- inputs: [{ name: "token", type: "address", internalType: "address" }],
140
+ inputs: [
141
+ {
142
+ name: "token",
143
+ type: "address",
144
+ internalType: "address"
145
+ }
146
+ ],
147
+ outputs: [],
148
+ stateMutability: "nonpayable"
149
+ },
150
+ {
151
+ type: "function",
152
+ name: "getProposal",
153
+ inputs: [
154
+ {
155
+ name: "callDataHash",
156
+ type: "bytes32",
157
+ internalType: "bytes32"
158
+ }
159
+ ],
160
+ outputs: [
161
+ {
162
+ name: "",
163
+ type: "tuple",
164
+ internalType: "struct TwoAdminProposal",
165
+ components: [
166
+ {
167
+ name: "callData",
168
+ type: "bytes",
169
+ internalType: "bytes"
170
+ },
171
+ {
172
+ name: "confirmedByAdmin",
173
+ type: "bool",
174
+ internalType: "bool"
175
+ },
176
+ {
177
+ name: "confirmedByTreasuryProxy",
178
+ type: "bool",
179
+ internalType: "bool"
180
+ }
181
+ ]
182
+ }
183
+ ],
184
+ stateMutability: "view"
185
+ },
186
+ {
187
+ type: "function",
188
+ name: "setDefaultSplit",
189
+ inputs: [
190
+ {
191
+ name: "receivers",
192
+ type: "address[]",
193
+ internalType: "address[]"
194
+ },
195
+ {
196
+ name: "proportions",
197
+ type: "uint16[]",
198
+ internalType: "uint16[]"
199
+ }
200
+ ],
201
+ outputs: [],
202
+ stateMutability: "nonpayable"
203
+ },
204
+ {
205
+ type: "function",
206
+ name: "setTokenInsuranceAmount",
207
+ inputs: [
208
+ {
209
+ name: "token",
210
+ type: "address",
211
+ internalType: "address"
212
+ },
213
+ {
214
+ name: "amount",
215
+ type: "uint256",
216
+ internalType: "uint256"
217
+ }
218
+ ],
219
+ outputs: [],
220
+ stateMutability: "nonpayable"
221
+ },
222
+ {
223
+ type: "function",
224
+ name: "setTokenSplit",
225
+ inputs: [
226
+ {
227
+ name: "token",
228
+ type: "address",
229
+ internalType: "address"
230
+ },
231
+ {
232
+ name: "receivers",
233
+ type: "address[]",
234
+ internalType: "address[]"
235
+ },
236
+ {
237
+ name: "proportions",
238
+ type: "uint16[]",
239
+ internalType: "uint16[]"
240
+ },
241
+ {
242
+ name: "distribute",
243
+ type: "bool",
244
+ internalType: "bool"
245
+ }
246
+ ],
29
247
  outputs: [],
30
248
  stateMutability: "nonpayable"
249
+ },
250
+ {
251
+ type: "function",
252
+ name: "tokenInsuranceAmount",
253
+ inputs: [
254
+ {
255
+ name: "token",
256
+ type: "address",
257
+ internalType: "address"
258
+ }
259
+ ],
260
+ outputs: [
261
+ {
262
+ name: "",
263
+ type: "uint256",
264
+ internalType: "uint256"
265
+ }
266
+ ],
267
+ stateMutability: "view"
268
+ },
269
+ {
270
+ type: "function",
271
+ name: "tokenSplits",
272
+ inputs: [
273
+ {
274
+ name: "token",
275
+ type: "address",
276
+ internalType: "address"
277
+ }
278
+ ],
279
+ outputs: [
280
+ {
281
+ name: "",
282
+ type: "tuple",
283
+ internalType: "struct Split",
284
+ components: [
285
+ {
286
+ name: "initialized",
287
+ type: "bool",
288
+ internalType: "bool"
289
+ },
290
+ {
291
+ name: "receivers",
292
+ type: "address[]",
293
+ internalType: "address[]"
294
+ },
295
+ {
296
+ name: "proportions",
297
+ type: "uint16[]",
298
+ internalType: "uint16[]"
299
+ }
300
+ ]
301
+ }
302
+ ],
303
+ stateMutability: "view"
304
+ },
305
+ {
306
+ type: "function",
307
+ name: "treasuryProxy",
308
+ inputs: [],
309
+ outputs: [
310
+ {
311
+ name: "",
312
+ type: "address",
313
+ internalType: "address"
314
+ }
315
+ ],
316
+ stateMutability: "view"
317
+ },
318
+ {
319
+ type: "function",
320
+ name: "version",
321
+ inputs: [],
322
+ outputs: [
323
+ {
324
+ name: "",
325
+ type: "uint256",
326
+ internalType: "uint256"
327
+ }
328
+ ],
329
+ stateMutability: "view"
330
+ },
331
+ {
332
+ type: "function",
333
+ name: "withdrawToken",
334
+ inputs: [
335
+ {
336
+ name: "token",
337
+ type: "address",
338
+ internalType: "address"
339
+ },
340
+ {
341
+ name: "to",
342
+ type: "address",
343
+ internalType: "address"
344
+ },
345
+ {
346
+ name: "amount",
347
+ type: "uint256",
348
+ internalType: "uint256"
349
+ }
350
+ ],
351
+ outputs: [],
352
+ stateMutability: "nonpayable"
353
+ },
354
+ {
355
+ type: "event",
356
+ name: "DistributeToken",
357
+ inputs: [
358
+ {
359
+ name: "token",
360
+ type: "address",
361
+ indexed: true,
362
+ internalType: "address"
363
+ },
364
+ {
365
+ name: "distributedAmount",
366
+ type: "uint256",
367
+ indexed: false,
368
+ internalType: "uint256"
369
+ }
370
+ ],
371
+ anonymous: false
372
+ },
373
+ {
374
+ type: "event",
375
+ name: "SetDefaultSplit",
376
+ inputs: [
377
+ {
378
+ name: "receivers",
379
+ type: "address[]",
380
+ indexed: false,
381
+ internalType: "address[]"
382
+ },
383
+ {
384
+ name: "proportions",
385
+ type: "uint16[]",
386
+ indexed: false,
387
+ internalType: "uint16[]"
388
+ }
389
+ ],
390
+ anonymous: false
391
+ },
392
+ {
393
+ type: "event",
394
+ name: "SetTokenInsuranceAmount",
395
+ inputs: [
396
+ {
397
+ name: "token",
398
+ type: "address",
399
+ indexed: true,
400
+ internalType: "address"
401
+ },
402
+ {
403
+ name: "amount",
404
+ type: "uint256",
405
+ indexed: false,
406
+ internalType: "uint256"
407
+ }
408
+ ],
409
+ anonymous: false
410
+ },
411
+ {
412
+ type: "event",
413
+ name: "SetTokenSplit",
414
+ inputs: [
415
+ {
416
+ name: "token",
417
+ type: "address",
418
+ indexed: true,
419
+ internalType: "address"
420
+ },
421
+ {
422
+ name: "receivers",
423
+ type: "address[]",
424
+ indexed: false,
425
+ internalType: "address[]"
426
+ },
427
+ {
428
+ name: "proportions",
429
+ type: "uint16[]",
430
+ indexed: false,
431
+ internalType: "uint16[]"
432
+ }
433
+ ],
434
+ anonymous: false
435
+ },
436
+ {
437
+ type: "event",
438
+ name: "WithdrawToken",
439
+ inputs: [
440
+ {
441
+ name: "token",
442
+ type: "address",
443
+ indexed: true,
444
+ internalType: "address"
445
+ },
446
+ {
447
+ name: "to",
448
+ type: "address",
449
+ indexed: true,
450
+ internalType: "address"
451
+ },
452
+ {
453
+ name: "withdrawnAmount",
454
+ type: "uint256",
455
+ indexed: false,
456
+ internalType: "uint256"
457
+ }
458
+ ],
459
+ anonymous: false
460
+ },
461
+ {
462
+ type: "error",
463
+ name: "IncorrectConfigureSelectorException",
464
+ inputs: []
465
+ },
466
+ {
467
+ type: "error",
468
+ name: "OnlyAdminOrTreasuryProxyException",
469
+ inputs: []
470
+ },
471
+ {
472
+ type: "error",
473
+ name: "OnlySelfException",
474
+ inputs: []
475
+ },
476
+ {
477
+ type: "error",
478
+ name: "PropotionSumIncorrectException",
479
+ inputs: []
480
+ },
481
+ {
482
+ type: "error",
483
+ name: "SplitArraysDifferentLengthException",
484
+ inputs: []
485
+ },
486
+ {
487
+ type: "error",
488
+ name: "TreasurySplitterAsReceiverException",
489
+ inputs: []
490
+ },
491
+ {
492
+ type: "error",
493
+ name: "UndefinedSplitException",
494
+ inputs: []
31
495
  }
32
496
  ];
33
497
  // Annotate the CommonJS export names for ESM import in node:
@@ -35,6 +35,7 @@ var import_base_contract = require("./base-contract.js");
35
35
  var import_compressors = require("./compressors/index.js");
36
36
  var import_price_feed_store = require("./price-feed-store.js");
37
37
  var import_router = require("./router/index.js");
38
+ var import_treasury_splitter = require("./treasury-splitter.js");
38
39
  const abi = import_instanceManager.instanceManagerAbi;
39
40
  class InstanceManagerContract extends import_base_contract.BaseContract {
40
41
  constructor(address, client) {
@@ -165,6 +166,36 @@ class InstanceManagerContract extends import_base_contract.BaseContract {
165
166
  }
166
167
  };
167
168
  }
169
+ case "configureTreasury": {
170
+ const [target, data] = params.args;
171
+ let decoded = void 0;
172
+ try {
173
+ const treasurySplitter = new import_treasury_splitter.TreasurySplitterContract(
174
+ target,
175
+ this.client
176
+ );
177
+ const parsedData = treasurySplitter.parseFunctionData(data);
178
+ if (!parsedData.functionName.startsWith("Unknown function")) {
179
+ decoded = parsedData;
180
+ }
181
+ } catch {
182
+ decoded = void 0;
183
+ }
184
+ return {
185
+ chainId: 0,
186
+ target: this.address,
187
+ label: this.name,
188
+ functionName: params.functionName,
189
+ args: decoded ? {
190
+ target,
191
+ functionName: decoded.functionName,
192
+ data: (0, import_utils.json_stringify)(decoded.args)
193
+ } : {
194
+ target,
195
+ data
196
+ }
197
+ };
198
+ }
168
199
  case "activate": {
169
200
  const [instanceOwner, treasury, weth, gear] = params.args;
170
201
  return this.wrapParseCall(params, {
@@ -216,6 +247,13 @@ class InstanceManagerContract extends import_base_contract.BaseContract {
216
247
  description: rawTx.description ? `InstanceManager.configureLocal(${rawTx.description})` : void 0
217
248
  });
218
249
  }
250
+ wrapConfigureTreasury(rawTx) {
251
+ return this.createRawTx({
252
+ functionName: "configureTreasury",
253
+ args: [rawTx.to, rawTx.callData],
254
+ description: rawTx.description ? `InstanceManager.configureTreasury(${rawTx.description})` : void 0
255
+ });
256
+ }
219
257
  setLocalAddress(args) {
220
258
  const { key, address, saveVersion } = args;
221
259
  return this.createRawTx({
@@ -449,6 +449,18 @@ class MarketConfiguratorContract extends import_index.BaseContract {
449
449
  args: [(0, import_viem.stringToHex)(role, { size: 32 }), address]
450
450
  });
451
451
  }
452
+ revokeRole(role, address) {
453
+ return this.createRawTx({
454
+ functionName: "revokeRole",
455
+ args: [(0, import_viem.stringToHex)(role, { size: 32 }), address]
456
+ });
457
+ }
458
+ setEmergencyAdmin(newEmergencyAdmin) {
459
+ return this.createRawTx({
460
+ functionName: "setEmergencyAdmin",
461
+ args: [newEmergencyAdmin]
462
+ });
463
+ }
452
464
  //
453
465
  // SYNC
454
466
  //
@@ -22,18 +22,72 @@ __export(treasury_splitter_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(treasury_splitter_exports);
24
24
  var import_iTreasurySplitter = require("../../abi/310/iTreasurySplitter.js");
25
+ var import_abi_decoder = require("../utils/abi-decoder.js");
25
26
  var import_base_contract = require("./base-contract.js");
26
27
  const abi = import_iTreasurySplitter.ITreasurySplitterAbi;
27
28
  class TreasurySplitterContract extends import_base_contract.BaseContract {
28
29
  constructor(address, client) {
29
30
  super(abi, address, client, "TreasurySplitter");
30
31
  }
32
+ async defaultSplit() {
33
+ return await this.contract.read.defaultSplit();
34
+ }
35
+ async activeProposals() {
36
+ return this.contract.read.activeProposals();
37
+ }
31
38
  distribute(token) {
32
39
  return this.createRawTx({
33
40
  functionName: "distribute",
34
41
  args: [token]
35
42
  });
36
43
  }
44
+ setDefaultSplitTx(receivers, proportions) {
45
+ const rawTx = this.createRawTx({
46
+ functionName: "setDefaultSplit",
47
+ args: [receivers, proportions]
48
+ });
49
+ return this.wrapConfigure(rawTx);
50
+ }
51
+ setTokenSplitTx(token, receivers, proportions, distributeBefore) {
52
+ const rawTx = this.createRawTx({
53
+ functionName: "setTokenSplit",
54
+ args: [token, receivers, proportions, distributeBefore]
55
+ });
56
+ return this.wrapConfigure(rawTx);
57
+ }
58
+ setTokenInsuranceAmountTx(token, amount) {
59
+ const rawTx = this.createRawTx({
60
+ functionName: "setTokenInsuranceAmount",
61
+ args: [token, amount]
62
+ });
63
+ return this.wrapConfigure(rawTx);
64
+ }
65
+ withdrawTokenTx(token, to, amount) {
66
+ const rawTx = this.createRawTx({
67
+ functionName: "withdrawToken",
68
+ args: [token, to, amount]
69
+ });
70
+ return this.wrapConfigure(rawTx);
71
+ }
72
+ configureTx(callData) {
73
+ return this.createRawTx({
74
+ functionName: "configure",
75
+ args: [callData]
76
+ });
77
+ }
78
+ cancelConfigureTx(callData) {
79
+ const rawTx = this.createRawTx({
80
+ functionName: "cancelConfigure",
81
+ args: [callData]
82
+ });
83
+ return rawTx;
84
+ }
85
+ wrapConfigure(rawTx) {
86
+ return this.createRawTx({
87
+ functionName: "configure",
88
+ args: [rawTx.callData]
89
+ });
90
+ }
37
91
  parseFunctionParams(params) {
38
92
  const { functionName, args } = params;
39
93
  switch (functionName) {
@@ -49,6 +103,23 @@ class TreasurySplitterContract extends import_base_contract.BaseContract {
49
103
  }
50
104
  };
51
105
  }
106
+ case "configure": {
107
+ const [callData] = args;
108
+ const decoded = (0, import_abi_decoder.decodeFunctionWithNamedArgs)(abi, callData);
109
+ if (decoded) {
110
+ return {
111
+ chainId: 0,
112
+ target: this.address,
113
+ label: this.name,
114
+ functionName,
115
+ args: {
116
+ functionName: decoded.functionName,
117
+ ...decoded.args
118
+ }
119
+ };
120
+ }
121
+ return void 0;
122
+ }
52
123
  default:
53
124
  return void 0;
54
125
  }