Skip to content

Commit 0512491

Browse files
authored
fix(FlashMintLeveragedZeroEx): Fix collateral amount withdrawn after redemption (#211)
1 parent eac9b1a commit 0512491

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

contracts/exchangeIssuance/FlashmintLeveragedZeroEx.sol

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,7 @@ contract FlashMintLeveragedZeroEx is ReentrancyGuard, Ownable {
539539
if(_decodedParams.isAave) {
540540
// Withdraw underlying collateral token from the aToken position returned by redeem step
541541
_withdrawCollateralToken(
542-
_decodedParams.leveragedTokenData.collateralToken,
543-
_decodedParams.leveragedTokenData.collateralAmount - ROUNDING_ERROR_MARGIN
542+
_decodedParams.leveragedTokenData.collateralToken
544543
);
545544
}
546545

@@ -869,13 +868,13 @@ contract FlashMintLeveragedZeroEx is ReentrancyGuard, Ownable {
869868
* Convert collateralAToken from set redemption to collateralToken by withdrawing underlying from Aave
870869
*
871870
* @param _collateralToken Address of the collateralToken to withdraw from Aave lending pool
872-
* @param _collateralAmount Amount of collateralToken to withdraw
873871
*/
874872
function _withdrawCollateralToken(
875-
address _collateralToken,
876-
uint256 _collateralAmount
873+
address _collateralToken
877874
) internal {
878-
aavePool.withdraw(_collateralToken, _collateralAmount, address(this));
875+
// Withdraw full aToken balance
876+
aavePool.withdraw(_collateralToken, type(uint256).max, address(this));
877+
879878
}
880879

881880

0 commit comments

Comments
 (0)