-
Notifications
You must be signed in to change notification settings - Fork 951
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #691 from timongll/aevo/changes
split aevo options and perp volume
- Loading branch information
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters