-
Notifications
You must be signed in to change notification settings - Fork 1k
/
dodo-fees.ts
46 lines (41 loc) · 1.26 KB
/
dodo-fees.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
45
46
import { Adapter, BreakdownAdapter } from "../adapters/types";
import { request, gql } from "graphql-request";
const feesReq = gql`
query FetchDashboardPairs($where: Dashboardrate24h_filter) {
dashboard_pairs_rate_24(where: $where) {
pages
pairs
__typename
}
}
`
const adapter: Adapter = {
adapter: ["ethereum", "bsc", "polygon", "arbitrum", "aurora", "boba"].reduce((all, chain)=>({
...all,
[chain]: {
fetch: async()=>{
const pairs = await request("https://gateway.dodoex.io/graphql?opname=FetchDashboardPairs", feesReq,
{ "where": { "page": 1, "limit": 10, "order_direction": "desc", "order_by": "fee", "chain": chain } }, {
"Content-Type": "application/json",
"user-agent": "insomnia/2022.5.0"
})
const fees = Object.values(pairs.dashboard_pairs_rate_24.pairs)
.filter((p:any)=> Number(p.tvl) > 1000)
.reduce((sum:number, p:any)=>sum+Number(p.fee), 0);
return {
timestamp: Date.now()/1e3,
dailyFees: fees,
dailyRevenue: fees*0.2,
};
},
runAtCurrTime: true,
}
}), {} as any)
};
const breakdownAdapter: BreakdownAdapter = {
version: 1,
breakdown: {
"dodo": adapter.adapter
}
}
export default breakdownAdapter;