Skip to content

Commit 4363ce4

Browse files
authored
use new api for eden (#4014)
1 parent 97327cf commit 4363ce4

File tree

1 file changed

+26
-38
lines changed

1 file changed

+26
-38
lines changed

dexs/aden/index.ts

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,42 @@
1-
import { FetchResultVolume, SimpleAdapter } from "../../adapters/types";
1+
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
22
import { httpGet } from "../../utils/fetchURL";
33
import { CHAIN } from "../../helpers/chains";
44

5-
interface FuturesMarketRow {
6-
symbol: string;
7-
"24h_amount": string;
8-
"24h_volume": number;
5+
interface DailyStats {
6+
date: string;
7+
dateString: string;
8+
createdAt: string;
9+
updatedAt: string;
10+
builderFee: string;
11+
takerVolume: string;
12+
makerVolume: string;
13+
activeUser: number;
914
}
1015

11-
interface FuturesMarketResponse {
12-
success: boolean;
13-
data: {
14-
rows: FuturesMarketRow[];
15-
};
16-
}
17-
18-
const fetch = async (): Promise<FetchResultVolume> => {
19-
// Using ADEN's CMC API endpoint with broker_id parameter
20-
const response: FuturesMarketResponse = await httpGet(
21-
"https://api.orderly.org/v1/public/futures_market?broker_id=aden"
16+
const fetch = async (_t: number, _: any, { startOfDay }: FetchOptions) => {
17+
const dailyStats: DailyStats[] = await httpGet(
18+
"https://api.orderly.org/md/volume/builder/daily_stats?broker_id=aden"
2219
);
2320

24-
if (!response.success || !response.data?.rows) {
25-
throw new Error("Invalid response from ADEN API");
21+
const targetDate = new Date(startOfDay * 1000).toISOString().split("T")[0];
22+
const dayStats = dailyStats.find((day) =>
23+
day.date.startsWith(targetDate)
24+
);
25+
if (!dayStats) {
26+
throw new Error(`No stats found for date: ${targetDate}`);
2627
}
2728

28-
// Calculate total 24h volume using 24h_amount (USD value)
29-
// Divide by 2 to avoid double counting when both maker and taker use ADEN
30-
const totalVolume = response.data.rows.reduce((total, row) => {
31-
return total + parseFloat(row["24h_amount"] || "0");
32-
}, 0);
33-
34-
const dailyVolume = totalVolume / 2;
29+
const dailyVolume = parseFloat(dayStats.takerVolume || "0");
3530

36-
return {
37-
dailyVolume,
38-
};
31+
return { dailyVolume };
3932
};
4033

4134
const adapter: SimpleAdapter = {
42-
adapter: {
43-
// ADEN operates on Solana, Arbitrum, and BNB Chain through Orderly Network
44-
// Using Arbitrum as the main chain since the API aggregates all chains data
45-
[CHAIN.ARBITRUM]: {
46-
fetch,
47-
runAtCurrTime: true,
48-
start: '2025-07-23', // ADEN launch date
49-
},
50-
},
51-
doublecounted: true,
35+
fetch,
36+
// ADEN operates on Solana, Arbitrum, and BNB Chain through Orderly Network
37+
// Using BNB Chain as the main chain since the API aggregates all chains data
38+
chains: [CHAIN.BSC],
39+
start: '2025-07-23',
5240
};
5341

5442
export default adapter;

0 commit comments

Comments
 (0)