Skip to content

Commit

Permalink
claim fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSaplin committed Aug 21, 2023
1 parent f635da8 commit 3d4e626
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/zkbob/ZkBobCompoundingMixin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ abstract contract ZkBobCompoundingMixin is ZkBobPool {
}
if (yieldAddress != address(0)) {
IERC20(token).approve(yieldAddress, 0);
_claim(0, yieldAddress, yieldParams.interestReceiver);
_claim(0, yieldAddress, yieldParams.interestReceiver, 0);
}
}

Expand Down Expand Up @@ -179,21 +179,28 @@ abstract contract ZkBobCompoundingMixin is ZkBobPool {
uint256 dust = params.dust;
minClaimAmount = minClaimAmount > dust ? minClaimAmount : dust;

return _claim(minClaimAmount, yieldAddress, params.interestReceiver);
return _claim(minClaimAmount, yieldAddress, params.interestReceiver, dust);
}

function _claim(
uint256 minClaimAmount,
address yieldAddress,
address interestReceiver
address interestReceiver,
uint256 dust
)
internal
returns (uint256)
{
IERC4626 yieldVault = IERC4626(yieldAddress);
uint256 currentInvestedSharesAmount = yieldVault.balanceOf(address(this));
uint256 lockedAmount = investedAssetsAmount + dust;
uint256 allAssets = yieldVault.convertToAssets(currentInvestedSharesAmount);

uint256 toClaimAmount = yieldVault.convertToAssets(currentInvestedSharesAmount) - investedAssetsAmount;
if (allAssets < lockedAmount) {
return 0;
}

uint256 toClaimAmount = allAssets - investedAssetsAmount;

if (toClaimAmount < minClaimAmount || toClaimAmount == 0) {
return 0;
Expand Down

0 comments on commit 3d4e626

Please sign in to comment.