File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ const { function_view } = require ( "../helper/chain/aptos" ) ;
2+ const contractAddress = "0xc49fd6643c260db7b453084751df8a5d0225b6f54dbf4fd1e2ea5298d309179e"
3+
4+ async function _getBalances ( ) {
5+ return function_view ( { functionStr : `${ contractAddress } ::treasury::balances` , type_arguments : [ ] , args : [ ] } )
6+ }
7+
8+ async function _getTvl ( ) {
9+ const tokenTvlMap = new Map ( ) ;
10+ const balances = await _getBalances ( )
11+ for ( const { key, value } of balances . data ) {
12+ tokenTvlMap . set ( key . inner , Number ( value ) )
13+ }
14+ return tokenTvlMap
15+ }
16+
17+ module . exports = {
18+ timetravel : false ,
19+ methodology :
20+ "TVL consists of total token balances held by the Collex contract treasury." ,
21+ aptos : {
22+ tvl : async ( api ) => {
23+ const tokenTvlMap = await _getTvl ( )
24+ for ( const [ key , value ] of tokenTvlMap ) {
25+ api . add ( key , value )
26+ }
27+ }
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments