impermax-sdk 1.0.27 → 1.0.29

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.
@@ -66,7 +66,7 @@ exports.BLOCKS_SUBGRAPH_URL = {
66
66
  [types_1.Networks.Aurora]: '',
67
67
  [types_1.Networks.Cronos]: '',
68
68
  [types_1.Networks.Fantom]: 'https://api.thegraph.com/subgraphs/name/matthewlilley/fantom-blocks',
69
- [types_1.Networks.Canto]: '',
69
+ [types_1.Networks.Canto]: 'https://api.impermax.finance/subgraphs/name/blocklytics/canto-blocks',
70
70
  [types_1.Networks.Harmony]: '',
71
71
  [types_1.Networks.Moonbeam]: '',
72
72
  [types_1.Networks.Sxnetwork]: '',
@@ -64,6 +64,8 @@ function fetchBlockByTimestamp(timestamp) {
64
64
  return __awaiter(this, void 0, void 0, function* () {
65
65
  const result = yield this.apolloFetcher(subgraphs_1.BLOCKS_SUBGRAPH_URL[this.network], query.blockQuery(timestamp));
66
66
  console.log(result.data._meta.block.number);
67
+ if (!result.data.blocks[0])
68
+ return null;
67
69
  return result.data.blocks[0].number;
68
70
  });
69
71
  }
@@ -90,6 +92,8 @@ function fetchLendingPoolsPast(seconds) {
90
92
  return __awaiter(this, void 0, void 0, function* () {
91
93
  const timestamp = Math.floor((new Date).getTime() / 1000);
92
94
  const blockNumber = yield this.fetchBlockByTimestamp(timestamp - seconds);
95
+ if (!blockNumber)
96
+ return null;
93
97
  try {
94
98
  const calls = [];
95
99
  for (const factory of Object.keys(subgraphs_1.IMPERMAX_SUBGRAPH_URL[this.network])) {
@@ -150,6 +154,8 @@ function fetchPastVolume(amm, lendingPools, seconds) {
150
154
  return __awaiter(this, void 0, void 0, function* () {
151
155
  const timestamp = Math.floor((new Date).getTime() / 1000);
152
156
  const blockNumber = yield this.fetchBlockByTimestamp(timestamp - seconds);
157
+ if (!blockNumber)
158
+ return {};
153
159
  let result;
154
160
  const pastVolume = {};
155
161
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",