Add Union TVL to escher project (#16747)

This commit is contained in:
Irfandi D Vendy
2025-10-22 21:06:25 +07:00
committed by GitHub
parent 8b96a88489
commit 1ab3acd8d9
3 changed files with 29 additions and 6 deletions

View File

@@ -1,13 +1,15 @@
const { queryContract } = require("../helper/chain/cosmos");
const { queryContract, queryV1Beta1 } = require("../helper/chain/cosmos");
const CORE_ASSETS = require('../helper/coreAssets.json');
const consts = {
const config = {
EBABY_CONTRACT: 'bbn1m7zr5jw4k9z22r9ajggf4ucalwy7uxvu9gkw6tnsmv42lvjpkwasagek5g',
U_DELEGATOR: 'union19ydrfy0d80vgpvs6p0cljlahgxwrkz54ps8455q7jfdfape7ld7quaq69v',
U_COINGECKO: 'coingecko:union-2'
}
async function eBabyTVL(api) {
const data = await queryContract({
contract: consts.EBABY_CONTRACT,
contract: config.EBABY_CONTRACT,
chain: api.chain,
data: { staking_liquidity: {} },
});
@@ -19,10 +21,29 @@ async function eBabyTVL(api) {
api.add(token, totalStakedAmount);
}
async function eUTVL(api) {
const data = await queryV1Beta1({
chain: api.chain,
url: `staking/v1beta1/delegations/${config.U_DELEGATOR}`
});
const delegations = Array.isArray(data?.delegation_responses) ? data.delegation_responses : [];
let tvlAtomic = 0;
for (const d of delegations) {
tvlAtomic += Number(d?.balance?.amount || 0);
}
tvlAtomic /= 10 ** 18;
api.add(config.U_COINGECKO, tvlAtomic, { skipChain: true });
}
module.exports = {
methodology: 'TVL counts the tokens that are locked in the Escher staking hub',
babylon: {
methodology: 'TVL counts the tokens that are locked in the Escher staking hub',
tvl: eBabyTVL,
},
} // node test.js projects/milky-way/index.js
union: {
methodology: 'TVL counts the token of each delegator',
tvl: eUTVL,
},
} // node test.js projects/escher/index.js

View File

@@ -70,7 +70,8 @@ const endPoints = {
embr: 'https://rest-embrmainnet-1.anvil.asia-southeast.initia.xyz',
civitia: 'https://rest-civitia-1.anvil.asia-southeast.initia.xyz',
echelon_initia: 'https://rest-echelon-1.anvil.asia-southeast.initia.xyz',
inertia: 'https://rest.inrt.fi'
inertia: 'https://rest.inrt.fi',
union: 'https://rest.union.build'
};
const chainSubpaths = {

View File

@@ -421,6 +421,7 @@
"ultron",
"umee",
"unichain",
"union",
"unit0",
"vana",
"vechain",