Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions projects/escher/index.js
Original file line number Diff line number Diff line change
@@ -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: {} },
});
Expand All @@ -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
3 changes: 2 additions & 1 deletion projects/helper/chain/cosmos.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions projects/helper/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@
"ultron",
"umee",
"unichain",
"union",
"unit0",
"vana",
"vechain",
Expand Down
Loading