@gearbox-protocol/sdk 1.5.20 → 1.5.21

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.
@@ -23,6 +23,7 @@ export declare class CreditAccountData {
23
23
  balances: Record<string, BigNumber>;
24
24
  allBalances: Record<string, BigNumber>;
25
25
  isDeleting: boolean;
26
+ enabledTokenMask: BigNumber;
26
27
  readonly version: number;
27
28
  constructor(payload: CreditAccountDataPayload);
28
29
  balancesSorted(prices: Record<string, BigNumber>, tokens: Record<string, TokenData>): Array<Asset>;
@@ -55,6 +55,7 @@ var CreditAccountData = /** @class */ (function () {
55
55
  _this.allBalances[tokenLC] = ethers_1.BigNumber.from(b.balance);
56
56
  _this.allTokens.push(tokenLC);
57
57
  });
58
+ this.enabledTokenMask = ethers_1.BigNumber.from(payload.enabledTokenMask);
58
59
  this.isDeleting = false;
59
60
  this.version = ethers_1.BigNumber.from(payload.version || 1).toNumber();
60
61
  }
@@ -72,17 +73,19 @@ var CreditAccountData = /** @class */ (function () {
72
73
  CreditAccountData.prototype.updateHealthFactor = function (creditManager, currentCumulativeIndex, priceOracle) {
73
74
  var _this = this;
74
75
  var twvUSDValue = this.collateralTokens
76
+ .filter(function (_, num) {
77
+ return !ethers_1.BigNumber.from(2).pow(num).and(_this.enabledTokenMask).isZero();
78
+ })
75
79
  .map(function (token) {
76
80
  return priceOracle
77
81
  .convertToUSD(_this.balances[token], token)
78
82
  .mul(creditManager.liquidationThresholds[token]);
79
83
  })
80
84
  .reduce(function (a, b) { return a.add(b); });
81
- this.healthFactor =
82
- priceOracle
83
- .convertFromUSD(twvUSDValue, this.underlyingToken)
84
- .div(this.calcBorrowAmountPlusInterestRate(currentCumulativeIndex))
85
- .toNumber() / constants_1.PERCENTAGE_FACTOR;
85
+ this.healthFactor = priceOracle
86
+ .convertFromUSD(twvUSDValue, this.underlyingToken)
87
+ .div(this.calcBorrowAmountPlusInterestRate(currentCumulativeIndex))
88
+ .toNumber();
86
89
  };
87
90
  Object.defineProperty(CreditAccountData.prototype, "id", {
88
91
  get: function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "1.5.20",
3
+ "version": "1.5.21",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",