From 30292862bf210688034ecc34e243f9bd8a9a64f4 Mon Sep 17 00:00:00 2001 From: graykode Date: Fri, 14 Jul 2023 20:51:14 +0900 Subject: [PATCH] feat: add `totalVolume` for Clober Dex --- dexs/clober/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dexs/clober/index.ts b/dexs/clober/index.ts index 14a19e9f94..8ad856d2ee 100644 --- a/dexs/clober/index.ts +++ b/dexs/clober/index.ts @@ -5,22 +5,27 @@ import { CHAIN } from "../../helpers/chains"; type TMarket = { volumeUsd24h: number; + accumulatedVolumeUsd: number; } type TVolume = { volume_usd24h: number; + accumulated_volume_usd: number; } const fetch = (chain: string) => async (timestamp: number) => { const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) const { markets }: { markets: TMarket[] } = (await fetchURL(`https://prod.clober-api.com/${chain}/markets`)).data; let dailyVolume = markets.map(market => market.volumeUsd24h).reduce((acc, cur) => acc + cur, 0) + let totalVolume = markets.map(market => market.accumulatedVolumeUsd).reduce((acc, cur) => acc + cur, 0) if (chain === '1101') { const {result}: {result: TVolume} = (await fetchURL(`https://pathfinder.clober-api.com/status`)).data; dailyVolume += result.volume_usd24h; + totalVolume += result.accumulated_volume_usd; } return { dailyVolume: `${dailyVolume}`, + totalVolume: `${totalVolume}`, timestamp: dayTimestamp, }; };