From 48d4b2144f53abc170d4c3ee5bf9c5b2628aa6c9 Mon Sep 17 00:00:00 2001 From: chef-plankton Date: Fri, 19 Jul 2024 23:58:37 +0330 Subject: [PATCH] integrate AKKA in aggregators --- aggregators/akka/index.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 aggregators/akka/index.ts diff --git a/aggregators/akka/index.ts b/aggregators/akka/index.ts new file mode 100644 index 0000000000..528cc4181c --- /dev/null +++ b/aggregators/akka/index.ts @@ -0,0 +1,35 @@ +import fetchURL from "../../utils/fetchURL" +import { FetchResult, SimpleAdapter } from "../../adapters/types"; +import { CHAIN } from "../../helpers/chains"; +import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; + +const URL = 'https://routerv2.akka.finance'; +const endpoint = '/v2/1116/statistics/dappradar'; +const startTimestamp = 1717200000;// 6/1/2024 + +interface IAPIResponse { + dailyVolume: string; + totalVolume: string; +} + +const fetch = async (timestamp: number): Promise => { + const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); + const { dailyVolume, totalVolume }: IAPIResponse = (await fetchURL(`${URL}${endpoint}`)); + return { + dailyVolume, + totalVolume, + timestamp: dayTimestamp, + }; +} + +const adapter: SimpleAdapter = { + version: 2, + adapter: { + [CHAIN.CORE]: { + fetch, + start: startTimestamp, + }, + }, +}; + +export default adapter;