@gearbox-protocol/sdk 3.0.0-vfour.3 → 3.0.0-vfour.30

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