Skip to content

Commit

Permalink
fix find data
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Apr 15, 2024
1 parent 6a6bba1 commit aabed9c
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions dexs/0x/zrx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ import { GraphQLClient, gql } from "graphql-request";
import { getUniqStartOfTodayTimestamp } from "../../../helpers/getUniSubgraphVolume";
import { getEnv } from "../../../helpers/env";
import { FetchOptions } from "../../../adapters/types";
import { CHAIN } from "../../../helpers/chains";

const CHAINS = [
"Arbitrum",
"Avalanche",
"Base",
"BSC",
"Celo",
"Ethereum",
"Fantom",
"Optimism",
"Polygon",
];
type TChain = {
[key: string]: string;
}
const CHAINS: TChain = {
[CHAIN.ARBITRUM]: "Arbitrum",
[CHAIN.AVAX]: "Avalanche",
[CHAIN.BASE]: "Base",
[CHAIN.BSC]: "BSC",
[CHAIN.CELO]: "Celo",
[CHAIN.ETHEREUM]: "Ethereum",
[CHAIN.FANTOM]: "Fantom",
[CHAIN.OPTIMISM]: "Optimism",
[CHAIN.POLYGON]: "Polygon",
};

const graphQLClient = new GraphQLClient("https://api.0x.org/data/v0");
const getGQLClient = () => {
Expand Down Expand Up @@ -48,9 +52,10 @@ const fetch = async (options: FetchOptions) => {
);
try {
const data = await getVolumeByChain(options.chain);
const strDate = new Date(unixTimestamp * 1000).toISOString().split("T")[0];
const dayData = data.find(
({ timestamp }: { timestamp: number }) =>
getUniqStartOfTodayTimestamp(new Date(timestamp)) === unixTimestamp
({ timestamp }: { timestamp: string }) =>
timestamp.split("T")[0] === strDate
);
return {
dailyVolume: dayData.volumeUSD,
Expand Down

0 comments on commit aabed9c

Please sign in to comment.