@bgd-labs/toolbox 0.0.1 → 0.0.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/index.mjs CHANGED
@@ -21,6 +21,16 @@ function getBits(uint256, startBit, _endBit) {
21
21
  const mask = (1n << endBit - startBit + 1n) - 1n;
22
22
  return uint256 >> startBit & mask;
23
23
  }
24
+ function setBits(input, startBit, endBit, replaceValue) {
25
+ const bigIntReplaceValue = BigInt(replaceValue);
26
+ let mask = BigInt(0);
27
+ for (let i = startBit; i < endBit + 1n; i++) {
28
+ mask |= BigInt(1) << BigInt(i);
29
+ }
30
+ const clearedNumber = input & ~mask;
31
+ const result = clearedNumber | bigIntReplaceValue << BigInt(startBit);
32
+ return result;
33
+ }
24
34
 
25
35
  // src/aave/user.ts
26
36
  function decodeUserConfiguration(userConfiguration) {
@@ -34,6 +44,1921 @@ function decodeUserConfiguration(userConfiguration) {
34
44
  return { borrowedAssetIds, collateralAssetIds };
35
45
  }
36
46
 
47
+ // src/aave/reserve.ts
48
+ function decodeReserveConfiguration(data) {
49
+ const ltv = getBits(data, 0n, 15n);
50
+ const liquidationThreshold = getBits(data, 16n, 31n);
51
+ const liquidationBonus = getBits(data, 32n, 47n);
52
+ const decimals = getBits(data, 48n, 55n);
53
+ const active = getBits(data, 56n, 56n);
54
+ const frozen = getBits(data, 57n, 57n);
55
+ const borrowingEnabled = getBits(data, 58n, 58n);
56
+ const paused = getBits(data, 60n, 60n);
57
+ const borrowingInIsolation = getBits(data, 61n, 61n);
58
+ const siloedBorrowingEnabled = getBits(data, 62n, 62n);
59
+ const flashloaningEnabled = getBits(data, 63n, 63n);
60
+ const reserveFactor = getBits(data, 64n, 79n);
61
+ const borrowCap = getBits(data, 80n, 115n);
62
+ const supplyCap = getBits(data, 116n, 151n);
63
+ const liquidationProtocolFee = getBits(data, 152n, 167n);
64
+ const unbackedMintCap = getBits(data, 176n, 211n);
65
+ const debtCeiling = getBits(data, 212n, 251n);
66
+ const virtualAccountingEnabled = getBits(data, 252n, 252n);
67
+ return {
68
+ ltv,
69
+ liquidationThreshold,
70
+ liquidationBonus,
71
+ decimals,
72
+ active: !!active,
73
+ frozen: !!frozen,
74
+ borrowingEnabled: !!borrowingEnabled,
75
+ // stableRateBorrowingEnabled: !!stableRateBorrowingEnabled,
76
+ paused: !!paused,
77
+ borrowingInIsolation: !!borrowingInIsolation,
78
+ reserveFactor,
79
+ borrowCap,
80
+ supplyCap,
81
+ liquidationProtocolFee,
82
+ // eModeCategory,
83
+ unbackedMintCap,
84
+ debtCeiling,
85
+ siloedBorrowingEnabled: !!siloedBorrowingEnabled,
86
+ flashloaningEnabled: !!flashloaningEnabled,
87
+ virtualAccountingEnabled: !!virtualAccountingEnabled
88
+ };
89
+ }
90
+ function decodeReserveConfigurationV2(data) {
91
+ const ltv = getBits(data, 0n, 15n);
92
+ const liquidationThreshold = getBits(data, 16n, 31n);
93
+ const liquidationBonus = getBits(data, 32n, 47n);
94
+ const decimals = getBits(data, 48n, 55n);
95
+ const active = Number(getBits(data, 56n, 56n));
96
+ const frozen = Number(getBits(data, 57n, 57n));
97
+ const borrowingEnabled = Number(getBits(data, 58n, 58n));
98
+ const stableBorrowingEnabled = Number(getBits(data, 59n, 59n));
99
+ const reserveFactor = getBits(data, 64n, 79n);
100
+ return {
101
+ ltv,
102
+ liquidationThreshold,
103
+ liquidationBonus,
104
+ decimals,
105
+ active: !!active,
106
+ frozen: !!frozen,
107
+ borrowingEnabled: !!borrowingEnabled,
108
+ stableBorrowingEnabled: !!stableBorrowingEnabled,
109
+ reserveFactor
110
+ };
111
+ }
112
+
113
+ // src/aave/constants.ts
114
+ var SECONDS_PER_YEAR = 31536000n;
115
+ var LTV_PRECISION = 4n;
116
+
117
+ // src/aave/ray-math.ts
118
+ var WAD = 10n ** 18n;
119
+ var HALF_WAD = WAD / 2n;
120
+ var RAY = 10n ** 27n;
121
+ var HALF_RAY = RAY / 2n;
122
+ var WAD_RAY_RATIO = 10n ** 9n;
123
+ function rayMul(a, b) {
124
+ return (a * b + HALF_RAY) / RAY;
125
+ }
126
+ function rayDiv(a, b) {
127
+ const halfB = b / 2n;
128
+ return (halfB + a * RAY) / b;
129
+ }
130
+ function rayToWad(a) {
131
+ const halfRatio = WAD_RAY_RATIO / 2n;
132
+ return (halfRatio + a) / WAD_RAY_RATIO;
133
+ }
134
+ function wadToRay(a) {
135
+ return a * WAD_RAY_RATIO;
136
+ }
137
+ function wadDiv(a, b) {
138
+ const halfB = b / 2n;
139
+ return (halfB + a * WAD) / b;
140
+ }
141
+
142
+ // src/aave/pool-math.ts
143
+ function calculateCompoundedInterest({
144
+ rate,
145
+ currentTimestamp,
146
+ lastUpdateTimestamp
147
+ }) {
148
+ const exp = BigInt(currentTimestamp - lastUpdateTimestamp);
149
+ if (exp == 0n) {
150
+ return RAY;
151
+ }
152
+ const expMinusOne = exp - 1n;
153
+ const expMinusTwo = exp > 2 ? exp - 2n : 0n;
154
+ const basePowerTwo = rayMul(rate, rate) / (SECONDS_PER_YEAR * SECONDS_PER_YEAR);
155
+ const basePowerThree = rayMul(basePowerTwo, rate) / SECONDS_PER_YEAR;
156
+ const secondTerm = exp * expMinusOne * basePowerTwo / 2n;
157
+ const thirdTerm = exp * expMinusOne * expMinusTwo * basePowerThree / 6n;
158
+ return RAY + rate * exp / SECONDS_PER_YEAR + secondTerm + thirdTerm;
159
+ }
160
+ function calculateLinearInterest({
161
+ rate,
162
+ currentTimestamp,
163
+ lastUpdateTimestamp
164
+ }) {
165
+ return rate * BigInt(currentTimestamp - lastUpdateTimestamp) / SECONDS_PER_YEAR + RAY;
166
+ }
167
+ function getNormalizedIncome({
168
+ rate,
169
+ index,
170
+ lastUpdateTimestamp,
171
+ currentTimestamp
172
+ }) {
173
+ if (!rate) {
174
+ return index;
175
+ }
176
+ const cumulatedInterest = calculateLinearInterest({
177
+ rate,
178
+ currentTimestamp,
179
+ lastUpdateTimestamp
180
+ });
181
+ return rayMul(index, cumulatedInterest);
182
+ }
183
+ function getNormalizedDebt({
184
+ rate,
185
+ index,
186
+ currentTimestamp,
187
+ lastUpdateTimestamp
188
+ }) {
189
+ if (currentTimestamp === lastUpdateTimestamp || rate === 0n) {
190
+ return index;
191
+ }
192
+ return rayMul(
193
+ index,
194
+ calculateCompoundedInterest({
195
+ rate,
196
+ currentTimestamp,
197
+ lastUpdateTimestamp
198
+ })
199
+ );
200
+ }
201
+ function getCurrentLiquidityBalance({
202
+ scaledBalance,
203
+ index,
204
+ rate,
205
+ lastUpdateTimestamp,
206
+ currentTimestamp
207
+ }) {
208
+ if (!scaledBalance) {
209
+ return 0n;
210
+ }
211
+ return rayToWad(
212
+ rayMul(
213
+ wadToRay(scaledBalance),
214
+ getNormalizedIncome({
215
+ rate,
216
+ index,
217
+ lastUpdateTimestamp,
218
+ currentTimestamp
219
+ })
220
+ )
221
+ );
222
+ }
223
+ function getCurrentDebtBalance({
224
+ index,
225
+ scaledBalance,
226
+ rate,
227
+ lastUpdateTimestamp,
228
+ currentTimestamp
229
+ }) {
230
+ if (!scaledBalance) {
231
+ return 0n;
232
+ }
233
+ return rayMul(
234
+ scaledBalance,
235
+ getNormalizedDebt({
236
+ index,
237
+ rate,
238
+ currentTimestamp,
239
+ lastUpdateTimestamp
240
+ })
241
+ );
242
+ }
243
+ function calculateHealthFactorFromBalances({
244
+ borrowBalanceMarketReferenceCurrency,
245
+ collateralBalanceMarketReferenceCurrency,
246
+ averageLiquidationThreshold
247
+ }) {
248
+ if (!borrowBalanceMarketReferenceCurrency) {
249
+ return -1n;
250
+ }
251
+ return wadDiv(
252
+ collateralBalanceMarketReferenceCurrency * averageLiquidationThreshold / 10n ** LTV_PRECISION,
253
+ borrowBalanceMarketReferenceCurrency
254
+ );
255
+ }
256
+ function calculateAvailableBorrowsMarketReferenceCurrency({
257
+ collateralBalanceMarketReferenceCurrency,
258
+ borrowBalanceMarketReferenceCurrency,
259
+ currentLtv
260
+ }) {
261
+ if (!currentLtv) {
262
+ return 0n;
263
+ }
264
+ const availableBorrowsMarketReferenceCurrency = collateralBalanceMarketReferenceCurrency * currentLtv / 10n ** LTV_PRECISION - borrowBalanceMarketReferenceCurrency;
265
+ return availableBorrowsMarketReferenceCurrency > 0 ? availableBorrowsMarketReferenceCurrency : 0n;
266
+ }
267
+ function getMarketReferenceCurrencyAndUsdBalance({
268
+ balance,
269
+ priceInMarketReferenceCurrency,
270
+ marketReferenceCurrencyDecimals,
271
+ decimals,
272
+ marketReferencePriceInUsdNormalized
273
+ }) {
274
+ const marketReferenceCurrencyBalance = balance * priceInMarketReferenceCurrency / BigInt(10 ** decimals);
275
+ const usdBalance = marketReferenceCurrencyBalance * marketReferencePriceInUsdNormalized / BigInt(10 ** marketReferenceCurrencyDecimals);
276
+ return { marketReferenceCurrencyBalance, usdBalance };
277
+ }
278
+
279
+ // ../../node_modules/.pnpm/@bgd-labs+aave-address-book@4.15.0/node_modules/@bgd-labs/aave-address-book/dist/abis/IPayloadsControllerCore.mjs
280
+ var IPayloadsControllerCore_ABI = [
281
+ {
282
+ type: "function",
283
+ name: "EXPIRATION_DELAY",
284
+ inputs: [],
285
+ outputs: [
286
+ {
287
+ name: "",
288
+ type: "uint40",
289
+ internalType: "uint40"
290
+ }
291
+ ],
292
+ stateMutability: "view"
293
+ },
294
+ {
295
+ type: "function",
296
+ name: "GRACE_PERIOD",
297
+ inputs: [],
298
+ outputs: [
299
+ {
300
+ name: "",
301
+ type: "uint40",
302
+ internalType: "uint40"
303
+ }
304
+ ],
305
+ stateMutability: "view"
306
+ },
307
+ {
308
+ type: "function",
309
+ name: "MAX_EXECUTION_DELAY",
310
+ inputs: [],
311
+ outputs: [
312
+ {
313
+ name: "",
314
+ type: "uint40",
315
+ internalType: "uint40"
316
+ }
317
+ ],
318
+ stateMutability: "view"
319
+ },
320
+ {
321
+ type: "function",
322
+ name: "MIN_EXECUTION_DELAY",
323
+ inputs: [],
324
+ outputs: [
325
+ {
326
+ name: "",
327
+ type: "uint40",
328
+ internalType: "uint40"
329
+ }
330
+ ],
331
+ stateMutability: "view"
332
+ },
333
+ {
334
+ type: "function",
335
+ name: "cancelPayload",
336
+ inputs: [
337
+ {
338
+ name: "payloadId",
339
+ type: "uint40",
340
+ internalType: "uint40"
341
+ }
342
+ ],
343
+ outputs: [],
344
+ stateMutability: "nonpayable"
345
+ },
346
+ {
347
+ type: "function",
348
+ name: "createPayload",
349
+ inputs: [
350
+ {
351
+ name: "actions",
352
+ type: "tuple[]",
353
+ internalType: "struct IPayloadsControllerCore.ExecutionAction[]",
354
+ components: [
355
+ {
356
+ name: "target",
357
+ type: "address",
358
+ internalType: "address"
359
+ },
360
+ {
361
+ name: "withDelegateCall",
362
+ type: "bool",
363
+ internalType: "bool"
364
+ },
365
+ {
366
+ name: "accessLevel",
367
+ type: "uint8",
368
+ internalType: "enum PayloadsControllerUtils.AccessControl"
369
+ },
370
+ {
371
+ name: "value",
372
+ type: "uint256",
373
+ internalType: "uint256"
374
+ },
375
+ {
376
+ name: "signature",
377
+ type: "string",
378
+ internalType: "string"
379
+ },
380
+ {
381
+ name: "callData",
382
+ type: "bytes",
383
+ internalType: "bytes"
384
+ }
385
+ ]
386
+ }
387
+ ],
388
+ outputs: [
389
+ {
390
+ name: "",
391
+ type: "uint40",
392
+ internalType: "uint40"
393
+ }
394
+ ],
395
+ stateMutability: "nonpayable"
396
+ },
397
+ {
398
+ type: "function",
399
+ name: "executePayload",
400
+ inputs: [
401
+ {
402
+ name: "payloadId",
403
+ type: "uint40",
404
+ internalType: "uint40"
405
+ }
406
+ ],
407
+ outputs: [],
408
+ stateMutability: "payable"
409
+ },
410
+ {
411
+ type: "function",
412
+ name: "getExecutorSettingsByAccessControl",
413
+ inputs: [
414
+ {
415
+ name: "accessControl",
416
+ type: "uint8",
417
+ internalType: "enum PayloadsControllerUtils.AccessControl"
418
+ }
419
+ ],
420
+ outputs: [
421
+ {
422
+ name: "",
423
+ type: "tuple",
424
+ internalType: "struct IPayloadsControllerCore.ExecutorConfig",
425
+ components: [
426
+ {
427
+ name: "executor",
428
+ type: "address",
429
+ internalType: "address"
430
+ },
431
+ {
432
+ name: "delay",
433
+ type: "uint40",
434
+ internalType: "uint40"
435
+ }
436
+ ]
437
+ }
438
+ ],
439
+ stateMutability: "view"
440
+ },
441
+ {
442
+ type: "function",
443
+ name: "getPayloadById",
444
+ inputs: [
445
+ {
446
+ name: "payloadId",
447
+ type: "uint40",
448
+ internalType: "uint40"
449
+ }
450
+ ],
451
+ outputs: [
452
+ {
453
+ name: "",
454
+ type: "tuple",
455
+ internalType: "struct IPayloadsControllerCore.Payload",
456
+ components: [
457
+ {
458
+ name: "creator",
459
+ type: "address",
460
+ internalType: "address"
461
+ },
462
+ {
463
+ name: "maximumAccessLevelRequired",
464
+ type: "uint8",
465
+ internalType: "enum PayloadsControllerUtils.AccessControl"
466
+ },
467
+ {
468
+ name: "state",
469
+ type: "uint8",
470
+ internalType: "enum IPayloadsControllerCore.PayloadState"
471
+ },
472
+ {
473
+ name: "createdAt",
474
+ type: "uint40",
475
+ internalType: "uint40"
476
+ },
477
+ {
478
+ name: "queuedAt",
479
+ type: "uint40",
480
+ internalType: "uint40"
481
+ },
482
+ {
483
+ name: "executedAt",
484
+ type: "uint40",
485
+ internalType: "uint40"
486
+ },
487
+ {
488
+ name: "cancelledAt",
489
+ type: "uint40",
490
+ internalType: "uint40"
491
+ },
492
+ {
493
+ name: "expirationTime",
494
+ type: "uint40",
495
+ internalType: "uint40"
496
+ },
497
+ {
498
+ name: "delay",
499
+ type: "uint40",
500
+ internalType: "uint40"
501
+ },
502
+ {
503
+ name: "gracePeriod",
504
+ type: "uint40",
505
+ internalType: "uint40"
506
+ },
507
+ {
508
+ name: "actions",
509
+ type: "tuple[]",
510
+ internalType: "struct IPayloadsControllerCore.ExecutionAction[]",
511
+ components: [
512
+ {
513
+ name: "target",
514
+ type: "address",
515
+ internalType: "address"
516
+ },
517
+ {
518
+ name: "withDelegateCall",
519
+ type: "bool",
520
+ internalType: "bool"
521
+ },
522
+ {
523
+ name: "accessLevel",
524
+ type: "uint8",
525
+ internalType: "enum PayloadsControllerUtils.AccessControl"
526
+ },
527
+ {
528
+ name: "value",
529
+ type: "uint256",
530
+ internalType: "uint256"
531
+ },
532
+ {
533
+ name: "signature",
534
+ type: "string",
535
+ internalType: "string"
536
+ },
537
+ {
538
+ name: "callData",
539
+ type: "bytes",
540
+ internalType: "bytes"
541
+ }
542
+ ]
543
+ }
544
+ ]
545
+ }
546
+ ],
547
+ stateMutability: "view"
548
+ },
549
+ {
550
+ type: "function",
551
+ name: "getPayloadState",
552
+ inputs: [
553
+ {
554
+ name: "payloadId",
555
+ type: "uint40",
556
+ internalType: "uint40"
557
+ }
558
+ ],
559
+ outputs: [
560
+ {
561
+ name: "",
562
+ type: "uint8",
563
+ internalType: "enum IPayloadsControllerCore.PayloadState"
564
+ }
565
+ ],
566
+ stateMutability: "view"
567
+ },
568
+ {
569
+ type: "function",
570
+ name: "getPayloadsCount",
571
+ inputs: [],
572
+ outputs: [
573
+ {
574
+ name: "",
575
+ type: "uint40",
576
+ internalType: "uint40"
577
+ }
578
+ ],
579
+ stateMutability: "view"
580
+ },
581
+ {
582
+ type: "function",
583
+ name: "updateExecutors",
584
+ inputs: [
585
+ {
586
+ name: "executors",
587
+ type: "tuple[]",
588
+ internalType: "struct IPayloadsControllerCore.UpdateExecutorInput[]",
589
+ components: [
590
+ {
591
+ name: "accessLevel",
592
+ type: "uint8",
593
+ internalType: "enum PayloadsControllerUtils.AccessControl"
594
+ },
595
+ {
596
+ name: "executorConfig",
597
+ type: "tuple",
598
+ internalType: "struct IPayloadsControllerCore.ExecutorConfig",
599
+ components: [
600
+ {
601
+ name: "executor",
602
+ type: "address",
603
+ internalType: "address"
604
+ },
605
+ {
606
+ name: "delay",
607
+ type: "uint40",
608
+ internalType: "uint40"
609
+ }
610
+ ]
611
+ }
612
+ ]
613
+ }
614
+ ],
615
+ outputs: [],
616
+ stateMutability: "nonpayable"
617
+ },
618
+ {
619
+ type: "event",
620
+ name: "ExecutorSet",
621
+ inputs: [
622
+ {
623
+ name: "accessLevel",
624
+ type: "uint8",
625
+ indexed: true,
626
+ internalType: "enum PayloadsControllerUtils.AccessControl"
627
+ },
628
+ {
629
+ name: "executor",
630
+ type: "address",
631
+ indexed: true,
632
+ internalType: "address"
633
+ },
634
+ {
635
+ name: "delay",
636
+ type: "uint40",
637
+ indexed: false,
638
+ internalType: "uint40"
639
+ }
640
+ ],
641
+ anonymous: false
642
+ },
643
+ {
644
+ type: "event",
645
+ name: "PayloadCancelled",
646
+ inputs: [
647
+ {
648
+ name: "payloadId",
649
+ type: "uint40",
650
+ indexed: false,
651
+ internalType: "uint40"
652
+ }
653
+ ],
654
+ anonymous: false
655
+ },
656
+ {
657
+ type: "event",
658
+ name: "PayloadCreated",
659
+ inputs: [
660
+ {
661
+ name: "payloadId",
662
+ type: "uint40",
663
+ indexed: true,
664
+ internalType: "uint40"
665
+ },
666
+ {
667
+ name: "creator",
668
+ type: "address",
669
+ indexed: true,
670
+ internalType: "address"
671
+ },
672
+ {
673
+ name: "actions",
674
+ type: "tuple[]",
675
+ indexed: false,
676
+ internalType: "struct IPayloadsControllerCore.ExecutionAction[]",
677
+ components: [
678
+ {
679
+ name: "target",
680
+ type: "address",
681
+ internalType: "address"
682
+ },
683
+ {
684
+ name: "withDelegateCall",
685
+ type: "bool",
686
+ internalType: "bool"
687
+ },
688
+ {
689
+ name: "accessLevel",
690
+ type: "uint8",
691
+ internalType: "enum PayloadsControllerUtils.AccessControl"
692
+ },
693
+ {
694
+ name: "value",
695
+ type: "uint256",
696
+ internalType: "uint256"
697
+ },
698
+ {
699
+ name: "signature",
700
+ type: "string",
701
+ internalType: "string"
702
+ },
703
+ {
704
+ name: "callData",
705
+ type: "bytes",
706
+ internalType: "bytes"
707
+ }
708
+ ]
709
+ },
710
+ {
711
+ name: "maximumAccessLevelRequired",
712
+ type: "uint8",
713
+ indexed: true,
714
+ internalType: "enum PayloadsControllerUtils.AccessControl"
715
+ }
716
+ ],
717
+ anonymous: false
718
+ },
719
+ {
720
+ type: "event",
721
+ name: "PayloadExecuted",
722
+ inputs: [
723
+ {
724
+ name: "payloadId",
725
+ type: "uint40",
726
+ indexed: false,
727
+ internalType: "uint40"
728
+ }
729
+ ],
730
+ anonymous: false
731
+ },
732
+ {
733
+ type: "event",
734
+ name: "PayloadExecutionMessageReceived",
735
+ inputs: [
736
+ {
737
+ name: "originSender",
738
+ type: "address",
739
+ indexed: true,
740
+ internalType: "address"
741
+ },
742
+ {
743
+ name: "originChainId",
744
+ type: "uint256",
745
+ indexed: true,
746
+ internalType: "uint256"
747
+ },
748
+ {
749
+ name: "delivered",
750
+ type: "bool",
751
+ indexed: true,
752
+ internalType: "bool"
753
+ },
754
+ {
755
+ name: "message",
756
+ type: "bytes",
757
+ indexed: false,
758
+ internalType: "bytes"
759
+ },
760
+ {
761
+ name: "reason",
762
+ type: "bytes",
763
+ indexed: false,
764
+ internalType: "bytes"
765
+ }
766
+ ],
767
+ anonymous: false
768
+ },
769
+ {
770
+ type: "event",
771
+ name: "PayloadQueued",
772
+ inputs: [
773
+ {
774
+ name: "payloadId",
775
+ type: "uint40",
776
+ indexed: false,
777
+ internalType: "uint40"
778
+ }
779
+ ],
780
+ anonymous: false
781
+ }
782
+ ];
783
+
784
+ // ../../node_modules/.pnpm/@bgd-labs+aave-address-book@4.15.0/node_modules/@bgd-labs/aave-address-book/dist/abis/IGovernanceCore.mjs
785
+ var IGovernanceCore_ABI = [
786
+ {
787
+ type: "function",
788
+ name: "ACHIEVABLE_VOTING_PARTICIPATION",
789
+ inputs: [],
790
+ outputs: [
791
+ {
792
+ name: "",
793
+ type: "uint256",
794
+ internalType: "uint256"
795
+ }
796
+ ],
797
+ stateMutability: "view"
798
+ },
799
+ {
800
+ type: "function",
801
+ name: "CANCELLATION_FEE_COLLECTOR",
802
+ inputs: [],
803
+ outputs: [
804
+ {
805
+ name: "",
806
+ type: "address",
807
+ internalType: "address"
808
+ }
809
+ ],
810
+ stateMutability: "view"
811
+ },
812
+ {
813
+ type: "function",
814
+ name: "COOLDOWN_PERIOD",
815
+ inputs: [],
816
+ outputs: [
817
+ {
818
+ name: "",
819
+ type: "uint256",
820
+ internalType: "uint256"
821
+ }
822
+ ],
823
+ stateMutability: "view"
824
+ },
825
+ {
826
+ type: "function",
827
+ name: "MIN_VOTING_DURATION",
828
+ inputs: [],
829
+ outputs: [
830
+ {
831
+ name: "",
832
+ type: "uint256",
833
+ internalType: "uint256"
834
+ }
835
+ ],
836
+ stateMutability: "view"
837
+ },
838
+ {
839
+ type: "function",
840
+ name: "NAME",
841
+ inputs: [],
842
+ outputs: [
843
+ {
844
+ name: "",
845
+ type: "string",
846
+ internalType: "string"
847
+ }
848
+ ],
849
+ stateMutability: "view"
850
+ },
851
+ {
852
+ type: "function",
853
+ name: "PRECISION_DIVIDER",
854
+ inputs: [],
855
+ outputs: [
856
+ {
857
+ name: "",
858
+ type: "uint256",
859
+ internalType: "uint256"
860
+ }
861
+ ],
862
+ stateMutability: "view"
863
+ },
864
+ {
865
+ type: "function",
866
+ name: "PROPOSAL_EXPIRATION_TIME",
867
+ inputs: [],
868
+ outputs: [
869
+ {
870
+ name: "",
871
+ type: "uint256",
872
+ internalType: "uint256"
873
+ }
874
+ ],
875
+ stateMutability: "view"
876
+ },
877
+ {
878
+ type: "function",
879
+ name: "VOTING_TOKENS_CAP",
880
+ inputs: [],
881
+ outputs: [
882
+ {
883
+ name: "",
884
+ type: "uint256",
885
+ internalType: "uint256"
886
+ }
887
+ ],
888
+ stateMutability: "view"
889
+ },
890
+ {
891
+ type: "function",
892
+ name: "activateVoting",
893
+ inputs: [
894
+ {
895
+ name: "proposalId",
896
+ type: "uint256",
897
+ internalType: "uint256"
898
+ }
899
+ ],
900
+ outputs: [],
901
+ stateMutability: "nonpayable"
902
+ },
903
+ {
904
+ type: "function",
905
+ name: "addVotingPortals",
906
+ inputs: [
907
+ {
908
+ name: "votingPortals",
909
+ type: "address[]",
910
+ internalType: "address[]"
911
+ }
912
+ ],
913
+ outputs: [],
914
+ stateMutability: "nonpayable"
915
+ },
916
+ {
917
+ type: "function",
918
+ name: "cancelProposal",
919
+ inputs: [
920
+ {
921
+ name: "proposalId",
922
+ type: "uint256",
923
+ internalType: "uint256"
924
+ }
925
+ ],
926
+ outputs: [],
927
+ stateMutability: "nonpayable"
928
+ },
929
+ {
930
+ type: "function",
931
+ name: "createProposal",
932
+ inputs: [
933
+ {
934
+ name: "payloads",
935
+ type: "tuple[]",
936
+ internalType: "struct PayloadsControllerUtils.Payload[]",
937
+ components: [
938
+ {
939
+ name: "chain",
940
+ type: "uint256",
941
+ internalType: "uint256"
942
+ },
943
+ {
944
+ name: "accessLevel",
945
+ type: "uint8",
946
+ internalType: "enum PayloadsControllerUtils.AccessControl"
947
+ },
948
+ {
949
+ name: "payloadsController",
950
+ type: "address",
951
+ internalType: "address"
952
+ },
953
+ {
954
+ name: "payloadId",
955
+ type: "uint40",
956
+ internalType: "uint40"
957
+ }
958
+ ]
959
+ },
960
+ {
961
+ name: "votingPortal",
962
+ type: "address",
963
+ internalType: "address"
964
+ },
965
+ {
966
+ name: "ipfsHash",
967
+ type: "bytes32",
968
+ internalType: "bytes32"
969
+ }
970
+ ],
971
+ outputs: [
972
+ {
973
+ name: "",
974
+ type: "uint256",
975
+ internalType: "uint256"
976
+ }
977
+ ],
978
+ stateMutability: "payable"
979
+ },
980
+ {
981
+ type: "function",
982
+ name: "executeProposal",
983
+ inputs: [
984
+ {
985
+ name: "proposalId",
986
+ type: "uint256",
987
+ internalType: "uint256"
988
+ }
989
+ ],
990
+ outputs: [],
991
+ stateMutability: "nonpayable"
992
+ },
993
+ {
994
+ type: "function",
995
+ name: "getCancellationFee",
996
+ inputs: [],
997
+ outputs: [
998
+ {
999
+ name: "",
1000
+ type: "uint256",
1001
+ internalType: "uint256"
1002
+ }
1003
+ ],
1004
+ stateMutability: "view"
1005
+ },
1006
+ {
1007
+ type: "function",
1008
+ name: "getPowerStrategy",
1009
+ inputs: [],
1010
+ outputs: [
1011
+ {
1012
+ name: "",
1013
+ type: "address",
1014
+ internalType: "contract IGovernancePowerStrategy"
1015
+ }
1016
+ ],
1017
+ stateMutability: "view"
1018
+ },
1019
+ {
1020
+ type: "function",
1021
+ name: "getProposal",
1022
+ inputs: [
1023
+ {
1024
+ name: "proposalId",
1025
+ type: "uint256",
1026
+ internalType: "uint256"
1027
+ }
1028
+ ],
1029
+ outputs: [
1030
+ {
1031
+ name: "",
1032
+ type: "tuple",
1033
+ internalType: "struct IGovernanceCore.Proposal",
1034
+ components: [
1035
+ {
1036
+ name: "state",
1037
+ type: "uint8",
1038
+ internalType: "enum IGovernanceCore.State"
1039
+ },
1040
+ {
1041
+ name: "accessLevel",
1042
+ type: "uint8",
1043
+ internalType: "enum PayloadsControllerUtils.AccessControl"
1044
+ },
1045
+ {
1046
+ name: "creationTime",
1047
+ type: "uint40",
1048
+ internalType: "uint40"
1049
+ },
1050
+ {
1051
+ name: "votingDuration",
1052
+ type: "uint24",
1053
+ internalType: "uint24"
1054
+ },
1055
+ {
1056
+ name: "votingActivationTime",
1057
+ type: "uint40",
1058
+ internalType: "uint40"
1059
+ },
1060
+ {
1061
+ name: "queuingTime",
1062
+ type: "uint40",
1063
+ internalType: "uint40"
1064
+ },
1065
+ {
1066
+ name: "cancelTimestamp",
1067
+ type: "uint40",
1068
+ internalType: "uint40"
1069
+ },
1070
+ {
1071
+ name: "creator",
1072
+ type: "address",
1073
+ internalType: "address"
1074
+ },
1075
+ {
1076
+ name: "votingPortal",
1077
+ type: "address",
1078
+ internalType: "address"
1079
+ },
1080
+ {
1081
+ name: "snapshotBlockHash",
1082
+ type: "bytes32",
1083
+ internalType: "bytes32"
1084
+ },
1085
+ {
1086
+ name: "ipfsHash",
1087
+ type: "bytes32",
1088
+ internalType: "bytes32"
1089
+ },
1090
+ {
1091
+ name: "forVotes",
1092
+ type: "uint128",
1093
+ internalType: "uint128"
1094
+ },
1095
+ {
1096
+ name: "againstVotes",
1097
+ type: "uint128",
1098
+ internalType: "uint128"
1099
+ },
1100
+ {
1101
+ name: "cancellationFee",
1102
+ type: "uint256",
1103
+ internalType: "uint256"
1104
+ },
1105
+ {
1106
+ name: "payloads",
1107
+ type: "tuple[]",
1108
+ internalType: "struct PayloadsControllerUtils.Payload[]",
1109
+ components: [
1110
+ {
1111
+ name: "chain",
1112
+ type: "uint256",
1113
+ internalType: "uint256"
1114
+ },
1115
+ {
1116
+ name: "accessLevel",
1117
+ type: "uint8",
1118
+ internalType: "enum PayloadsControllerUtils.AccessControl"
1119
+ },
1120
+ {
1121
+ name: "payloadsController",
1122
+ type: "address",
1123
+ internalType: "address"
1124
+ },
1125
+ {
1126
+ name: "payloadId",
1127
+ type: "uint40",
1128
+ internalType: "uint40"
1129
+ }
1130
+ ]
1131
+ }
1132
+ ]
1133
+ }
1134
+ ],
1135
+ stateMutability: "view"
1136
+ },
1137
+ {
1138
+ type: "function",
1139
+ name: "getProposalState",
1140
+ inputs: [
1141
+ {
1142
+ name: "proposalId",
1143
+ type: "uint256",
1144
+ internalType: "uint256"
1145
+ }
1146
+ ],
1147
+ outputs: [
1148
+ {
1149
+ name: "",
1150
+ type: "uint8",
1151
+ internalType: "enum IGovernanceCore.State"
1152
+ }
1153
+ ],
1154
+ stateMutability: "view"
1155
+ },
1156
+ {
1157
+ type: "function",
1158
+ name: "getProposalsCount",
1159
+ inputs: [],
1160
+ outputs: [
1161
+ {
1162
+ name: "",
1163
+ type: "uint256",
1164
+ internalType: "uint256"
1165
+ }
1166
+ ],
1167
+ stateMutability: "view"
1168
+ },
1169
+ {
1170
+ type: "function",
1171
+ name: "getRepresentativeByChain",
1172
+ inputs: [
1173
+ {
1174
+ name: "voter",
1175
+ type: "address",
1176
+ internalType: "address"
1177
+ },
1178
+ {
1179
+ name: "chainId",
1180
+ type: "uint256",
1181
+ internalType: "uint256"
1182
+ }
1183
+ ],
1184
+ outputs: [
1185
+ {
1186
+ name: "",
1187
+ type: "address",
1188
+ internalType: "address"
1189
+ }
1190
+ ],
1191
+ stateMutability: "view"
1192
+ },
1193
+ {
1194
+ type: "function",
1195
+ name: "getRepresentedVotersByChain",
1196
+ inputs: [
1197
+ {
1198
+ name: "representative",
1199
+ type: "address",
1200
+ internalType: "address"
1201
+ },
1202
+ {
1203
+ name: "chainId",
1204
+ type: "uint256",
1205
+ internalType: "uint256"
1206
+ }
1207
+ ],
1208
+ outputs: [
1209
+ {
1210
+ name: "",
1211
+ type: "address[]",
1212
+ internalType: "address[]"
1213
+ }
1214
+ ],
1215
+ stateMutability: "view"
1216
+ },
1217
+ {
1218
+ type: "function",
1219
+ name: "getVotingConfig",
1220
+ inputs: [
1221
+ {
1222
+ name: "accessLevel",
1223
+ type: "uint8",
1224
+ internalType: "enum PayloadsControllerUtils.AccessControl"
1225
+ }
1226
+ ],
1227
+ outputs: [
1228
+ {
1229
+ name: "",
1230
+ type: "tuple",
1231
+ internalType: "struct IGovernanceCore.VotingConfig",
1232
+ components: [
1233
+ {
1234
+ name: "coolDownBeforeVotingStart",
1235
+ type: "uint24",
1236
+ internalType: "uint24"
1237
+ },
1238
+ {
1239
+ name: "votingDuration",
1240
+ type: "uint24",
1241
+ internalType: "uint24"
1242
+ },
1243
+ {
1244
+ name: "yesThreshold",
1245
+ type: "uint56",
1246
+ internalType: "uint56"
1247
+ },
1248
+ {
1249
+ name: "yesNoDifferential",
1250
+ type: "uint56",
1251
+ internalType: "uint56"
1252
+ },
1253
+ {
1254
+ name: "minPropositionPower",
1255
+ type: "uint56",
1256
+ internalType: "uint56"
1257
+ }
1258
+ ]
1259
+ }
1260
+ ],
1261
+ stateMutability: "view"
1262
+ },
1263
+ {
1264
+ type: "function",
1265
+ name: "getVotingPortalsCount",
1266
+ inputs: [],
1267
+ outputs: [
1268
+ {
1269
+ name: "",
1270
+ type: "uint256",
1271
+ internalType: "uint256"
1272
+ }
1273
+ ],
1274
+ stateMutability: "view"
1275
+ },
1276
+ {
1277
+ type: "function",
1278
+ name: "isVotingPortalApproved",
1279
+ inputs: [
1280
+ {
1281
+ name: "votingPortal",
1282
+ type: "address",
1283
+ internalType: "address"
1284
+ }
1285
+ ],
1286
+ outputs: [
1287
+ {
1288
+ name: "",
1289
+ type: "bool",
1290
+ internalType: "bool"
1291
+ }
1292
+ ],
1293
+ stateMutability: "view"
1294
+ },
1295
+ {
1296
+ type: "function",
1297
+ name: "queueProposal",
1298
+ inputs: [
1299
+ {
1300
+ name: "proposalId",
1301
+ type: "uint256",
1302
+ internalType: "uint256"
1303
+ },
1304
+ {
1305
+ name: "forVotes",
1306
+ type: "uint128",
1307
+ internalType: "uint128"
1308
+ },
1309
+ {
1310
+ name: "againstVotes",
1311
+ type: "uint128",
1312
+ internalType: "uint128"
1313
+ }
1314
+ ],
1315
+ outputs: [],
1316
+ stateMutability: "nonpayable"
1317
+ },
1318
+ {
1319
+ type: "function",
1320
+ name: "redeemCancellationFee",
1321
+ inputs: [
1322
+ {
1323
+ name: "proposalIds",
1324
+ type: "uint256[]",
1325
+ internalType: "uint256[]"
1326
+ }
1327
+ ],
1328
+ outputs: [],
1329
+ stateMutability: "nonpayable"
1330
+ },
1331
+ {
1332
+ type: "function",
1333
+ name: "removeVotingPortals",
1334
+ inputs: [
1335
+ {
1336
+ name: "votingPortals",
1337
+ type: "address[]",
1338
+ internalType: "address[]"
1339
+ }
1340
+ ],
1341
+ outputs: [],
1342
+ stateMutability: "nonpayable"
1343
+ },
1344
+ {
1345
+ type: "function",
1346
+ name: "rescueVotingPortal",
1347
+ inputs: [
1348
+ {
1349
+ name: "votingPortal",
1350
+ type: "address",
1351
+ internalType: "address"
1352
+ }
1353
+ ],
1354
+ outputs: [],
1355
+ stateMutability: "nonpayable"
1356
+ },
1357
+ {
1358
+ type: "function",
1359
+ name: "setPowerStrategy",
1360
+ inputs: [
1361
+ {
1362
+ name: "newPowerStrategy",
1363
+ type: "address",
1364
+ internalType: "contract IGovernancePowerStrategy"
1365
+ }
1366
+ ],
1367
+ outputs: [],
1368
+ stateMutability: "nonpayable"
1369
+ },
1370
+ {
1371
+ type: "function",
1372
+ name: "setVotingConfigs",
1373
+ inputs: [
1374
+ {
1375
+ name: "votingConfigs",
1376
+ type: "tuple[]",
1377
+ internalType: "struct IGovernanceCore.SetVotingConfigInput[]",
1378
+ components: [
1379
+ {
1380
+ name: "accessLevel",
1381
+ type: "uint8",
1382
+ internalType: "enum PayloadsControllerUtils.AccessControl"
1383
+ },
1384
+ {
1385
+ name: "coolDownBeforeVotingStart",
1386
+ type: "uint24",
1387
+ internalType: "uint24"
1388
+ },
1389
+ {
1390
+ name: "votingDuration",
1391
+ type: "uint24",
1392
+ internalType: "uint24"
1393
+ },
1394
+ {
1395
+ name: "yesThreshold",
1396
+ type: "uint256",
1397
+ internalType: "uint256"
1398
+ },
1399
+ {
1400
+ name: "yesNoDifferential",
1401
+ type: "uint256",
1402
+ internalType: "uint256"
1403
+ },
1404
+ {
1405
+ name: "minPropositionPower",
1406
+ type: "uint256",
1407
+ internalType: "uint256"
1408
+ }
1409
+ ]
1410
+ }
1411
+ ],
1412
+ outputs: [],
1413
+ stateMutability: "nonpayable"
1414
+ },
1415
+ {
1416
+ type: "function",
1417
+ name: "updateCancellationFee",
1418
+ inputs: [
1419
+ {
1420
+ name: "cancellationFee",
1421
+ type: "uint256",
1422
+ internalType: "uint256"
1423
+ }
1424
+ ],
1425
+ outputs: [],
1426
+ stateMutability: "nonpayable"
1427
+ },
1428
+ {
1429
+ type: "function",
1430
+ name: "updateRepresentativesForChain",
1431
+ inputs: [
1432
+ {
1433
+ name: "representatives",
1434
+ type: "tuple[]",
1435
+ internalType: "struct IGovernanceCore.RepresentativeInput[]",
1436
+ components: [
1437
+ {
1438
+ name: "representative",
1439
+ type: "address",
1440
+ internalType: "address"
1441
+ },
1442
+ {
1443
+ name: "chainId",
1444
+ type: "uint256",
1445
+ internalType: "uint256"
1446
+ }
1447
+ ]
1448
+ }
1449
+ ],
1450
+ outputs: [],
1451
+ stateMutability: "nonpayable"
1452
+ },
1453
+ {
1454
+ type: "event",
1455
+ name: "CancellationFeeRedeemed",
1456
+ inputs: [
1457
+ {
1458
+ name: "proposalId",
1459
+ type: "uint256",
1460
+ indexed: true,
1461
+ internalType: "uint256"
1462
+ },
1463
+ {
1464
+ name: "to",
1465
+ type: "address",
1466
+ indexed: true,
1467
+ internalType: "address"
1468
+ },
1469
+ {
1470
+ name: "cancellationFee",
1471
+ type: "uint256",
1472
+ indexed: false,
1473
+ internalType: "uint256"
1474
+ },
1475
+ {
1476
+ name: "success",
1477
+ type: "bool",
1478
+ indexed: true,
1479
+ internalType: "bool"
1480
+ }
1481
+ ],
1482
+ anonymous: false
1483
+ },
1484
+ {
1485
+ type: "event",
1486
+ name: "CancellationFeeUpdated",
1487
+ inputs: [
1488
+ {
1489
+ name: "cancellationFee",
1490
+ type: "uint256",
1491
+ indexed: false,
1492
+ internalType: "uint256"
1493
+ }
1494
+ ],
1495
+ anonymous: false
1496
+ },
1497
+ {
1498
+ type: "event",
1499
+ name: "PayloadSent",
1500
+ inputs: [
1501
+ {
1502
+ name: "proposalId",
1503
+ type: "uint256",
1504
+ indexed: true,
1505
+ internalType: "uint256"
1506
+ },
1507
+ {
1508
+ name: "payloadId",
1509
+ type: "uint40",
1510
+ indexed: false,
1511
+ internalType: "uint40"
1512
+ },
1513
+ {
1514
+ name: "payloadsController",
1515
+ type: "address",
1516
+ indexed: true,
1517
+ internalType: "address"
1518
+ },
1519
+ {
1520
+ name: "chainId",
1521
+ type: "uint256",
1522
+ indexed: true,
1523
+ internalType: "uint256"
1524
+ },
1525
+ {
1526
+ name: "payloadNumberOnProposal",
1527
+ type: "uint256",
1528
+ indexed: false,
1529
+ internalType: "uint256"
1530
+ },
1531
+ {
1532
+ name: "numberOfPayloadsOnProposal",
1533
+ type: "uint256",
1534
+ indexed: false,
1535
+ internalType: "uint256"
1536
+ }
1537
+ ],
1538
+ anonymous: false
1539
+ },
1540
+ {
1541
+ type: "event",
1542
+ name: "PowerStrategyUpdated",
1543
+ inputs: [
1544
+ {
1545
+ name: "newPowerStrategy",
1546
+ type: "address",
1547
+ indexed: true,
1548
+ internalType: "address"
1549
+ }
1550
+ ],
1551
+ anonymous: false
1552
+ },
1553
+ {
1554
+ type: "event",
1555
+ name: "ProposalCanceled",
1556
+ inputs: [
1557
+ {
1558
+ name: "proposalId",
1559
+ type: "uint256",
1560
+ indexed: true,
1561
+ internalType: "uint256"
1562
+ }
1563
+ ],
1564
+ anonymous: false
1565
+ },
1566
+ {
1567
+ type: "event",
1568
+ name: "ProposalCreated",
1569
+ inputs: [
1570
+ {
1571
+ name: "proposalId",
1572
+ type: "uint256",
1573
+ indexed: true,
1574
+ internalType: "uint256"
1575
+ },
1576
+ {
1577
+ name: "creator",
1578
+ type: "address",
1579
+ indexed: true,
1580
+ internalType: "address"
1581
+ },
1582
+ {
1583
+ name: "accessLevel",
1584
+ type: "uint8",
1585
+ indexed: true,
1586
+ internalType: "enum PayloadsControllerUtils.AccessControl"
1587
+ },
1588
+ {
1589
+ name: "ipfsHash",
1590
+ type: "bytes32",
1591
+ indexed: false,
1592
+ internalType: "bytes32"
1593
+ }
1594
+ ],
1595
+ anonymous: false
1596
+ },
1597
+ {
1598
+ type: "event",
1599
+ name: "ProposalExecuted",
1600
+ inputs: [
1601
+ {
1602
+ name: "proposalId",
1603
+ type: "uint256",
1604
+ indexed: true,
1605
+ internalType: "uint256"
1606
+ }
1607
+ ],
1608
+ anonymous: false
1609
+ },
1610
+ {
1611
+ type: "event",
1612
+ name: "ProposalFailed",
1613
+ inputs: [
1614
+ {
1615
+ name: "proposalId",
1616
+ type: "uint256",
1617
+ indexed: true,
1618
+ internalType: "uint256"
1619
+ },
1620
+ {
1621
+ name: "votesFor",
1622
+ type: "uint128",
1623
+ indexed: false,
1624
+ internalType: "uint128"
1625
+ },
1626
+ {
1627
+ name: "votesAgainst",
1628
+ type: "uint128",
1629
+ indexed: false,
1630
+ internalType: "uint128"
1631
+ }
1632
+ ],
1633
+ anonymous: false
1634
+ },
1635
+ {
1636
+ type: "event",
1637
+ name: "ProposalQueued",
1638
+ inputs: [
1639
+ {
1640
+ name: "proposalId",
1641
+ type: "uint256",
1642
+ indexed: true,
1643
+ internalType: "uint256"
1644
+ },
1645
+ {
1646
+ name: "votesFor",
1647
+ type: "uint128",
1648
+ indexed: false,
1649
+ internalType: "uint128"
1650
+ },
1651
+ {
1652
+ name: "votesAgainst",
1653
+ type: "uint128",
1654
+ indexed: false,
1655
+ internalType: "uint128"
1656
+ }
1657
+ ],
1658
+ anonymous: false
1659
+ },
1660
+ {
1661
+ type: "event",
1662
+ name: "RepresentativeUpdated",
1663
+ inputs: [
1664
+ {
1665
+ name: "voter",
1666
+ type: "address",
1667
+ indexed: true,
1668
+ internalType: "address"
1669
+ },
1670
+ {
1671
+ name: "representative",
1672
+ type: "address",
1673
+ indexed: true,
1674
+ internalType: "address"
1675
+ },
1676
+ {
1677
+ name: "chainId",
1678
+ type: "uint256",
1679
+ indexed: true,
1680
+ internalType: "uint256"
1681
+ }
1682
+ ],
1683
+ anonymous: false
1684
+ },
1685
+ {
1686
+ type: "event",
1687
+ name: "VoteForwarded",
1688
+ inputs: [
1689
+ {
1690
+ name: "proposalId",
1691
+ type: "uint256",
1692
+ indexed: true,
1693
+ internalType: "uint256"
1694
+ },
1695
+ {
1696
+ name: "voter",
1697
+ type: "address",
1698
+ indexed: true,
1699
+ internalType: "address"
1700
+ },
1701
+ {
1702
+ name: "support",
1703
+ type: "bool",
1704
+ indexed: true,
1705
+ internalType: "bool"
1706
+ },
1707
+ {
1708
+ name: "votingAssetsWithSlot",
1709
+ type: "tuple[]",
1710
+ indexed: false,
1711
+ internalType: "struct IVotingMachineWithProofs.VotingAssetWithSlot[]",
1712
+ components: [
1713
+ {
1714
+ name: "underlyingAsset",
1715
+ type: "address",
1716
+ internalType: "address"
1717
+ },
1718
+ {
1719
+ name: "slot",
1720
+ type: "uint128",
1721
+ internalType: "uint128"
1722
+ }
1723
+ ]
1724
+ }
1725
+ ],
1726
+ anonymous: false
1727
+ },
1728
+ {
1729
+ type: "event",
1730
+ name: "VotingActivated",
1731
+ inputs: [
1732
+ {
1733
+ name: "proposalId",
1734
+ type: "uint256",
1735
+ indexed: true,
1736
+ internalType: "uint256"
1737
+ },
1738
+ {
1739
+ name: "snapshotBlockHash",
1740
+ type: "bytes32",
1741
+ indexed: true,
1742
+ internalType: "bytes32"
1743
+ },
1744
+ {
1745
+ name: "votingDuration",
1746
+ type: "uint24",
1747
+ indexed: false,
1748
+ internalType: "uint24"
1749
+ }
1750
+ ],
1751
+ anonymous: false
1752
+ },
1753
+ {
1754
+ type: "event",
1755
+ name: "VotingConfigUpdated",
1756
+ inputs: [
1757
+ {
1758
+ name: "accessLevel",
1759
+ type: "uint8",
1760
+ indexed: true,
1761
+ internalType: "enum PayloadsControllerUtils.AccessControl"
1762
+ },
1763
+ {
1764
+ name: "votingDuration",
1765
+ type: "uint24",
1766
+ indexed: false,
1767
+ internalType: "uint24"
1768
+ },
1769
+ {
1770
+ name: "coolDownBeforeVotingStart",
1771
+ type: "uint24",
1772
+ indexed: false,
1773
+ internalType: "uint24"
1774
+ },
1775
+ {
1776
+ name: "yesThreshold",
1777
+ type: "uint256",
1778
+ indexed: false,
1779
+ internalType: "uint256"
1780
+ },
1781
+ {
1782
+ name: "yesNoDifferential",
1783
+ type: "uint256",
1784
+ indexed: false,
1785
+ internalType: "uint256"
1786
+ },
1787
+ {
1788
+ name: "minPropositionPower",
1789
+ type: "uint256",
1790
+ indexed: false,
1791
+ internalType: "uint256"
1792
+ }
1793
+ ],
1794
+ anonymous: false
1795
+ },
1796
+ {
1797
+ type: "event",
1798
+ name: "VotingPortalUpdated",
1799
+ inputs: [
1800
+ {
1801
+ name: "votingPortal",
1802
+ type: "address",
1803
+ indexed: true,
1804
+ internalType: "address"
1805
+ },
1806
+ {
1807
+ name: "approved",
1808
+ type: "bool",
1809
+ indexed: true,
1810
+ internalType: "bool"
1811
+ }
1812
+ ],
1813
+ anonymous: false
1814
+ }
1815
+ ];
1816
+
1817
+ // src/aave/governance/payloadsController.ts
1818
+ import {
1819
+ encodePacked,
1820
+ getContract
1821
+ } from "viem";
1822
+
1823
+ // src/math/slot.ts
1824
+ import {
1825
+ concat,
1826
+ encodeAbiParameters,
1827
+ fromHex,
1828
+ getAddress,
1829
+ keccak256,
1830
+ pad,
1831
+ parseAbiParameters,
1832
+ slice,
1833
+ toBytes,
1834
+ toHex,
1835
+ trim
1836
+ } from "viem";
1837
+ function getSolidityStorageSlotUint(mappingSlot, key) {
1838
+ return keccak256(
1839
+ encodeAbiParameters(parseAbiParameters("uint256, uint256"), [
1840
+ key,
1841
+ mappingSlot
1842
+ ])
1843
+ );
1844
+ }
1845
+
1846
+ // src/aave/governance/payloadsController.ts
1847
+ import { getBlock } from "viem/actions";
1848
+ var PayloadState = /* @__PURE__ */ ((PayloadState2) => {
1849
+ PayloadState2[PayloadState2["None"] = 0] = "None";
1850
+ PayloadState2[PayloadState2["Created"] = 1] = "Created";
1851
+ PayloadState2[PayloadState2["Queued"] = 2] = "Queued";
1852
+ PayloadState2[PayloadState2["Executed"] = 3] = "Executed";
1853
+ PayloadState2[PayloadState2["Cancelled"] = 4] = "Cancelled";
1854
+ PayloadState2[PayloadState2["Expired"] = 5] = "Expired";
1855
+ return PayloadState2;
1856
+ })(PayloadState || {});
1857
+ var HUMAN_READABLE_PAYLOAD_STATE = {
1858
+ [0 /* None */]: "None",
1859
+ [1 /* Created */]: "Created",
1860
+ [2 /* Queued */]: "Queued",
1861
+ [3 /* Executed */]: "Executed",
1862
+ [4 /* Cancelled */]: "Cancelled",
1863
+ [5 /* Expired */]: "Expired"
1864
+ };
1865
+ function getPayloadsController(client, address) {
1866
+ return getContract({
1867
+ abi: IPayloadsControllerCore_ABI,
1868
+ client,
1869
+ address
1870
+ });
1871
+ }
1872
+ async function makePayloadExecutableOnTestClient(client, payloadsController, payloadId) {
1873
+ const controllerContract = getPayloadsController(client, payloadsController);
1874
+ const payload = await controllerContract.read.getPayloadById([payloadId]);
1875
+ const currentBlock = await getBlock(client);
1876
+ return client.setStorageAt({
1877
+ address: payloadsController,
1878
+ // 3 is the slot of the payloads mapping
1879
+ index: getSolidityStorageSlotUint(3n, BigInt(payloadId)),
1880
+ value: encodePacked(
1881
+ ["uint40", "uint40", "uint8", "uint8", "address"],
1882
+ [
1883
+ // we subtract 240n(4min), as tenderly might have been fallen behind
1884
+ // therefore using block_number -1 (latest on tenderly) and a 4min margin should give a save margin
1885
+ Number(currentBlock.timestamp - BigInt(payload.delay) - 1n - 240n),
1886
+ // altering queued time so can be executed in current block
1887
+ payload.createdAt,
1888
+ 2 /* Queued */,
1889
+ payload.maximumAccessLevelRequired,
1890
+ payload.creator
1891
+ ]
1892
+ )
1893
+ });
1894
+ }
1895
+ async function getNonFinalizedPayloads(client, payloadsController) {
1896
+ const controllerContract = getPayloadsController(client, payloadsController);
1897
+ const payloadsCount = await controllerContract.read.getPayloadsCount();
1898
+ const nonFinalPayloads = [];
1899
+ for (const payloadId of [...Array(Number(payloadsCount)).keys()].reverse()) {
1900
+ const maxRange = (35 + 10 + 7) * 24 * 60 * 60;
1901
+ const payload = await controllerContract.read.getPayloadById([payloadId]);
1902
+ if ([2 /* Queued */, 1 /* Created */].includes(payload.state))
1903
+ nonFinalPayloads.push(payloadId);
1904
+ if (payload.createdAt < Date.now() / 1e3 - maxRange) break;
1905
+ }
1906
+ return nonFinalPayloads;
1907
+ }
1908
+
1909
+ // src/aave/governance/governance.ts
1910
+ import {
1911
+ fromHex as fromHex2,
1912
+ getContract as getContract2,
1913
+ toHex as toHex2
1914
+ } from "viem";
1915
+ import { getBlock as getBlock2, getStorageAt } from "viem/actions";
1916
+ var HUMAN_READABLE_PROPOSAL_STATE = {
1917
+ [ProposalState.Null]: "Null",
1918
+ [ProposalState.Created]: "Created",
1919
+ [ProposalState.Active]: "Active",
1920
+ [ProposalState.Queued]: "Queued",
1921
+ [ProposalState.Executed]: "Executed",
1922
+ [ProposalState.Failed]: "Failed",
1923
+ [ProposalState.Cancelled]: "Cancelled",
1924
+ [ProposalState.Expired]: "Expired"
1925
+ };
1926
+ function getGovernance(client, address) {
1927
+ return getContract2({
1928
+ abi: IGovernanceCore_ABI,
1929
+ client,
1930
+ address
1931
+ });
1932
+ }
1933
+ async function makeProposalExecutableOnTestClient(client, governance, proposalId) {
1934
+ const currentBlock = await getBlock2(client);
1935
+ const proposalSlot = getSolidityStorageSlotUint(7n, proposalId);
1936
+ const data = await getStorageAt(client, {
1937
+ address: governance,
1938
+ slot: proposalSlot
1939
+ });
1940
+ let manipulatedStorage = fromHex2(data, { to: "bigint" });
1941
+ manipulatedStorage = setBits(
1942
+ manipulatedStorage,
1943
+ 0n,
1944
+ 8n,
1945
+ ProposalState.Queued
1946
+ );
1947
+ manipulatedStorage = setBits(
1948
+ manipulatedStorage,
1949
+ 16n,
1950
+ 56n,
1951
+ currentBlock.timestamp - 2592000n
1952
+ // (await governanceContract.read.PROPOSAL_EXPIRATION_TIME())
1953
+ );
1954
+ return client.setStorageAt({
1955
+ address: governance,
1956
+ // 3 is the slot of the payloads mapping
1957
+ index: proposalSlot,
1958
+ value: toHex2(manipulatedStorage, { size: 32 })
1959
+ });
1960
+ }
1961
+
37
1962
  // src/ecosystem/generated/etherscanExplorers.ts
38
1963
  var etherscanExplorers = {
39
1964
  1: {
@@ -608,6 +2533,10 @@ var routescanExplorers = {
608
2533
  api: "https://api.routescan.io/v2/network/testnet/evm/11124/etherscan",
609
2534
  explorer: "11124.routescan.io"
610
2535
  },
2536
+ 12150: {
2537
+ api: "https://api.routescan.io/v2/network/mainnet/evm/12150/etherscan",
2538
+ explorer: "12150.routescan.io"
2539
+ },
611
2540
  17e3: {
612
2541
  api: "https://api.routescan.io/v2/network/testnet/evm/17000/etherscan",
613
2542
  explorer: "17000.routescan.io"
@@ -720,6 +2649,10 @@ var routescanExplorers = {
720
2649
  api: "https://api.routescan.io/v2/network/testnet/evm/80008/etherscan",
721
2650
  explorer: "80008.routescan.io"
722
2651
  },
2652
+ 80069: {
2653
+ api: "https://api.routescan.io/v2/network/testnet/evm/80069/etherscan",
2654
+ explorer: "80069.routescan.io"
2655
+ },
723
2656
  80084: {
724
2657
  api: "https://api.routescan.io/v2/network/testnet/evm/80084/etherscan",
725
2658
  explorer: "80084.routescan.io"
@@ -926,6 +2859,103 @@ function parseApiSourceCode(sourceCode) {
926
2859
  return JSON.parse(sourceCode);
927
2860
  }
928
2861
 
2862
+ // src/ecosystem/tenderly.ts
2863
+ import {
2864
+ createTestClient,
2865
+ createWalletClient,
2866
+ http
2867
+ } from "viem";
2868
+ var TENDERLY_BASE_URL = "https://api.tenderly.co/api/v1";
2869
+ async function tenderly_createVnet({
2870
+ slug,
2871
+ displayName,
2872
+ baseChainId,
2873
+ forkChainId,
2874
+ blockNumber
2875
+ }, { accessToken, accountSlug, projectSlug }) {
2876
+ if (!accessToken) throw new Error("Tenderly access token not provided");
2877
+ if (!accountSlug) throw new Error("Tenderly account slug not provided");
2878
+ if (!projectSlug) throw new Error("Tenderly project slug not provided");
2879
+ const body = {
2880
+ slug,
2881
+ display_name: displayName,
2882
+ fork_config: {
2883
+ network_id: baseChainId,
2884
+ ...blockNumber ? { block_number: blockNumber } : {}
2885
+ },
2886
+ virtual_network_config: {
2887
+ chain_config: {
2888
+ chain_id: forkChainId
2889
+ }
2890
+ },
2891
+ sync_state_config: {
2892
+ enabled: false
2893
+ },
2894
+ explorer_page_config: {
2895
+ enabled: false,
2896
+ verification_visibility: "bytecode"
2897
+ }
2898
+ };
2899
+ const response = await fetch(
2900
+ `${TENDERLY_BASE_URL}/account/${accountSlug}/project/${projectSlug}/vnets`,
2901
+ {
2902
+ method: "POST",
2903
+ body: JSON.stringify(body),
2904
+ headers: new Headers({
2905
+ "Content-Type": "application/json",
2906
+ "X-Access-Key": accessToken
2907
+ })
2908
+ }
2909
+ );
2910
+ const json = await response.json();
2911
+ if (json.error) {
2912
+ console.info(json.error);
2913
+ throw new Error("Tenderly vnet could not be created");
2914
+ }
2915
+ return {
2916
+ vnet: json,
2917
+ testClient: createTestClient({
2918
+ mode: "tenderly",
2919
+ transport: http(json.rpcs[0].url)
2920
+ }),
2921
+ walletClient: createWalletClient({
2922
+ chain: { id: forkChainId },
2923
+ account: "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9",
2924
+ transport: http(json.rpcs[0].url)
2925
+ }),
2926
+ simulate: (body2) => {
2927
+ return fetch(
2928
+ // Note: this is subject to change and currently uses the internal api of tenderly
2929
+ `${TENDERLY_BASE_URL}/account/${accountSlug}/project/${projectSlug}/testnet/${json.id}/simulate`,
2930
+ {
2931
+ method: "POST",
2932
+ body: JSON.stringify(body2),
2933
+ headers: new Headers({
2934
+ "Content-Type": "application/json",
2935
+ "X-Access-Key": accessToken
2936
+ })
2937
+ }
2938
+ );
2939
+ },
2940
+ delete: () => {
2941
+ return fetch(
2942
+ `${TENDERLY_BASE_URL}/account/${accountSlug}/project/${projectSlug}/vnets/${json.id}`,
2943
+ {
2944
+ method: "DELETE",
2945
+ headers: new Headers({
2946
+ "Content-Type": "application/json",
2947
+ "X-Access-Key": accessToken
2948
+ })
2949
+ }
2950
+ );
2951
+ }
2952
+ };
2953
+ }
2954
+
2955
+ // src/ecosystem/constants.ts
2956
+ var erc1967_ImplementationSlot = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
2957
+ var erc1967_AdminSlot = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
2958
+
929
2959
  // src/operations/diffCode.ts
930
2960
  import { createPatch, createTwoFilesPatch } from "diff";
931
2961
  import { format } from "prettier/standalone";
@@ -976,11 +3006,47 @@ async function diffCode(codeBefore, codeAfter) {
976
3006
  return changes;
977
3007
  }
978
3008
  export {
3009
+ HALF_RAY,
3010
+ HALF_WAD,
3011
+ HUMAN_READABLE_PAYLOAD_STATE,
3012
+ HUMAN_READABLE_PROPOSAL_STATE,
3013
+ LTV_PRECISION,
3014
+ PayloadState,
3015
+ RAY,
3016
+ SECONDS_PER_YEAR,
3017
+ WAD,
3018
+ WAD_RAY_RATIO,
979
3019
  bitmapToIndexes,
3020
+ calculateAvailableBorrowsMarketReferenceCurrency,
3021
+ calculateCompoundedInterest,
3022
+ calculateHealthFactorFromBalances,
3023
+ calculateLinearInterest,
3024
+ decodeReserveConfiguration,
3025
+ decodeReserveConfigurationV2,
980
3026
  decodeUserConfiguration,
981
3027
  diffCode,
3028
+ erc1967_AdminSlot,
3029
+ erc1967_ImplementationSlot,
982
3030
  getBits,
3031
+ getCurrentDebtBalance,
3032
+ getCurrentLiquidityBalance,
983
3033
  getExplorer,
3034
+ getGovernance,
3035
+ getMarketReferenceCurrencyAndUsdBalance,
3036
+ getNonFinalizedPayloads,
3037
+ getNormalizedDebt,
3038
+ getNormalizedIncome,
3039
+ getPayloadsController,
984
3040
  getSourceCode,
985
- parseApiSourceCode
3041
+ makePayloadExecutableOnTestClient,
3042
+ makeProposalExecutableOnTestClient,
3043
+ parseApiSourceCode,
3044
+ rayDiv,
3045
+ rayMul,
3046
+ rayToWad,
3047
+ setBits,
3048
+ tenderly_createVnet,
3049
+ wadDiv,
3050
+ wadToRay
986
3051
  };
3052
+ //# sourceMappingURL=index.mjs.map