Skip to content

Commit

Permalink
Merge pull request #1899 from SHADOWDANCH/swap-coffee
Browse files Browse the repository at this point in the history
Add swap.coffee adapter
  • Loading branch information
dtmkeng committed Sep 14, 2024
2 parents e72a220 + ebb9711 commit d5b128e
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 d5b128e

Please sign in to comment.