-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
523e542
commit ebb9711
Showing
1 changed file
with
38 additions
and
0 deletions.
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,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; |