1
- import { FetchResultVolume , SimpleAdapter } from "../../adapters/types" ;
1
+ import { FetchOptions , SimpleAdapter } from "../../adapters/types" ;
2
2
import { httpGet } from "../../utils/fetchURL" ;
3
3
import { CHAIN } from "../../helpers/chains" ;
4
4
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 ;
9
14
}
10
15
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"
22
19
) ;
23
20
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 } ` ) ;
26
27
}
27
28
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" ) ;
35
30
36
- return {
37
- dailyVolume,
38
- } ;
31
+ return { dailyVolume } ;
39
32
} ;
40
33
41
34
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' ,
52
40
} ;
53
41
54
42
export default adapter ;
0 commit comments