impermax-sdk 2.1.3 → 2.1.4
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.
package/lib/offchain/offchain.js
CHANGED
|
@@ -165,7 +165,9 @@ class Offchain {
|
|
|
165
165
|
return Promise.all(requests);
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
|
-
|
|
168
|
+
/* --------------------------------------------------
|
|
169
|
+
* Cross chain stats
|
|
170
|
+
* -------------------------------------------------*/
|
|
169
171
|
getCrossChainTVL() {
|
|
170
172
|
return __awaiter(this, void 0, void 0, function* () {
|
|
171
173
|
// Try llama
|
|
@@ -179,16 +181,28 @@ class Offchain {
|
|
|
179
181
|
}
|
|
180
182
|
getCrossChainTotalValueSupplied() {
|
|
181
183
|
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
// Try llama
|
|
185
|
+
const llamaSupplied = yield this.getAPRHelper().getImpermaxTotalSupplied();
|
|
186
|
+
if (llamaSupplied)
|
|
187
|
+
return llamaSupplied;
|
|
188
|
+
// Fallback to subgraph
|
|
182
189
|
const tvlData = yield this.getTvlData();
|
|
183
190
|
return tvlData.crossChainSupplyUSD;
|
|
184
191
|
});
|
|
185
192
|
}
|
|
186
193
|
getCrossChainTotalValueBorrowed() {
|
|
187
194
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
+
// Try llama
|
|
196
|
+
const llamaBorrows = yield this.getAPRHelper().getImpermaxBorrows();
|
|
197
|
+
if (llamaBorrows)
|
|
198
|
+
return llamaBorrows;
|
|
188
199
|
const tvlData = yield this.getTvlData();
|
|
189
200
|
return tvlData.crossChainBorrowUSD;
|
|
190
201
|
});
|
|
191
202
|
}
|
|
203
|
+
/* --------------------------------------------------
|
|
204
|
+
* Same as above, but for specific networks.
|
|
205
|
+
* -------------------------------------------------*/
|
|
192
206
|
// This chain TVL Data
|
|
193
207
|
getTotalValueLocked() {
|
|
194
208
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -223,6 +237,9 @@ class Offchain {
|
|
|
223
237
|
return tvlData.totalBorrowsUSD;
|
|
224
238
|
});
|
|
225
239
|
}
|
|
240
|
+
/* --------------------------------------------------
|
|
241
|
+
* Misc
|
|
242
|
+
* -------------------------------------------------*/
|
|
226
243
|
// IMX Staking
|
|
227
244
|
getXIMXAPY() {
|
|
228
245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -232,6 +249,9 @@ class Offchain {
|
|
|
232
249
|
return Math.pow(1 + parseFloat(ximxData.dailyAPR), 365) - 1;
|
|
233
250
|
});
|
|
234
251
|
}
|
|
252
|
+
/* --------------------------------------------------
|
|
253
|
+
* Charts
|
|
254
|
+
* -------------------------------------------------*/
|
|
235
255
|
getProtocolChart() {
|
|
236
256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
237
257
|
const protocolTvlChart = yield this.getAPRHelper().getProtocolTvlChart();
|
|
@@ -40,6 +40,7 @@ export default class OffchainAPRHelper {
|
|
|
40
40
|
}>;
|
|
41
41
|
getImpermaxBorrows(): Promise<number>;
|
|
42
42
|
getImpermaxTvl(): Promise<number>;
|
|
43
|
+
getImpermaxTotalSupplied(): Promise<number>;
|
|
43
44
|
getProtocolTvlChart(): Promise<LlamaTvlChart>;
|
|
44
45
|
getChainTvlChart(chain: Networks): Promise<LlamaTvlChart>;
|
|
45
46
|
}
|
|
@@ -216,6 +216,16 @@ class OffchainAPRHelper {
|
|
|
216
216
|
return crossChainTvl;
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
|
+
getImpermaxTotalSupplied() {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
const totalSuppliedYields = yield this.getChainsTotalSupplied();
|
|
222
|
+
let totalSupplied = 0;
|
|
223
|
+
for (const supplied of Object.values(totalSuppliedYields)) {
|
|
224
|
+
totalSupplied += supplied;
|
|
225
|
+
}
|
|
226
|
+
return totalSupplied;
|
|
227
|
+
});
|
|
228
|
+
}
|
|
219
229
|
// Charts
|
|
220
230
|
// Impermax historic TVL chart
|
|
221
231
|
getProtocolTvlChart() {
|