From bb9fe1cac43486ab6edcefa3af94aa2d0164343d Mon Sep 17 00:00:00 2001 From: Lawson Graham Date: Mon, 29 Jul 2024 12:37:48 -0700 Subject: [PATCH] add thala validator apt --- projects/thala-lsd/index.js | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/projects/thala-lsd/index.js b/projects/thala-lsd/index.js index eaa9cd9e96..5685d9aa7c 100644 --- a/projects/thala-lsd/index.js +++ b/projects/thala-lsd/index.js @@ -1,34 +1,26 @@ -const { function_view } = require('../helper/chain/aptos') +const { aQuery, function_view } = require('../helper/chain/aptos') // Note: thala-lsd is under the umbrella of Thala protocols const LSD_ACCOUNT = "0xfaf4e633ae9eb31366c9ca24214231760926576c7b625313b3688b5e900731f6"; +const THALA_VALIDATOR = "0xe888a0adfb4ca871bfe6aada8511f5326e877a8ce66a9980ef089eb2218d740c"; module.exports = { timetravel: false, - methodology: "Aggregates APT in delegation pools backing Thala LSD.", + methodology: "Aggregates thAPT backing Thala LSD's APT delegation.", aptos: { tvl: async () => { - const delegation_pools = (await function_view({ - functionStr: `${LSD_ACCOUNT}::pool_router::get_pools`, + const { data: { supply } } = await aQuery(`/v1/accounts/${LSD_ACCOUNT}/resource/0x1::coin::CoinInfo%3C${LSD_ACCOUNT}::staking::ThalaAPT%3E`); + const [active, inactive, pending_active, pending_inactive] = await function_view({ + functionStr: `0x1::delegation_pool::get_delegation_pool_stake`, type_arguments: [], - args: [] - }))[0]; - let total_apt = 0; - - for (let i = 0; i < delegation_pools.length; i++) { - const [active, inactive, pending_active, pending_inactive] = await function_view({ - functionStr: `0x1::delegation_pool::get_delegation_pool_stake`, - type_arguments: [], - args: [delegation_pools[i]] - }); - total_apt += Number(active) + Number(inactive) + Number(pending_active) + Number(pending_inactive); - } - + args: [THALA_VALIDATOR] + }); + const validator_apt = Number(active) + Number(inactive) + Number(pending_active) + Number(pending_inactive); + return { - aptos: total_apt / 1e8 + aptos: (Number(supply.vec[0].integer.vec[0].value) + validator_apt) / 1e8 } } } } -