add adapter for Collex (#16820)

This commit is contained in:
maximus-collex
2025-10-27 17:00:45 +07:00
committed by GitHub
parent dabf061709
commit f2c93ee0d3

29
projects/collex/index.js Normal file
View File

@@ -0,0 +1,29 @@
const { function_view } = require("../helper/chain/aptos");
const contractAddress = "0xc49fd6643c260db7b453084751df8a5d0225b6f54dbf4fd1e2ea5298d309179e"
async function _getBalances() {
return function_view({ functionStr: `${contractAddress}::treasury::balances`, type_arguments: [], args: [] })
}
async function _getTvl() {
const tokenTvlMap = new Map();
const balances = await _getBalances()
for (const { key, value } of balances.data) {
tokenTvlMap.set(key.inner, Number(value))
}
return tokenTvlMap
}
module.exports = {
timetravel: false,
methodology:
"TVL consists of total token balances held by the Collex contract treasury.",
aptos: {
tvl: async (api) => {
const tokenTvlMap = await _getTvl()
for (const [key, value] of tokenTvlMap) {
api.add(key, value)
}
}
}
}