File tree 1 file changed +30
-12
lines changed
1 file changed +30
-12
lines changed Original file line number Diff line number Diff line change 1
- const ADDRESSES = require ( '../helper/coreAssets.json ' )
2
- const { uniV3Export } = require ( '../helper/uniswapV3 ' )
1
+ const { getConfig } = require ( '../helper/cache ' )
2
+ const { get } = require ( '../helper/http ' )
3
3
4
- module . exports = uniV3Export ( {
5
- hyperliquid : {
6
- factory : '0xB1c0fa0B789320044A6F623cFe5eBda9562602E3' ,
7
- fromBlock : 1 ,
8
- blacklistedTokens : [ // cause failures
9
- '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ,
10
- '0xdac17f958d2ee523a2206206994597c13d831ec7' ,
11
- '0x6b175474e89094c44da98b954eedeac495271d0f'
12
- ]
4
+ module . exports = {
5
+ hyperliquid : {
6
+ tvl
13
7
} ,
14
- } )
8
+ }
9
+
10
+ async function tvl ( api ) {
11
+ const ownerTokens = await getConfig ( 'hyperswap-v3/' + api . chain , undefined , {
12
+ fetcher : async ( ) => {
13
+ let page = 0
14
+ const ownerTokens = [ ]
15
+ let hasMore = false
16
+ do {
17
+ const { data : { pairs, pageCount } } = await get ( `https://api.hyperswap.exchange/api/pairs?page=${ page } &maxPerPage=50` )
18
+ page ++
19
+ hasMore = page < pageCount
20
+ pairs . forEach ( p => {
21
+ const pair = p . pairAddress
22
+ const token0 = p . token0 . token0Address
23
+ const token1 = p . token1 . token1Address
24
+ if ( ! pair || ! token0 || ! token1 ) throw new Error ( 'Invalid pair data' )
25
+ ownerTokens . push ( [ [ token0 , token1 ] , pair ] )
26
+ } )
27
+ } while ( hasMore )
28
+ return ownerTokens
29
+ }
30
+ } )
31
+ return api . sumTokens ( { ownerTokens } )
32
+ }
You can’t perform that action at this time.
0 commit comments