Skip to content

Commit

Permalink
add bsx volume data
Browse files Browse the repository at this point in the history
  • Loading branch information
bsx-engineering committed May 1, 2024
1 parent f36d6d9 commit 1c4cee6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions dexs/bsx/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { SimpleAdapter, FetchV2 } from "../../adapters/types";
import fetchURL from "../../utils/fetchURL";
import { CHAIN } from "../../helpers/chains";
import { getTimestampAtStartOfPreviousDayUTC } from "../../utils/date";

interface IBsxStatsResponse {
volume_24h: string;
volume_total: string;
}

const fetchBsxVolumeData: FetchV2 = async ({ endTimestamp }) => {
const url = "https://api.bsx.exchange/defillama-stats?end_time=" + endTimestamp * 1e9;
const data: IBsxStatsResponse = await fetchURL(url);
const dailyVolume = Number(data.volume_24h).toFixed(2);
const totalVolume = Number(data.volume_total).toFixed(2);

return {
timestamp: endTimestamp,
dailyVolume,
totalVolume,
};
}

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.BASE]: {
fetch: fetchBsxVolumeData,
start: 1711929600,
},
},
};

export default adapter;

0 comments on commit 1c4cee6

Please sign in to comment.