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