@gearbox-protocol/sdk 3.1.2 → 3.1.3-next.2

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 (48) hide show
  1. package/dist/cjs/abi/compressors.js +1124 -518
  2. package/dist/cjs/adapters/abi/adapters.js +123 -0
  3. package/dist/cjs/adapters/abi/index.js +1 -3
  4. package/dist/cjs/dev/setLTZero.js +7 -0
  5. package/dist/cjs/sdk/GearboxSDK.js +1 -6
  6. package/dist/cjs/sdk/accounts/CreditAccountsService.js +45 -30
  7. package/dist/cjs/sdk/accounts/utils.js +38 -0
  8. package/dist/cjs/sdk/constants/address-provider.js +11 -17
  9. package/dist/cjs/sdk/market/MarketSuite.js +1 -1
  10. package/dist/cjs/sdk/market/credit/CreditFacadeV300Contract.js +1 -5
  11. package/dist/cjs/sdk/market/credit/CreditFacadeV310Contract.js +1 -5
  12. package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +6 -5
  13. package/dist/cjs/sdk/market/pool/PoolSuite.js +1 -1
  14. package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +4 -4
  15. package/dist/cjs/sdk/sdk-legacy/core/creditAccount.js +3 -1
  16. package/dist/esm/abi/compressors.js +1124 -513
  17. package/dist/esm/adapters/abi/adapters.js +120 -0
  18. package/dist/esm/adapters/abi/index.js +0 -1
  19. package/dist/esm/dev/setLTZero.js +7 -0
  20. package/dist/esm/sdk/GearboxSDK.js +1 -6
  21. package/dist/esm/sdk/accounts/CreditAccountsService.js +45 -30
  22. package/dist/esm/sdk/accounts/utils.js +14 -0
  23. package/dist/esm/sdk/constants/address-provider.js +11 -15
  24. package/dist/esm/sdk/market/MarketSuite.js +1 -1
  25. package/dist/esm/sdk/market/credit/CreditFacadeV300Contract.js +1 -5
  26. package/dist/esm/sdk/market/credit/CreditFacadeV310Contract.js +1 -5
  27. package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +6 -5
  28. package/dist/esm/sdk/market/pool/PoolSuite.js +1 -1
  29. package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +9 -6
  30. package/dist/esm/sdk/sdk-legacy/core/creditAccount.js +3 -1
  31. package/dist/types/abi/compressors.d.ts +1403 -775
  32. package/dist/types/adapters/BalancerV3RouterAdapterContract.d.ts +62 -104
  33. package/dist/types/adapters/abi/adapters.d.ts +213 -0
  34. package/dist/types/adapters/abi/index.d.ts +0 -1
  35. package/dist/types/sdk/accounts/CreditAccountsService.d.ts +3 -3
  36. package/dist/types/sdk/accounts/types.d.ts +15 -2
  37. package/dist/types/sdk/accounts/utils.d.ts +2 -0
  38. package/dist/types/sdk/base/types.d.ts +6 -6
  39. package/dist/types/sdk/constants/address-provider.d.ts +11 -13
  40. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +425 -85
  41. package/dist/types/sdk/market/pool/PoolQuotaKeeperV300Contract.d.ts +2 -2
  42. package/dist/types/sdk/market/pool/PoolQuotaKeeperV310Contract.d.ts +2 -2
  43. package/dist/types/sdk/market/pool/createPoolQuotaKeeper.d.ts +2 -2
  44. package/dist/types/sdk/types/state-human.d.ts +1 -3
  45. package/package.json +1 -1
  46. package/dist/cjs/adapters/abi/iBalancerV3RouterAdapter.js +0 -153
  47. package/dist/esm/adapters/abi/iBalancerV3RouterAdapter.js +0 -129
  48. package/dist/types/adapters/abi/iBalancerV3RouterAdapter.d.ts +0 -230
@@ -287,6 +287,123 @@ const iBalancerV2VaultAdapterAbi = [
287
287
  },
288
288
  { type: "error", inputs: [], name: "PoolNotSupportedException" }
