1- const { queryContract } = require ( "../helper/chain/cosmos" ) ;
1+ const { queryContract, queryV1Beta1 } = require ( "../helper/chain/cosmos" ) ;
22const 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
810async 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
2340module . 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
0 commit comments