Skip to content

Commit

Permalink
Add swap.coffee adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
SHADOWDANCH committed Sep 12, 2024
1 parent 523e542 commit ebb9711
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions aggregators/swap-coffee/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Adapter, FetchV2 } from "../../adapters/types";
import { httpGet } from "../../utils/fetchURL";
import { CHAIN } from "../../helpers/chains";
import { DAY, getTimestampAtStartOfDay } from "../../utils/date";

const statisticsEndpoint = "https://backend.swap.coffee/v1/statistics/generic"

const fetch: FetchV2 = async ({startTimestamp}) => {
const start = getTimestampAtStartOfDay(startTimestamp)
const end = start + DAY

const statistics = await httpGet(
statisticsEndpoint,
{
params: {
from: start,
to: end
}
})

return {
timestamp: end,
dailyVolume: statistics?.volume,
dailyFees: statistics?.fees,
};
}

const adapter: Adapter = {
version: 2,
adapter: {
[CHAIN.TON]: {
fetch,
start: 1717957740,
},
}
}

export default adapter;

0 comments on commit ebb9711

Please sign in to comment.