289
289
  ];
290
+ const iBalancerV3RouterAdapterAbi = [
291
+ {
292
+ type: "function",
293
+ inputs: [],
294
+ name: "contractType",
295
+ outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
296
+ stateMutability: "view"
297
+ },
298
+ {
299
+ type: "function",
300
+ inputs: [],
301
+ name: "creditManager",
302
+ outputs: [{ name: "", internalType: "address", type: "address" }],
303
+ stateMutability: "view"
304
+ },
305
+ {
306
+ type: "function",
307
+ inputs: [],
308
+ name: "getAllowedPools",
309
+ outputs: [{ name: "pools", internalType: "address[]", type: "address[]" }],
310
+ stateMutability: "view"
311
+ },
312
+ {
313
+ type: "function",
314
+ inputs: [{ name: "pool", internalType: "address", type: "address" }],
315
+ name: "isPoolAllowed",
316
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
317
+ stateMutability: "view"
318
+ },
319
+ {
320
+ type: "function",
321
+ inputs: [],
322
+ name: "serialize",
323
+ outputs: [{ name: "serializedData", internalType: "bytes", type: "bytes" }],
324
+ stateMutability: "view"
325
+ },
326
+ {
327
+ type: "function",
328
+ inputs: [
329
+ { name: "pools", internalType: "address[]", type: "address[]" },
330
+ { name: "statuses", internalType: "bool[]", type: "bool[]" }
331
+ ],
332
+ name: "setPoolStatusBatch",
333
+ outputs: [],
334
+ stateMutability: "nonpayable"
335
+ },
336
+ {
337
+ type: "function",
338
+ inputs: [
339
+ { name: "pool", internalType: "address", type: "address" },
340
+ { name: "tokenIn", internalType: "contract IERC20", type: "address" },
341
+ { name: "tokenOut", internalType: "contract IERC20", type: "address" },
342
+ { name: "leftoverAmount", internalType: "uint256", type: "uint256" },
343
+ { name: "rateMinRAY", internalType: "uint256", type: "uint256" },
344
+ { name: "deadline", internalType: "uint256", type: "uint256" }
345
+ ],
346
+ name: "swapSingleTokenDiffIn",
347
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
348
+ stateMutability: "nonpayable"
349
+ },
350
+ {
351
+ type: "function",
352
+ inputs: [
353
+ { name: "pool", internalType: "address", type: "address" },
354
+ { name: "tokenIn", internalType: "contract IERC20", type: "address" },
355
+ { name: "tokenOut", internalType: "contract IERC20", type: "address" },
356
+ { name: "exactAmountIn", internalType: "uint256", type: "uint256" },
357
+ { name: "minAmountOut", internalType: "uint256", type: "uint256" },
358
+ { name: "deadline", internalType: "uint256", type: "uint256" },
359
+ { name: "wethIsEth", internalType: "bool", type: "bool" },
360
+ { name: "userData", internalType: "bytes", type: "bytes" }
361
+ ],
362
+ name: "swapSingleTokenExactIn",
363
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
364
+ stateMutability: "nonpayable"
365
+ },
366
+ {
367
+ type: "function",
368
+ inputs: [],
369
+ name: "targetContract",
370
+ outputs: [{ name: "", internalType: "address", type: "address" }],
371
+ stateMutability: "view"
372
+ },
373
+ {
374
+ type: "function",
375
+ inputs: [],
376
+ name: "version",
377
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
378
+ stateMutability: "view"
379
+ },
380
+ {
381
+ type: "event",
382
+ anonymous: false,
383
+ inputs: [
384
+ { name: "pool", internalType: "address", type: "address", indexed: true },
385
+ { name: "allowed", internalType: "bool", type: "bool", indexed: false }
386
+ ],
387
+ name: "SetPoolStatus"
388
+ },
389
+ { type: "error", inputs: [], name: "InvalidLengthException" },
390
+ { type: "error", inputs: [], name: "InvalidPoolException" }
391
+ ];
392
+ const iBalancerV3RouterAdapterEventsAbi = [
393
+ {
394
+ type: "event",
395
+ anonymous: false,
396
+ inputs: [
397
+ { name: "pool", internalType: "address", type: "address", indexed: true },
398
+ { name: "allowed", internalType: "bool", type: "bool", indexed: false }
399
+ ],
400
+ name: "SetPoolStatus"
401
+ }
402
+ ];
403
+ const iBalancerV3RouterAdapterExceptionsAbi = [
404
+ { type: "error", inputs: [], name: "InvalidLengthException" },
405
+ { type: "error", inputs: [], name: "InvalidPoolException" }
406
+ ];
290
407
  const iCamelotV3AdapterAbi = [
291
408
  {
292
409
  type: "function",
@@ -4198,6 +4315,9 @@ const iwstEthv1AdapterAbi = [
4198
4315
  ];
4199
4316
  export {
4200
4317
  iBalancerV2VaultAdapterAbi,
4318
+ iBalancerV3RouterAdapterAbi,
4319
+ iBalancerV3RouterAdapterEventsAbi,
4320
+ iBalancerV3RouterAdapterExceptionsAbi,
4201
4321
  iCamelotV3AdapterAbi,
4202
4322
  iConvexV1BaseRewardPoolAdapterAbi,
4203
4323
  iConvexV1BoosterAdapterAbi,
@@ -1,2 +1 @@
1
1
  export * from "./adapters.js";
2
- export * from "./iBalancerV3RouterAdapter.js";
@@ -90,6 +90,13 @@ async function setLTZero(anvil, cm, logger) {
90
90
  address: cm.creditConfigurator
91
91
  });
92
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}`);
93
100
  }
94
101
  export {
95
102
  setLTZero
@@ -37,7 +37,6 @@ class GearboxSDK {
37
37
  #currentBlock;
38
38
  #timestamp;
39
39
  #syncing = false;
40
- #gear;
41
40
  // Collection of core singleton contracts
42
41
  #addressProvider;
43
42
  #botListContract;
@@ -185,7 +184,6 @@ class GearboxSDK {
185
184
  } catch (e) {
186
185
  this.logger?.error(e);
187
186
  }
188
- this.#gear = this.#addressProvider.getAddress(AP_GEAR_TOKEN, NO_VERSION);
189
187
  const gearStakingAddress = this.#addressProvider.getAddress(
190
188
  AP_GEAR_STAKING,
191
189
  NO_VERSION
@@ -405,10 +403,7 @@ class GearboxSDK {
405
403
  return this.#timestamp;
406
404
  }
407
405
  get gear() {
408
- if (this.#gear === void 0) {
409
- throw ERR_NOT_ATTACHED;
410
- }
411
- return this.#gear;
406
+ return this.addressProvider.getAddress(AP_GEAR_TOKEN, NO_VERSION);
412
407
  }
413
408
  get addressProvider() {
414
409
  if (this.#addressProvider === void 0) {
@@ -36,6 +36,7 @@ import {
36
36
  } from "../sdk-gov-legacy/index.js";
37
37
  import { childLogger } from "../utils/index.js";
38
38
  import { simulateWithPriceUpdates } from "../utils/viem/index.js";
39
+ import { stringifyGetCreditAccountsArgs } from "./utils.js";
39
40
  class CreditAccountsService extends SDKConstruct {
40
41
  #compressor;
41
42
  #batchSize;
@@ -47,6 +48,9 @@ class CreditAccountsService extends SDKConstruct {
47
48
  );
48
49
  this.#batchSize = options?.batchSize;
49
50
  this.#logger = childLogger("CreditAccountsService", sdk.logger);
51
+ this.#logger?.debug(
52
+ `credit account compressor address: ${this.#compressor}`
53
+ );
50
54
  }
