@gearbox-protocol/sdk 11.0.0-next.2 → 11.0.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.
@@ -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:
@@ -27,6 +27,7 @@ __reExport(dev_exports, require("./ltUtils.js"), module.exports);
27
27
  __reExport(dev_exports, require("./migrateFaucet.js"), module.exports);
28
28
  __reExport(dev_exports, require("./mint/index.js"), module.exports);
29
29
  __reExport(dev_exports, require("./RevolverTransport.js"), module.exports);
30
+ __reExport(dev_exports, require("./replaceStorage.js"), module.exports);
30
31
  __reExport(dev_exports, require("./types.js"), module.exports);
31
32
  // Annotate the CommonJS export names for ESM import in node:
32
33
  0 && (module.exports = {
@@ -42,5 +43,6 @@ __reExport(dev_exports, require("./types.js"), module.exports);
42
43
  ...require("./migrateFaucet.js"),
43
44
  ...require("./mint/index.js"),
44
45
  ...require("./RevolverTransport.js"),
46
+ ...require("./replaceStorage.js"),
45
47
  ...require("./types.js")
46
48
  });
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var replaceStorage_exports = {};
20
+ __export(replaceStorage_exports, {
21
+ replaceStorage: () => replaceStorage
22
+ });
23
+ module.exports = __toCommonJS(replaceStorage_exports);
24
+ var import_viem = require("viem");
25
+ var import_actions = require("viem/actions");
26
+ async function replaceStorage(client, params) {
27
+ const { value, slotMatch, address, abi, functionName, args } = params;
28
+ const newValHex = (0, import_viem.numberToHex)(params.value, { size: 32 });
29
+ const { accessList } = await client.createAccessList({
30
+ to: address,
31
+ data: (0, import_viem.encodeFunctionData)({
32
+ abi,
33
+ functionName,
34
+ args
35
+ })
36
+ });
37
+ for (const { address: addr_, storageKeys } of accessList) {
38
+ const addr = addr_.toLowerCase();
39
+ for (const slot of storageKeys) {
40
+ try {
41
+ const result = await (0, import_actions.readContract)(client, {
42
+ abi,
43
+ address,
44
+ functionName,
45
+ args,
46
+ stateOverride: [
47
+ {
48
+ address: addr,
49
+ stateDiff: [
50
+ {
51
+ slot,
52
+ value: newValHex
53
+ }
54
+ ]
55
+ }
56
+ ]
57
+ });
58
+ if (slotMatch(
59
+ result,
60
+ value
61
+ )) {
62
+ await client.setStorageAt({
63
+ address,
64
+ index: slot,
65
+ value: newValHex
66
+ });
67
+ return;
68
+ }
69
+ } catch {
70
+ }
71
+ }
72
+ }
73
+ }
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ replaceStorage
77
+ });
@@ -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
  //