impermax-sdk 1.2.138 → 1.2.139
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
|
@@ -171,23 +171,29 @@ class Offchain {
|
|
|
171
171
|
async getTotalValueLocked() {
|
|
172
172
|
// Try llama
|
|
173
173
|
const { tvl } = await this.getAPRHelper().getLlamaTvlAndBorrows(this.network);
|
|
174
|
+
if (tvl)
|
|
175
|
+
return tvl;
|
|
174
176
|
// Fallback to subgraph
|
|
175
177
|
const tvlData = await this.getTvlData();
|
|
176
|
-
return tvl
|
|
178
|
+
return tvl > tvlData.totalBalanceUSD ? tvl : tvlData.totalBalanceUSD;
|
|
177
179
|
}
|
|
178
180
|
async getTotalValueSupplied() {
|
|
179
181
|
// Try llama
|
|
180
182
|
const { totalSupplied } = await this.getAPRHelper().getLlamaTvlAndBorrows(this.network);
|
|
183
|
+
if (totalSupplied)
|
|
184
|
+
return totalSupplied;
|
|
181
185
|
// Fallback to subgraph
|
|
182
186
|
const tvlData = await this.getTvlData();
|
|
183
|
-
return totalSupplied
|
|
187
|
+
return totalSupplied > tvlData.totalSupplyUSD ? totalSupplied : tvlData.totalSupplyUSD;
|
|
184
188
|
}
|
|
185
189
|
async getTotalValueBorrowed() {
|
|
186
190
|
// Try llama
|
|
187
191
|
const { borrowed } = await this.getAPRHelper().getLlamaTvlAndBorrows(this.network);
|
|
192
|
+
if (borrowed)
|
|
193
|
+
return borrowed;
|
|
188
194
|
// Fallback to subgraph
|
|
189
195
|
const tvlData = await this.getTvlData();
|
|
190
|
-
return borrowed
|
|
196
|
+
return borrowed > tvlData.totalBorrowsUSD ? borrowed : tvlData.totalBorrowsUSD;
|
|
191
197
|
}
|
|
192
198
|
// IMX Staking
|
|
193
199
|
async getXIMXAPY() {
|
|
@@ -117,10 +117,11 @@ class OffchainAPRHelper {
|
|
|
117
117
|
async initializePoolsBorrow() {
|
|
118
118
|
try {
|
|
119
119
|
const response = await fetch("https://yields.llama.fi/poolsBorrow").then((i) => i.json());
|
|
120
|
-
const impermaxPools = response.data.filter((i) => i.project === "impermax-
|
|
120
|
+
const impermaxPools = response.data.filter((i) => i.project === "impermax-v2" || i.project === "impermax-v3");
|
|
121
121
|
this.chainsTotalSupplied = impermaxPools.reduce((acc, pool) => {
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
// OP is outdated, report to llama
|
|
123
|
+
const chain = pool.chain.toLowerCase() === "optimism" ? "op mainnet" : pool.chain.toLowerCase();
|
|
124
|
+
acc[chain] = (acc[chain] || 0) + pool.totalSupplyUsd;
|
|
124
125
|
return acc;
|
|
125
126
|
}, {});
|
|
126
127
|
}
|