-
Notifications
You must be signed in to change notification settings - Fork 821
/
sns.ts
44 lines (38 loc) · 1.24 KB
/
sns.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Adapter, FetchResultFees } from "../adapters/types";
import { CHAIN } from "../helpers/chains";
import { getTimestampAtStartOfDayUTC, getTimestampAtStartOfNextDayUTC } from "../utils/date";
import { httpGet } from "../utils/fetchURL";
const API_URL = "https://sns-api.bonfida.com/v2/defilama/fees-adapter";
interface IData {
daily_fees: number;
total_fees: number;
}
const fetch = async (timestamp: number): Promise<FetchResultFees> => {
const todaysTimestamp = getTimestampAtStartOfNextDayUTC(timestamp);
const fromTimestamp = getTimestampAtStartOfDayUTC(timestamp);
const url = `${API_URL}?from=${fromTimestamp}&to=${todaysTimestamp-1}`;
const data: IData = await httpGet(url);
return {
timestamp: todaysTimestamp,
dailyFees: data.daily_fees.toString(),
dailyRevenue: data.daily_fees.toString(),
totalFees: data.total_fees.toString(),
totalRevenue: data.total_fees.toString(),
};
};
const methodology = {
Fees: "registration cost and fees on secondary sales",
Revenue: "registration revenue and revenue from secondary sales",
};
const adapter: Adapter = {
adapter: {
[CHAIN.SOLANA]: {
fetch,
start: 1624941677,
meta: {
methodology,
},
},
},
};
export default adapter;