Skip to content

Commit

Permalink
Merge pull request #688 from ZkSwapFinance/master
Browse files Browse the repository at this point in the history
rename and fixed volume query
  • Loading branch information
dtmkeng authored Jul 30, 2023
2 parents 1a5ce47 + b77e367 commit ddeb2ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dexs/zkSwap_Finance/index.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,30 @@ const getData = async (chain: string, timestamp: number) => {
totalSum += Number(pair.volumeToken0) * price0
}

let lasTimestampQuery = startDayTimestamp

while (returnCount == 1000) {
const graphQL = `{
swaps(
orderBy: id
orderDirection: desc
first: 1000
skip: ${step * 1000}
where: {timestamp_gt: ${startDayTimestamp}, timestamp_lt: ${startDayTimestamp + dayMiliseconds} }
orderBy: timestamp
orderDirection: asc
first: 1000
where: {timestamp_gte: ${lasTimestampQuery}, timestamp_lt: ${startDayTimestamp + dayMiliseconds} }
) {
amount0In
amount0Out
timestamp
pair {
token0 {
id
}
}
timestamp
}
}`;

const data = await request(info[chain].subgraph, graphQL);
returnCount = data.swaps.length;
step++;

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

for (const swap of data.swaps) {

Expand Down

0 comments on commit ddeb2ea

Please sign in to comment.