From 3206c5297fe9afd35bd6756aa5947047e19fa249 Mon Sep 17 00:00:00 2001 From: eboado Date: Thu, 26 Nov 2020 10:58:38 +0100 Subject: [PATCH 1/2] - Added return value to repay() --- contracts/interfaces/ILendingPool.sol | 3 +-- contracts/protocol/lendingpool/LendingPool.sol | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/contracts/interfaces/ILendingPool.sol b/contracts/interfaces/ILendingPool.sol index d445579a..816655cb 100644 --- a/contracts/interfaces/ILendingPool.sol +++ b/contracts/interfaces/ILendingPool.sol @@ -5,7 +5,6 @@ pragma experimental ABIEncoderV2; import {ILendingPoolAddressesProvider} from './ILendingPoolAddressesProvider.sol'; import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; - interface ILendingPool { /** * @dev Emitted on deposit() @@ -241,7 +240,7 @@ interface ILendingPool { uint256 amount, uint256 rateMode, address onBehalfOf - ) external; + ) external returns (uint256); /** * @dev Allows a borrower to swap his debt between stable and variable mode, or viceversa diff --git a/contracts/protocol/lendingpool/LendingPool.sol b/contracts/protocol/lendingpool/LendingPool.sol index 525141a6..9b2fec20 100644 --- a/contracts/protocol/lendingpool/LendingPool.sol +++ b/contracts/protocol/lendingpool/LendingPool.sol @@ -235,7 +235,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage uint256 amount, uint256 rateMode, address onBehalfOf - ) external override whenNotPaused { + ) external override whenNotPaused returns (uint256) { DataTypes.ReserveData storage reserve = _reserves[asset]; (uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(onBehalfOf, reserve); @@ -281,6 +281,8 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage IERC20(asset).safeTransferFrom(msg.sender, aToken, paybackAmount); emit Repay(asset, onBehalfOf, msg.sender, paybackAmount); + + return paybackAmount; } /** From e418bcc01e5737c5daa929f6ab32dc63cf6cce43 Mon Sep 17 00:00:00 2001 From: eboado Date: Thu, 26 Nov 2020 11:02:26 +0100 Subject: [PATCH 2/2] - Added return of withdraw amount to withdraw() --- contracts/interfaces/ILendingPool.sol | 4 +++- contracts/protocol/lendingpool/LendingPool.sol | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/contracts/interfaces/ILendingPool.sol b/contracts/interfaces/ILendingPool.sol index 816655cb..64f726c0 100644 --- a/contracts/interfaces/ILendingPool.sol +++ b/contracts/interfaces/ILendingPool.sol @@ -194,12 +194,13 @@ interface ILendingPool { * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet + * @return The final amount withdrawn **/ function withdraw( address asset, uint256 amount, address to - ) external; + ) external returns (uint256); /** * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower @@ -234,6 +235,7 @@ interface ILendingPool { * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed + * @return The final amount repaid **/ function repay( address asset, diff --git a/contracts/protocol/lendingpool/LendingPool.sol b/contracts/protocol/lendingpool/LendingPool.sol index 9b2fec20..c7041409 100644 --- a/contracts/protocol/lendingpool/LendingPool.sol +++ b/contracts/protocol/lendingpool/LendingPool.sol @@ -138,12 +138,13 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet + * @return The final amount withdrawn **/ function withdraw( address asset, uint256 amount, address to - ) external override whenNotPaused { + ) external override whenNotPaused returns (uint256) { DataTypes.ReserveData storage reserve = _reserves[asset]; address aToken = reserve.aTokenAddress; @@ -179,6 +180,8 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage IAToken(aToken).burn(msg.sender, to, amountToWithdraw, reserve.liquidityIndex); emit Withdraw(asset, msg.sender, to, amountToWithdraw); + + return amountToWithdraw; } /** @@ -229,6 +232,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed + * @return The final amount repaid **/ function repay( address asset,