1
1
const { sumTokens } = require ( "../helper/chain/fuel" ) ;
2
2
3
- async function tvl ( api ) {
4
- const contractIds = [
5
- '0xfe2c524ad8e088f33d232a45dbea43e792861640b71aa1814b30506bf8430ee5' ,
6
- '0xdafe498b31f24ea5577055e86bf77e96bcba2c39a7ae47abaa819c303a45a352' ,
7
- '0x81e83f73530c262b0dbf5414649a875c48a48144de3c08ff68cb9d54b36f2eaa' ,
8
- ] ;
9
-
10
- const balancesList = await Promise . all (
11
- contractIds . map ( async ( contractId ) => {
12
- const balances = await sumTokens ( { api, owner : contractId } ) ;
13
- console . log ( `Balances from contract ${ contractId } :` , balances ) ;
14
- return balances ;
15
- } )
16
- ) ;
17
-
18
- const combinedBalances = balancesList . reduce ( ( acc , balances ) => {
19
- Object . entries ( balances ) . forEach ( ( [ key , value ] ) => {
20
- const numericValue = BigInt ( value || 0 ) ;
21
- acc [ key ] = acc [ key ] ? BigInt ( Math . max ( Number ( acc [ key ] ) , Number ( numericValue ) ) ) : numericValue ;
22
- } ) ;
23
- return acc ;
24
- } , { } ) ;
25
-
26
- console . log ( "Final combined balances:" , combinedBalances ) ;
27
-
28
- const totalTvl = Object . values ( combinedBalances ) . reduce ( ( sum , value ) => {
29
- return sum + Number ( value ) ;
30
- } , 0 ) ;
31
-
32
- const formattedBalances = Object . fromEntries (
33
- Object . entries ( combinedBalances ) . map ( ( [ key , value ] ) => [ key , value . toString ( ) ] )
34
- ) ;
35
-
36
- console . log ( "Formatted Balances for TVL:" , formattedBalances ) ;
37
-
38
- return formattedBalances ;
39
- }
40
-
41
3
module . exports = {
42
- fuel : { tvl } ,
43
- timetravel : false ,
44
- } ;
4
+ fuel : {
5
+ tvl : ( api ) =>
6
+ sumTokens ( {
7
+ api, owners : [
8
+ '0xfe2c524ad8e088f33d232a45dbea43e792861640b71aa1814b30506bf8430ee5' ,
9
+ '0xdafe498b31f24ea5577055e86bf77e96bcba2c39a7ae47abaa819c303a45a352' ,
10
+ '0x81e83f73530c262b0dbf5414649a875c48a48144de3c08ff68cb9d54b36f2eaa' ,
11
+ ]
12
+ } )
13
+ }
14
+ }
0 commit comments