From e57f0777ffc65cf93cec0ab1c2099a0b388b488b Mon Sep 17 00:00:00 2001 From: not found Date: Sun, 30 Jul 2023 17:48:49 +0700 Subject: [PATCH 1/3] rename file and change volume query --- dexs/zkSwap_Finance/index.ts | 2 +- .../{zkswapFiance.ts => zkswapFinance.ts} | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) rename dexs/zkSwap_Finance/{zkswapFiance.ts => zkswapFinance.ts} (86%) diff --git a/dexs/zkSwap_Finance/index.ts b/dexs/zkSwap_Finance/index.ts index a020f5a10e..51d42f1eac 100644 --- a/dexs/zkSwap_Finance/index.ts +++ b/dexs/zkSwap_Finance/index.ts @@ -1,6 +1,6 @@ import { SimpleAdapter } from "../../adapters/types"; import { CHAIN } from "../../helpers/chains"; -import { fetchVolume } from "./zkswapFiance"; +import { fetchVolume } from "./zkswapFinance"; const adapter: SimpleAdapter = { adapter: { diff --git a/dexs/zkSwap_Finance/zkswapFiance.ts b/dexs/zkSwap_Finance/zkswapFinance.ts similarity index 86% rename from dexs/zkSwap_Finance/zkswapFiance.ts rename to dexs/zkSwap_Finance/zkswapFinance.ts index 817787b5ca..f3287695bf 100644 --- a/dexs/zkSwap_Finance/zkswapFiance.ts +++ b/dexs/zkSwap_Finance/zkswapFinance.ts @@ -53,18 +53,20 @@ const getData = async (chain: string, timestamp: number) => { totalSum += Number(pair.volumeToken0) * price0 } + let lasTimestampQuery = startDayTimestamp while (returnCount == 1000) { + console.log("aaa", lasTimestampQuery, startDayTimestamp + dayMiliseconds) const graphQL = `{ swaps( - orderBy: id - orderDirection: desc - first: 1000 - skip: ${step * 1000} - where: {timestamp_gt: ${startDayTimestamp}, timestamp_lt: ${startDayTimestamp + dayMiliseconds} } + orderBy: timestamp + orderDirection: desc + first: 1000 + where: {timestamp_gt: ${lasTimestampQuery}, timestamp_lt: ${startDayTimestamp + dayMiliseconds} } ) { amount0In amount0Out + timestamp pair { token0 { id @@ -76,8 +78,7 @@ const getData = async (chain: string, timestamp: number) => { const data = await request(info[chain].subgraph, graphQL); returnCount = data.swaps.length; - step++; - + lasTimestampQuery = data?.swaps[0]?.timestamp | 0 for (const swap of data.swaps) { From 9d1a28df260f09525e9a1f84f9ed20a8a2348b1a Mon Sep 17 00:00:00 2001 From: not found Date: Sun, 30 Jul 2023 17:52:25 +0700 Subject: [PATCH 2/3] removelog --- dexs/zkSwap_Finance/zkswapFinance.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/dexs/zkSwap_Finance/zkswapFinance.ts b/dexs/zkSwap_Finance/zkswapFinance.ts index f3287695bf..4662120f0e 100644 --- a/dexs/zkSwap_Finance/zkswapFinance.ts +++ b/dexs/zkSwap_Finance/zkswapFinance.ts @@ -56,7 +56,6 @@ const getData = async (chain: string, timestamp: number) => { let lasTimestampQuery = startDayTimestamp while (returnCount == 1000) { - console.log("aaa", lasTimestampQuery, startDayTimestamp + dayMiliseconds) const graphQL = `{ swaps( orderBy: timestamp From b77e3670b96602eb47b8703f02a08353af98a007 Mon Sep 17 00:00:00 2001 From: not found Date: Sun, 30 Jul 2023 22:34:19 +0700 Subject: [PATCH 3/3] fixed query --- dexs/zkSwap_Finance/zkswapFinance.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dexs/zkSwap_Finance/zkswapFinance.ts b/dexs/zkSwap_Finance/zkswapFinance.ts index 4662120f0e..361b592566 100644 --- a/dexs/zkSwap_Finance/zkswapFinance.ts +++ b/dexs/zkSwap_Finance/zkswapFinance.ts @@ -59,9 +59,9 @@ const getData = async (chain: string, timestamp: number) => { const graphQL = `{ swaps( orderBy: timestamp - orderDirection: desc + orderDirection: asc first: 1000 - where: {timestamp_gt: ${lasTimestampQuery}, timestamp_lt: ${startDayTimestamp + dayMiliseconds} } + where: {timestamp_gte: ${lasTimestampQuery}, timestamp_lt: ${startDayTimestamp + dayMiliseconds} } ) { amount0In amount0Out @@ -71,13 +71,12 @@ const getData = async (chain: string, timestamp: number) => { id } } - timestamp } }`; const data = await request(info[chain].subgraph, graphQL); returnCount = data.swaps.length; - lasTimestampQuery = data?.swaps[0]?.timestamp | 0 + lasTimestampQuery = data?.swaps[returnCount-1]?.timestamp for (const swap of data.swaps) {