@gearbox-protocol/sdk 3.0.0-vfour.46 → 3.0.0-vfour.48

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.
@@ -1473,21 +1473,17 @@ var iCreditManagerV3Abi = [
1473
1473
  ];
1474
1474
 
1475
1475
  // src/dev/setLTs.ts
1476
- async function setLTs(sdk, cm, newLTs, logger) {
1477
- const aclAddr = await sdk.provider.publicClient.readContract({
1478
- address: cm.creditConfigurator.address,
1476
+ async function setLTs(anvil, cm, newLTs, logger) {
1477
+ const aclAddr = await anvil.readContract({
1478
+ address: cm.creditConfigurator,
1479
1479
  abi: iaclTraitAbi,
1480
1480
  functionName: "acl"
1481
1481
  });
1482
- const configuratorAddr = await sdk.provider.publicClient.readContract({
1482
+ const configuratorAddr = await anvil.readContract({
1483
1483
  address: aclAddr,
1484
1484
  abi: iaclAbi,
1485
1485
  functionName: "owner"
1486
1486
  });
1487
- const anvil = createAnvilClient({
1488
- transport: sdk.provider.transport,
1489
- chain: sdk.provider.chain
1490
- });
1491
1487
  await anvil.impersonateAccount({
1492
1488
  address: configuratorAddr
1493
1489
  });
@@ -1498,30 +1494,115 @@ async function setLTs(sdk, cm, newLTs, logger) {
1498
1494
  for (const [t, lt] of Object.entries(newLTs)) {
1499
1495
  await anvil.writeContract({
1500
1496
  chain: anvil.chain,
1501
- address: cm.creditConfigurator.address,
1497
+ address: cm.creditConfigurator,
1502
1498
  account: configuratorAddr,
1503
1499
  abi: iCreditConfiguratorV3Abi,
1504
1500
  functionName: "setLiquidationThreshold",
1505
1501
  args: [t, lt]
1506
1502
  });
1507
1503
  const newLT = await anvil.readContract({
1508
- address: cm.creditManager.address,
1504
+ address: cm.address,
1509
1505
  abi: iCreditManagerV3Abi,
1510
1506
  functionName: "liquidationThresholds",
1511
1507
  args: [t]
1512
1508
  });
1513
- logger?.debug(
1514
- `set ${sdk.marketRegister.tokensMeta.mustGet(t).symbol} LT to ${newLT}`
1515
- );
1509
+ logger?.debug(`set ${t} LT to ${newLT}`);
1516
1510
  }
1517
1511
  await anvil.stopImpersonatingAccount({
1518
1512
  address: configuratorAddr
1519
1513
  });
1520
1514
  }
1515
+ async function setLTZero(anvil, cm, logger) {
1516
+ const aclAddr = await anvil.readContract({
1517
+ address: cm.creditConfigurator,
1518
+ abi: iaclTraitAbi,
1519
+ functionName: "acl"
1520
+ });
1521
+ const configuratorAddr = await anvil.readContract({
1522
+ address: aclAddr,
1523
+ abi: iaclAbi,
1524
+ functionName: "owner"
1525
+ });
1526
+ await anvil.impersonateAccount({
1527
+ address: configuratorAddr
1528
+ });
1529
+ await anvil.setBalance({
1530
+ address: configuratorAddr,
1531
+ value: viem.parseEther("100")
1532
+ });
1533
+ let hash = await anvil.writeContract({
1534
+ chain: anvil.chain,
1535
+ address: cm.creditConfigurator,
1536
+ account: configuratorAddr,
1537
+ abi: iCreditConfiguratorV3Abi,
1538
+ functionName: "setFees",
1539
+ args: [
1540
+ cm.feeInterest,
1541
+ cm.liquidationDiscount - 1,
1542
+ Number(sdk.PERCENTAGE_FACTOR) - cm.liquidationDiscount,
1543
+ cm.feeLiquidationExpired,
1544
+ cm.liquidationDiscountExpired
1545
+ ]
1546
+ });
1547
+ await anvil.waitForTransactionReceipt({ hash });
1548
+ logger?.debug(`[${cm.name}] setFees part 2`);
1549
+ hash = await anvil.writeContract({
1550
+ chain: anvil.chain,
1551
+ address: cm.creditConfigurator,
1552
+ account: configuratorAddr,
1553
+ abi: iCreditConfiguratorV3Abi,
1554
+ functionName: "setFees",
1555
+ args: [
1556
+ cm.feeInterest,
1557
+ cm.feeLiquidation,
1558
+ Number(sdk.PERCENTAGE_FACTOR) - cm.liquidationDiscount,
1559
+ cm.feeLiquidationExpired,
1560
+ cm.liquidationDiscountExpired
1561
+ ]
1562
+ });
1563
+ await anvil.waitForTransactionReceipt({ hash });
1564
+ logger?.debug(`[${cm.name}] setFees done`);
1565
+ await anvil.impersonateAccount({
1566
+ address: cm.creditConfigurator
1567
+ });
1568
+ await anvil.setBalance({
1569
+ address: cm.creditConfigurator,
1570
+ value: viem.parseEther("100")
1571
+ });
1572
+ logger?.debug(
1573
+ `[${cm.name}] impresonating creditConfigurator ${cm.creditConfigurator}`
1574
+ );
1575
+ logger?.debug(`[${cm.name}] setting liquidation threshold`);
1576
+ hash = await anvil.writeContract({
1577
+ chain: anvil.chain,
1578
+ address: cm.address,
1579
+ account: cm.creditConfigurator,
1580
+ abi: iCreditManagerV3Abi,
1581
+ functionName: "setCollateralTokenData",
1582
+ args: [cm.underlying, 1, 1, Number(2n ** 40n - 1n), 0]
1583
+ });
1584
+ await anvil.waitForTransactionReceipt({ hash });
1585
+ logger?.debug(`[${cm.name}] setting configurator ${cm.creditConfigurator}`);
1586
+ hash = await anvil.writeContract({
1587
+ chain: anvil.chain,
1588
+ address: cm.address,
1589
+ account: cm.creditConfigurator,
1590
+ abi: iCreditManagerV3Abi,
1591
+ functionName: "setCreditConfigurator",
1592
+ args: [cm.creditConfigurator]
1593
+ });
1594
+ await anvil.waitForTransactionReceipt({ hash });
1595
+ logger?.debug(`[${cm.name}] done`);
1596
+ await anvil.stopImpersonatingAccount({
1597
+ address: cm.creditConfigurator
1598
+ });
1599
+ await anvil.stopImpersonatingAccount({ address: configuratorAddr });
1600
+ }
1521
1601
 
1522
1602
  exports.anvilNodeInfo = anvilNodeInfo;
1523
1603
  exports.calcLiquidatableLTs = calcLiquidatableLTs;
1524
1604
  exports.createAnvilClient = createAnvilClient;
1525
1605
  exports.evmMineDetailed = evmMineDetailed;
1526
1606
  exports.isAnvil = isAnvil;
1607
+ exports.setLTZero = setLTZero;
1527
1608
  exports.setLTs = setLTs;
@@ -1,5 +1,5 @@
1
1
  import { Address, TestRpcSchema, Hex, Block, Prettify, Client, Transport, Chain, TestActions, PublicClient, WalletClient } from 'viem';
2
- import { GearboxSDK, CreditAccountData, ILogger, CreditFactory } from '../sdk';
2
+ import { GearboxSDK, CreditAccountData, ILogger, CreditManagerState } from '../sdk';
3
3
 
4
4
  /**
5
5
  * Given credit accounts, calculates new liquidation thresholds that needs to be set to drop account health factor a bit to make it eligible for partial liquidation
@@ -81,6 +81,12 @@ declare function evmMineDetailed(client: Client<any, any, any, AnvilRPCSchema, a
81
81
  * @param cm
82
82
  * @param newLTs
83
83
  */
84
- declare function setLTs(sdk: GearboxSDK, cm: CreditFactory, newLTs: Record<Address, number>, logger?: ILogger): Promise<void>;
84
+ declare function setLTs(anvil: AnvilClient, cm: CreditManagerState & {
85
+ address: Address;
86
+ }, newLTs: Record<Address, number>, logger?: ILogger): Promise<void>;
85
87
 
86
- export { type AnvilActions, type AnvilClient, type AnvilClientConfig, type AnvilNodeInfo, type AnvilRPCSchema, anvilNodeInfo, calcLiquidatableLTs, createAnvilClient, evmMineDetailed, isAnvil, setLTs };
88
+ declare function setLTZero(anvil: AnvilClient, cm: CreditManagerState & {
89
+ address: Address;
90
+ }, logger?: ILogger): Promise<void>;
91
+
92
+ export { type AnvilActions, type AnvilClient, type AnvilClientConfig, type AnvilNodeInfo, type AnvilRPCSchema, anvilNodeInfo, calcLiquidatableLTs, createAnvilClient, evmMineDetailed, isAnvil, setLTZero, setLTs };