@gearbox-protocol/sdk 4.1.8 → 4.2.0-next.1

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.
Files changed (41) hide show
  1. package/dist/cjs/dev/index.js +3 -5
  2. package/dist/cjs/dev/ltUtils.js +200 -0
  3. package/dist/cjs/sdk/GearboxSDK.js +68 -42
  4. package/dist/cjs/sdk/core/address-provider/{AddressProviderV3Contract.js → AddressProviderV300Contract.js} +9 -9
  5. package/dist/cjs/sdk/core/address-provider/{AddressProviderV3_1Contract.js → AddressProviderV310Contract.js} +9 -9
  6. package/dist/cjs/sdk/core/address-provider/createAddressProvider.js +25 -29
  7. package/dist/cjs/sdk/core/address-provider/index.js +4 -4
  8. package/dist/cjs/sdk/gauges/GaugeStakingService.js +15 -9
  9. package/dist/cjs/sdk/market/MarketRegister.js +5 -2
  10. package/dist/cjs/sdk/utils/index.js +3 -1
  11. package/dist/cjs/sdk/utils/version.js +35 -0
  12. package/dist/esm/dev/index.js +1 -2
  13. package/dist/esm/dev/ltUtils.js +178 -0
  14. package/dist/esm/sdk/GearboxSDK.js +68 -42
  15. package/dist/esm/sdk/core/address-provider/{AddressProviderV3Contract.js → AddressProviderV300Contract.js} +5 -5
  16. package/dist/esm/sdk/core/address-provider/{AddressProviderV3_1Contract.js → AddressProviderV310Contract.js} +5 -5
  17. package/dist/esm/sdk/core/address-provider/createAddressProvider.js +23 -28
  18. package/dist/esm/sdk/core/address-provider/index.js +2 -2
  19. package/dist/esm/sdk/gauges/GaugeStakingService.js +15 -9
  20. package/dist/esm/sdk/market/MarketRegister.js +5 -2
  21. package/dist/esm/sdk/utils/index.js +1 -0
  22. package/dist/esm/sdk/utils/version.js +10 -0
  23. package/dist/types/dev/index.d.ts +1 -2
  24. package/dist/types/dev/ltUtils.d.ts +11 -0
  25. package/dist/types/sdk/GearboxSDK.d.ts +8 -2
  26. package/dist/types/sdk/core/address-provider/{AddressProviderV3Contract.d.ts → AddressProviderV300Contract.d.ts} +2 -2
  27. package/dist/types/sdk/core/address-provider/{AddressProviderV3_1Contract.d.ts → AddressProviderV310Contract.d.ts} +2 -2
  28. package/dist/types/sdk/core/address-provider/createAddressProvider.d.ts +2 -5
  29. package/dist/types/sdk/core/address-provider/index.d.ts +2 -2
  30. package/dist/types/sdk/market/MarketRegister.d.ts +2 -1
  31. package/dist/types/sdk/types/state-human.d.ts +2 -2
  32. package/dist/types/sdk/types/state.d.ts +9 -0
  33. package/dist/types/sdk/utils/index.d.ts +1 -0
  34. package/dist/types/sdk/utils/version.d.ts +2 -0
  35. package/package.json +1 -1
  36. package/dist/cjs/dev/setLTZero.js +0 -124
  37. package/dist/cjs/dev/setLTs.js +0 -73
  38. package/dist/esm/dev/setLTZero.js +0 -103
  39. package/dist/esm/dev/setLTs.js +0 -49
  40. package/dist/types/dev/setLTZero.d.ts +0 -5
  41. package/dist/types/dev/setLTs.d.ts +0 -14
@@ -11,6 +11,10 @@ import { type PluginInstances, type PluginMap } from "./plugins/index.js";
11
11
  import { type IRouterContract } from "./router/index.js";
12
12
  import type { GearboxState, GearboxStateHuman, ILogger, MultiCall } from "./types/index.js";
13
13
  import { AddressMap } from "./utils/index.js";
14
+ /**
15
+ * State version, checked duryng hydration
16
+ */
17
+ export declare const STATE_VERSION = 1;
14
18
  export interface SDKOptions<Plugins extends PluginMap = {}> {
15
19
  /**
16
20
  * If not set, address provider address is determinted automatically from networkType
@@ -51,6 +55,7 @@ export interface SDKOptions<Plugins extends PluginMap = {}> {
51
55
  */
52
56
  logger?: ILogger;
53
57
  }
