-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathgamma.ts
More file actions
179 lines (167 loc) · 4.16 KB
/
Copy pathgamma.ts
File metadata and controls
179 lines (167 loc) · 4.16 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import { FetchResultFees, SimpleAdapter, FetchOptions } from "../adapters/types";
import { CHAIN } from "../helpers/chains";
import fetchURL from "../utils/fetchURL";
interface Item {
chain: string;
total_fees: number;
total_revenue: number;
}
interface IData {
datetime: string;
items: Item[];
}
const _fetchApi = async (from_timestamp: number) => {
const url = `https://wire2.gamma.xyz/frontend/revenue_status/main_charts?from_timestamp=${from_timestamp}&yearly=false&monthly=false&filter_zero_revenue=false`;
const data: IData[] = (await fetchURL(url));
return data;
}
const query: { [key: number]: Promise<IData[]> } = {};
const fetchApi = async (from_timestamp: number) => {
if (!query[from_timestamp]) {
query[from_timestamp] = _fetchApi(from_timestamp)
}
return query[from_timestamp]
}
const fetch = async (options: FetchOptions): Promise<FetchResultFees> => {
const fromTimestamp = options.toTimestamp - 60 * 60 * 24
const data: IData[] = await fetchApi(fromTimestamp);
const dailyItem: IData | undefined = data.find((e: IData) => e.datetime.split('T')[0] === options.dateString)
const result: IData = dailyItem || { datetime: '', items: [] };
const dailyFees = result.items.filter((e: Item) => e.chain === options.chain)
.reduce((a: number, b: Item) => a + b.total_fees, 0);
const dailyRevenue = result.items.filter((e: Item) => e.chain === options.chain)
.reduce((a: number, b: Item) => a + b.total_revenue, 0);
return {
dailyFees,
dailyRevenue,
dailyProtocolRevenue: dailyRevenue,
}
}
const breakdownMethodology = {
Fees: {
'LP management fees': 'Performance and management fees charged on liquidity provider positions managed by Gamma across all integrated DEXs'
},
Revenue: {
'Protocol revenue': 'All management fees collected are retained by Gamma Protocol'
},
ProtocolRevenue: {
'Protocol revenue': 'All management fees collected are retained by Gamma Protocol'
}
};
const adapter: SimpleAdapter = {
fetch,
breakdownMethodology,
adapter: {
[CHAIN.ETHEREUM]: {
start: '2023-04-22',
},
[CHAIN.POLYGON]: {
start: '2023-04-22',
},
[CHAIN.POLYGON_ZKEVM]: {
start: '2023-04-22',
},
[CHAIN.OPTIMISM]: {
start: '2023-04-22',
},
[CHAIN.ARBITRUM]: {
start: '2023-04-22',
},
[CHAIN.BSC]: {
start: '2023-04-22',
},
[CHAIN.MOONBEAM]: {
start: '2023-04-22',
},
[CHAIN.CELO]: {
start: '2023-04-22',
},
[CHAIN.AVAX]: {
start: '2023-04-22',
},
[CHAIN.FANTOM]: {
start: '2023-04-22',
},
[CHAIN.MANTLE]: {
start: '2023-04-22',
},
[CHAIN.ROLLUX]: {
start: '2023-04-22',
},
[CHAIN.LINEA]: {
start: '2023-04-22',
},
[CHAIN.BASE]: {
start: '2023-04-22',
},
[CHAIN.KAVA]: {
start: '2023-04-22',
},
[CHAIN.OP_BNB]: {
start: '2023-04-22',
},
[CHAIN.MANTA]: {
start: '2023-04-22',
},
[CHAIN.METIS]: {
start: '2023-04-22',
},
[CHAIN.XDAI]: {
start: '2023-04-22',
},
// [CHAIN.ASTRZK]: {
// start: '2023-04-22',
// },
[CHAIN.IMX]: {
start: '2023-04-22',
},
[CHAIN.SCROLL]: {
start: '2023-04-22',
},
[CHAIN.BLAST]: {
start: '2023-04-22',
},
[CHAIN.XLAYER]: {
start: '2023-04-22',
},
[CHAIN.MODE]: {
start: '2023-04-22',
},
[CHAIN.TAIKO]: {
start: '2023-04-22',
},
[CHAIN.ROOTSTOCK]: {
start: '2023-04-22',
},
[CHAIN.SEI]: {
start: '2023-04-22',
},
[CHAIN.IOTAEVM]: {
start: '2023-04-22',
},
[CHAIN.CORE]: {
start: '2023-04-22',
},
[CHAIN.ZIRCUIT]: {
start: '2023-04-22',
},
[CHAIN.WC]: {
start: '2023-04-22',
},
[CHAIN.APECHAIN]: {
start: '2023-04-22',
},
[CHAIN.SONIC]: {
start: '2023-04-22',
},
[CHAIN.BOB]: {
start: '2023-04-22',
},
},
methodology: {
Fees: 'All yields are generated from liquidity providers.',
Revenue: 'All yields are distributed to Gamma Protocol.',
ProtocolRevenue: 'All yields are distributed to Gamma Protocol.',
},
}
export default adapter;