impermax-sdk 2.1.7 → 2.1.8

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.
@@ -65,26 +65,32 @@ exports.fetchBlockByTimestamp = fetchBlockByTimestamp;
65
65
  function fetchVaults() {
66
66
  return __awaiter(this, void 0, void 0, function* () {
67
67
  const calls = [];
68
+ const vaultTypes = [];
68
69
  let vaultType;
69
70
  for (vaultType in subgraphs_1.VAULT_SUBGRAPH_URL[this.network]) {
70
71
  const subgraphs = subgraphs_1.VAULT_SUBGRAPH_URL[this.network][vaultType];
71
72
  if (!subgraphs || subgraphs.length === 0)
72
73
  continue;
73
74
  calls.push(this.endpointManager.fetch(subgraphs, this.network, (queryBuilder) => queryBuilder.vaultsQuery(vaultType, [])));
75
+ vaultTypes.push(vaultType);
74
76
  }
75
77
  const results = yield Promise.all(calls);
76
78
  const vaults = {};
77
- let i = 0;
78
- for (vaultType in subgraphs_1.VAULT_SUBGRAPH_URL[this.network]) {
79
- const subgraphs = subgraphs_1.VAULT_SUBGRAPH_URL[this.network][vaultType];
80
- if (!subgraphs || subgraphs.length === 0)
81
- continue;
82
- // WARN: data.lendingVaults will be wrong for different vaults! In the subgraph schema
83
- // we should name it to just vaults and replace here once done.
84
- const vaultsForType = results[i++].data.lendingVaults;
79
+ results.forEach((result, index) => {
80
+ var _a;
81
+ // `offchainEndpointManager` returns null when using filters and cant find subgraph with filter
82
+ if (!result)
83
+ return;
84
+ // Get the vault type for this result
85
+ const vaultType = vaultTypes[index];
86
+ // WARN: data.lendingVaults will be wrong for different vaults! We should rename it to just vaults
87
+ const vaultsForType = (_a = result.data) === null || _a === void 0 ? void 0 : _a.lendingVaults;
88
+ if (!vaultsForType)
89
+ return;
90
+ // Add all vaults for this vault type
85
91
  const typedVaults = vaultsForType.map((vault) => (Object.assign(Object.assign({}, vault), { vaultType })));
86
92
  vaults[vaultType] = typedVaults;
87
- }
93
+ });
88
94
  return vaults;
89
95
  });
90
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",