-
Notifications
You must be signed in to change notification settings - Fork 825
/
index.ts
98 lines (88 loc) · 2.19 KB
/
index.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { Chain } from "@defillama/sdk/build/types";
import { BaseAdapter, BreakdownAdapter, IJSON } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getGraphDimensions } from "../../helpers/getUniSubgraph";
const endpoints = {
[CHAIN.KLAYTN]: "https://graph.dgswap.io/subgraphs/name/dragonswap/exchange-v2",
};
const v3Endpoint = {
[CHAIN.KLAYTN]: "https://graph.dgswap.io/subgraphs/name/dragonswap/exchange-v3",
};
const VOLUME_USD = "volumeUSD";
const startTimes = {
[CHAIN.KLAYTN]: 1707297572,
} as IJSON<number>;
const v3StartTimes = {
[CHAIN.KLAYTN]: 1707297572,
} as IJSON<number>;
const methodology = {
UserFees: "User pays 0.3% fees on each swap.",
ProtocolRevenue: "Treasury receives 0.06% of each swap.",
SupplySideRevenue: "LPs receive 0.24% of the fees.",
HoldersRevenue: "",
Revenue: "All revenue generated comes from user fees.",
Fees: "All fees comes from the user."
}
const graphs = getGraphDimensions({
graphUrls: endpoints,
graphRequestHeaders: {
[CHAIN.KLAYTN]: {
"origin": "https://dgswap.io",
},
},
totalVolume: {
factory: "pancakeFactories"
},
dailyVolume: {
factory: "pancakeDayData"
},
feesPercent: {
type: "volume",
Fees: 0.3,
ProtocolRevenue: 0.06,
HoldersRevenue: 0,
UserFees: 0.3,
SupplySideRevenue: 0.24,
Revenue: 0.06
}
});
const v3Graph = getGraphDimensions({
graphUrls: v3Endpoint,
totalVolume: {
factory: "factories",
},
dailyVolume: {
factory: "pancakeDayData",
field: VOLUME_USD
},
totalFees: {
factory: "factories",
},
dailyFees: {
factory: "pancakeDayData",
field: "feesUSD"
},
});
const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v2: Object.keys(endpoints).reduce((acc, chain) => {
acc[chain] = {
fetch: graphs(chain as Chain),
start: startTimes[chain],
meta: {
methodology
}
}
return acc
}, {} as BaseAdapter),
v3: Object.keys(v3Endpoint).reduce((acc, chain) => {
acc[chain] = {
fetch: v3Graph(chain),
start: v3StartTimes[chain],
}
return acc
}, {} as BaseAdapter),
},
};
export default adapter;