1
+ const { get } = require ( '../helper/http' )
2
+ const { getConfig } = require ( '../helper/cache' )
3
+
4
+ const positionManager = '0x0b95Ea9Eb46716d20991163AE60eD2e16645Ef38' ;
5
+ const getValueFarmAbi = 'function getFarmValue(address) view returns (address token0, uint256 amount0, address token1, uint256 amount1)' ;
6
+ const OPEN = '0x58cb98a966f62aa6f2190eb3aa03132a0c3de3d5'
7
+
8
+ async function tvl ( api ) {
9
+ const vaults = await getConfig ( 'open-world/lev-farming-vaults/' + api . chain , undefined , {
10
+ fetcher : async ( ) => {
11
+ const data = await get ( 'https://analytic.ow.finance/lending-synthetic' )
12
+ return data . data . map ( v => v . vaultAddress )
13
+ }
14
+ } )
15
+ const farms = await getConfig ( 'open-world/lev-farming-farms/' + api . chain , undefined , {
16
+ fetcher : async ( ) => {
17
+ const data = await get ( 'https://product-exploration.ow.finance/pools' )
18
+ return data . data . map ( v => v . workerAddress )
19
+ }
20
+ } )
21
+ const tokens = await api . multiCall ( { abi : 'address:token' , calls : vaults } )
22
+ await api . sumTokens ( { tokensAndOwners2 : [ tokens , vaults ] , } )
23
+ const farmData = await api . multiCall ( { abi : getValueFarmAbi , calls : farms , target : positionManager } )
24
+ for ( const i of farmData ) {
25
+ api . add ( i . token0 , i . amount0 )
26
+ api . add ( i . token1 , i . amount1 )
27
+ }
28
+
29
+ api . removeTokenBalance ( OPEN )
30
+ }
31
+
32
+ module . exports = {
33
+ arbitrum : { tvl } ,
34
+ }
0 commit comments