51
55
  /**
52
56
  * Returns single credit account data, or undefined if it's not found
@@ -95,21 +99,21 @@ class CreditAccountsService extends SDKConstruct {
95
99
  * TODO: do we want to expose pagination?
96
100
  * TODO: do we want to expose "reverting"?
97
101
  * TODO: do we want to expose MarketFilter in any way? If so, we need to check that the MarketFilter is compatibled with attached markets?
98
- * @param args
102
+ * @param options
99
103
  * @param blockNumber
100
104
  * @returns returned credit accounts are sorted by health factor in ascending order
101
105
  */
102
- async getCreditAccounts(args, blockNumber) {
106
+ async getCreditAccounts(options, blockNumber) {
103
107
  const {
104
108
  creditManager,
105
109
  includeZeroDebt = false,
106
- maxHealthFactor = 65535,
107
- // TODO: this will change to bigint
108
- minHealthFactor = 0,
110
+ maxHealthFactor = MAX_UINT256,
111
+ minHealthFactor = 0n,
109
112
  owner = ADDRESS_0X0
110
- } = args ?? {};
113
+ } = options ?? {};
111
114
  const arg0 = creditManager ?? {
112
115
  configurators: this.marketConfigurators,
116
+ creditManagers: [],
113
117
  pools: [],
114
118
  underlying: ADDRESS_0X0
115
119
  };
@@ -117,7 +121,8 @@ class CreditAccountsService extends SDKConstruct {
117
121
  owner,
118
122
  includeZeroDebt,
119
123
  minHealthFactor,
120
- maxHealthFactor
124
+ maxHealthFactor,
125
+ reverting: false
121
126
  };
122
127
  const { txs: priceUpdateTxs } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs();
123
128
  const allCAs = [];
@@ -722,31 +727,41 @@ class CreditAccountsService extends SDKConstruct {
722
727
  * @returns
723
728
  */
724
729
  async #getCreditAccounts(args, priceUpdateTxs, blockNumber) {
730
+ this.#logger?.debug(
731
+ { args: stringifyGetCreditAccountsArgs(args) },
732
+ "getting credit accounts"
733
+ );
734
+ let resp;
725
735
  if (priceUpdateTxs?.length) {
726
- const [resp] = await simulateWithPriceUpdates(
727
- this.provider.publicClient,
728
- {
729
- priceUpdates: priceUpdateTxs,
730
- contracts: [
731
- {
732
- abi: iCreditAccountCompressorAbi,
733
- address: this.#compressor,
734
- functionName: "getCreditAccounts",
735
- args
736
- }
737
- ],
738
- blockNumber
739
- }
740
- );
741
- return resp;
736
+ [resp] = await simulateWithPriceUpdates(this.provider.publicClient, {
737
+ priceUpdates: priceUpdateTxs,
738
+ contracts: [
739
+ {
740
+ abi: iCreditAccountCompressorAbi,
741
+ address: this.#compressor,
742
+ functionName: "getCreditAccounts",
743
+ args
744
+ }
745
+ ],
746
+ blockNumber
747
+ });
748
+ } else {
749
+ resp = await this.provider.publicClient.readContract({
750
+ abi: iCreditAccountCompressorAbi,
751
+ address: this.#compressor,
752
+ functionName: "getCreditAccounts",
753
+ args,
754
+ blockNumber
755
+ });
742
756
  }
743
- return this.provider.publicClient.readContract({
744
- abi: iCreditAccountCompressorAbi,
745
- address: this.#compressor,
746
- functionName: "getCreditAccounts",
747
- args,
748
- blockNumber
749
- });
757
+ this.#logger?.debug(
758
+ {
759
+ accounts: resp[0]?.length ?? 0,
760
+ nextOffset: Number(resp[1])
761
+ },
762
+ "got credit accounts"
763
+ );
764
+ return resp;
750
765
  }