58
+ export type HydrateOptions = Pick<SDKOptions, "ignoreUpdateablePrices" | "logger" | "redstoneGateways" | "redstoneHistoricTimestamp" | "strictContractTypes">;
54
59
  export interface SyncStateOptions {
55
60
  blockNumber: bigint;
56
61
  timestamp: bigint;
@@ -87,6 +92,7 @@ export declare class GearboxSDK<Plugins extends PluginMap = {}> {
87
92
  addHook: <K extends "syncState">(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
88
93
  removeHook: <K extends "syncState">(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
89
94
  static attach<Plugins extends PluginMap>(options: SDKOptions<Plugins> & Partial<NetworkOptions> & ConnectionOptions & TransportOptions): Promise<GearboxSDK<Plugins>>;
95
+ static hydrate(options: HydrateOptions & ConnectionOptions & TransportOptions, state: GearboxState): GearboxSDK;
90
96
  private constructor();
91
97
  /**
92
98
  * Reattach SDK with the same config as before, without re-creating instance. Will load all state from scratch
@@ -147,8 +153,8 @@ export declare class GearboxSDK<Plugins extends PluginMap = {}> {
147
153
  get timestamp(): bigint;
148
154
  get gear(): Address | undefined;
149
155
  get addressProvider(): IAddressProviderContract;
150
- get botListContract(): BotListContract;
151
- get gearStakingContract(): GearStakingContract;
156
+ get botListContract(): BotListContract | undefined;
157
+ get gearStakingContract(): GearStakingContract | undefined;
152
158
  get marketRegister(): MarketRegister;
153
159
  /**
154
160
  * Returns router contract that will work for given credit manager or credit facade
@@ -88,8 +88,8 @@ declare const abi: readonly [{
88
88
  readonly anonymous: false;
89
89
  }];
90
90
  type abi = typeof abi;
91
- export declare class AddressProviderContractV3 extends AbstractAddressProviderContract<abi> implements IAddressProviderContract {
92
- constructor(sdk: GearboxSDK, address: Address, addresses?: Record<string, Record<number, Address>>);
91
+ export declare class AddressProviderV300Contract extends AbstractAddressProviderContract<abi> implements IAddressProviderContract {
92
+ constructor(sdk: GearboxSDK, address: Address, version: number, addresses?: Record<string, Record<number, Address>>);
93
93
  protected parseFunctionParams(params: DecodeFunctionDataReturnType<abi>): Array<string> | undefined;
94
94
  processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
95
95
  syncState(blockNumber?: bigint): Promise<void>;
@@ -253,8 +253,8 @@ declare const abi: readonly [{
253
253
  readonly name: "ZeroAddressException";
254
254
  }];
255
255
  type abi = typeof abi;
256
- export declare class AddressProviderContractV3_1 extends AbstractAddressProviderContract<abi> implements IAddressProviderContract {
257
- constructor(sdk: GearboxSDK, address: Address, addresses?: Record<string, Record<number, Address>>);
256
+ export declare class AddressProviderV310Contract extends AbstractAddressProviderContract<abi> implements IAddressProviderContract {
257
+ constructor(sdk: GearboxSDK, address: Address, version: number, addresses?: Record<string, Record<number, Address>>);
258
258
  protected parseFunctionParams(params: DecodeFunctionDataReturnType<abi>): Array<string> | undefined;
259
259
  processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
260
260
  syncState(blockNumber?: bigint): Promise<void>;
@@ -1,8 +1,5 @@
1
1
  import type { Address } from "viem";
2
2
  import type { GearboxSDK } from "../../GearboxSDK.js";
3
3
  import type { AddressProviderState, IAddressProviderContract } from "./types.js";
4
- export interface CreateAddressProviderOptions {
5
- version?: number;
6
- state?: AddressProviderState;
7
- }
8
- export declare function createAddressProvider(sdk: GearboxSDK, address: Address, options?: CreateAddressProviderOptions): Promise<IAddressProviderContract>;
4
+ export declare function createAddressProvider(sdk: GearboxSDK, address: Address): Promise<IAddressProviderContract>;
5
+ export declare function hydrateAddressProvider(sdk: GearboxSDK, state: AddressProviderState): IAddressProviderContract;
@@ -1,4 +1,4 @@
1
- export * from "./AddressProviderV3_1Contract.js";
2
- export * from "./AddressProviderV3Contract.js";
1
+ export * from "./AddressProviderV300Contract.js";
2
+ export * from "./AddressProviderV310Contract.js";
3
3
  export * from "./createAddressProvider.js";
4
4
  export * from "./types.js";
@@ -10,7 +10,8 @@ import { MarketSuite } from "./MarketSuite.js";
10
10
  import type { PoolSuite } from "./pool/index.js";
11
11
  export declare class MarketRegister extends SDKConstruct {
12
12
  #private;
13
- constructor(sdk: GearboxSDK, markets?: MarketData[]);
13
+ constructor(sdk: GearboxSDK);
14
+ hydrate(state: MarketData[]): void;
14
15
  loadMarkets(marketConfigurators: Address[], ignoreUpdateablePrices?: boolean): Promise<void>;
15
16
  get marketFilter(): {
16
17
  configurators: readonly `0x${string}`[];
@@ -16,8 +16,8 @@ export interface GearStakingV3StateHuman extends BaseContractStateHuman {
16
16
  export type BotListStateHuman = BaseContractStateHuman;
17
17
  export interface CoreStateHuman {
18
18
  addressProviderV3: AddressProviderV3StateHuman;
19
- botList: BotListStateHuman;
20
- gearStakingV3: GearStakingV3StateHuman;
19
+ botList?: BotListStateHuman;
20
+ gearStakingV3?: GearStakingV3StateHuman;
21
21
  }
22
22
  export type PriceFeedStateHuman = BoundedOracleStateHuman | AssetPriceFeedStateHuman | RedstonePriceFeedStateHuman | LPPriceFeedStateHuman | BalancerWeightedPriceFeedStateHuman;
23
23
  export interface BasePriceFeedStateHuman extends BaseContractStateHuman {
@@ -1,7 +1,16 @@
1
1
  import type { MarketData } from "../base/index.js";
2
+ import type { NetworkType } from "../chain/chains.js";
2
3
  import type { AddressProviderState } from "../core/index.js";
3
4
  export interface GearboxState {
5
+ /**
6
+ * State version, checked duryng hydration
7
+ * This is not the same as @gearbox-protocol/sdk package version
8
+ */
9
+ version: number;
10
+ network: NetworkType;
11
+ chainId: number;
4
12
  currentBlock: bigint;
13
+ timestamp: bigint;
5
14
  addressProvider: AddressProviderState;
6
15
  markets: MarketData[];
7
16
  }
@@ -10,3 +10,4 @@ export * from "./json.js";
10
10
  export * from "./mappers.js";
11
11
  export * from "./retry.js";
12
12
  export * from "./toAddress.js";
13
+ export * from "./version.js";
@@ -0,0 +1,2 @@
1
+ export declare function isV300(version: number): boolean;
2
+ export declare function isV310(version: number): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "4.1.8",
3
+ "version": "4.2.0-next.1",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",
@@ -1,124 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var setLTZero_exports = {};
20
- __export(setLTZero_exports, {
21
- setLTZero: () => setLTZero
22
- });
23
- module.exports = __toCommonJS(setLTZero_exports);
24
- var import_viem = require("viem");
25
- var import_v300 = require("../abi/v300.js");
26
- var import_sdk = require("../sdk/index.js");
27
- var import_abi = require("./abi.js");
28
- async function setLTZero(anvil, cm, logger) {
29
- const aclAddr = await anvil.readContract({
30
- address: cm.creditConfigurator,
31
- abi: import_abi.iaclTraitAbi,
32
- functionName: "acl"
33
- });
34
- const configuratorAddr = await anvil.readContract({
35
- address: aclAddr,
36
- abi: import_abi.iOwnableAbi,
37
- functionName: "owner"
38
- });
39
- await anvil.impersonateAccount({
40
- address: configuratorAddr
41
- });
42
- await anvil.setBalance({
43
- address: configuratorAddr,
44
- value: (0, import_viem.parseEther)("100")
45
- });
46
- let hash = await anvil.writeContract({
47
- chain: anvil.chain,
48
- address: cm.creditConfigurator,
49
- account: configuratorAddr,
50
- abi: import_v300.iCreditConfiguratorV300Abi,
51
- functionName: "setFees",
52
- args: [
53
- cm.feeInterest,
54
- cm.liquidationDiscount - 1,
55
- Number(import_sdk.PERCENTAGE_FACTOR) - cm.liquidationDiscount,
56
- cm.feeLiquidationExpired,
57
- cm.liquidationDiscountExpired
58
- ]
59
- });
60
- await anvil.waitForTransactionReceipt({ hash });
61
- logger?.debug(`[${cm.name}] setFees part 2`);
62
- hash = await anvil.writeContract({
63
- chain: anvil.chain,
64
- address: cm.creditConfigurator,
65
- account: configuratorAddr,
66
- abi: import_v300.iCreditConfiguratorV300Abi,
67
- functionName: "setFees",
68
- args: [
69
- cm.feeInterest,
70
- cm.feeLiquidation,
71
- Number(import_sdk.PERCENTAGE_FACTOR) - cm.liquidationDiscount,
72
- cm.feeLiquidationExpired,
73
- cm.liquidationDiscountExpired
74
- ]
75
- });
76
- await anvil.waitForTransactionReceipt({ hash });
77
- logger?.debug(`[${cm.name}] setFees done`);
78
- await anvil.impersonateAccount({
79
- address: cm.creditConfigurator
80
- });
81
- await anvil.setBalance({
82
- address: cm.creditConfigurator,
83
- value: (0, import_viem.parseEther)("100")
84
- });
85
- logger?.debug(
86
- `[${cm.name}] impresonating creditConfigurator ${cm.creditConfigurator}`
87
- );
88
- logger?.debug(`[${cm.name}] setting liquidation threshold`);
89
- hash = await anvil.writeContract({
90
- chain: anvil.chain,
91
- address: cm.baseParams.addr,
92
- account: cm.creditConfigurator,
93
- abi: import_v300.iCreditManagerV300Abi,
94
- functionName: "setCollateralTokenData",
95
- args: [cm.underlying, 1, 1, Number(2n ** 40n - 1n), 0]
96
- });
97
- await anvil.waitForTransactionReceipt({ hash });
98
- logger?.debug(`[${cm.name}] setting configurator ${cm.creditConfigurator}`);
99
- hash = await anvil.writeContract({
100
- chain: anvil.chain,
101
- address: cm.baseParams.addr,
102
- account: cm.creditConfigurator,
103
- abi: import_v300.iCreditManagerV300Abi,
104
- functionName: "setCreditConfigurator",
105
- args: [cm.creditConfigurator]
106
- });
107
- await anvil.waitForTransactionReceipt({ hash });
108
- logger?.debug(`[${cm.name}] done`);
109
- await anvil.stopImpersonatingAccount({
110
- address: cm.creditConfigurator
111
- });
112
- await anvil.stopImpersonatingAccount({ address: configuratorAddr });
113
- const lt = await anvil.readContract({
114
- address: cm.baseParams.addr,
115
- abi: import_v300.iCreditManagerV300Abi,
116
- functionName: "liquidationThresholds",
117
- args: [cm.underlying]
118
- });
119
- logger?.debug(`[${cm.name}] underlying lt: ${lt}`);
120
- }
121
- // Annotate the CommonJS export names for ESM import in node:
122
- 0 && (module.exports = {
123
- setLTZero
124
- });
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var setLTs_exports = {};
20
- __export(setLTs_exports, {
21
- setLTs: () => setLTs
22
- });
23
- module.exports = __toCommonJS(setLTs_exports);
24
- var import_viem = require("viem");
25
- var import_v300 = require("../abi/v300.js");
26
- var import_v310 = require("../abi/v310.js");
27
- var import_abi = require("./abi.js");
28
- async function setLTs(anvil, cm, newLTs, logger) {
29
- const aclAddr = await anvil.readContract({
30
- address: cm.creditConfigurator,
31
- abi: import_abi.iaclTraitAbi,
32
- functionName: "acl"
33
- });
34
- const configuratorAddr = await anvil.readContract({
35
- address: aclAddr,
36
- abi: import_abi.iOwnableAbi,
37
- functionName: "owner"
38
- });
39
- await anvil.impersonateAccount({
40
- address: configuratorAddr
41
- });
42
- await anvil.setBalance({
43
- address: configuratorAddr,
44
- value: (0, import_viem.parseEther)("100")
45
- });
46
- for (const [t, lt] of Object.entries(newLTs)) {
47
- try {
48
- await anvil.writeContract({
49
- chain: anvil.chain,
50
- address: cm.creditConfigurator,
51
- account: configuratorAddr,
52
- abi: import_v300.iCreditConfiguratorV300Abi,
53
- functionName: "setLiquidationThreshold",
54
- args: [t, lt]
55
- });
56
- const newLT = await anvil.readContract({
57
- address: cm.address,
58
- abi: import_v310.iCreditManagerV310Abi,
59
- functionName: "liquidationThresholds",
60
- args: [t]
61
- });
62
- logger?.debug(`set ${t} LT to ${newLT}`);
63
- } catch {
64
- }
65
- }
66
- await anvil.stopImpersonatingAccount({
67
- address: configuratorAddr
68
- });
69
- }
70
- // Annotate the CommonJS export names for ESM import in node:
71
- 0 && (module.exports = {
72
- setLTs
73
- });
@@ -1,103 +0,0 @@
1
- import { parseEther } from "viem";
2
- import {
3
- iCreditConfiguratorV300Abi,
4
- iCreditManagerV300Abi
5
- } from "../abi/v300.js";
6
- import { PERCENTAGE_FACTOR } from "../sdk/index.js";
7
- import { iaclTraitAbi, iOwnableAbi } from "./abi.js";
8
- async function setLTZero(anvil, cm, logger) {
9
- const aclAddr = await anvil.readContract({
10
- address: cm.creditConfigurator,
11
- abi: iaclTraitAbi,
12
- functionName: "acl"
13
- });
14
- const configuratorAddr = await anvil.readContract({
15
- address: aclAddr,
16
- abi: iOwnableAbi,
17
- functionName: "owner"
18
- });
19
- await anvil.impersonateAccount({
20
- address: configuratorAddr
21
- });
22
- await anvil.setBalance({
23
- address: configuratorAddr,
24
- value: parseEther("100")
25
- });
26
- let hash = await anvil.writeContract({
27
- chain: anvil.chain,
28
- address: cm.creditConfigurator,
29
- account: configuratorAddr,
30
- abi: iCreditConfiguratorV300Abi,
31
- functionName: "setFees",
32
- args: [
33
- cm.feeInterest,
34
- cm.liquidationDiscount - 1,
35
- Number(PERCENTAGE_FACTOR) - cm.liquidationDiscount,
36
- cm.feeLiquidationExpired,
37
- cm.liquidationDiscountExpired
38
- ]
39
- });
40
- await anvil.waitForTransactionReceipt({ hash });
41
- logger?.debug(`[${cm.name}] setFees part 2`);
42
- hash = await anvil.writeContract({
43
- chain: anvil.chain,
44
- address: cm.creditConfigurator,
45
- account: configuratorAddr,
46
- abi: iCreditConfiguratorV300Abi,
47
- functionName: "setFees",
48
- args: [
49
- cm.feeInterest,
50
- cm.feeLiquidation,
51
- Number(PERCENTAGE_FACTOR) - cm.liquidationDiscount,
52
- cm.feeLiquidationExpired,
53
- cm.liquidationDiscountExpired
54
- ]
55
- });
56
- await anvil.waitForTransactionReceipt({ hash });
57
- logger?.debug(`[${cm.name}] setFees done`);
58
- await anvil.impersonateAccount({
59
- address: cm.creditConfigurator
60
- });
61
- await anvil.setBalance({
62
- address: cm.creditConfigurator,
63
- value: parseEther("100")
64
- });
65
- logger?.debug(
66
- `[${cm.name}] impresonating creditConfigurator ${cm.creditConfigurator}`
67
- );
68
- logger?.debug(`[${cm.name}] setting liquidation threshold`);
69
- hash = await anvil.writeContract({
70
- chain: anvil.chain,
71
- address: cm.baseParams.addr,
72
- account: cm.creditConfigurator,
73
- abi: iCreditManagerV300Abi,
74
- functionName: "setCollateralTokenData",
75
- args: [cm.underlying, 1, 1, Number(2n ** 40n - 1n), 0]
76
- });
77
- await anvil.waitForTransactionReceipt({ hash });
78
- logger?.debug(`[${cm.name}] setting configurator ${cm.creditConfigurator}`);
79
- hash = await anvil.writeContract({
80
- chain: anvil.chain,
81
- address: cm.baseParams.addr,
82
- account: cm.creditConfigurator,
83
- abi: iCreditManagerV300Abi,
84
- functionName: "setCreditConfigurator",
85
- args: [cm.creditConfigurator]
86
- });
87
- await anvil.waitForTransactionReceipt({ hash });
88
- logger?.debug(`[${cm.name}] done`);
89
- await anvil.stopImpersonatingAccount({
90
- address: cm.creditConfigurator
91
- });
92
- await anvil.stopImpersonatingAccount({ address: configuratorAddr });
93
- const lt = await anvil.readContract({
94
- address: cm.baseParams.addr,
95
- abi: iCreditManagerV300Abi,
96
- functionName: "liquidationThresholds",
97
- args: [cm.underlying]
98
- });
99
- logger?.debug(`[${cm.name}] underlying lt: ${lt}`);
100
- }
101
- export {
102
- setLTZero
103
- };
@@ -1,49 +0,0 @@
1
- import { parseEther } from "viem";
2
- import { iCreditConfiguratorV300Abi } from "../abi/v300.js";
3
- import { iCreditManagerV310Abi } from "../abi/v310.js";
4
- import { iaclTraitAbi, iOwnableAbi } from "./abi.js";
5
- async function setLTs(anvil, cm, newLTs, logger) {
6
- const aclAddr = await anvil.readContract({
7
- address: cm.creditConfigurator,
8
- abi: iaclTraitAbi,
9
- functionName: "acl"
10
- });
11
- const configuratorAddr = await anvil.readContract({
12
- address: aclAddr,
13
- abi: iOwnableAbi,
14
- functionName: "owner"
15
- });
16
- await anvil.impersonateAccount({
17
- address: configuratorAddr
18
- });
19
- await anvil.setBalance({
20
- address: configuratorAddr,
21
- value: parseEther("100")
22
- });
23
- for (const [t, lt] of Object.entries(newLTs)) {
24
- try {
25
- await anvil.writeContract({
26
- chain: anvil.chain,
27
- address: cm.creditConfigurator,
28
- account: configuratorAddr,
29
- abi: iCreditConfiguratorV300Abi,
30
- functionName: "setLiquidationThreshold",
31
- args: [t, lt]
32
- });
33
- const newLT = await anvil.readContract({
34
- address: cm.address,
35
- abi: iCreditManagerV310Abi,
36
- functionName: "liquidationThresholds",
37
- args: [t]
38
- });
39
- logger?.debug(`set ${t} LT to ${newLT}`);
40
- } catch {
41
- }
42
- }
43
- await anvil.stopImpersonatingAccount({
44
- address: configuratorAddr
45
- });
46
- }
47
- export {
48
- setLTs
49
- };
@@ -1,5 +0,0 @@
1
- import type { CreditManagerState, ILogger } from "../sdk/index.js";
2
- import type { AnvilClient } from "./createAnvilClient.js";
3
- type ZeroLTCMSlice = Pick<CreditManagerState, "creditConfigurator" | "feeInterest" | "liquidationDiscount" | "feeLiquidationExpired" | "liquidationDiscountExpired" | "feeLiquidation" | "name" | "underlying" | "baseParams">;
4
- export declare function setLTZero(anvil: AnvilClient, cm: ZeroLTCMSlice, logger?: ILogger): Promise<void>;
5
- export {};
@@ -1,14 +0,0 @@
1
- import type { Address } from "viem";
2
- import type { ILogger } from "../sdk/index.js";
3
- import type { AnvilClient } from "./createAnvilClient.js";
4
- export interface SetLTsCMSlice {
5
- creditConfigurator: Address;
6
- address: Address;
7
- }
8
- /**
9
- * Helper function to set liquidation thresholds on credit manager via anvil impersonation
10
- * @param sdk
11
- * @param cm
12
- * @param newLTs
13
- */
14
- export declare function setLTs(anvil: AnvilClient, cm: SetLTsCMSlice, newLTs: Record<Address, number>, logger?: ILogger): Promise<void>;