From 6a89b7b8fb9c589906c3c5333c55359a20bcf355 Mon Sep 17 00:00:00 2001 From: Chelioso Date: Fri, 21 Nov 2025 14:50:13 -0500 Subject: [PATCH 1/3] perena data update --- projects/perena/index.js | 43 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/projects/perena/index.js b/projects/perena/index.js index ab30576e627..e14959cb32f 100644 --- a/projects/perena/index.js +++ b/projects/perena/index.js @@ -2,7 +2,7 @@ const { getProvider, sumTokens2, } = require('../helper/solana') const { Program } = require("@coral-xyz/anchor"); const { PublicKey } = require('@solana/web3.js'); -async function tvl() { +async function numeraireTvlData() { const provider = getProvider() const programId = new PublicKey('NUMERUNsFCP3kuNmWZuXtm1AaQCPj9uw6Guv2Ekoi5P') @@ -20,10 +20,47 @@ async function tvl() { tokenAccounts.push(pair.xVault.toString()) }) }) - return sumTokens2({ tokenAccounts: tokenAccounts.filter(i => i !== '11111111111111111111111111111111'), blacklistedTokens, }) + + return { tokenAccounts: tokenAccounts.filter(i => i !== '11111111111111111111111111111111'), blacklistedTokens }; +} + +async function usdStarTvlData() { + const provider = getProvider() + + const programId = new PublicKey('save8RQVPMWNTzU18t3GBvBkN9hT7jsGjiCQ28FpD9H') + const idl = await Program.fetchIdl(programId, provider) + const program = new Program(idl, provider) + + const usdStarVaults = (await program.account.vaultGenState.all()).filter( + (x) => + x.account.config.bank.equals( + new PublicKey("sM6P4mh53CnG4faN4Fo3seY7wMSAiHdy8o6gKjwQF7A") // USD* bank + ) + ); + + const balances = {}; + for (let i = 0; i < usdStarVaults.length; i++) { + const vault = usdStarVaults[i]; + const tvl = vault.account.accounting.yieldingTvl.toNumber() / 10 ** 6; + const key = "solana:" + vault.account.config.yieldingTokenMint.toString(); + + if (!(key in balances)) { + balances[key] = tvl; + } else { + balances[key] = balances[key] + tvl; + } + } + + return { balances }; +} + +async function tvl() { + const { tokenAccounts, blacklistedTokens } = await numeraireTvlData(); + const { balances } = await usdStarTvlData(); + return sumTokens2({ balances, tokenAccounts, blacklistedTokens }); } module.exports = { timetravel: false, - solana: { tvl, }, + solana: { tvl }, } \ No newline at end of file From df5a17d60cd4cb1ca48818802693bf036514bd45 Mon Sep 17 00:00:00 2001 From: Chelioso Date: Fri, 21 Nov 2025 15:35:14 -0500 Subject: [PATCH 2/3] fix tvl data --- projects/perena/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/perena/index.js b/projects/perena/index.js index e14959cb32f..14ed8a23c55 100644 --- a/projects/perena/index.js +++ b/projects/perena/index.js @@ -41,7 +41,7 @@ async function usdStarTvlData() { const balances = {}; for (let i = 0; i < usdStarVaults.length; i++) { const vault = usdStarVaults[i]; - const tvl = vault.account.accounting.yieldingTvl.toNumber() / 10 ** 6; + const tvl = vault.account.accounting.yieldingTvl.toNumber(); const key = "solana:" + vault.account.config.yieldingTokenMint.toString(); if (!(key in balances)) { From 681850c1c9e882f5791578f80d9fb7f693ccb7db Mon Sep 17 00:00:00 2001 From: Chelioso Date: Fri, 21 Nov 2025 15:55:11 -0500 Subject: [PATCH 3/3] accomodate for tokens that aren't 6 decimals --- projects/perena/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/perena/index.js b/projects/perena/index.js index 14ed8a23c55..1693e150bb4 100644 --- a/projects/perena/index.js +++ b/projects/perena/index.js @@ -41,7 +41,7 @@ async function usdStarTvlData() { const balances = {}; for (let i = 0; i < usdStarVaults.length; i++) { const vault = usdStarVaults[i]; - const tvl = vault.account.accounting.yieldingTvl.toNumber(); + const tvl = vault.account.accounting.yieldingTvl.toNumber() / 10 ** 6 * 10 ** vault.account.config.yieldingMintDecimals; const key = "solana:" + vault.account.config.yieldingTokenMint.toString(); if (!(key in balances)) {