Skip to content

Commit

Permalink
Add AVNU aggregators volume
Browse files Browse the repository at this point in the history
  • Loading branch information
0xlny committed Jun 24, 2023
1 parent dd95a22 commit 624085f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions aggregators/avnu/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import fetchURL from "../../utils/fetchURL"
import { FetchResult, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume";

const URL = 'https://starknet.api.avnu.fi';
const endpoint = '/v1/analytics/volumes/';
const startTimestamp = 1684108800;// 15.05.2023

interface IAPIResponse {
date: number;
dailyVolume: string;
totalVolume: string;
}
const fetch = async (timestamp: number): Promise<FetchResult> => {
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000));
const {dailyVolume, totalVolume}: IAPIResponse = (await fetchURL(`${URL}${endpoint}${timestamp * 1000}`)).data;
return {
dailyVolume,
totalVolume,
timestamp: dayTimestamp,
};
}

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.STARKNET]: {
fetch,
start: async () => startTimestamp,
},
},
};

export default adapter;

0 comments on commit 624085f

Please sign in to comment.