Skip to content

Commit 6cd11a2

Browse files
authored
feat(nami-index): add nami index project (#15683)
1 parent d59cb2c commit 6cd11a2

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

projects/nami-index/index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
}

0 commit comments

Comments
 (0)