Skip to content

Commit

Permalink
Merge pull request #691 from timongll/aevo/changes
Browse files Browse the repository at this point in the history
split aevo options and perp volume
  • Loading branch information
dtmkeng committed Jul 31, 2023
2 parents c39a19c + 8edd362 commit be06420
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
45 changes: 45 additions & 0 deletions dexs/aevo/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { SimpleAdapter } from "../../adapters/types";
import fetchURL from "../../utils/fetchURL";
import { CHAIN } from "../../helpers/chains";

interface IAevoVolumeResponse {
daily_volume: string;
total_volume: string;
}

// endTime is in nanoseconds
export const aevoVolumeEndpoint = (endTime: number) => {
return "https://api.aevo.xyz/statistics?instrument_type=PERPETUAL&end_time=" + endTime;
}

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.ETHEREUM]: {
fetch: fetchAevoVolumeData,
start: async () => 1681430400
},
},
};

export async function fetchAevoVolumeData(
/** Timestamp representing the end of the 24 hour period */
timestamp: number
) {
const timestampInNanoSeconds = timestamp * 1e9
const aevoVolumeData = await getAevoVolumeData(aevoVolumeEndpoint(timestampInNanoSeconds));

const dailyVolume = Number(aevoVolumeData.daily_volume).toFixed(2);
const totalVolume = Number(aevoVolumeData.total_volume).toFixed(2);

return {
timestamp,
dailyVolume,
totalVolume,
};
}

async function getAevoVolumeData(endpoint: string): Promise<IAevoVolumeResponse> {
return (await fetchURL(endpoint))?.data;
}

export default adapter;
2 changes: 1 addition & 1 deletion options/aevo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface IAevoVolumeResponse {

// endTime is in nanoseconds
export const aevoVolumeEndpoint = (endTime: number) => {
return "https://api.aevo.xyz/statistics?end_time=" + endTime;
return "https://api.aevo.xyz/statistics?instrument_type=OPTION&end_time=" + endTime;
}

const adapter: SimpleAdapter = {
Expand Down

0 comments on commit be06420

Please sign in to comment.