From 1ab3acd8d9e511c407ce380bde1e2fd37152bcde Mon Sep 17 00:00:00 2001 From: Irfandi D Vendy Date: Wed, 22 Oct 2025 21:06:25 +0700 Subject: [PATCH] Add Union TVL to escher project (#16747) --- projects/escher/index.js | 31 ++++++++++++++++++++++++++----- projects/helper/chain/cosmos.js | 3 ++- projects/helper/chains.json | 1 + 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/projects/escher/index.js b/projects/escher/index.js index f05d28767..9ebace7f2 100644 --- a/projects/escher/index.js +++ b/projects/escher/index.js @@ -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 \ No newline at end of file + union: { + methodology: 'TVL counts the token of each delegator', + tvl: eUTVL, + }, +} // node test.js projects/escher/index.js \ No newline at end of file diff --git a/projects/helper/chain/cosmos.js b/projects/helper/chain/cosmos.js index 82caac0c2..1f68f17a0 100644 --- a/projects/helper/chain/cosmos.js +++ b/projects/helper/chain/cosmos.js @@ -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 = { diff --git a/projects/helper/chains.json b/projects/helper/chains.json index 463407cc8..72ef6dded 100644 --- a/projects/helper/chains.json +++ b/projects/helper/chains.json @@ -421,6 +421,7 @@ "ultron", "umee", "unichain", + "union", "unit0", "vana", "vechain",