File tree Expand file tree Collapse file tree 1 file changed +63
-0
lines changed Expand file tree Collapse file tree 1 file changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { CHAIN } from "../helpers/chains" ;
2
+ import { httpGet } from "../utils/fetchURL" ;
3
+
4
+ type TickerItem = {
5
+ symbol : string ;
6
+ priceChange : string ;
7
+ priceChangePercent : string ;
8
+ weightedAvgPrice : string ;
9
+ lastPrice : string ;
10
+ lastQty : string ;
11
+ openPrice : string ;
12
+ highPrice : string ;
13
+ lowPrice : string ;
14
+ volume : string ;
15
+ quoteVolume : string ;
16
+ openTime : number ;
17
+ closeTime : number ;
18
+ firstId : number ;
19
+ lastId : number ;
20
+ count : number ;
21
+ baseAsset : string ;
22
+ quoteAsset : string ;
23
+ bidPrice : string ;
24
+ bidQty : string ;
25
+ askPrice : string ;
26
+ askQty : string ;
27
+ } ;
28
+
29
+ const dayAPI = "https://sapi.asterdex.com/api/v1/ticker/24hr" ;
30
+
31
+ const fetch = async ( ) => {
32
+ const data = ( await httpGet ( dayAPI ) ) as TickerItem [ ] ;
33
+ const tickerPrices : { [ symbol : string ] : number } = { } ;
34
+ data . forEach ( ( t ) => {
35
+ if ( t . quoteAsset === "USDT" ) {
36
+ tickerPrices [ t . baseAsset ] = Number ( t . lastPrice ) ;
37
+ }
38
+ tickerPrices [ t . symbol ] = Number ( t . lastPrice ) ;
39
+ } ) ;
40
+ const dailyVolume = data
41
+ . filter ( ( d ) => d . baseAsset !== "TEST" )
42
+ . reduce ( ( p : any , c : any ) => {
43
+ let vol = Number ( c . quoteVolume ) ;
44
+ let price = 1
45
+ if ( c . quoteAsset !== "USDT" ) {
46
+ price = tickerPrices [ c . quoteAsset ]
47
+ if ( ! price ) return p ;
48
+ }
49
+ return p + ( vol * price ) ;
50
+ } , 0 ) ;
51
+
52
+ return { dailyVolume } ;
53
+ } ;
54
+
55
+
56
+ export default {
57
+ fetch,
58
+ version : 2 ,
59
+ runAtCurrTime : true ,
60
+ start : "2025-09-02" ,
61
+ chains : [ CHAIN . OFF_CHAIN ] ,
62
+ } ;
63
+
You can’t perform that action at this time.
0 commit comments