From 945a1a393959545bc9edd6ff8865ca79c4729056 Mon Sep 17 00:00:00 2001 From: Javokhir Artykov Date: Thu, 6 Jun 2024 15:26:56 +0500 Subject: [PATCH 1/2] dexs azuro --- dexs/azuro/index.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 dexs/azuro/index.ts diff --git a/dexs/azuro/index.ts b/dexs/azuro/index.ts new file mode 100644 index 0000000000..b7d887e855 --- /dev/null +++ b/dexs/azuro/index.ts @@ -0,0 +1,42 @@ +import { CHAIN } from "../../helpers/chains"; +import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; +import { queryDune } from "../../helpers/dune"; +import type { SimpleAdapter, FetchOptions } from "../../adapters/types"; + +type TChain = { + [key: string]: string; + }; + +const CHAINS: TChain = { + [CHAIN.POLYGON]: "polygon", + [CHAIN.XDAI]: "gnosis", + [CHAIN.ARBITRUM]: "arbitrum" +}; + +const fetch = async (options: FetchOptions) => { + const unixTimestamp = getUniqStartOfTodayTimestamp(new Date(options.endTimestamp * 1000)); + const data = await queryDune("3800632", { endTime: unixTimestamp, blockchain: options.chain }); + + return { + dailyVolume: data[0].daily_volume, + totalVolume: data[0].total_volume, + timestamp: unixTimestamp, + }; +}; + +const adapter: any = { + version: 2, + adapter: { + ...Object.values(CHAINS).reduce((acc, chain) => { + return { + ...acc, + [chain]: { + fetch: fetch, + start: 1717372800, + }, + }; + }, {}), + }, + }; + +export default adapter; From 28e49b4fbee3488ce9c98b48416f79b4c08c2499 Mon Sep 17 00:00:00 2001 From: Javokhir Artykov Date: Fri, 14 Jun 2024 10:31:07 +0500 Subject: [PATCH 2/2] fix(dexs): switched from dune to api --- dexs/azuro/index.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/dexs/azuro/index.ts b/dexs/azuro/index.ts index b7d887e855..c14556f878 100644 --- a/dexs/azuro/index.ts +++ b/dexs/azuro/index.ts @@ -1,7 +1,7 @@ import { CHAIN } from "../../helpers/chains"; import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; -import { queryDune } from "../../helpers/dune"; -import type { SimpleAdapter, FetchOptions } from "../../adapters/types"; +import type { FetchOptions } from "../../adapters/types"; +import { httpGet } from "../../utils/fetchURL"; type TChain = { [key: string]: string; @@ -13,15 +13,31 @@ const CHAINS: TChain = { [CHAIN.ARBITRUM]: "arbitrum" }; +const URL = 'https://api.azuro.org/volumes/' + const fetch = async (options: FetchOptions) => { const unixTimestamp = getUniqStartOfTodayTimestamp(new Date(options.endTimestamp * 1000)); - const data = await queryDune("3800632", { endTime: unixTimestamp, blockchain: options.chain }); + const { data } = await httpGet(URL, { + params: { + blockchain: options.chain, + endTime: unixTimestamp + } + }); + + if (!data) { + return { + dailyVolume: '0', + totalVolume: '0', + timestamp: unixTimestamp, + }; + } return { - dailyVolume: data[0].daily_volume, + dailyVolume: data[0].daily_volume ?? '0', totalVolume: data[0].total_volume, timestamp: unixTimestamp, }; + }; const adapter: any = {