@bgd-labs/toolbox 0.0.1 → 0.0.3

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