Skip to content

Commit f2c93ee

Browse files
add adapter for Collex (#16820)
1 parent dabf061 commit f2c93ee

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

projects/collex/index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { function_view } = require("../helper/chain/aptos");
2+
const contractAddress = "0xc49fd6643c260db7b453084751df8a5d0225b6f54dbf4fd1e2ea5298d309179e"
3+
4+
async function _getBalances() {
5+
return function_view({ functionStr: `${contractAddress}::treasury::balances`, type_arguments: [], args: [] })
6+
}
7+
8+
async function _getTvl() {
9+
const tokenTvlMap = new Map();
10+
const balances = await _getBalances()
11+
for (const { key, value } of balances.data) {
12+
tokenTvlMap.set(key.inner, Number(value))
13+
}
14+
return tokenTvlMap
15+
}
16+
17+
module.exports = {
18+
timetravel: false,
19+
methodology:
20+
"TVL consists of total token balances held by the Collex contract treasury.",
21+
aptos: {
22+
tvl: async (api) => {
23+
const tokenTvlMap = await _getTvl()
24+
for (const [key, value] of tokenTvlMap) {
25+
api.add(key, value)
26+
}
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)