Skip to content

Commit

Permalink
fix: Calculate assets correctly on UI on deposit day
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasia committed Oct 17, 2024
1 parent fd63b88 commit 09e8e34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ const ViewSection = () => {
<>
<br/>
shares: {request?.shareAmount?.toString()}<br/>
assets: {request?.assetAmount?.toString()}
assets: {request?.assetAmount?.toString()} USDC
</>
)}
onClickHandler={() => setRequestAmountToRedeem(request)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ export const useFetchRedeemRequests = ({
const depositPeriod = depositPeriods[index];
const share = shares[index];

// Call the contract function to convert shares to assets for each deposit period
const assetAmount = await contract.convertToAssetsForDepositPeriod(share, depositPeriod);

totalShareAmount += ethers.toBigInt(share);
totalAssetAmount += ethers.toBigInt(assetAmount);

// only yield if the deposit was in the past
if (currentPeriod > depositPeriod) {
const assetAmount = await contract.convertToAssetsForDepositPeriod(share, depositPeriod);
totalAssetAmount += ethers.toBigInt(assetAmount);
} else {
totalAssetAmount += ethers.toBigInt(share); // yield is 0, assets = shares
}
}

if (totalShareAmount > 0) {
Expand Down

0 comments on commit 09e8e34

Please sign in to comment.