1
1
const { staking } = require ( '../helper/staking' )
2
+ const { request, gql } = require ( "graphql-request" ) ;
3
+ const { sumTokens2 } = require ( '../helper/unwrapLPs' ) ;
2
4
const { getConfig } = require ( '../helper/cache' )
3
5
const { getUniqueAddresses } = require ( '../helper/utils' )
4
6
const { transformDexBalances } = require ( '../helper/portedTokens' )
@@ -8,8 +10,10 @@ async function tvl(api) {
8
10
9
11
// const impl = await api.call({ abi: 'address:swapsImpl', target: '0x5a0d867e0d70fcc6ade25c3f1b89d618b5b4eaa7' })
10
12
11
- const protocolContract = '0x5a0d867e0d70fcc6ade25c3f1b89d618b5b4eaa7'
13
+ const RSKprotocolContract = '0x5a0d867e0d70fcc6ade25c3f1b89d618b5b4eaa7'
14
+
12
15
const res = await getConfig ( 'sovryn' , 'https://backend.sovryn.app/tvl' )
16
+
13
17
let pools = Object . values ( res . tvlAmm ) . map ( i => i ?. contract ) . filter ( i => i )
14
18
pools = getUniqueAddresses ( pools )
15
19
const ownerTokens = [ ]
@@ -31,14 +35,27 @@ async function tvl(api) {
31
35
} )
32
36
await Promise . all ( promises )
33
37
34
- ownerTokens . push ( [ allTokens , protocolContract ] )
38
+ ownerTokens . push ( [ allTokens , RSKprotocolContract ] )
35
39
await api . sumTokens ( { ownerTokens } )
36
40
return transformDexBalances ( { data, api, } )
37
41
}
42
+
38
43
module . exports = {
39
44
misrepresentedTokens : true ,
45
+ bob : {
46
+ tvl : async ( ) => { const query = gql `
47
+ {
48
+ pools { base quote }
49
+ }
50
+ `
51
+ pools = await request ( `https://bob-ambient-subgraph.sovryn.app/subgraphs/name/DistributedCollective/bob-ambient-subgraph` , query )
52
+ const tokens = pools . pools . map ( i => [ i . base , i . quote ] ) . flat ( )
53
+ return sumTokens2 ( { chain : "bob" , owner : '0xe5bc234A484A912A61Aa74501960cFc202e773dA' , tokens, } ) ;
54
+ } ,
55
+ //staking: staking('0xc17C6462cEAFE9A8819258c6bA168BEF5544Fc21') // does not work
56
+ } ,
40
57
rsk : {
41
58
tvl,
42
59
staking : staking ( '0x5684a06cab22db16d901fee2a5c081b4c91ea40e' , '0xefc78fc7d48b64958315949279ba181c2114abbd' )
43
60
}
44
- }
61
+ }
0 commit comments