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.
@@ -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
- const data = results[i].data.impermaxFactories[0];
510
- if (data != null) {
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
- const data = results[i].data.impermaxFactories[0];
534
- if (data != null) {
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) => pair.chainId.includes(chainId) && (pair.baseToken.address.toLowerCase() == tokenAddress || pair.quoteToken.address.toLowerCase() == tokenAddress));
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) {
@@ -171,6 +171,9 @@ class PonderQueryBuilder {
171
171
  totalBorrowsUSD
172
172
  }
173
173
  }
174
+ _meta {
175
+ status
176
+ }
174
177
  }
175
178
  `;
176
179
  }
@@ -173,6 +173,12 @@ class TheGraphQueryBuilder {
173
173
  totalSupplyUSD
174
174
  totalBorrowsUSD
175
175
  }
176
+ _meta {
177
+ block {
178
+ number
179
+ }
180
+ hasIndexingErrors
181
+ }
176
182
  }`;
177
183
  }
178
184
  /*-----------------------------*
@@ -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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "1.2.107",
3
+ "version": "1.2.108",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",