1
1
const ADDRESSES = require ( './helper/coreAssets.json' )
2
2
const { request, gql } = require ( "graphql-request" ) ;
3
3
4
- const graphUrl =
5
- "https://api.studio.thegraph.com/query/62472/intentx-analytics_082/version/latest" ;
6
-
7
4
const BETA_START = 1700006400 ; // 2023-11-15T00:00:00+00:00
8
5
9
6
const query = gql `
@@ -25,31 +22,32 @@ const query = gql`
25
22
}
26
23
` ;
27
24
25
+ const config = {
26
+ blast : { token : ADDRESSES . blast . USDB , graphUrl : "https://api.studio.thegraph.com/query/62472/intentx-analytics_082_blast/version/latest" , } ,
27
+ base : { token : ADDRESSES . base . USDbC , graphUrl : "https://api.studio.thegraph.com/query/62472/intentx-analytics_082/version/latest" , } ,
28
+ }
28
29
29
- async function getTVL ( toTimestamp ) {
30
+ async function getTVL ( api ) {
31
+ const { token, graphUrl } = config [ api . chain ] ;
30
32
const { dailyHistories } = await request ( graphUrl , query , {
31
33
from : BETA_START . toString ( ) ,
32
- to : toTimestamp . toString ( ) ,
34
+ to : api . timestamp . toString ( ) ,
33
35
} ) ;
34
36
35
- const total = dailyHistories . reduce (
36
- ( acc , cur ) => acc + ( Number ( cur . deposit ) - Number ( cur . withdraw ) ) ,
37
- 0
38
- ) ;
39
-
40
- return {
41
- [ "base:" + ADDRESSES . base . USDbC ] : total ,
42
- } ;
37
+ const total = dailyHistories . reduce ( ( acc , cur ) => acc + ( Number ( cur . deposit ) - Number ( cur . withdraw ) ) , 0 ) ;
38
+ api . add ( token , total )
43
39
}
44
40
45
41
module . exports = {
46
42
timetravel : false ,
47
43
start : BETA_START ,
48
- base : {
49
- tvl : async ( { timestamp } ) => {
50
- return getTVL ( timestamp ) ;
51
- } ,
52
- } ,
53
- hallmarks : [ [ 1700006400 , "Open Beta Start" ] , [ 1704200400 , "0.8.2 Migration" ] ] ,
44
+ } ;
54
45
46
+
47
+ module . exports = {
48
+ timetravel : false ,
49
+ start : BETA_START ,
50
+ blast : { tvl : getTVL } ,
51
+ base : { tvl : getTVL } ,
52
+ hallmarks : [ [ 1700006400 , "Open Beta Start" ] , [ 1704200400 , "0.8.2 Migration" ] ] ,
55
53
} ;
0 commit comments