From 0c94b24700c21f3326bf305141c7b8c511c5903b Mon Sep 17 00:00:00 2001 From: eboado Date: Tue, 15 Sep 2020 10:43:22 +0200 Subject: [PATCH] - Fixed description on swapLiquidity(). --- contracts/interfaces/ILendingPool.sol | 2 +- contracts/lendingpool/LendingPool.sol | 2 +- .../LendingPoolLiquidationManager.sol | 23 +++++++++++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/contracts/interfaces/ILendingPool.sol b/contracts/interfaces/ILendingPool.sol index e206d15c..41b13f07 100644 --- a/contracts/interfaces/ILendingPool.sol +++ b/contracts/interfaces/ILendingPool.sol @@ -291,7 +291,7 @@ interface ILendingPool { ) external; /** - * @dev Allows an user to release one of his assets deposited in the protocol, even if it is used as collateral. + * @dev Allows an user to release one of his assets deposited in the protocol, even if it is used as collateral, to swap for another. * - It's not possible to release one asset to swap for the same * @param receiverAddress The address of the contract receiving the funds. The receiver should implement the ISwapAdapter interface * @param fromAsset Asset to swap from diff --git a/contracts/lendingpool/LendingPool.sol b/contracts/lendingpool/LendingPool.sol index 153c45d0..ba5e7894 100644 --- a/contracts/lendingpool/LendingPool.sol +++ b/contracts/lendingpool/LendingPool.sol @@ -582,7 +582,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { } /** - * @dev Allows an user to release one of his assets deposited in the protocol, even if it is used as collateral. + * @dev Allows an user to release one of his assets deposited in the protocol, even if it is used as collateral, to swap for another. * - It's not possible to release one asset to swap for the same * @param receiverAddress The address of the contract receiving the funds. The receiver should implement the ISwapAdapter interface * @param fromAsset Asset to swap from diff --git a/contracts/lendingpool/LendingPoolLiquidationManager.sol b/contracts/lendingpool/LendingPoolLiquidationManager.sol index 944c681e..664e32f4 100644 --- a/contracts/lendingpool/LendingPoolLiquidationManager.sol +++ b/contracts/lendingpool/LendingPoolLiquidationManager.sol @@ -447,7 +447,7 @@ contract LendingPoolLiquidationManager is VersionedInitializable { } /** - * @dev Allows an user to release one of his assets deposited in the protocol, even if it is used as collateral. + * @dev Allows an user to release one of his assets deposited in the protocol, even if it is used as collateral, to swap for another. * - It's not possible to release one asset to swap for the same * @param receiverAddress The address of the contract receiving the funds. The receiver should implement the ISwapAdapter interface * @param fromAsset Asset to swap from @@ -490,7 +490,12 @@ contract LendingPoolLiquidationManager is VersionedInitializable { fromReserve.updateInterestRates(fromAsset, address(vars.fromReserveAToken), 0, amountToSwap); - vars.fromReserveAToken.burn(msg.sender, receiverAddress, amountToSwap, fromReserve.liquidityIndex); + vars.fromReserveAToken.burn( + msg.sender, + receiverAddress, + amountToSwap, + fromReserve.liquidityIndex + ); // Notifies the receiver to proceed, sending as param the underlying already transferred ISwapAdapter(receiverAddress).executeOperation( fromAsset, @@ -502,9 +507,18 @@ contract LendingPoolLiquidationManager is VersionedInitializable { vars.amountToReceive = IERC20(toAsset).balanceOf(receiverAddress); if (vars.amountToReceive != 0) { - IERC20(toAsset).transferFrom(receiverAddress, address(vars.toReserveAToken), vars.amountToReceive); + IERC20(toAsset).transferFrom( + receiverAddress, + address(vars.toReserveAToken), + vars.amountToReceive + ); vars.toReserveAToken.mint(msg.sender, vars.amountToReceive, toReserve.liquidityIndex); - toReserve.updateInterestRates(toAsset, address(vars.toReserveAToken), vars.amountToReceive, 0); + toReserve.updateInterestRates( + toAsset, + address(vars.toReserveAToken), + vars.amountToReceive, + 0 + ); } (, , , , vars.healthFactor) = GenericLogic.calculateUserAccountData( @@ -582,5 +596,4 @@ contract LendingPoolLiquidationManager is VersionedInitializable { } return (collateralAmount, principalAmountNeeded); } - }