@@ -19,36 +19,25 @@ const config = {
19
19
usdplus : "0x98C6616F1CC0D3E938A16200830DD55663dd7DD3"
20
20
} ,
21
21
plume : {
22
- factory : "0x84ad0De589B0075E057123c800959f10C29869D8"
22
+ // factory: "0x84ad0De589B0075E057123c800959f10C29869D8"
23
23
} ,
24
24
plume_mainnet : {
25
25
factory : "0x7a861Ae8C708DC6171006C57c9163BD2BB57a8Aa" ,
26
26
usdplus : "0x1fA3671dF7300DF728858B88c7216708f22dA3Fb"
27
27
}
28
28
}
29
29
30
- async function getTokens ( api ) {
31
- const abi = config [ api . chain ] . getTokensAbi ?? "function getDShares() external view returns (address[] memory, address[] memory)"
32
- return ( await api . call ( {
33
- target : config [ api . chain ] . factory ,
34
- abi
35
- } ) ) [ 0 ] ;
30
+ const abi = "function getDShares() external view returns (address[] memory, address[] memory)"
31
+
32
+ const tvl = async ( api ) => {
33
+ const { factory, usdplus } = config [ api . chain ]
34
+ if ( usdplus ) api . add ( usdplus , await api . call ( { target : usdplus , abi : 'erc20:totalSupply' } ) )
35
+ if ( ! factory ) return
36
+ const [ tokens ] = await api . call ( { target : factory , abi } )
37
+ const balances = await api . multiCall ( { calls : tokens , abi : 'erc20:totalSupply' } )
38
+ api . add ( tokens , balances )
36
39
}
37
40
38
- Object . keys ( config ) . forEach ( chain => {
39
- module . exports [ chain ] = {
40
- tvl : async ( api ) => {
41
- // get dShare tokens
42
- const tokens = await getTokens ( api , chain )
43
- const bals = await api . multiCall ( { chain : chain , abi : 'erc20:totalSupply' , calls : tokens } )
44
- // add USD+
45
- const usdplus = config [ chain ] . usdplus
46
- if ( usdplus ) {
47
- const usdplusBal = await api . call ( { chain : chain , target : usdplus , abi : 'erc20:totalSupply' } )
48
- tokens . push ( usdplus )
49
- bals . push ( usdplusBal )
50
- }
51
- api . add ( tokens , bals )
52
- }
53
- }
54
- } )
41
+ Object . keys ( config ) . forEach ( ( chain ) => {
42
+ module . exports [ chain ] = { tvl }
43
+ } )
0 commit comments