impermax-sdk 1.2.6 → 1.2.8

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.
@@ -86,12 +86,28 @@ class OffchainAccount {
86
86
  }
87
87
  getLendingVaultsSuppliedUSD() {
88
88
  return __awaiter(this, void 0, void 0, function* () {
89
- return 0;
89
+ let suppliedUSD = 0;
90
+ const lendingVaultUserData = yield this.getLendingVaultsUserData();
91
+ if (lendingVaultUserData === null)
92
+ return 0;
93
+ for (const address in lendingVaultUserData) {
94
+ const lendingVault = yield this.getLendingVault(address);
95
+ suppliedUSD += yield lendingVault.getValue();
96
+ }
97
+ return suppliedUSD;
90
98
  });
91
99
  }
92
100
  getLendingVaultsEarningsUSD() {
93
101
  return __awaiter(this, void 0, void 0, function* () {
94
- return 0;
102
+ let earningsUSD = 0;
103
+ const lendingVaultUserData = yield this.getLendingVaultsUserData();
104
+ if (lendingVaultUserData === null)
105
+ return 0;
106
+ for (const address in lendingVaultUserData) {
107
+ const lendingVault = yield this.getLendingVault(address);
108
+ earningsUSD += yield lendingVault.getEarningsUSD();
109
+ }
110
+ return earningsUSD;
95
111
  });
96
112
  }
97
113
  }
@@ -9,6 +9,7 @@ export default class OffchainLendingVault extends OffchainPoolToken {
9
9
  getOffchain: () => Offchain;
10
10
  getVaultAddress: () => string;
11
11
  getPoolTokenData(): Promise<PoolTokenData>;
12
+ private getTotalSupply;
12
13
  private getLastUpdate;
13
14
  private getAccrueFactor;
14
15
  getCurrentExchangeRate(): Promise<number>;
@@ -27,6 +27,11 @@ class OffchainLendingVault extends offchainPoolToken_1.default {
27
27
  return this.offchain.getLendingVaultData(this.vaultAddress);
28
28
  });
29
29
  }
30
+ getTotalSupply() {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ return this.getPoolTokenParamFloat("totalSupply");
33
+ });
34
+ }
30
35
  getLastUpdate() {
31
36
  return __awaiter(this, void 0, void 0, function* () {
32
37
  return this.getPoolTokenParamInt("lastUpdate");
@@ -34,7 +39,7 @@ class OffchainLendingVault extends offchainPoolToken_1.default {
34
39
  }
35
40
  getAccrueFactor() {
36
41
  return __awaiter(this, void 0, void 0, function* () {
37
- const now = Date.now() * 1000;
42
+ const now = Date.now() / 1000;
38
43
  const timeElapsed = now - (yield this.getLastUpdate());
39
44
  const supplyRate = yield this.getSupplyRate();
40
45
  return 1 + timeElapsed * supplyRate;
@@ -50,9 +55,9 @@ class OffchainLendingVault extends offchainPoolToken_1.default {
50
55
  // Vault Supply
51
56
  getVaultSupply() {
52
57
  return __awaiter(this, void 0, void 0, function* () {
53
- const totalBalance = yield this.getTotalBalance();
54
- const accrueFactor = yield this.getAccrueFactor();
55
- return totalBalance * accrueFactor;
58
+ const totalSupply = yield this.getTotalSupply();
59
+ const exchageRate = yield this.getCurrentExchangeRate();
60
+ return totalSupply * exchageRate;
56
61
  });
57
62
  }
58
63
  getVaultSupplyUSD() {
@@ -239,6 +239,7 @@ function lendingVaultsQuery(addressesFilter) {
239
239
  decimals
240
240
  }
241
241
  totalBalance
242
+ totalSupply
242
243
  supplyRate
243
244
  reserveFactor
244
245
  exchangeRate
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",