Skip to content

Commit

Permalink
fix issue filter time
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Feb 16, 2024
1 parent e287080 commit 5d18ae3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions dexs/zkSwap_Finance/zkswapFinance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ const getData = async ({ chain, startOfDay, createBalances}: FetchOptions) => {
let dayMiliseconds = 24 * 60 * 60;
let returnCount = 1000;

let lasTimestampQuery = startOfDay;
let fromTimestamp = startOfDay - dayMiliseconds;
const todaysTimestamp = startOfDay;

while (returnCount == 1000) {
const graphQL = `{
swaps(
orderBy: timestamp
orderDirection: asc
first: 1000
where: {timestamp_gte: ${lasTimestampQuery}, timestamp_lt: ${
startOfDay + dayMiliseconds
} }
where: {timestamp_gte: ${fromTimestamp}, timestamp_lt: ${todaysTimestamp} }
) {
amount0In
amount0Out
Expand All @@ -44,7 +43,7 @@ const getData = async ({ chain, startOfDay, createBalances}: FetchOptions) => {
const data = await request(info[chain].subgraph_v1, graphQL);
returnCount = data.swaps.length;

lasTimestampQuery = data?.swaps[returnCount - 1]?.timestamp;
fromTimestamp = data?.swaps[returnCount - 1]?.timestamp;

for (const swap of data.swaps) {
const token0Id = swap.pair.token0.id;
Expand Down

0 comments on commit 5d18ae3

Please sign in to comment.