Skip to content

Commit

Permalink
Use the correct total supply
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed Aug 12, 2024
1 parent 963a327 commit d1655ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion adapters/beefy/hourly_blocks.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ number,timestamp
5784890,1718972096
6301186,1720005441
7643069,1722689579
7848072,1723099948
7848072,1723099948
8029967,1723464243
21 changes: 15 additions & 6 deletions adapters/beefy/src/sdk/breakdown/protocol_type/beefy_clm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})),
};
};

0 comments on commit d1655ac

Please sign in to comment.