@defillama/sdk 2.3.121 → 2.3.122
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/util/index.js +5 -2
- package/package.json +1 -1
package/build/util/index.js
CHANGED
|
@@ -142,7 +142,7 @@ function lookupBlock(timestamp, extraParams) {
|
|
|
142
142
|
var _a, _b, _c, _d;
|
|
143
143
|
if (extraParams === void 0) { extraParams = {}; }
|
|
144
144
|
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
-
var chain, low, lowBlock, highBlock, provider, _e, lastBlock, firstBlock, block, i, time, allowedTimeRange, imprecision, getPrecision_1, blockDiff, timeDiff, avgBlockTime, closeBlock, midBlock, blocks, e_1;
|
|
145
|
+
var chain, low, lowBlock, highBlock, provider, _e, lastBlock, firstBlock, block, i, time, allowedTimeRange, acceptableBlockImprecision, blockImprecision, imprecision, getPrecision_1, blockDiff, timeDiff, avgBlockTime, closeBlock, midBlock, blocks, e_1;
|
|
146
146
|
return __generator(this, function (_f) {
|
|
147
147
|
switch (_f.label) {
|
|
148
148
|
case 0:
|
|
@@ -175,6 +175,8 @@ function lookupBlock(timestamp, extraParams) {
|
|
|
175
175
|
time = Date.now();
|
|
176
176
|
allowedTimeRange = 15 * 60 // how much imprecision is allowed (15 minutes now)
|
|
177
177
|
;
|
|
178
|
+
acceptableBlockImprecision = chain === 'ethereum' ? 20 : 200;
|
|
179
|
+
blockImprecision = void 0;
|
|
178
180
|
imprecision = void 0;
|
|
179
181
|
getPrecision_1 = function (block) { return block.timestamp - timestamp > 0 ? block.timestamp - timestamp : timestamp - block.timestamp; };
|
|
180
182
|
_f.label = 3;
|
|
@@ -198,9 +200,10 @@ function lookupBlock(timestamp, extraParams) {
|
|
|
198
200
|
lowBlock = blocks.filter(function (i) { return i.timestamp < timestamp; }).reduce(function (lowestBlock, block) { return (timestamp - lowestBlock.timestamp) < (timestamp - block.timestamp) ? lowestBlock : block; });
|
|
199
201
|
highBlock = blocks.filter(function (i) { return i.timestamp > timestamp; }).reduce(function (highestBlock, block) { return (highestBlock.timestamp - timestamp) < (block.timestamp - timestamp) ? highestBlock : block; });
|
|
200
202
|
imprecision = getPrecision_1(block);
|
|
203
|
+
blockImprecision = highBlock.number - lowBlock.number;
|
|
201
204
|
_f.label = 5;
|
|
202
205
|
case 5:
|
|
203
|
-
if (imprecision > allowedTimeRange) return [3 /*break*/, 3];
|
|
206
|
+
if (imprecision > allowedTimeRange && blockImprecision > acceptableBlockImprecision) return [3 /*break*/, 3];
|
|
204
207
|
_f.label = 6;
|
|
205
208
|
case 6:
|
|
206
209
|
if (process.env.LLAMA_DEBUG_MODE)
|