@gearbox-protocol/sdk 3.0.0-next.96 → 3.0.0-next.98

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.
@@ -182,24 +182,26 @@ class CreditAccountData {
182
182
  static calcHealthFactor({ assets, quotas, quotasInfo, liquidationThresholds, underlyingToken, debt, prices, }) {
183
183
  const [, underlyingDecimals] = (0, sdk_gov_1.extractTokenData)(underlyingToken);
184
184
  const underlyingPrice = prices[underlyingToken] || 0n;
185
- const assetLTMoney = assets.reduce((acc, { token: tokenAddress, balance: amount }) => {
185
+ const assetMoney = assets.reduce((acc, { token: tokenAddress, balance: amount }) => {
186
186
  const [, tokenDecimals] = (0, sdk_gov_1.extractTokenData)(tokenAddress);
187
187
  const lt = liquidationThresholds[tokenAddress] || 0n;
188
188
  const price = prices[tokenAddress] || 0n;
189
189
  const tokenMoney = price_1.PriceUtils.calcTotalPrice(price, amount, tokenDecimals);
190
+ const tokenLtMoney = (tokenMoney * lt) / sdk_gov_1.PERCENTAGE_FACTOR;
190
191
  const { isActive = false } = quotasInfo?.[tokenAddress] || {};
191
192
  const quota = quotas[tokenAddress];
192
193
  const quotaBalance = isActive ? quota?.balance || 0n : 0n;
193
194
  const quotaMoney = price_1.PriceUtils.calcTotalPrice(underlyingPrice, quotaBalance, underlyingDecimals);
194
195
  // if quota is undefined, then it is not a quoted token
195
196
  const money = quota
196
- ? math_1.BigIntMath.min(quotaMoney, tokenMoney)
197
- : tokenMoney;
198
- const ltMoney = money * lt;
199
- return acc + ltMoney;
197
+ ? math_1.BigIntMath.min(quotaMoney, tokenLtMoney)
198
+ : tokenLtMoney;
199
+ return acc + money;
200
200
  }, 0n);
201
201
  const borrowedMoney = price_1.PriceUtils.calcTotalPrice(underlyingPrice || sdk_gov_1.PRICE_DECIMALS, debt, underlyingDecimals);
202
- const hfInPercent = borrowedMoney > 0n ? assetLTMoney / borrowedMoney : 0n;
202
+ const hfInPercent = borrowedMoney > 0n
203
+ ? (assetMoney * sdk_gov_1.PERCENTAGE_FACTOR) / borrowedMoney
204
+ : 0n;
203
205
  return Number(hfInPercent);
204
206
  }
205
207
  static calcQuotaUpdate({ quotas, initialQuotas, assetsAfterUpdate, allowedToSpend, allowedToObtain, quotaReserve, }) {
@@ -59,6 +59,8 @@ export declare class CreditManagerData {
59
59
  export declare class ChartsCreditManagerData {
60
60
  readonly address: string;
61
61
  readonly underlyingToken: string;
62
+ readonly configurator: string;
63
+ readonly creditFacade: string;
62
64
  readonly pool: string;
63
65
  readonly version: number;
64
66
  readonly name: string;
@@ -229,6 +229,8 @@ exports.CreditManagerData = CreditManagerData;
229
229
  class ChartsCreditManagerData {
230
230
  address;
231
231
  underlyingToken;
232
+ configurator;
233
+ creditFacade;
232
234
  pool;
233
235
  version;
234
236
  name;
@@ -269,6 +271,8 @@ class ChartsCreditManagerData {
269
271
  constructor(payload) {
270
272
  this.address = (payload.addr || "").toLowerCase();
271
273
  this.underlyingToken = (payload.underlyingToken || "").toLowerCase();
274
+ this.configurator = (payload.configurator || "").toLowerCase();
275
+ this.creditFacade = (payload.creditFacade || "").toLowerCase();
272
276
  this.pool = (payload.poolAddress || "").toLowerCase();
273
277
  this.version = payload.version || 2;
274
278
  this.name = payload.name || "";
@@ -14,6 +14,8 @@ export type CreditManagerDataPayload = ExcludeArrayProps<CreditManagerDataStruct
14
14
  export interface ChartsCreditManagerPayload {
15
15
  addr: string;
16
16
  underlyingToken: string;
17
+ configurator: string;
18
+ creditFacade: string;
17
19
  isWeth: boolean;
18
20
  poolAddress: string;
19
21
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-next.96",
3
+ "version": "3.0.0-next.98",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",