impermax-sdk 1.2.107 → 1.2.108
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/offchainInitializer.js +6 -4
- package/lib/offchain/offchainPriceHelper.js +1 -1
- package/lib/offchain/queries/apis/ponder/index.js +3 -0
- package/lib/offchain/queries/apis/thegraph/index.js +6 -0
- package/lib/offchain/queries/index.d.ts +4 -0
- package/lib/offchain/queries/index.js +6 -0
- package/package.json +1 -1
|
@@ -506,8 +506,9 @@ function initializeTvlData() {
|
|
|
506
506
|
let i = 0;
|
|
507
507
|
for (const network of networks) {
|
|
508
508
|
for (const _ in subgraphs_1.IMPERMAX_SUBGRAPH_URL[network]) {
|
|
509
|
-
|
|
510
|
-
|
|
509
|
+
// Need to pluralize `impermaxFactory`
|
|
510
|
+
const data = queries_1.QueryBuilderFactory.getImpermaxFactory(results[i]);
|
|
511
|
+
if (data) {
|
|
511
512
|
crossChainTVLUSD += parseFloat(data.totalBalanceUSD);
|
|
512
513
|
crossChainSupplyUSD += parseFloat(data.totalSupplyUSD);
|
|
513
514
|
crossChainBorrowUSD += parseFloat(data.totalBorrowsUSD);
|
|
@@ -530,8 +531,9 @@ function initializeTvlData() {
|
|
|
530
531
|
const results = yield Promise.all(calls);
|
|
531
532
|
i = 0;
|
|
532
533
|
for (const _ in subgraphs_1.IMPERMAX_SUBGRAPH_URL[this.network]) {
|
|
533
|
-
|
|
534
|
-
|
|
534
|
+
// Need to pluralize `impermaxFactory`
|
|
535
|
+
const data = queries_1.QueryBuilderFactory.getImpermaxFactory(results[i]);
|
|
536
|
+
if (data) {
|
|
535
537
|
thisChainTVLUSD += parseFloat(data.totalBalanceUSD);
|
|
536
538
|
thisChainSupplyUSD += parseFloat(data.totalSupplyUSD);
|
|
537
539
|
thisChainBorrowUSD += parseFloat(data.totalBorrowsUSD);
|
|
@@ -223,7 +223,7 @@ class OffchainPriceHelper {
|
|
|
223
223
|
if (!data || !data.pairs || data.pairs.length === 0)
|
|
224
224
|
return 0;
|
|
225
225
|
const pairs = data.pairs;
|
|
226
|
-
const pairItem = pairs.filter((pair) =>
|
|
226
|
+
const pairItem = pairs.filter((pair) => chainId.includes(pair.chainId) && (pair.baseToken.address.toLowerCase() == tokenAddress || pair.quoteToken.address.toLowerCase() == tokenAddress));
|
|
227
227
|
return pairItem.length > 0 ? pairItem[0].priceUsd : 0;
|
|
228
228
|
}
|
|
229
229
|
catch (_a) {
|
|
@@ -8,6 +8,10 @@ export declare class QueryBuilderFactory {
|
|
|
8
8
|
* Gets an API's query builder given an endpoint
|
|
9
9
|
*/
|
|
10
10
|
static getQuery(endpoint: string): IQueryBuilder;
|
|
11
|
+
/**
|
|
12
|
+
* Ponder does not pluralize like the graph so `factory` becomes `factorys`, etc.
|
|
13
|
+
*/
|
|
14
|
+
static getImpermaxFactory(input: ApolloQueryResult<any>): any;
|
|
11
15
|
/**
|
|
12
16
|
* Helper to transform nested query results from various apis during apollo fetch.
|
|
13
17
|
* Mainly used for Ponder as the graphql schema is different to thegraph due to pagination.
|
|
@@ -16,6 +16,12 @@ class QueryBuilderFactory {
|
|
|
16
16
|
return new ponder_1.PonderQueryBuilder();
|
|
17
17
|
return new thegraph_1.TheGraphQueryBuilder();
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Ponder does not pluralize like the graph so `factory` becomes `factorys`, etc.
|
|
21
|
+
*/
|
|
22
|
+
static getImpermaxFactory(input) {
|
|
23
|
+
return input.data.impermaxFactories ? input.data.impermaxFactories[0] : input.data.impermaxFactorys[0];
|
|
24
|
+
}
|
|
19
25
|
/**
|
|
20
26
|
* Helper to transform nested query results from various apis during apollo fetch.
|
|
21
27
|
* Mainly used for Ponder as the graphql schema is different to thegraph due to pagination.
|