751
766
  /**
752
767
  * Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
@@ -0,0 +1,14 @@
1
+ function stringifyGetCreditAccountsArgs(args) {
2
+ const s = JSON.stringify(args, replacer);
3
+ return JSON.parse(s);
4
+ }
5
+ function replacer(_key, value) {
6
+ if (typeof value === "bigint") {
7
+ return value.toString();
8
+ } else {
9
+ return value;
10
+ }
11
+ }
12
+ export {
13
+ stringifyGetCreditAccountsArgs
14
+ };
@@ -2,32 +2,30 @@ import { NOT_DEPLOYED } from "./addresses.js";
2
2
  const NO_VERSION = 0;
3
3
  const AP_ACCOUNT_FACTORY = "ACCOUNT_FACTORY";
4
4
  const AP_ACL = "ACL";
5
- const AP_ADAPTER_COMPRESSOR = "ADAPTER_COMPRESSOR";
6
5
  const AP_BOT_LIST = "BOT_LIST";
7
6
  const AP_BYTECODE_REPOSITORY = "BYTECODE_REPOSITORY";
8
7
  const AP_CONTRACTS_REGISTER = "CONTRACTS_REGISTER";
9
8
  const AP_CONTROLLER_TIMELOCK = "CONTROLLER_TIMELOCK";
10
- const AP_CREDIT_ACCOUNT_COMPRESSOR = "CREDIT_ACCOUNT_COMPRESSOR";
11
- const AP_CREDIT_SUITE_COMPRESSOR = "CREDIT_SUITE_COMPRESSOR";
9
+ const AP_CREDIT_ACCOUNT_COMPRESSOR = "GLOBAL::ACCOUNT_COMPRESSOR";
10
+ const AP_CREDIT_SUITE_COMPRESSOR = "GLOBAL::CREDIT_SUITE_COMPRESSOR";
12
11
  const AP_DATA_COMPRESSOR = "DATA_COMPRESSOR";
13
12
  const AP_DELEVERAGE_BOT_HV = "DELEVERAGE_BOT_HV";
14
13
  const AP_DELEVERAGE_BOT_LV = "DELEVERAGE_BOT_LV";
15
14
  const AP_DELEVERAGE_BOT_PEGGED = "DELEVERAGE_BOT_PEGGED";
16
- const AP_GAUGE_COMPRESSOR = "GAUGE_COMPRESSOR";
15
+ const AP_GAUGE_COMPRESSOR = "GLOBAL::GAUGE_COMPRESSOR";
17
16
  const AP_GEAR_STAKING = "GEAR_STAKING";
18
- const AP_GEAR_TOKEN = "GEAR_TOKEN";
17
+ const AP_GEAR_TOKEN = "GLOBAL::GEAR_TOKEN";
19
18
  const AP_INFLATION_ATTACK_BLOCKER = "INFLATION_ATTACK_BLOCKER";
20
19
  const AP_INSOLVENCY_CHECKER = "INSOLVENCY_CHECKER";
21
- const AP_MARKET_COMPRESSOR = "MARKET_COMPRESSOR";
20
+ const AP_MARKET_COMPRESSOR = "GLOBAL::MARKET_COMPRESSOR";
22
21
  const AP_MARKET_CONFIGURATOR = "MARKET_CONFIGURATOR";
23
22
  const AP_PARTIAL_LIQUIDATION_BOT = "PARTIAL_LIQUIDATION_BOT";
24
- const AP_PERIPHERY_COMPRESSOR = "PERIPHERY_COMPRESSOR";
25
- const AP_POOL_COMPRESSOR = "POOL_COMPRESSOR";
26
- const AP_PRICE_FEED_COMPRESSOR = "PRICE_FEED_COMPRESSOR";
23
+ const AP_PERIPHERY_COMPRESSOR = "GLOBAL::PERIPHERY_COMPRESSOR";
24
+ const AP_PRICE_FEED_COMPRESSOR = "GLOBAL::PRICE_FEED_COMPRESSOR";
27
25
  const AP_PRICE_ORACLE = "PRICE_ORACLE";
28
- const AP_REWARDS_COMPRESSOR = "REWARDS_COMPRESSOR";
29
- const AP_ROUTER = "LOCAL::ROUTER";
30
- const AP_TOKEN_COMPRESSOR = "TOKEN_COMPRESSOR";
26
+ const AP_REWARDS_COMPRESSOR = "GLOBAL::REWARDS_COMPRESSOR";
27
+ const AP_ROUTER = "GLOBAL::ROUTER";
28
+ const AP_TOKEN_COMPRESSOR = "GLOBAL::TOKEN_COMPRESSOR";
31
29
  const AP_TREASURY = "TREASURY";
32
30
  const AP_WETH_GATEWAY = "WETH_GATEWAY";
33
31
  const AP_WETH_TOKEN = "WETH_TOKEN";
@@ -46,13 +44,12 @@ const ADDRESS_PROVIDER = {
46
44
  Avalanche: NOT_DEPLOYED,
47
45
  BNB: NOT_DEPLOYED
48
46
  };
49
- const ADDRESS_PROVIDER_V310 = "0xBaB2014Dd88223E168bA06911c06df638311a097";
47
+ const ADDRESS_PROVIDER_V310 = "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38";
50
48
  export {
51
49
  ADDRESS_PROVIDER,
52
50
  ADDRESS_PROVIDER_V310,
53
51
  AP_ACCOUNT_FACTORY,
54
52
  AP_ACL,
55
- AP_ADAPTER_COMPRESSOR,
56
53
  AP_BOT_LIST,
57
54
  AP_BYTECODE_REPOSITORY,
58
55
  AP_CONTRACTS_REGISTER,
@@ -72,7 +69,6 @@ export {
72
69
  AP_MARKET_CONFIGURATOR,
73
70
  AP_PARTIAL_LIQUIDATION_BOT,
74
71
  AP_PERIPHERY_COMPRESSOR,
75
- AP_POOL_COMPRESSOR,
76
72
  AP_PRICE_FEED_COMPRESSOR,
77
73
  AP_PRICE_ORACLE,
78
74
  AP_REWARDS_COMPRESSOR,
@@ -37,7 +37,7 @@ class MarketSuite extends SDKConstruct {
37
37
  }
38
38
  this.priceOracle = createPriceOracle(
39
39
  sdk,
40
- marketData.priceOracleData,
40
+ marketData.priceOracle,
41
41
  marketData.pool.underlying
42
42
  );
43
43
  }
@@ -36,11 +36,7 @@ class CreditFacadeV300Contract extends BaseContract {
36
36
  botList: this.labelAddress(this.botList),
37
37
  minDebt: formatBNvalue(this.minDebt, decimals),
38
38
  maxDebt: formatBNvalue(this.maxDebt, decimals),
39
- currentCumulativeLoss: "0",
40
- // TODO
41
- maxCumulativeLoss: "0",
42
- // TODO
43
- forbiddenTokenMask: fmtBinaryMask(this.forbiddenTokenMask),
39
+ forbiddenTokensMask: fmtBinaryMask(this.forbiddenTokensMask),
44
40
  isPaused: this.isPaused
45
41
  };
46
42
  }
@@ -36,11 +36,7 @@ class CreditFacadeV310Contract extends BaseContract {
36
36
  botList: this.labelAddress(this.botList),
37
37
  minDebt: formatBNvalue(this.minDebt, decimals),
38
38
  maxDebt: formatBNvalue(this.maxDebt, decimals),
39
- currentCumulativeLoss: "0",
40
- // TODO
41
- maxCumulativeLoss: "0",
42
- // TODO
43
- forbiddenTokenMask: fmtBinaryMask(this.forbiddenTokenMask),
39
+ forbiddenTokensMask: fmtBinaryMask(this.forbiddenTokensMask),
44
40
  isPaused: this.isPaused
45
41
  };
46
42
  }
@@ -42,8 +42,8 @@ class PriceOracleBaseContract extends BaseContract {
42
42
  constructor(sdk, args, data, underlying) {
43
43
  super(sdk, args);
44
44
  this.underlying = underlying;
45
- const { priceFeedMapping, priceFeedStructure } = data;
46
- this.#loadState(priceFeedMapping, priceFeedStructure);
45
+ const { priceFeedMap, priceFeedTree } = data;
46
+ this.#loadState(priceFeedMap, priceFeedTree);
47
47
  }
48
48
  /**
49
49
  * Returns main and reserve price feeds for given tokens
@@ -216,11 +216,12 @@ class PriceOracleBaseContract extends BaseContract {
216
216
  call: {
217
217
  abi: iPriceFeedCompressorAbi,
218
218
  address,
219
- functionName: "getPriceFeeds",
219
+ functionName: "getPriceOracleState",
220
220
  args
221
221
  },
222
- onResult: ([entries, tree]) => {
223
- this.#loadState(entries, tree);
222
+ onResult: (resp) => {
223
+ const { priceFeedMap, priceFeedTree } = resp;
224
+ this.#loadState(priceFeedMap, priceFeedTree);
224
225
  }
225
226
  };
226
227
  }
@@ -14,7 +14,7 @@ class PoolSuite extends SDKConstruct {
14
14
  constructor(sdk, data) {
15
15
  super(sdk);
16
16
  this.pool = createPool(sdk, data.pool);
17
- this.pqk = createPoolQuotaKeeper(sdk, data.pool, data.poolQuotaKeeper);
17
+ this.pqk = createPoolQuotaKeeper(sdk, data.pool, data.quotaKeeper);
18
18
  this.rateKeeper = createRateKeeper(sdk, data.pool, data.rateKeeper);
19
19
  this.interestRateModel = createInterestRateModel(
20
20
  sdk,
@@ -1,6 +1,9 @@
1
- import { iMarketCompressorAbi } from "../../../abi/compressors.js";
1
+ import { iPriceFeedCompressorAbi } from "../../../abi/compressors.js";
2
2
  import { SDKConstruct } from "../../base/index.js";
3
- import { ADDRESS_0X0, AP_MARKET_COMPRESSOR } from "../../constants/index.js";
3
+ import {
4
+ ADDRESS_0X0,
5
+ AP_PRICE_FEED_COMPRESSOR
6
+ } from "../../constants/index.js";
4
7
  import { AddressMap, bytes32ToString, childLogger } from "../../utils/index.js";
5
8
  import { Hooks } from "../../utils/internal/index.js";
6
9
  import {
@@ -106,8 +109,8 @@ class PriceFeedRegister extends SDKConstruct {
106
109
  * This is not saved anywhere in PriceFeedRegister, and can later be used to load price feed updates
107
110
  */
