From d1655ac1e0b327c3b469e2d34efabfffea0e463e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pr=C3=A9vost?= <998369+prevostc@users.noreply.github.com> Date: Mon, 12 Aug 2024 14:30:17 +0200 Subject: [PATCH] Use the correct total supply --- adapters/beefy/hourly_blocks.csv | 3 ++- .../sdk/breakdown/protocol_type/beefy_clm.ts | 21 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/adapters/beefy/hourly_blocks.csv b/adapters/beefy/hourly_blocks.csv index 2a3841cc..67294af4 100644 --- a/adapters/beefy/hourly_blocks.csv +++ b/adapters/beefy/hourly_blocks.csv @@ -13,4 +13,5 @@ number,timestamp 5784890,1718972096 6301186,1720005441 7643069,1722689579 -7848072,1723099948 \ No newline at end of file +7848072,1723099948 +8029967,1723464243 \ No newline at end of file diff --git a/adapters/beefy/src/sdk/breakdown/protocol_type/beefy_clm.ts b/adapters/beefy/src/sdk/breakdown/protocol_type/beefy_clm.ts index f465d675..a0a7f6eb 100644 --- a/adapters/beefy/src/sdk/breakdown/protocol_type/beefy_clm.ts +++ b/adapters/beefy/src/sdk/breakdown/protocol_type/beefy_clm.ts @@ -73,19 +73,28 @@ export const getBeefyClmVaultBreakdown = async ( abi: BeefyVaultV7Abi, }); - const [balance, totalSupply] = await Promise.all([ - vaultContract.read.balance({ blockNumber }), - vaultContract.read.totalSupply({ blockNumber }), - ]); + const underlyingContract = getContract({ + client, + address: vault.undelying_lp_address, + abi: BeefyVaultConcLiqAbi, + }); + + const [underlyingBalance, vaultTotalSupply, underlyingTotalSypply] = + await Promise.all([ + vaultContract.read.balance({ blockNumber }), + vaultContract.read.totalSupply({ blockNumber }), + underlyingContract.read.totalSupply({ blockNumber }), + ]); return { vault, blockNumber, - vaultTotalSupply: totalSupply, + vaultTotalSupply: vaultTotalSupply, isLiquidityEligible: underlyingClmBreakdown.isLiquidityEligible, balances: underlyingClmBreakdown.balances.map((tokenBalance) => ({ tokenAddress: tokenBalance.tokenAddress, - vaultBalance: (balance * tokenBalance.vaultBalance) / totalSupply, + vaultBalance: + (underlyingBalance * tokenBalance.vaultBalance) / underlyingTotalSypply, })), }; };