File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ const { request } = require ( "../helper/utils/graphql" )
2
+
3
+ async function tvl ( api ) {
4
+ const query = `
5
+ query {
6
+ index {
7
+ status {
8
+ totalValue
9
+ }
10
+ }
11
+ }
12
+ `
13
+
14
+ const res = await request ( 'https://api.rujira.network/api/graphiql' , query )
15
+ const indexData = res . index
16
+
17
+ // totalValue is a string representing a bigint with 8 decimals in USD
18
+ const totalValue = indexData . reduce ( ( acc , item ) => {
19
+ const value = item . status ?. totalValue || '0'
20
+ return acc + BigInt ( value )
21
+ } , BigInt ( 0 ) )
22
+
23
+ const finalValue = Number ( totalValue ) / 1e8
24
+
25
+ api . addUSDValue ( finalValue )
26
+ }
27
+
28
+ module . exports = {
29
+ methodology : "TVL is calculated by retrieving the USD value of each index and aggregating the results using the official Rujira Network GraphQL API." ,
30
+ timetravel : false ,
31
+ misrepresentedTokens : true ,
32
+ thorchain : {
33
+ tvl
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments