mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Update amountToSwap calc in liquidity swap adapter
This commit is contained in:
parent
37a2f14fca
commit
4c693d1947
|
@ -183,7 +183,9 @@ contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
address aToken = _getReserveData(assetFrom).aTokenAddress;
|
||||
|
||||
uint256 aTokenInitiatorBalance = IERC20(aToken).balanceOf(initiator);
|
||||
uint256 amountToSwap = swapAllBalance ? aTokenInitiatorBalance.sub(premium) : amount;
|
||||
uint256 amountToSwap = swapAllBalance && aTokenInitiatorBalance.sub(premium) <= amount
|
||||
? aTokenInitiatorBalance.sub(premium)
|
||||
: amount;
|
||||
|
||||
uint256 receivedAmount = _swapExactTokensForTokens(
|
||||
assetFrom,
|
||||
|
@ -197,7 +199,7 @@ contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter, IFlashLoanReceiver {
|
|||
POOL.deposit(assetTo, receivedAmount, initiator, 0);
|
||||
|
||||
uint256 flashLoanDebt = amount.add(premium);
|
||||
uint256 amountToPull = swapAllBalance ? aTokenInitiatorBalance : flashLoanDebt;
|
||||
uint256 amountToPull = amountToSwap.add(premium);
|
||||
|
||||
_pullAToken(assetFrom, aToken, initiator, amountToPull, permitSignature);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user