diff --git a/adapters/stargate/hourly_blocks.csv b/adapters/stargate/hourly_blocks.csv index cc795db9..72d296b1 100644 --- a/adapters/stargate/hourly_blocks.csv +++ b/adapters/stargate/hourly_blocks.csv @@ -1,2 +1,3 @@ number,timestamp -5154879,1717513197 \ No newline at end of file +11535322,1717513197 +11537120,1730541599 \ No newline at end of file diff --git a/adapters/stargate/src/index.ts b/adapters/stargate/src/index.ts index 51d95ea1..abff785c 100644 --- a/adapters/stargate/src/index.ts +++ b/adapters/stargate/src/index.ts @@ -36,16 +36,16 @@ const readBlocksFromCSV = async (filePath: string): Promise => { readBlocksFromCSV(path.resolve(__dirname, "../hourly_blocks.csv")) .then(async (blocks) => { - const streams = blocks.flatMap((block) => [ - new PositionsStream(block, POSITIONS_V1_SUBGRAPH_URL), - new PositionsStream(block, POSITIONS_V2_SUBGRAPH_URL), - ]); - - mergeStreams(streams); - }) - .catch((err) => { - console.error("Error reading CSV file:", err); - }); + for (const block of blocks) { + // Sequentially process each stream for the block + const v2Stream = new PositionsStream(block, POSITIONS_V2_SUBGRAPH_URL); + const v1Stream = new PositionsStream(block, POSITIONS_V1_SUBGRAPH_URL); + await mergeStreams([v1Stream, v2Stream]); + } +}) +.catch((err) => { + console.error("Error reading CSV file:", err); +}); function mergeStreams(positionStreams: PositionsStream[]) { const csvWriteStream = fs.createWriteStream(`outputData.csv`, { diff --git a/adapters/stargate/src/sdk/config.ts b/adapters/stargate/src/sdk/config.ts index 1578e272..78c44ed4 100644 --- a/adapters/stargate/src/sdk/config.ts +++ b/adapters/stargate/src/sdk/config.ts @@ -8,7 +8,7 @@ export const POSITIONS_V2_SUBGRAPH_URL = export const client = createPublicClient({ chain: linea, - transport: http(`https://linea-mainnet.infura.io/v3/${process.env.OPENBLOCK_LINEA_INFURA_API_KEY}`, { + transport: http(`https://rpc.linea.build`, { retryCount: 5, timeout: 60_000, }), diff --git a/adapters/stargate/src/sdk/lib.ts b/adapters/stargate/src/sdk/lib.ts index b7b370d2..14bd1f8a 100644 --- a/adapters/stargate/src/sdk/lib.ts +++ b/adapters/stargate/src/sdk/lib.ts @@ -3,6 +3,7 @@ import { client } from "./config"; import { Position } from "./types"; const WHITELISTED_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; +const FETCH_DELAY_MS = 5000 export const getTimestampAtBlock = async (blockNumber: number) => { const block = await client.getBlock({ @@ -23,6 +24,7 @@ export class PositionsStream extends Readable { } async _read() { + await new Promise(resolve => setTimeout(resolve, FETCH_DELAY_MS)); const query = ` query { farmPositions(