108
111
  async getPartialUpdatablePriceFeeds(marketConfigurators, pools) {
109
- const marketCompressorAddress = this.sdk.addressProvider.getAddress(
110
- AP_MARKET_COMPRESSOR,
112
+ const priceFeedCompressorAddress = this.sdk.addressProvider.getAddress(
113
+ AP_PRICE_FEED_COMPRESSOR,
111
114
  310
112
115
  );
113
116
  const configurators = marketConfigurators ?? this.sdk.marketRegister.marketConfigurators.map((mc) => mc.address);
@@ -116,8 +119,8 @@ class PriceFeedRegister extends SDKConstruct {
116
119
  `calling getUpdatablePriceFeeds in block ${this.sdk.currentBlock}`
117
120
  );
118
121
  const result = await this.provider.publicClient.readContract({
119
- address: marketCompressorAddress,
120
- abi: iMarketCompressorAbi,
122
+ address: priceFeedCompressorAddress,
123
+ abi: iPriceFeedCompressorAbi,
121
124
  functionName: "getUpdatablePriceFeeds",
122
125
  args: [
123
126
  {
@@ -50,7 +50,9 @@ class CreditAccountData_Legacy {
50
50
  this.underlying = payload.underlying.toLowerCase();
51
51
  this.expirationDate = Number(payload.expirationDate);
52
52
  this.version = Number(payload.cfVersion);
53
- this.healthFactor = Number(payload.healthFactor || 0n);
53
+ this.healthFactor = Number(
54
+ (payload.healthFactor || 0n) * PERCENTAGE_FACTOR / WAD
55
+ );
54
56
  this.enabledTokensMask = payload.enabledTokensMask;
55
57
  this.isDeleting = false;
56
58
  this.borrowedAmount = payload.debt;