Skip to content

Commit 1ab3acd

Browse files
authored
Add Union TVL to escher project (#16747)
1 parent 8b96a88 commit 1ab3acd

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

projects/escher/index.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
const { queryContract } = require("../helper/chain/cosmos");
1+
const { queryContract, queryV1Beta1 } = require("../helper/chain/cosmos");
22
const CORE_ASSETS = require('../helper/coreAssets.json');
33

4-
const consts = {
4+
const config = {
55
EBABY_CONTRACT: 'bbn1m7zr5jw4k9z22r9ajggf4ucalwy7uxvu9gkw6tnsmv42lvjpkwasagek5g',
6+
U_DELEGATOR: 'union19ydrfy0d80vgpvs6p0cljlahgxwrkz54ps8455q7jfdfape7ld7quaq69v',
7+
U_COINGECKO: 'coingecko:union-2'
68
}
79

810
async function eBabyTVL(api) {
911
const data = await queryContract({
10-
contract: consts.EBABY_CONTRACT,
12+
contract: config.EBABY_CONTRACT,
1113
chain: api.chain,
1214
data: { staking_liquidity: {} },
1315
});
@@ -19,10 +21,29 @@ async function eBabyTVL(api) {
1921
api.add(token, totalStakedAmount);
2022
}
2123

24+
async function eUTVL(api) {
25+
const data = await queryV1Beta1({
26+
chain: api.chain,
27+
url: `staking/v1beta1/delegations/${config.U_DELEGATOR}`
28+
});
29+
const delegations = Array.isArray(data?.delegation_responses) ? data.delegation_responses : [];
30+
31+
let tvlAtomic = 0;
32+
for (const d of delegations) {
33+
tvlAtomic += Number(d?.balance?.amount || 0);
34+
}
35+
tvlAtomic /= 10 ** 18;
36+
37+
api.add(config.U_COINGECKO, tvlAtomic, { skipChain: true });
38+
}
2239

2340
module.exports = {
24-
methodology: 'TVL counts the tokens that are locked in the Escher staking hub',
2541
babylon: {
42+
methodology: 'TVL counts the tokens that are locked in the Escher staking hub',
2643
tvl: eBabyTVL,
2744
},
28-
} // node test.js projects/milky-way/index.js
45+
union: {
46+
methodology: 'TVL counts the token of each delegator',
47+
tvl: eUTVL,
48+
},
49+
} // node test.js projects/escher/index.js

projects/helper/chain/cosmos.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ const endPoints = {
7070
embr: 'https://rest-embrmainnet-1.anvil.asia-southeast.initia.xyz',
7171
civitia: 'https://rest-civitia-1.anvil.asia-southeast.initia.xyz',
7272
echelon_initia: 'https://rest-echelon-1.anvil.asia-southeast.initia.xyz',
73-
inertia: 'https://rest.inrt.fi'
73+
inertia: 'https://rest.inrt.fi',
74+
union: 'https://rest.union.build'
7475
};
7576

7677
const chainSubpaths = {

projects/helper/chains.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@
421421
"ultron",
422422
"umee",
423423
"unichain",
424+
"union",
424425
"unit0",
425426
"vana",
426427
"vechain",

0 commit comments

Comments
 (0)