@defillama/sdk 5.0.173 → 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.
- package/build/providers.json +1 -1
- package/build/util/indexer.js +9 -1
- package/package.json +3 -1
package/build/util/indexer.js
CHANGED
|
@@ -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
|
-
|
|
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) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defillama/sdk",
|
|
3
|
-
"version": "5.0.
|
|
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\"",
|