@defillama/sdk 5.0.172 → 5.0.175

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.
@@ -44,8 +44,8 @@ function modifyEndpoint(endpoint, network = 'arbitrum') {
44
44
  return endpoint;
45
45
  else if (!graphKey) {
46
46
  graphKey = "5a1340b49fa9efe00" + "21452daa260564e";
47
- if (!graphKeyWarned)
48
- console.log("GRAPH_API_KEY env variable is not set, using the default api key");
47
+ // if (!graphKeyWarned)
48
+ // console.log("GRAPH_API_KEY env variable is not set, using the default api key")
49
49
  graphKeyWarned = true;
50
50
  }
51
51
  endpoint = endpoint.replace('[api-key]', graphKey);
@@ -204,7 +204,15 @@ async function getLogs(options) {
204
204
  const chainIndexStatus = await getChainIndexStatus("v2");
205
205
  const lastIndexedBlock = (_b = (_a = chainIndexStatus[chain]) === null || _a === void 0 ? void 0 : _a.block) !== null && _b !== void 0 ? _b : 0;
206
206
  if (lastIndexedBlock < toBlock) {
207
- throw new Error(`Indexer not up to date for ${chain}. Last indexed block: ${lastIndexedBlock}, requested block: ${toBlock}`);
207
+ const percentageMissing = ((toBlock - lastIndexedBlock) / (toBlock - fromBlock)) * 100;
208
+ if (percentageMissing > 50) // more than 50% of the requested range is missing, throw an error and so we pull the logs through rpc calls
209
+ throw new Error(`Indexer not up to date for ${chain}. Last indexed block: ${lastIndexedBlock}, requested block: ${toBlock}`);
210
+ (0, debugLog_1.debugLog)(`Indexer only partially up to date for ${chain}. Last indexed block: ${lastIndexedBlock}, requested block: ${toBlock}, missing ${percentageMissing}%. Pulling part of the logs through RPC calls.`);
211
+ // now we split the request into two parts, one that goes to the indexer and one that goes through rpc calls
212
+ const breakBlock = lastIndexedBlock - 50; // we add a small buffer to avoid missing logs due to reorgs
213
+ const indexerLogs = await getLogs({ ...options, fromBlock, toBlock: breakBlock });
214
+ const rpcLogs = await (0, logs_1.getLogs)({ ...options, fromBlock: breakBlock + 1, toBlock, skipIndexer: true });
215
+ return indexerLogs.concat(rpcLogs);
208
216
  }
209
217
  // Re‑curse if the requested range is too large ------------------------------------------------
210
218
  if (blockRange > effectiveMaxBlockRange) {
@@ -126,6 +126,7 @@ const chainShortNameMapping = {
126
126
  fraxtal: 'frax',
127
127
  elsm: 'ely',
128
128
  tac: 'tacchain',
129
+ xone: 'xoc',
129
130
  };
130
131
  async function filterForWorkingRPCs(rpc, chain, chainId) {
131
132
  if (rpc.length < 10)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "5.0.172",
3
+ "version": "5.0.175",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -9,6 +9,8 @@
9
9
  "watch": "tsc --watch",
10
10
  "load-providers": "wget https://unpkg.com/@defillama/sdk@latest/build/providers.json -O build/providers.json",
11
11
  "test": "npm run load-providers && TEST_MODE=true LLAMA_DEBUG_MODE='' SDK_DEBUG='' LLAMA_DEBUG_LEVEL2='' jest",
12
+ "test-only": "echo 'skipped building providers.json' && TEST_MODE=true LLAMA_DEBUG_MODE='' SDK_DEBUG='' LLAMA_DEBUG_LEVEL2='' jest",
13
+ "test-debug": "jest",
12
14
  "update-providers": "ts-node src/util/updateProviderList.ts",
13
15
  "remove-rpcs": "ts-node src/util/removeRedundantRPCs.ts",
14
16
  "format": "prettier --write \"src/**/*.ts\"",