free flashamt

This commit is contained in:
Samyak Jain 2021-04-09 05:17:32 +05:30
parent e6bcc576e8
commit 4158bce7d4

View File

@ -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));
}
}
}
}
}