File tree Expand file tree Collapse file tree 3 files changed +93
-0
lines changed Expand file tree Collapse file tree 3 files changed +93
-0
lines changed Original file line number Diff line number Diff line change
1
+ const sui = require ( "../helper/chain/sui" ) ;
2
+ const { cachedGraphQuery } = require ( '../helper/cache' ) ;
3
+
4
+ const graphQL_endpoint = "https://5lox8etck8.execute-api.eu-central-1.amazonaws.com/api/v1" ;
5
+ const GET_SUI_POOLS = `query GetSuiPools {
6
+ getSuiPools {
7
+ pools {
8
+ poolId
9
+ }
10
+ }
11
+ }`
12
+
13
+ async function tvl ( api ) {
14
+ const sui_pools = await cachedGraphQuery ( 'degen-hive-sui-pools' , graphQL_endpoint , GET_SUI_POOLS ) ;
15
+ const poolIds = sui_pools . getSuiPools . pools . map ( pool => pool . poolId ) ;
16
+ const suiPoolsData = await sui . getObjects ( poolIds ) ;
17
+
18
+ for ( const { type, fields } of suiPoolsData ) {
19
+ if ( fields . coin_x_reserve == 0 && fields . coin_y_reserve == 0 ) continue ;
20
+ let coin_x_type = type . split ( '<' ) [ 1 ] . split ( ',' ) [ 0 ] . trim ( ) ;
21
+ let coin_y_type = type . split ( '<' ) [ 1 ] . split ( ',' ) [ 1 ] . trim ( ) ;
22
+
23
+ api . add ( coin_x_type , fields . coin_x_reserve ) ;
24
+ api . add ( coin_y_type , fields . coin_y_reserve ) ;
25
+
26
+ if ( fields . coin_z_reserve && fields . coin_z_reserve > 0 ) {
27
+ let coin_z_type = type . split ( '<' ) [ 1 ] . split ( ',' ) [ 2 ] . trim ( ) ;
28
+ api . add ( coin_z_type , fields . coin_z_reserve ) ;
29
+ }
30
+ }
31
+ }
32
+
33
+ // Export first
34
+ module . exports = {
35
+ timetravel : false ,
36
+ sui : {
37
+ tvl,
38
+ } ,
39
+ methodology : "TVL consists of the liquidity in the DegenHive's AMM pools."
40
+ } ;
Original file line number Diff line number Diff line change
1
+ const sui = require ( "../helper/chain/sui" ) ;
2
+
3
+ async function tvl ( api ) {
4
+
5
+ // Add TVL from SUI liquid staking
6
+ const dsui_vault = await sui . getObject ( "0x85aaf87a770b4a09822e7ca3de7f9424a4f58688cfa120f55b294a98d599d402" ) ;
7
+ let sui_staked = Number ( Number ( dsui_vault . fields . dsui_supply * dsui_vault . fields . sui_claimable_per_dsui / 1e9 + dsui_vault . fields . sui_to_stake ) . toFixed ( 0 ) ) ;
8
+ api . add ( "0x2::sui::SUI" , sui_staked )
9
+
10
+ }
11
+
12
+ module . exports = {
13
+ timetravel : false ,
14
+ sui : {
15
+ tvl,
16
+ } ,
17
+ methodology : "TVL consists of SUI staked with DegenHive's liquid staking protocol."
18
+ } ;
Original file line number Diff line number Diff line change
1
+ const sui = require ( "../helper/chain/sui" ) ;
2
+ const { cachedGraphQuery } = require ( '../helper/cache' ) ;
3
+
4
+ const graphQL_endpoint = "https://5lox8etck8.execute-api.eu-central-1.amazonaws.com/api/v1" ;
5
+ const GET_SUI_MEME_POOLS = `query GetSuiMemePools {
6
+ getSuiMemePools {
7
+ pools {
8
+ meme_pool_addr
9
+ }
10
+ }
11
+ }`
12
+
13
+
14
+
15
+ async function tvl ( api ) {
16
+ const sui_meme_pools = await cachedGraphQuery ( 'degen-hive-sui-meme-pools' , graphQL_endpoint , GET_SUI_MEME_POOLS ) ;
17
+
18
+ // Extract arrays of pool IDs
19
+ const poolIds = sui_meme_pools . getSuiMemePools . pools . map ( pool => pool . meme_pool_addr ) ;
20
+ const suiMemePoolsData = await sui . getObjects ( poolIds )
21
+
22
+ // Add TVL for MEME Pools
23
+ for ( const { fields } of suiMemePoolsData ) {
24
+ if ( fields . sui_available == 0 ) continue ;
25
+ api . add ( "0x2::sui::SUI" , fields . sui_available )
26
+ }
27
+ }
28
+
29
+ module . exports = {
30
+ timetravel : false ,
31
+ sui : {
32
+ tvl,
33
+ } ,
34
+ methodology : "TVL consists of the liquidity in meme-coin launchpad pools."
35
+ } ;
You can’t perform that action at this time.
0 commit comments