From 08265c5594a7afd6330d96fc7b1a96380c08dae4 Mon Sep 17 00:00:00 2001 From: Mantas S Date: Tue, 4 Feb 2025 16:52:37 +0200 Subject: [PATCH] Update uniswapV3chain.ts --- src/util/calculators/uniswapV3chain.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util/calculators/uniswapV3chain.ts b/src/util/calculators/uniswapV3chain.ts index eff1efe..07ac6b5 100644 --- a/src/util/calculators/uniswapV3chain.ts +++ b/src/util/calculators/uniswapV3chain.ts @@ -80,6 +80,8 @@ async function getTvl( let offset = 10000; + let iterationCount = 0; // New iteration counter + if (Math.max(v3Pairs.block, startBlock) < block) { for (let i = Math.max(v3Pairs.block, startBlock); ; ) { console.log(`Trying from ${i} with offset ${offset}`); @@ -127,8 +129,10 @@ async function getTvl( token1.push(`0x${log.topics[2].slice(26)}`); }); + iterationCount++; // Increment the iteration counter + // Save into cache every 25 iterations - if (((i - Math.max(v3Pairs.block, startBlock)) / offset) % 25 === 0) { + if (iterationCount % 25 === 0) { console.log('save'); await basicUtil.saveIntoCache( i,