/
liquid-bolt.ts
93 lines (80 loc) · 2.32 KB
/
liquid-bolt.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
import { CHAIN } from "../helpers/chains";
import { BaseAdapter, Adapter } from "../adapters/types";
import { httpGet } from "../utils/fetchURL";
const methodology = {
UserFees: "20% performance fees on the arbitrage revenue",
Fees: "The revenue distributed by the arbitrage robots",
Revenue: "20% performance fees on the arbitrage revenue",
ProtocolRevenue: "20% performance fees on the arbitrage revenue",
HoldersRevenue: "No token yet",
SupplySideRevenue: "80% of arbitrage revenue to Liquidity Providers"
}
let cachedData: any = undefined;
const getData = async () => {
if (cachedData === undefined) {
cachedData = (await httpGet('https://stats.liquidbolt.finance/defillama-liquidbolt.json'));
}
return cachedData;
}
const fetch = (chain: string) => {
return async (timestamp: number) => {
const data = await getData();
const stats = data.chains.find((item: any) => item.chain === chain);
return {
timestamp,
totalUserFees: stats.total_user_fees,
dailyUserFees: stats.daily_user_fees,
totalFees: stats.total_fees,
dailyFees: stats.daily_fees,
totalRevenue: stats.total_revenue,
dailyRevenue: stats.daily_revenue,
totalProtocolRevenue: stats.total_protocol_revenue,
dailyProtocolRevenue: stats.daily_protocol_revenue,
totalHoldersRevenue: stats.total_holders_revenue,
dailyHoldersRevenue: stats.daily_holders_revenue,
totalSupplySideRevenue: stats.total_supply_side_revenue,
dailySupplySideRevenue: stats.daily_supply_side_revenue,
};
}
}
const getAdapter = () => {
const baseAdapter: BaseAdapter = {
[CHAIN.FANTOM]: {
fetch: fetch(CHAIN.FANTOM),
start: 1669312800,
runAtCurrTime: true,
meta: {
methodology
}
},
[CHAIN.ARBITRUM]: {
fetch: fetch(CHAIN.ARBITRUM),
start: 1675893600,
runAtCurrTime: true,
meta: {
methodology
}
},
[CHAIN.BSC]: {
fetch: fetch(CHAIN.BSC),
start: 1669312800,
runAtCurrTime: true,
meta: {
methodology
}
},
[CHAIN.POLYGON]: {
fetch: fetch(CHAIN.POLYGON),
start: 1669312800,
runAtCurrTime: true,
meta: {
methodology
}
},
}
return baseAdapter;
}
const adapter: Adapter = {
adapter: getAdapter()
};
export default adapter;