Skip to content

Commit e1a8e69

Browse files
authored
Merge pull request #1563 from bryansniyve/master
feat: fetchTotalVolume for apx
2 parents 8547088 + cd10fae commit e1a8e69

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

dexs/apollox/index.ts

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ type V1TickerItem = {
3535
count: number;
3636
};
3737

38+
type TotalVolumeItem = {
39+
"alpFeeVOFor24Hour": {
40+
"fee": number
41+
"revenue": number
42+
},
43+
"allAlpFeeVO": {
44+
"fee": number
45+
"revenue": number
46+
},
47+
"cumVol": number
48+
}
49+
50+
const TotalVolumeAPI = "https://www.apollox.finance/bapi/futures/v1/public/future/apx/fee/all"
51+
3852
const v2VolumeAPI =
3953
"https://www.apollox.finance/bapi/future/v1/public/future/apx/pair";
4054

@@ -56,17 +70,26 @@ const fetchV1Volume = async () => {
5670
return dailyVolume
5771
};
5872

73+
const fetchTotalVolume = async (chain: Chain) => {
74+
const { data } = (
75+
await httpGet(TotalVolumeAPI, { params: { chain, } })
76+
) as { data: TotalVolumeItem }
77+
78+
return data.cumVol
79+
};
5980
const adapter: SimpleAdapter = {
6081
adapter: {
6182
[CHAIN.BSC]: {
6283
runAtCurrTime: true,
6384
fetch: async (timestamp) => {
64-
const [v1, v2] = await Promise.all([
85+
const [v1, v2, totalVolume] = await Promise.all([
6586
fetchV2Volume(CHAIN.BSC),
6687
fetchV1Volume(),
88+
fetchTotalVolume(CHAIN.BSC),
6789
]);
6890
return {
6991
dailyVolume: v1 + v2,
92+
totalVolume,
7093
timestamp,
7194
};
7295
},
@@ -75,32 +98,44 @@ const adapter: SimpleAdapter = {
7598
[CHAIN.ARBITRUM]: {
7699
runAtCurrTime: true,
77100
fetch: async (timestamp) => {
78-
const dailyVolume = await fetchV2Volume(CHAIN.ARBITRUM);
101+
const [v2, totalVolume] = await Promise.all([
102+
fetchV2Volume(CHAIN.ARBITRUM),
103+
fetchTotalVolume(CHAIN.ARBITRUM),
104+
]);
79105
return {
80106
timestamp,
81-
dailyVolume: dailyVolume,
107+
dailyVolume: v2,
108+
totalVolume,
82109
};
83110
},
84111
start: 1682035200,
85112
},
86113
[CHAIN.OP_BNB]: {
87114
runAtCurrTime: true,
88115
fetch: async (timestamp) => {
89-
const dailyVolume = await fetchV2Volume('opbnb');
116+
const [v2, totalVolume] = await Promise.all([
117+
fetchV2Volume('opbnb'),
118+
fetchTotalVolume('opbnb'),
119+
]);
90120
return {
91121
timestamp,
92-
dailyVolume: dailyVolume,
122+
dailyVolume: v2,
123+
totalVolume,
93124
};
94125
},
95126
start: 1682035200,
96127
},
97128
[CHAIN.BASE]: {
98129
runAtCurrTime: true,
99130
fetch: async (timestamp) => {
100-
const dailyVolume = await fetchV2Volume(CHAIN.BASE);
131+
const [v2, totalVolume] = await Promise.all([
132+
fetchV2Volume(CHAIN.BASE),
133+
fetchTotalVolume(CHAIN.BASE),
134+
]);
101135
return {
102136
timestamp,
103-
dailyVolume: dailyVolume,
137+
dailyVolume: v2,
138+
totalVolume,
104139
};
105140
},
106141
start: 1682035200,

0 commit comments

Comments
 (0)