Skip to content

Commit

Permalink
Merge pull request #284 from prevostc/fix-beefy-adapter
Browse files Browse the repository at this point in the history
beefy : yield : fix percent of clm vault calc
  • Loading branch information
0xroll authored Aug 12, 2024
2 parents 963a327 + d1655ac commit c5de871
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 c5de871

Please sign in to comment.