@@ -2,23 +2,20 @@ const config = require("./config");
2
2
const { sumTokens2 } = require ( "../helper/unwrapLPs" ) ;
3
3
4
4
Object . keys ( config ) . forEach ( ( chain ) => {
5
- const arg = config [ chain ] ;
5
+ const { master } = config [ chain ] ;
6
6
module . exports [ chain ] = {
7
7
tvl : async ( api ) => {
8
- const pools = Object . values ( arg [ "pools" ] ) ;
9
-
10
- let allUnderlying = await api . multiCall ( { abi : "address[]:getTokens" , calls : pools , } ) ;
11
-
12
- const tokens = [ ] ;
13
- const calls = [ ] ;
14
- pools . forEach ( ( v , i ) => {
15
- allUnderlying [ i ] . forEach ( ( t ) => {
16
- tokens . push ( t ) ;
17
- calls . push ( { target : v , params : t } ) ;
18
- } ) ;
8
+ const poolInfos = await api . fetchList ( {
9
+ // Reference: https://github.com/wombat-exchange/v1-core/blob/5887ec5e1f1cbd067eaee8aee49fcb857fb867c5/contracts/wombat-governance/MasterWombatV3.sol#L587
10
+ lengthAbi : 'poolLength' ,
11
+ itemAbi : "function poolInfo(uint256) external view returns (address asset, uint96, address, uint256, uint104, uint104, uint40)" ,
12
+ target : master ,
19
13
} ) ;
20
- const wTokens = await api . multiCall ( { abi : "function addressOfAsset(address) view returns (address)" , calls, } ) ;
21
- return sumTokens2 ( { api, tokensAndOwners2 : [ tokens , wTokens ] , } ) ;
14
+ // Reference: https://github.com/wombat-exchange/v1-core/blob/5887ec5e1f1cbd067eaee8aee49fcb857fb867c5/contracts/wombat-core/asset/Asset.sol#L4
15
+ const assets = poolInfos . map ( i => i . asset ) ;
16
+ const uTokens = await api . multiCall ( { abi : 'address:underlyingToken' , calls : assets } )
17
+
18
+ return sumTokens2 ( { api, tokensAndOwners2 : [ uTokens , assets ] , } ) ;
22
19
} ,
23
20
} ;
24
21
} ) ;
0 commit comments