From 4158bce7d4fbf679571ae7fedd20517511e0f962 Mon Sep 17 00:00:00 2001 From: Samyak Jain <34437877+KaymasJain@users.noreply.github.com> Date: Fri, 9 Apr 2021 05:17:32 +0530 Subject: [PATCH] free flashamt --- contracts/receivers/aave-v2-receiver/main.sol | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/contracts/receivers/aave-v2-receiver/main.sol b/contracts/receivers/aave-v2-receiver/main.sol index ae64a2e..c7335df 100644 --- a/contracts/receivers/aave-v2-receiver/main.sol +++ b/contracts/receivers/aave-v2-receiver/main.sol @@ -115,7 +115,6 @@ contract MigrateResolver is Helpers, Events { function settle() external { AaveInterface aave = AaveInterface(aaveProvider.getLendingPool()); for (uint i = 0; i < supportedTokens.length; i++) { - for (uint i = 0; i < supportedTokens.length; i++) { address _token = supportedTokens[i]; if (_token == maticAddr) { _token = wmaticAddr; @@ -137,16 +136,16 @@ contract MigrateResolver is Helpers, Events { if (supplyBal != 0 && borrowBal != 0) { uint _withdrawAmt; if (supplyBal > borrowBal) { - aave.withdraw(_token, borrowBal, address(this)); // TODO: fail because of not enough withdrawing capacity? + aave.withdraw(_token, (borrowBal + flashAmts[_token]), address(this)); // TODO: fail because of not enough withdrawing capacity? IERC20(_token).approve(address(aave), borrowBal); aave.repay(_token, borrowBal, 2, address(this)); } else { - aave.withdraw(_token, supplyBal, address(this)); // TODO: fail because of not enough withdrawing capacity? + aave.withdraw(_token, (supplyBal + flashAmts[_token]), address(this)); // TODO: fail because of not enough withdrawing capacity? IERC20(_token).approve(address(aave), supplyBal); aave.repay(_token, supplyBal, 2, address(this)); } } - } + } }