Skip to content

Commit

Permalink
fix(dexs): switched from dune to api
Browse files Browse the repository at this point in the history
  • Loading branch information
Javokhir Artykov committed Jun 14, 2024
1 parent 945a1a3 commit 28e49b4
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions dexs/azuro/index.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 = {
Expand Down

0 comments on commit 28e49b4

Please sign in to comment.