Skip to content

Commit

Permalink
Update uniswapV3chain.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mantasfam committed Feb 4, 2025
1 parent 0dfe1dc commit 08265c5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/util/calculators/uniswapV3chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 08265c5

Please sign in to comment.