From a5d3d62c0718e60e77f822402a7c92002e91f329 Mon Sep 17 00:00:00 2001 From: Alex Sanchez Date: Wed, 5 Jun 2024 13:16:42 +0200 Subject: [PATCH] add autolayer --- dexs/autolayer/index.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 dexs/autolayer/index.ts diff --git a/dexs/autolayer/index.ts b/dexs/autolayer/index.ts new file mode 100644 index 0000000000..a7aadd4465 --- /dev/null +++ b/dexs/autolayer/index.ts @@ -0,0 +1,31 @@ +import { FetchResult, FetchV2, SimpleAdapter } from '../../adapters/types'; +import { queryDune } from '../../helpers/dune'; +import { CHAIN } from "../../helpers/chains"; + +const formatDate = (timestamp: number): string => + new Date(timestamp * 1000).toISOString().substring(0, 10); + +const fetch: FetchV2 = async (options): Promise => { + const { startOfDay } = options; + + const result = await queryDune("3800672", { + time: formatDate(startOfDay) + }); + + const { daily_volume: dailyVolume, cumulative_volume: totalVolume } = result[0]; + + return { dailyVolume, totalVolume, timestamp: startOfDay }; +} + +const adapter: SimpleAdapter = { + version: 2, + adapter: { + [CHAIN.ARBITRUM]: { + fetch, + start: 1709114400, + }, + }, + isExpensiveAdapter: true +}; + +export default adapter;