Skip to content

Commit

Permalink
Merge pull request #317 from delta-hq/revert-316-stargate-fix
Browse files Browse the repository at this point in the history
Revert "[stargate] add delay between calls"
  • Loading branch information
0xroll authored Nov 2, 2024
2 parents 9d7d5e2 + 1c1e3d9 commit b13a0f1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
3 changes: 1 addition & 2 deletions adapters/stargate/hourly_blocks.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
number,timestamp
11535322,1717513197
11537120,1730541599
5154879,1717513197
20 changes: 10 additions & 10 deletions adapters/stargate/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ const readBlocksFromCSV = async (filePath: string): Promise<BlockData[]> => {

readBlocksFromCSV(path.resolve(__dirname, "../hourly_blocks.csv"))
.then(async (blocks) => {
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);
});
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);
});

function mergeStreams(positionStreams: PositionsStream[]) {
const csvWriteStream = fs.createWriteStream(`outputData.csv`, {
Expand Down
2 changes: 1 addition & 1 deletion adapters/stargate/src/sdk/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const POSITIONS_V2_SUBGRAPH_URL =

export const client = createPublicClient({
chain: linea,
transport: http(`https://rpc.linea.build`, {
transport: http(`https://linea-mainnet.infura.io/v3/${process.env.OPENBLOCK_LINEA_INFURA_API_KEY}`, {
retryCount: 5,
timeout: 60_000,
}),
Expand Down
2 changes: 0 additions & 2 deletions adapters/stargate/src/sdk/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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({
Expand All @@ -24,7 +23,6 @@ export class PositionsStream extends Readable {
}

async _read() {
await new Promise(resolve => setTimeout(resolve, FETCH_DELAY_MS));
const query = `
query {
farmPositions(
Expand Down

0 comments on commit b13a0f1

Please sign in to comment.