@gearbox-protocol/sdk 3.0.0-vfour.8 → 3.0.0-vfour.80

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.
@@ -0,0 +1,1611 @@
1
+ 'use strict';
2
+
3
+ var sdk = require('../sdk');
4
+ var viem = require('viem');
5
+
6
+ // src/dev/calcLiquidatableLTs.ts
7
+ async function calcLiquidatableLTs(sdk$1, ca, factor = 9990n, logger) {
8
+ const cm = sdk$1.marketRegister.findCreditManager(ca.creditManager);
9
+ const market = sdk$1.marketRegister.findByCreditManager(ca.creditManager);
10
+ const weightedBalances = ca.tokens.map((t) => {
11
+ const { token, balance } = t;
12
+ const balanceU = market.priceOracle.convertToUnderlying(token, balance);
13
+ const lt = BigInt(cm.collateralTokens[token]);
14
+ return {
15
+ token,
16
+ weightedBalance: balanceU * lt / sdk.PERCENTAGE_FACTOR,
17
+ lt
18
+ };
19
+ }).sort((a, b) => {
20
+ if (a.token === ca.underlying) return 1;
21
+ if (b.token === ca.underlying) return -1;
22
+ return b.weightedBalance > a.weightedBalance ? 1 : -1;
23
+ });
24
+ let divisor = 0n;
25
+ let dividend = factor * (ca.debt + ca.accruedInterest + ca.accruedFees) / sdk.PERCENTAGE_FACTOR;
26
+ for (const { token, weightedBalance } of weightedBalances) {
27
+ if (token === ca.underlying) {
28
+ dividend -= weightedBalance;
29
+ } else {
30
+ divisor += weightedBalance;
31
+ }
32
+ }
33
+ if (divisor === 0n) {
34
+ throw new Error("warning: assets have zero weighted value in underlying");
35
+ }
36
+ if (dividend <= 0n) {
37
+ throw new Error(`warning: account balance in underlying covers debt`);
38
+ }
39
+ const k = sdk.WAD * dividend / divisor;
40
+ const result = {};
41
+ for (const { token, lt: oldLT } of weightedBalances) {
42
+ if (token !== ca.underlying) {
43
+ const newLT = oldLT * k / sdk.WAD;
44
+ logger?.debug(
45
+ `proposed ${sdk$1.tokensMeta.symbol(token)} LT change: ${oldLT} => ${newLT} `
46
+ );
47
+ result[token] = Number(newLT);
48
+ }
49
+ }
50
+ return result;
51
+ }
52
+ function createAnvilClient({
53
+ chain,
54
+ transport
55
+ }) {
56
+ return viem.createTestClient(
57
+ {
58
+ chain,
59
+ mode: "anvil",
60
+ transport,
61
+ cacheTime: 0
62
+ }
63
+ ).extend(viem.publicActions).extend(viem.walletActions).extend((client) => ({
64
+ anvilNodeInfo: () => anvilNodeInfo(client),
65
+ isAnvil: () => isAnvil(client),
66
+ evmMineDetailed: (timestamp) => evmMineDetailed(client, timestamp)
67
+ }));
68
+ }
69
+ async function isAnvil(client) {
70
+ try {
71
+ const resp = await client.request({
72
+ method: "anvil_nodeInfo",
73
+ params: []
74
+ });
75
+ return !!resp.currentBlockNumber;
76
+ } catch {
77
+ return false;
78
+ }
79
+ }
80
+ async function anvilNodeInfo(client) {
81
+ return client.request({
82
+ method: "anvil_nodeInfo",
83
+ params: []
84
+ });
85
+ }
86
+ async function evmMineDetailed(client, timestamp) {
87
+ try {
88
+ const [block] = await client.request({
89
+ method: "evm_mine_detailed",
90
+ params: [viem.toHex(timestamp)]
91
+ });
92
+ return block;
93
+ } catch {
94
+ return void 0;
95
+ }
96
+ }
97
+
98
+ // src/dev/abi/v3.ts
99
+ var iaclAbi = [
100
+ {
101
+ type: "function",
102
+ inputs: [{ name: "account", internalType: "address", type: "address" }],
103
+ name: "isConfigurator",
104
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
105
+ stateMutability: "view"
106
+ },
107
+ {
108
+ type: "function",
109
+ inputs: [{ name: "addr", internalType: "address", type: "address" }],
110
+ name: "isPausableAdmin",
111
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
112
+ stateMutability: "view"
113
+ },
114
+ {
115
+ type: "function",
116
+ inputs: [{ name: "addr", internalType: "address", type: "address" }],
117
+ name: "isUnpausableAdmin",
118
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
119
+ stateMutability: "view"
120
+ },
121
+ {
122
+ type: "function",
123
+ inputs: [],
124
+ name: "owner",
125
+ outputs: [{ name: "", internalType: "address", type: "address" }],
126
+ stateMutability: "view"
127
+ },
128
+ {
129
+ type: "function",
130
+ inputs: [],
131
+ name: "version",
132
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
133
+ stateMutability: "view"
134
+ },
135
+ {
136
+ type: "event",
137
+ anonymous: false,
138
+ inputs: [
139
+ {
140
+ name: "newAdmin",
141
+ internalType: "address",
142
+ type: "address",
143
+ indexed: true
144
+ }
145
+ ],
146
+ name: "PausableAdminAdded"
147
+ },
148
+ {
149
+ type: "event",
150
+ anonymous: false,
151
+ inputs: [
152
+ {
153
+ name: "admin",
154
+ internalType: "address",
155
+ type: "address",
156
+ indexed: true
157
+ }
158
+ ],
159
+ name: "PausableAdminRemoved"
160
+ },
161
+ {
162
+ type: "event",
163
+ anonymous: false,
164
+ inputs: [
165
+ {
166
+ name: "newAdmin",
167
+ internalType: "address",
168
+ type: "address",
169
+ indexed: true
170
+ }
171
+ ],
172
+ name: "UnpausableAdminAdded"
173
+ },
174
+ {
175
+ type: "event",
176
+ anonymous: false,
177
+ inputs: [
178
+ {
179
+ name: "admin",
180
+ internalType: "address",
181
+ type: "address",
182
+ indexed: true
183
+ }
184
+ ],
185
+ name: "UnpausableAdminRemoved"
186
+ },
187
+ {
188
+ type: "error",
189
+ inputs: [{ name: "addr", internalType: "address", type: "address" }],
190
+ name: "AddressNotPausableAdminException"
191
+ },
192
+ {
193
+ type: "error",
194
+ inputs: [{ name: "addr", internalType: "address", type: "address" }],
195
+ name: "AddressNotUnpausableAdminException"
196
+ }
197
+ ];
198
+ var iaclTraitAbi = [
199
+ {
200
+ type: "function",
201
+ name: "acl",
202
+ inputs: [],
203
+ outputs: [
204
+ {
205
+ name: "",
206
+ type: "address",
207
+ internalType: "address"
208
+ }
209
+ ],
210
+ stateMutability: "view"
211
+ }
212
+ ];
213
+ var iCreditConfiguratorV3Abi = [
214
+ {
215
+ type: "function",
216
+ inputs: [
217
+ { name: "token", internalType: "address", type: "address" },
218
+ { name: "liquidationThreshold", internalType: "uint16", type: "uint16" }
219
+ ],
220
+ name: "addCollateralToken",
221
+ outputs: [],
222
+ stateMutability: "nonpayable"
223
+ },
224
+ {
225
+ type: "function",
226
+ inputs: [{ name: "liquidator", internalType: "address", type: "address" }],
227
+ name: "addEmergencyLiquidator",
228
+ outputs: [],
229
+ stateMutability: "nonpayable"
230
+ },
231
+ {
232
+ type: "function",
233
+ inputs: [],
234
+ name: "addressProvider",
235
+ outputs: [{ name: "", internalType: "address", type: "address" }],
236
+ stateMutability: "view"
237
+ },
238
+ {
239
+ type: "function",
240
+ inputs: [{ name: "adapter", internalType: "address", type: "address" }],
241
+ name: "allowAdapter",
242
+ outputs: [],
243
+ stateMutability: "nonpayable"
244
+ },
245
+ {
246
+ type: "function",
247
+ inputs: [{ name: "token", internalType: "address", type: "address" }],
248
+ name: "allowToken",
249
+ outputs: [],
250
+ stateMutability: "nonpayable"
251
+ },
252
+ {
253
+ type: "function",
254
+ inputs: [],
255
+ name: "allowedAdapters",
256
+ outputs: [{ name: "", internalType: "address[]", type: "address[]" }],
257
+ stateMutability: "view"
258
+ },
259
+ {
260
+ type: "function",
261
+ inputs: [],
262
+ name: "creditFacade",
263
+ outputs: [{ name: "", internalType: "address", type: "address" }],
264
+ stateMutability: "view"
265
+ },
266
+ {
267
+ type: "function",
268
+ inputs: [],
269
+ name: "creditManager",
270
+ outputs: [{ name: "", internalType: "address", type: "address" }],
271
+ stateMutability: "view"
272
+ },
273
+ {
274
+ type: "function",
275
+ inputs: [],
276
+ name: "emergencyLiquidators",
277
+ outputs: [{ name: "", internalType: "address[]", type: "address[]" }],
278
+ stateMutability: "view"
279
+ },
280
+ {
281
+ type: "function",
282
+ inputs: [{ name: "adapter", internalType: "address", type: "address" }],
283
+ name: "forbidAdapter",
284
+ outputs: [],
285
+ stateMutability: "nonpayable"
286
+ },
287
+ {
288
+ type: "function",
289
+ inputs: [],
290
+ name: "forbidBorrowing",
291
+ outputs: [],
292
+ stateMutability: "nonpayable"
293
+ },
294
+ {
295
+ type: "function",
296
+ inputs: [{ name: "token", internalType: "address", type: "address" }],
297
+ name: "forbidToken",
298
+ outputs: [],
299
+ stateMutability: "nonpayable"
300
+ },
301
+ {
302
+ type: "function",
303
+ inputs: [{ name: "token", internalType: "address", type: "address" }],
304
+ name: "makeTokenQuoted",
305
+ outputs: [],
306
+ stateMutability: "nonpayable"
307
+ },
308
+ {
309
+ type: "function",
310
+ inputs: [
311
+ { name: "token", internalType: "address", type: "address" },
312
+ {
313
+ name: "liquidationThresholdFinal",
314
+ internalType: "uint16",
315
+ type: "uint16"
316
+ },
317
+ { name: "rampStart", internalType: "uint40", type: "uint40" },
318
+ { name: "rampDuration", internalType: "uint24", type: "uint24" }
319
+ ],
320
+ name: "rampLiquidationThreshold",
321
+ outputs: [],
322
+ stateMutability: "nonpayable"
323
+ },
324
+ {
325
+ type: "function",
326
+ inputs: [{ name: "liquidator", internalType: "address", type: "address" }],
327
+ name: "removeEmergencyLiquidator",
328
+ outputs: [],
329
+ stateMutability: "nonpayable"
330
+ },
331
+ {
332
+ type: "function",
333
+ inputs: [],
334
+ name: "resetCumulativeLoss",
335
+ outputs: [],
336
+ stateMutability: "nonpayable"
337
+ },
338
+ {
339
+ type: "function",
340
+ inputs: [{ name: "newVersion", internalType: "uint256", type: "uint256" }],
341
+ name: "setBotList",
342
+ outputs: [],
343
+ stateMutability: "nonpayable"
344
+ },
345
+ {
346
+ type: "function",
347
+ inputs: [
348
+ { name: "newCreditFacade", internalType: "address", type: "address" },
349
+ { name: "migrateParams", internalType: "bool", type: "bool" }
350
+ ],
351
+ name: "setCreditFacade",
352
+ outputs: [],
353
+ stateMutability: "nonpayable"
354
+ },
355
+ {
356
+ type: "function",
357
+ inputs: [
358
+ { name: "newExpirationDate", internalType: "uint40", type: "uint40" }
359
+ ],
360
+ name: "setExpirationDate",
361
+ outputs: [],
362
+ stateMutability: "nonpayable"
363
+ },
364
+ {
365
+ type: "function",
366
+ inputs: [
367
+ { name: "feeInterest", internalType: "uint16", type: "uint16" },
368
+ { name: "feeLiquidation", internalType: "uint16", type: "uint16" },
369
+ { name: "liquidationPremium", internalType: "uint16", type: "uint16" },
370
+ { name: "feeLiquidationExpired", internalType: "uint16", type: "uint16" },
371
+ {
372
+ name: "liquidationPremiumExpired",
373
+ internalType: "uint16",
374
+ type: "uint16"
375
+ }
376
+ ],
377
+ name: "setFees",
378
+ outputs: [],
379
+ stateMutability: "nonpayable"
380
+ },
381
+ {
382
+ type: "function",
383
+ inputs: [
384
+ { name: "token", internalType: "address", type: "address" },
385
+ { name: "liquidationThreshold", internalType: "uint16", type: "uint16" }
386
+ ],
387
+ name: "setLiquidationThreshold",
388
+ outputs: [],
389
+ stateMutability: "nonpayable"
390
+ },
391
+ {
392
+ type: "function",
393
+ inputs: [
394
+ {
395
+ name: "newMaxCumulativeLoss",
396
+ internalType: "uint128",
397
+ type: "uint128"
398
+ }
399
+ ],
400
+ name: "setMaxCumulativeLoss",
401
+ outputs: [],
402
+ stateMutability: "nonpayable"
403
+ },
404
+ {
405
+ type: "function",
406
+ inputs: [{ name: "newMaxDebt", internalType: "uint128", type: "uint128" }],
407
+ name: "setMaxDebtLimit",
408
+ outputs: [],
409
+ stateMutability: "nonpayable"
410
+ },
411
+ {
412
+ type: "function",
413
+ inputs: [
414
+ {
415
+ name: "newMaxDebtLimitPerBlockMultiplier",
416
+ internalType: "uint8",
417
+ type: "uint8"
418
+ }
419
+ ],
420
+ name: "setMaxDebtPerBlockMultiplier",
421
+ outputs: [],
422
+ stateMutability: "nonpayable"
423
+ },
424
+ {
425
+ type: "function",
426
+ inputs: [
427
+ { name: "newMaxEnabledTokens", internalType: "uint8", type: "uint8" }
428
+ ],
429
+ name: "setMaxEnabledTokens",
430
+ outputs: [],
431
+ stateMutability: "nonpayable"
432
+ },
433
+ {
434
+ type: "function",
435
+ inputs: [{ name: "newMinDebt", internalType: "uint128", type: "uint128" }],
436
+ name: "setMinDebtLimit",
437
+ outputs: [],
438
+ stateMutability: "nonpayable"
439
+ },
440
+ {
441
+ type: "function",
442
+ inputs: [{ name: "newVersion", internalType: "uint256", type: "uint256" }],
443
+ name: "setPriceOracle",
444
+ outputs: [],
445
+ stateMutability: "nonpayable"
446
+ },
447
+ {
448
+ type: "function",
449
+ inputs: [],
450
+ name: "underlying",
451
+ outputs: [{ name: "", internalType: "address", type: "address" }],
452
+ stateMutability: "view"
453
+ },
454
+ {
455
+ type: "function",
456
+ inputs: [
457
+ {
458
+ name: "newCreditConfigurator",
459
+ internalType: "address",
460
+ type: "address"
461
+ }
462
+ ],
463
+ name: "upgradeCreditConfigurator",
464
+ outputs: [],
465
+ stateMutability: "nonpayable"
466
+ },
467
+ {
468
+ type: "function",
469
+ inputs: [],
470
+ name: "version",
471
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
472
+ stateMutability: "view"
473
+ },
474
+ {
475
+ type: "event",
476
+ anonymous: false,
477
+ inputs: [
478
+ {
479
+ name: "token",
480
+ internalType: "address",
481
+ type: "address",
482
+ indexed: true
483
+ }
484
+ ],
485
+ name: "AddCollateralToken"
486
+ },
487
+ {
488
+ type: "event",
489
+ anonymous: false,
490
+ inputs: [
491
+ {
492
+ name: "liquidator",
493
+ internalType: "address",
494
+ type: "address",
495
+ indexed: true
496
+ }
497
+ ],
498
+ name: "AddEmergencyLiquidator"
499
+ },
500
+ {
501
+ type: "event",
502
+ anonymous: false,
503
+ inputs: [
504
+ {
505
+ name: "targetContract",
506
+ internalType: "address",
507
+ type: "address",
508
+ indexed: true
509
+ },
510
+ {
511
+ name: "adapter",
512
+ internalType: "address",
513
+ type: "address",
514
+ indexed: true
515
+ }
516
+ ],
517
+ name: "AllowAdapter"
518
+ },
519
+ {
520
+ type: "event",
521
+ anonymous: false,
522
+ inputs: [
523
+ {
524
+ name: "token",
525
+ internalType: "address",
526
+ type: "address",
527
+ indexed: true
528
+ }
529
+ ],
530
+ name: "AllowToken"
531
+ },
532
+ {
533
+ type: "event",
534
+ anonymous: false,
535
+ inputs: [
536
+ {
537
+ name: "creditConfigurator",
538
+ internalType: "address",
539
+ type: "address",
540
+ indexed: true
541
+ }
542
+ ],
543
+ name: "CreditConfiguratorUpgraded"
544
+ },
545
+ {
546
+ type: "event",
547
+ anonymous: false,
548
+ inputs: [
549
+ {
550
+ name: "targetContract",
551
+ internalType: "address",
552
+ type: "address",
553
+ indexed: true
554
+ },
555
+ {
556
+ name: "adapter",
557
+ internalType: "address",
558
+ type: "address",
559
+ indexed: true
560
+ }
561
+ ],
562
+ name: "ForbidAdapter"
563
+ },
564
+ {
565
+ type: "event",
566
+ anonymous: false,
567
+ inputs: [
568
+ {
569
+ name: "token",
570
+ internalType: "address",
571
+ type: "address",
572
+ indexed: true
573
+ }
574
+ ],
575
+ name: "ForbidToken"
576
+ },
577
+ {
578
+ type: "event",
579
+ anonymous: false,
580
+ inputs: [
581
+ {
582
+ name: "token",
583
+ internalType: "address",
584
+ type: "address",
585
+ indexed: true
586
+ }
587
+ ],
588
+ name: "QuoteToken"
589
+ },
590
+ {
591
+ type: "event",
592
+ anonymous: false,
593
+ inputs: [
594
+ {
595
+ name: "liquidator",
596
+ internalType: "address",
597
+ type: "address",
598
+ indexed: true
599
+ }
600
+ ],
601
+ name: "RemoveEmergencyLiquidator"
602
+ },
603
+ { type: "event", anonymous: false, inputs: [], name: "ResetCumulativeLoss" },
604
+ {
605
+ type: "event",
606
+ anonymous: false,
607
+ inputs: [
608
+ {
609
+ name: "token",
610
+ internalType: "address",
611
+ type: "address",
612
+ indexed: true
613
+ },
614
+ {
615
+ name: "liquidationThresholdInitial",
616
+ internalType: "uint16",
617
+ type: "uint16",
618
+ indexed: false
619
+ },
620
+ {
621
+ name: "liquidationThresholdFinal",
622
+ internalType: "uint16",
623
+ type: "uint16",
624
+ indexed: false
625
+ },
626
+ {
627
+ name: "timestampRampStart",
628
+ internalType: "uint40",
629
+ type: "uint40",
630
+ indexed: false
631
+ },
632
+ {
633
+ name: "timestampRampEnd",
634
+ internalType: "uint40",
635
+ type: "uint40",
636
+ indexed: false
637
+ }
638
+ ],
639
+ name: "ScheduleTokenLiquidationThresholdRamp"
640
+ },
641
+ {
642
+ type: "event",
643
+ anonymous: false,
644
+ inputs: [
645
+ {
646
+ name: "minDebt",
647
+ internalType: "uint256",
648
+ type: "uint256",
649
+ indexed: false
650
+ },
651
+ {
652
+ name: "maxDebt",
653
+ internalType: "uint256",
654
+ type: "uint256",
655
+ indexed: false
656
+ }
657
+ ],
658
+ name: "SetBorrowingLimits"
659
+ },
660
+ {
661
+ type: "event",
662
+ anonymous: false,
663
+ inputs: [
664
+ {
665
+ name: "botList",
666
+ internalType: "address",
667
+ type: "address",
668
+ indexed: true
669
+ }
670
+ ],
671
+ name: "SetBotList"
672
+ },
673
+ {
674
+ type: "event",
675
+ anonymous: false,
676
+ inputs: [
677
+ {
678
+ name: "creditFacade",
679
+ internalType: "address",
680
+ type: "address",
681
+ indexed: true
682
+ }
683
+ ],
684
+ name: "SetCreditFacade"
685
+ },
686
+ {
687
+ type: "event",
688
+ anonymous: false,
689
+ inputs: [
690
+ {
691
+ name: "expirationDate",
692
+ internalType: "uint40",
693
+ type: "uint40",
694
+ indexed: false
695
+ }
696
+ ],
697
+ name: "SetExpirationDate"
698
+ },
699
+ {
700
+ type: "event",
701
+ anonymous: false,
702
+ inputs: [
703
+ {
704
+ name: "maxCumulativeLoss",
705
+ internalType: "uint128",
706
+ type: "uint128",
707
+ indexed: false
708
+ }
709
+ ],
710
+ name: "SetMaxCumulativeLoss"
711
+ },
712
+ {
713
+ type: "event",
714
+ anonymous: false,
715
+ inputs: [
716
+ {
717
+ name: "maxDebtPerBlockMultiplier",
718
+ internalType: "uint8",
719
+ type: "uint8",
720
+ indexed: false
721
+ }
722
+ ],
723
+ name: "SetMaxDebtPerBlockMultiplier"
724
+ },
725
+ {
726
+ type: "event",
727
+ anonymous: false,
728
+ inputs: [
729
+ {
730
+ name: "maxEnabledTokens",
731
+ internalType: "uint8",
732
+ type: "uint8",
733
+ indexed: false
734
+ }
735
+ ],
736
+ name: "SetMaxEnabledTokens"
737
+ },
738
+ {
739
+ type: "event",
740
+ anonymous: false,
741
+ inputs: [
742
+ {
743
+ name: "priceOracle",
744
+ internalType: "address",
745
+ type: "address",
746
+ indexed: true
747
+ }
748
+ ],
749
+ name: "SetPriceOracle"
750
+ },
751
+ {
752
+ type: "event",
753
+ anonymous: false,
754
+ inputs: [
755
+ {
756
+ name: "token",
757
+ internalType: "address",
758
+ type: "address",
759
+ indexed: true
760
+ },
761
+ {
762
+ name: "liquidationThreshold",
763
+ internalType: "uint16",
764
+ type: "uint16",
765
+ indexed: false
766
+ }
767
+ ],
768
+ name: "SetTokenLiquidationThreshold"
769
+ },
770
+ {
771
+ type: "event",
772
+ anonymous: false,
773
+ inputs: [
774
+ {
775
+ name: "feeInterest",
776
+ internalType: "uint16",
777
+ type: "uint16",
778
+ indexed: false
779
+ },
780
+ {
781
+ name: "feeLiquidation",
782
+ internalType: "uint16",
783
+ type: "uint16",
784
+ indexed: false
785
+ },
786
+ {
787
+ name: "liquidationPremium",
788
+ internalType: "uint16",
789
+ type: "uint16",
790
+ indexed: false
791
+ },
792
+ {
793
+ name: "feeLiquidationExpired",
794
+ internalType: "uint16",
795
+ type: "uint16",
796
+ indexed: false
797
+ },
798
+ {
799
+ name: "liquidationPremiumExpired",
800
+ internalType: "uint16",
801
+ type: "uint16",
802
+ indexed: false
803
+ }
804
+ ],
805
+ name: "UpdateFees"
806
+ }
807
+ ];
808
+ var iCreditManagerV3Abi = [
809
+ {
810
+ type: "function",
811
+ inputs: [],
812
+ name: "accountFactory",
813
+ outputs: [{ name: "", internalType: "address", type: "address" }],
814
+ stateMutability: "view"
815
+ },
816
+ {
817
+ type: "function",
818
+ inputs: [{ name: "adapter", internalType: "address", type: "address" }],
819
+ name: "adapterToContract",
820
+ outputs: [
821
+ { name: "targetContract", internalType: "address", type: "address" }
822
+ ],
823
+ stateMutability: "view"
824
+ },
825
+ {
826
+ type: "function",
827
+ inputs: [
828
+ { name: "payer", internalType: "address", type: "address" },
829
+ { name: "creditAccount", internalType: "address", type: "address" },
830
+ { name: "token", internalType: "address", type: "address" },
831
+ { name: "amount", internalType: "uint256", type: "uint256" }
832
+ ],
833
+ name: "addCollateral",
834
+ outputs: [
835
+ { name: "tokensToEnable", internalType: "uint256", type: "uint256" }
836
+ ],
837
+ stateMutability: "nonpayable"
838
+ },
839
+ {
840
+ type: "function",
841
+ inputs: [{ name: "token", internalType: "address", type: "address" }],
842
+ name: "addToken",
843
+ outputs: [],
844
+ stateMutability: "nonpayable"
845
+ },
846
+ {
847
+ type: "function",
848
+ inputs: [],
849
+ name: "addressProvider",
850
+ outputs: [{ name: "", internalType: "address", type: "address" }],
851
+ stateMutability: "view"
852
+ },
853
+ {
854
+ type: "function",
855
+ inputs: [
856
+ { name: "token", internalType: "address", type: "address" },
857
+ { name: "amount", internalType: "uint256", type: "uint256" }
858
+ ],
859
+ name: "approveCreditAccount",
860
+ outputs: [],
861
+ stateMutability: "nonpayable"
862
+ },
863
+ {
864
+ type: "function",
865
+ inputs: [
866
+ { name: "creditAccount", internalType: "address", type: "address" },
867
+ { name: "token", internalType: "address", type: "address" },
868
+ { name: "spender", internalType: "address", type: "address" },
869
+ { name: "amount", internalType: "uint256", type: "uint256" }
870
+ ],
871
+ name: "approveToken",
872
+ outputs: [],
873
+ stateMutability: "nonpayable"
874
+ },
875
+ {
876
+ type: "function",
877
+ inputs: [
878
+ { name: "creditAccount", internalType: "address", type: "address" },
879
+ { name: "task", internalType: "enum CollateralCalcTask", type: "uint8" }
880
+ ],
881
+ name: "calcDebtAndCollateral",
882
+ outputs: [
883
+ {
884
+ name: "cdd",
885
+ internalType: "struct CollateralDebtData",
886
+ type: "tuple",
887
+ components: [
888
+ { name: "debt", internalType: "uint256", type: "uint256" },
889
+ {
890
+ name: "cumulativeIndexNow",
891
+ internalType: "uint256",
892
+ type: "uint256"
893
+ },
894
+ {
895
+ name: "cumulativeIndexLastUpdate",
896
+ internalType: "uint256",
897
+ type: "uint256"
898
+ },
899
+ {
900
+ name: "cumulativeQuotaInterest",
901
+ internalType: "uint128",
902
+ type: "uint128"
903
+ },
904
+ { name: "accruedInterest", internalType: "uint256", type: "uint256" },
905
+ { name: "accruedFees", internalType: "uint256", type: "uint256" },
906
+ { name: "totalDebtUSD", internalType: "uint256", type: "uint256" },
907
+ { name: "totalValue", internalType: "uint256", type: "uint256" },
908
+ { name: "totalValueUSD", internalType: "uint256", type: "uint256" },
909
+ { name: "twvUSD", internalType: "uint256", type: "uint256" },
910
+ {
911
+ name: "enabledTokensMask",
912
+ internalType: "uint256",
913
+ type: "uint256"
914
+ },
915
+ {
916
+ name: "quotedTokensMask",
917
+ internalType: "uint256",
918
+ type: "uint256"
919
+ },
920
+ {
921
+ name: "quotedTokens",
922
+ internalType: "address[]",
923
+ type: "address[]"
924
+ },
925
+ {
926
+ name: "_poolQuotaKeeper",
927
+ internalType: "address",
928
+ type: "address"
929
+ }
930
+ ]
931
+ }
932
+ ],
933
+ stateMutability: "view"
934
+ },
935
+ {
936
+ type: "function",
937
+ inputs: [
938
+ { name: "creditAccount", internalType: "address", type: "address" }
939
+ ],
940
+ name: "closeCreditAccount",
941
+ outputs: [],
942
+ stateMutability: "nonpayable"
943
+ },
944
+ {
945
+ type: "function",
946
+ inputs: [{ name: "tokenMask", internalType: "uint256", type: "uint256" }],
947
+ name: "collateralTokenByMask",
948
+ outputs: [
949
+ { name: "token", internalType: "address", type: "address" },
950
+ { name: "liquidationThreshold", internalType: "uint16", type: "uint16" }
951
+ ],
952
+ stateMutability: "view"
953
+ },
954
+ {
955
+ type: "function",
956
+ inputs: [],
957
+ name: "collateralTokensCount",
958
+ outputs: [{ name: "", internalType: "uint8", type: "uint8" }],
959
+ stateMutability: "view"
960
+ },
961
+ {
962
+ type: "function",
963
+ inputs: [
964
+ { name: "targetContract", internalType: "address", type: "address" }
965
+ ],
966
+ name: "contractToAdapter",
967
+ outputs: [{ name: "adapter", internalType: "address", type: "address" }],
968
+ stateMutability: "view"
969
+ },
970
+ {
971
+ type: "function",
972
+ inputs: [
973
+ { name: "creditAccount", internalType: "address", type: "address" }
974
+ ],
975
+ name: "creditAccountInfo",
976
+ outputs: [
977
+ { name: "debt", internalType: "uint256", type: "uint256" },
978
+ {
979
+ name: "cumulativeIndexLastUpdate",
980
+ internalType: "uint256",
981
+ type: "uint256"
982
+ },
983
+ {
984
+ name: "cumulativeQuotaInterest",
985
+ internalType: "uint128",
986
+ type: "uint128"
987
+ },
988
+ { name: "quotaFees", internalType: "uint128", type: "uint128" },
989
+ { name: "enabledTokensMask", internalType: "uint256", type: "uint256" },
990
+ { name: "flags", internalType: "uint16", type: "uint16" },
991
+ { name: "lastDebtUpdate", internalType: "uint64", type: "uint64" },
992
+ { name: "borrower", internalType: "address", type: "address" }
993
+ ],
994
+ stateMutability: "view"
995
+ },
996
+ {
997
+ type: "function",
998
+ inputs: [
999
+ { name: "offset", internalType: "uint256", type: "uint256" },
1000
+ { name: "limit", internalType: "uint256", type: "uint256" }
1001
+ ],
1002
+ name: "creditAccounts",
1003
+ outputs: [{ name: "", internalType: "address[]", type: "address[]" }],
1004
+ stateMutability: "view"
1005
+ },
1006
+ {
1007
+ type: "function",
1008
+ inputs: [],
1009
+ name: "creditAccounts",
1010
+ outputs: [{ name: "", internalType: "address[]", type: "address[]" }],
1011
+ stateMutability: "view"
1012
+ },
1013
+ {
1014
+ type: "function",
1015
+ inputs: [],
1016
+ name: "creditAccountsLen",
1017
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
1018
+ stateMutability: "view"
1019
+ },
1020
+ {
1021
+ type: "function",
1022
+ inputs: [],
1023
+ name: "creditConfigurator",
1024
+ outputs: [{ name: "", internalType: "address", type: "address" }],
1025
+ stateMutability: "view"
1026
+ },
1027
+ {
1028
+ type: "function",
1029
+ inputs: [],
1030
+ name: "creditFacade",
1031
+ outputs: [{ name: "", internalType: "address", type: "address" }],
1032
+ stateMutability: "view"
1033
+ },
1034
+ {
1035
+ type: "function",
1036
+ inputs: [
1037
+ { name: "creditAccount", internalType: "address", type: "address" }
1038
+ ],
1039
+ name: "enabledTokensMaskOf",
1040
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
1041
+ stateMutability: "view"
1042
+ },
1043
+ {
1044
+ type: "function",
1045
+ inputs: [{ name: "data", internalType: "bytes", type: "bytes" }],
1046
+ name: "execute",
1047
+ outputs: [{ name: "result", internalType: "bytes", type: "bytes" }],
1048
+ stateMutability: "nonpayable"
1049
+ },
1050
+ {
1051
+ type: "function",
1052
+ inputs: [
1053
+ { name: "creditAccount", internalType: "address", type: "address" },
1054
+ { name: "target", internalType: "address", type: "address" },
1055
+ { name: "callData", internalType: "bytes", type: "bytes" }
1056
+ ],
1057
+ name: "externalCall",
1058
+ outputs: [{ name: "result", internalType: "bytes", type: "bytes" }],
1059
+ stateMutability: "nonpayable"
1060
+ },
1061
+ {
1062
+ type: "function",
1063
+ inputs: [],
1064
+ name: "fees",
1065
+ outputs: [
1066
+ { name: "feeInterest", internalType: "uint16", type: "uint16" },
1067
+ { name: "feeLiquidation", internalType: "uint16", type: "uint16" },
1068
+ { name: "liquidationDiscount", internalType: "uint16", type: "uint16" },
1069
+ { name: "feeLiquidationExpired", internalType: "uint16", type: "uint16" },
1070
+ {
1071
+ name: "liquidationDiscountExpired",
1072
+ internalType: "uint16",
1073
+ type: "uint16"
1074
+ }
1075
+ ],
1076
+ stateMutability: "view"
1077
+ },
1078
+ {
1079
+ type: "function",
1080
+ inputs: [
1081
+ { name: "creditAccount", internalType: "address", type: "address" }
1082
+ ],
1083
+ name: "flagsOf",
1084
+ outputs: [{ name: "", internalType: "uint16", type: "uint16" }],
1085
+ stateMutability: "view"
1086
+ },
1087
+ {
1088
+ type: "function",
1089
+ inputs: [
1090
+ { name: "creditAccount", internalType: "address", type: "address" },
1091
+ { name: "enabledTokensMask", internalType: "uint256", type: "uint256" },
1092
+ { name: "collateralHints", internalType: "uint256[]", type: "uint256[]" },
1093
+ { name: "minHealthFactor", internalType: "uint16", type: "uint16" },
1094
+ { name: "useSafePrices", internalType: "bool", type: "bool" }
1095
+ ],
1096
+ name: "fullCollateralCheck",
1097
+ outputs: [
1098
+ {
1099
+ name: "enabledTokensMaskAfter",
1100
+ internalType: "uint256",
1101
+ type: "uint256"
1102
+ }
1103
+ ],
1104
+ stateMutability: "nonpayable"
1105
+ },
1106
+ {
1107
+ type: "function",
1108
+ inputs: [],
1109
+ name: "getActiveCreditAccountOrRevert",
1110
+ outputs: [
1111
+ { name: "creditAccount", internalType: "address", type: "address" }
1112
+ ],
1113
+ stateMutability: "view"
1114
+ },
1115
+ {
1116
+ type: "function",
1117
+ inputs: [
1118
+ { name: "creditAccount", internalType: "address", type: "address" }
1119
+ ],
1120
+ name: "getBorrowerOrRevert",
1121
+ outputs: [{ name: "borrower", internalType: "address", type: "address" }],
1122
+ stateMutability: "view"
1123
+ },
1124
+ {
1125
+ type: "function",
1126
+ inputs: [{ name: "tokenMask", internalType: "uint256", type: "uint256" }],
1127
+ name: "getTokenByMask",
1128
+ outputs: [{ name: "token", internalType: "address", type: "address" }],
1129
+ stateMutability: "view"
1130
+ },
1131
+ {
1132
+ type: "function",
1133
+ inputs: [{ name: "token", internalType: "address", type: "address" }],
1134
+ name: "getTokenMaskOrRevert",
1135
+ outputs: [{ name: "tokenMask", internalType: "uint256", type: "uint256" }],
1136
+ stateMutability: "view"
1137
+ },
1138
+ {
1139
+ type: "function",
1140
+ inputs: [
1141
+ { name: "creditAccount", internalType: "address", type: "address" },
1142
+ { name: "minHealthFactor", internalType: "uint16", type: "uint16" }
1143
+ ],
1144
+ name: "isLiquidatable",
1145
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
1146
+ stateMutability: "view"
1147
+ },
1148
+ {
1149
+ type: "function",
1150
+ inputs: [
1151
+ { name: "creditAccount", internalType: "address", type: "address" },
1152
+ {
1153
+ name: "collateralDebtData",
1154
+ internalType: "struct CollateralDebtData",
1155
+ type: "tuple",
1156
+ components: [
1157
+ { name: "debt", internalType: "uint256", type: "uint256" },
1158
+ {
1159
+ name: "cumulativeIndexNow",
1160
+ internalType: "uint256",
1161
+ type: "uint256"
1162
+ },
1163
+ {
1164
+ name: "cumulativeIndexLastUpdate",
1165
+ internalType: "uint256",
1166
+ type: "uint256"
1167
+ },
1168
+ {
1169
+ name: "cumulativeQuotaInterest",
1170
+ internalType: "uint128",
1171
+ type: "uint128"
1172
+ },
1173
+ { name: "accruedInterest", internalType: "uint256", type: "uint256" },
1174
+ { name: "accruedFees", internalType: "uint256", type: "uint256" },
1175
+ { name: "totalDebtUSD", internalType: "uint256", type: "uint256" },
1176
+ { name: "totalValue", internalType: "uint256", type: "uint256" },
1177
+ { name: "totalValueUSD", internalType: "uint256", type: "uint256" },
1178
+ { name: "twvUSD", internalType: "uint256", type: "uint256" },
1179
+ {
1180
+ name: "enabledTokensMask",
1181
+ internalType: "uint256",
1182
+ type: "uint256"
1183
+ },
1184
+ {
1185
+ name: "quotedTokensMask",
1186
+ internalType: "uint256",
1187
+ type: "uint256"
1188
+ },
1189
+ {
1190
+ name: "quotedTokens",
1191
+ internalType: "address[]",
1192
+ type: "address[]"
1193
+ },
1194
+ {
1195
+ name: "_poolQuotaKeeper",
1196
+ internalType: "address",
1197
+ type: "address"
1198
+ }
1199
+ ]
1200
+ },
1201
+ { name: "to", internalType: "address", type: "address" },
1202
+ { name: "isExpired", internalType: "bool", type: "bool" }
1203
+ ],
1204
+ name: "liquidateCreditAccount",
1205
+ outputs: [
1206
+ { name: "remainingFunds", internalType: "uint256", type: "uint256" },
1207
+ { name: "loss", internalType: "uint256", type: "uint256" }
1208
+ ],
1209
+ stateMutability: "nonpayable"
1210
+ },
1211
+ {
1212
+ type: "function",
1213
+ inputs: [{ name: "token", internalType: "address", type: "address" }],
1214
+ name: "liquidationThresholds",
1215
+ outputs: [{ name: "lt", internalType: "uint16", type: "uint16" }],
1216
+ stateMutability: "view"
1217
+ },
1218
+ {
1219
+ type: "function",
1220
+ inputs: [{ name: "token", internalType: "address", type: "address" }],
1221
+ name: "ltParams",
1222
+ outputs: [
1223
+ { name: "ltInitial", internalType: "uint16", type: "uint16" },
1224
+ { name: "ltFinal", internalType: "uint16", type: "uint16" },
1225
+ { name: "timestampRampStart", internalType: "uint40", type: "uint40" },
1226
+ { name: "rampDuration", internalType: "uint24", type: "uint24" }
1227
+ ],
1228
+ stateMutability: "view"
1229
+ },
1230
+ {
1231
+ type: "function",
1232
+ inputs: [
1233
+ { name: "creditAccount", internalType: "address", type: "address" },
1234
+ { name: "amount", internalType: "uint256", type: "uint256" },
1235
+ { name: "enabledTokensMask", internalType: "uint256", type: "uint256" },
1236
+ { name: "action", internalType: "enum ManageDebtAction", type: "uint8" }
1237
+ ],
1238
+ name: "manageDebt",
1239
+ outputs: [
1240
+ { name: "newDebt", internalType: "uint256", type: "uint256" },
1241
+ { name: "tokensToEnable", internalType: "uint256", type: "uint256" },
1242
+ { name: "tokensToDisable", internalType: "uint256", type: "uint256" }
1243
+ ],
1244
+ stateMutability: "nonpayable"
1245
+ },
1246
+ {
1247
+ type: "function",
1248
+ inputs: [],
1249
+ name: "maxEnabledTokens",
1250
+ outputs: [{ name: "", internalType: "uint8", type: "uint8" }],
1251
+ stateMutability: "view"
1252
+ },
1253
+ {
1254
+ type: "function",
1255
+ inputs: [],
1256
+ name: "name",
1257
+ outputs: [{ name: "", internalType: "string", type: "string" }],
1258
+ stateMutability: "view"
1259
+ },
1260
+ {
1261
+ type: "function",
1262
+ inputs: [{ name: "onBehalfOf", internalType: "address", type: "address" }],
1263
+ name: "openCreditAccount",
1264
+ outputs: [{ name: "", internalType: "address", type: "address" }],
1265
+ stateMutability: "nonpayable"
1266
+ },
1267
+ {
1268
+ type: "function",
1269
+ inputs: [],
1270
+ name: "pool",
1271
+ outputs: [{ name: "", internalType: "address", type: "address" }],
1272
+ stateMutability: "view"
1273
+ },
1274
+ {
1275
+ type: "function",
1276
+ inputs: [],
1277
+ name: "poolQuotaKeeper",
1278
+ outputs: [{ name: "", internalType: "address", type: "address" }],
1279
+ stateMutability: "view"
1280
+ },
1281
+ {
1282
+ type: "function",
1283
+ inputs: [],
1284
+ name: "priceOracle",
1285
+ outputs: [{ name: "", internalType: "address", type: "address" }],
1286
+ stateMutability: "view"
1287
+ },
1288
+ {
1289
+ type: "function",
1290
+ inputs: [],
1291
+ name: "quotedTokensMask",
1292
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
1293
+ stateMutability: "view"
1294
+ },
1295
+ {
1296
+ type: "function",
1297
+ inputs: [
1298
+ { name: "creditAccount", internalType: "address", type: "address" },
1299
+ {
1300
+ name: "revocations",
1301
+ internalType: "struct RevocationPair[]",
1302
+ type: "tuple[]",
1303
+ components: [
1304
+ { name: "spender", internalType: "address", type: "address" },
1305
+ { name: "token", internalType: "address", type: "address" }
1306
+ ]
1307
+ }
1308
+ ],
1309
+ name: "revokeAdapterAllowances",
1310
+ outputs: [],
1311
+ stateMutability: "nonpayable"
1312
+ },
1313
+ {
1314
+ type: "function",
1315
+ inputs: [
1316
+ { name: "creditAccount", internalType: "address", type: "address" }
1317
+ ],
1318
+ name: "setActiveCreditAccount",
1319
+ outputs: [],
1320
+ stateMutability: "nonpayable"
1321
+ },
1322
+ {
1323
+ type: "function",
1324
+ inputs: [
1325
+ { name: "token", internalType: "address", type: "address" },
1326
+ { name: "ltInitial", internalType: "uint16", type: "uint16" },
1327
+ { name: "ltFinal", internalType: "uint16", type: "uint16" },
1328
+ { name: "timestampRampStart", internalType: "uint40", type: "uint40" },
1329
+ { name: "rampDuration", internalType: "uint24", type: "uint24" }
1330
+ ],
1331
+ name: "setCollateralTokenData",
1332
+ outputs: [],
1333
+ stateMutability: "nonpayable"
1334
+ },
1335
+ {
1336
+ type: "function",
1337
+ inputs: [
1338
+ { name: "adapter", internalType: "address", type: "address" },
1339
+ { name: "targetContract", internalType: "address", type: "address" }
1340
+ ],
1341
+ name: "setContractAllowance",
1342
+ outputs: [],
1343
+ stateMutability: "nonpayable"
1344
+ },
1345
+ {
1346
+ type: "function",
1347
+ inputs: [
1348
+ { name: "creditConfigurator", internalType: "address", type: "address" }
1349
+ ],
1350
+ name: "setCreditConfigurator",
1351
+ outputs: [],
1352
+ stateMutability: "nonpayable"
1353
+ },
1354
+ {
1355
+ type: "function",
1356
+ inputs: [
1357
+ { name: "creditFacade", internalType: "address", type: "address" }
1358
+ ],
1359
+ name: "setCreditFacade",
1360
+ outputs: [],
1361
+ stateMutability: "nonpayable"
1362
+ },
1363
+ {
1364
+ type: "function",
1365
+ inputs: [
1366
+ { name: "feeInterest", internalType: "uint16", type: "uint16" },
1367
+ { name: "feeLiquidation", internalType: "uint16", type: "uint16" },
1368
+ { name: "liquidationDiscount", internalType: "uint16", type: "uint16" },
1369
+ { name: "feeLiquidationExpired", internalType: "uint16", type: "uint16" },
1370
+ {
1371
+ name: "liquidationDiscountExpired",
1372
+ internalType: "uint16",
1373
+ type: "uint16"
1374
+ }
1375
+ ],
1376
+ name: "setFees",
1377
+ outputs: [],
1378
+ stateMutability: "nonpayable"
1379
+ },
1380
+ {
1381
+ type: "function",
1382
+ inputs: [
1383
+ { name: "creditAccount", internalType: "address", type: "address" },
1384
+ { name: "flag", internalType: "uint16", type: "uint16" },
1385
+ { name: "value", internalType: "bool", type: "bool" }
1386
+ ],
1387
+ name: "setFlagFor",
1388
+ outputs: [],
1389
+ stateMutability: "nonpayable"
1390
+ },
1391
+ {
1392
+ type: "function",
1393
+ inputs: [
1394
+ { name: "maxEnabledTokens", internalType: "uint8", type: "uint8" }
1395
+ ],
1396
+ name: "setMaxEnabledTokens",
1397
+ outputs: [],
1398
+ stateMutability: "nonpayable"
1399
+ },
1400
+ {
1401
+ type: "function",
1402
+ inputs: [{ name: "priceOracle", internalType: "address", type: "address" }],
1403
+ name: "setPriceOracle",
1404
+ outputs: [],
1405
+ stateMutability: "nonpayable"
1406
+ },
1407
+ {
1408
+ type: "function",
1409
+ inputs: [
1410
+ { name: "quotedTokensMask", internalType: "uint256", type: "uint256" }
1411
+ ],
1412
+ name: "setQuotedMask",
1413
+ outputs: [],
1414
+ stateMutability: "nonpayable"
1415
+ },
1416
+ {
1417
+ type: "function",
1418
+ inputs: [],
1419
+ name: "underlying",
1420
+ outputs: [{ name: "", internalType: "address", type: "address" }],
1421
+ stateMutability: "view"
1422
+ },
1423
+ {
1424
+ type: "function",
1425
+ inputs: [
1426
+ { name: "creditAccount", internalType: "address", type: "address" },
1427
+ { name: "token", internalType: "address", type: "address" },
1428
+ { name: "quotaChange", internalType: "int96", type: "int96" },
1429
+ { name: "minQuota", internalType: "uint96", type: "uint96" },
1430
+ { name: "maxQuota", internalType: "uint96", type: "uint96" }
1431
+ ],
1432
+ name: "updateQuota",
1433
+ outputs: [
1434
+ { name: "tokensToEnable", internalType: "uint256", type: "uint256" },
1435
+ { name: "tokensToDisable", internalType: "uint256", type: "uint256" }
1436
+ ],
1437
+ stateMutability: "nonpayable"
1438
+ },
1439
+ {
1440
+ type: "function",
1441
+ inputs: [],
1442
+ name: "version",
1443
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
1444
+ stateMutability: "view"
1445
+ },
1446
+ {
1447
+ type: "function",
1448
+ inputs: [
1449
+ { name: "creditAccount", internalType: "address", type: "address" },
1450
+ { name: "token", internalType: "address", type: "address" },
1451
+ { name: "amount", internalType: "uint256", type: "uint256" },
1452
+ { name: "to", internalType: "address", type: "address" }
1453
+ ],
1454
+ name: "withdrawCollateral",
1455
+ outputs: [
1456
+ { name: "tokensToDisable", internalType: "uint256", type: "uint256" }
1457
+ ],
1458
+ stateMutability: "nonpayable"
1459
+ },
1460
+ {
1461
+ type: "event",
1462
+ anonymous: false,
1463
+ inputs: [
1464
+ {
1465
+ name: "newConfigurator",
1466
+ internalType: "address",
1467
+ type: "address",
1468
+ indexed: true
1469
+ }
1470
+ ],
1471
+ name: "SetCreditConfigurator"
1472
+ }
1473
+ ];
1474
+
1475
+ // src/dev/setLTs.ts
1476
+ async function setLTs(anvil, cm, newLTs, logger) {
1477
+ const aclAddr = await anvil.readContract({
1478
+ address: cm.creditConfigurator,
1479
+ abi: iaclTraitAbi,
1480
+ functionName: "acl"
1481
+ });
1482
+ const configuratorAddr = await anvil.readContract({
1483
+ address: aclAddr,
1484
+ abi: iaclAbi,
1485
+ functionName: "owner"
1486
+ });
1487
+ await anvil.impersonateAccount({
1488
+ address: configuratorAddr
1489
+ });
1490
+ await anvil.setBalance({
1491
+ address: configuratorAddr,
1492
+ value: viem.parseEther("100")
1493
+ });
1494
+ for (const [t, lt] of Object.entries(newLTs)) {
1495
+ try {
1496
+ await anvil.writeContract({
1497
+ chain: anvil.chain,
1498
+ address: cm.creditConfigurator,
1499
+ account: configuratorAddr,
1500
+ abi: iCreditConfiguratorV3Abi,
1501
+ functionName: "setLiquidationThreshold",
1502
+ args: [t, lt]
1503
+ });
1504
+ const newLT = await anvil.readContract({
1505
+ address: cm.baseParams.addr,
1506
+ abi: iCreditManagerV3Abi,
1507
+ functionName: "liquidationThresholds",
1508
+ args: [t]
1509
+ });
1510
+ logger?.debug(`set ${t} LT to ${newLT}`);
1511
+ } catch {
1512
+ }
1513
+ }
1514
+ await anvil.stopImpersonatingAccount({
1515
+ address: configuratorAddr
1516
+ });
1517
+ }
1518
+ async function setLTZero(anvil, cm, logger) {
1519
+ const aclAddr = await anvil.readContract({
1520
+ address: cm.creditConfigurator,
1521
+ abi: iaclTraitAbi,
1522
+ functionName: "acl"
1523
+ });
1524
+ const configuratorAddr = await anvil.readContract({
1525
+ address: aclAddr,
1526
+ abi: iaclAbi,
1527
+ functionName: "owner"
1528
+ });
1529
+ await anvil.impersonateAccount({
1530
+ address: configuratorAddr
1531
+ });
1532
+ await anvil.setBalance({
1533
+ address: configuratorAddr,
1534
+ value: viem.parseEther("100")
1535
+ });
1536
+ let hash = await anvil.writeContract({
1537
+ chain: anvil.chain,
1538
+ address: cm.creditConfigurator,
1539
+ account: configuratorAddr,
1540
+ abi: iCreditConfiguratorV3Abi,
1541
+ functionName: "setFees",
1542
+ args: [
1543
+ cm.feeInterest,
1544
+ cm.liquidationDiscount - 1,
1545
+ Number(sdk.PERCENTAGE_FACTOR) - cm.liquidationDiscount,
1546
+ cm.feeLiquidationExpired,
1547
+ cm.liquidationDiscountExpired
1548
+ ]
1549
+ });
1550
+ await anvil.waitForTransactionReceipt({ hash });
1551
+ logger?.debug(`[${cm.name}] setFees part 2`);
1552
+ hash = await anvil.writeContract({
1553
+ chain: anvil.chain,
1554
+ address: cm.creditConfigurator,
1555
+ account: configuratorAddr,
1556
+ abi: iCreditConfiguratorV3Abi,
1557
+ functionName: "setFees",
1558
+ args: [
1559
+ cm.feeInterest,
1560
+ cm.feeLiquidation,
1561
+ Number(sdk.PERCENTAGE_FACTOR) - cm.liquidationDiscount,
1562
+ cm.feeLiquidationExpired,
1563
+ cm.liquidationDiscountExpired
1564
+ ]
1565
+ });
1566
+ await anvil.waitForTransactionReceipt({ hash });
1567
+ logger?.debug(`[${cm.name}] setFees done`);
1568
+ await anvil.impersonateAccount({
1569
+ address: cm.creditConfigurator
1570
+ });
1571
+ await anvil.setBalance({
1572
+ address: cm.creditConfigurator,
1573
+ value: viem.parseEther("100")
1574
+ });
1575
+ logger?.debug(
1576
+ `[${cm.name}] impresonating creditConfigurator ${cm.creditConfigurator}`
1577
+ );
1578
+ logger?.debug(`[${cm.name}] setting liquidation threshold`);
1579
+ hash = await anvil.writeContract({
1580
+ chain: anvil.chain,
1581
+ address: cm.baseParams.addr,
1582
+ account: cm.creditConfigurator,
1583
+ abi: iCreditManagerV3Abi,
1584
+ functionName: "setCollateralTokenData",
1585
+ args: [cm.underlying, 1, 1, Number(2n ** 40n - 1n), 0]
1586
+ });
1587
+ await anvil.waitForTransactionReceipt({ hash });
1588
+ logger?.debug(`[${cm.name}] setting configurator ${cm.creditConfigurator}`);
1589
+ hash = await anvil.writeContract({
1590
+ chain: anvil.chain,
1591
+ address: cm.baseParams.addr,
1592
+ account: cm.creditConfigurator,
1593
+ abi: iCreditManagerV3Abi,
1594
+ functionName: "setCreditConfigurator",
1595
+ args: [cm.creditConfigurator]
1596
+ });
1597
+ await anvil.waitForTransactionReceipt({ hash });
1598
+ logger?.debug(`[${cm.name}] done`);
1599
+ await anvil.stopImpersonatingAccount({
1600
+ address: cm.creditConfigurator
1601
+ });
1602
+ await anvil.stopImpersonatingAccount({ address: configuratorAddr });
1603
+ }
1604
+
1605
+ exports.anvilNodeInfo = anvilNodeInfo;
1606
+ exports.calcLiquidatableLTs = calcLiquidatableLTs;
1607
+ exports.createAnvilClient = createAnvilClient;
1608
+ exports.evmMineDetailed = evmMineDetailed;
1609
+ exports.isAnvil = isAnvil;
1610
+ exports.setLTZero = setLTZero;
1611
+ exports.setLTs = setLTs;