impermax-sdk 2.1.413 → 2.1.415
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
|
@@ -148,8 +148,6 @@ class Offchain {
|
|
|
148
148
|
this.whitelistData = null;
|
|
149
149
|
this.solidexHelper.cleanCache();
|
|
150
150
|
this.configManager.cleanCache();
|
|
151
|
-
this.getPriceHelper().cleanCache();
|
|
152
|
-
this.getAPRHelper().cleanCache();
|
|
153
151
|
this.borrowersList = null;
|
|
154
152
|
this.userNewlyEarnedFeesData = {};
|
|
155
153
|
this.xibexUsersData = {};
|
|
@@ -14,14 +14,7 @@ import { AddressIndex } from "../config/types";
|
|
|
14
14
|
import OffchainAccount from "./account/offchainAccount";
|
|
15
15
|
import { PairState } from '../config/whitelist';
|
|
16
16
|
import { LlamaTvlChart } from './offchainAPRHelper';
|
|
17
|
-
|
|
18
|
-
token: `${Networks}:${Address}`;
|
|
19
|
-
id: Address;
|
|
20
|
-
symbol: string;
|
|
21
|
-
name: string;
|
|
22
|
-
decimals: number;
|
|
23
|
-
chainId: number;
|
|
24
|
-
};
|
|
17
|
+
import { Token } from "./offchainPriceHelper";
|
|
25
18
|
export declare enum SortDirection {
|
|
26
19
|
ASC = "asc",
|
|
27
20
|
DESC = "desc"
|
|
@@ -93,6 +86,5 @@ export default class OffchainMultichain {
|
|
|
93
86
|
totalCollateralUSD: number;
|
|
94
87
|
}>;
|
|
95
88
|
getImpermaxTvlChart(network?: Networks): Promise<LlamaTvlChart>;
|
|
96
|
-
getNetworkTokens(networks?: Networks[]): Promise<
|
|
89
|
+
getNetworkTokens(networks?: Networks[]): Promise<Token[]>;
|
|
97
90
|
}
|
|
98
|
-
export {};
|
|
@@ -256,71 +256,21 @@ class OffchainMultichain {
|
|
|
256
256
|
return impermaxTvlChart;
|
|
257
257
|
}
|
|
258
258
|
async getNetworkTokens(networks) {
|
|
259
|
-
const
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
// Get borrowables
|
|
275
|
-
const [borrowableA, borrowableB] = await Promise.all([lendingPool.getBorrowableA(), lendingPool.getBorrowableB()]);
|
|
276
|
-
// Get underlyings
|
|
277
|
-
const tokenPromises = [borrowableA, borrowableB].map(async (borrowable) => {
|
|
278
|
-
try {
|
|
279
|
-
const [address, symbol, name, decimals] = await Promise.all([
|
|
280
|
-
borrowable.getUnderlyingAddress(),
|
|
281
|
-
borrowable.getSymbol(),
|
|
282
|
-
borrowable.getName(),
|
|
283
|
-
borrowable.getDecimals(),
|
|
284
|
-
]);
|
|
285
|
-
if (!address)
|
|
286
|
-
return null;
|
|
287
|
-
return {
|
|
288
|
-
token: `${network}:${address}`,
|
|
289
|
-
id: address,
|
|
290
|
-
symbol,
|
|
291
|
-
name,
|
|
292
|
-
decimals,
|
|
293
|
-
chainId,
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
catch (error) {
|
|
297
|
-
console.error(`Error getting token details for borrowable in pool ${poolId}:`, error);
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
const tokens = await Promise.all(tokenPromises);
|
|
302
|
-
return tokens.filter((token) => token !== null);
|
|
303
|
-
}
|
|
304
|
-
catch (error) {
|
|
305
|
-
console.error(`Error processing pool ${poolId} in factory ${factory} on ${network}:`, error);
|
|
306
|
-
return [];
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
const poolResults = await Promise.all(poolPromises);
|
|
310
|
-
return poolResults.flat();
|
|
311
|
-
});
|
|
312
|
-
const factoryResults = await Promise.all(factoryPromises);
|
|
313
|
-
const networkTokens = factoryResults.flat();
|
|
314
|
-
networkTokens.forEach(tokenData => tokenMap.set(tokenData.token, tokenData));
|
|
315
|
-
return networkTokens;
|
|
316
|
-
}
|
|
317
|
-
catch (error) {
|
|
318
|
-
console.error(`Error processing network ${network}:`, error);
|
|
319
|
-
return [];
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
await Promise.all(networkPromises);
|
|
323
|
-
return Array.from(tokenMap.values());
|
|
259
|
+
const lendingPools = await this.getLendingPoolList({ networks });
|
|
260
|
+
const tokenSet = new Set();
|
|
261
|
+
await Promise.all(lendingPools.map(async (pool) => {
|
|
262
|
+
const network = pool.getOffchain().network;
|
|
263
|
+
const [borrowableA, borrowableB] = await Promise.all([
|
|
264
|
+
pool.getBorrowableA(),
|
|
265
|
+
pool.getBorrowableB()
|
|
266
|
+
]);
|
|
267
|
+
const addresses = await Promise.all([
|
|
268
|
+
borrowableA.getUnderlyingAddress(),
|
|
269
|
+
borrowableB.getUnderlyingAddress()
|
|
270
|
+
]);
|
|
271
|
+
addresses.forEach(addr => tokenSet.add(`${network}:${addr}`));
|
|
272
|
+
}));
|
|
273
|
+
return Array.from(tokenSet);
|
|
324
274
|
}
|
|
325
275
|
}
|
|
326
276
|
exports.default = OffchainMultichain;
|