mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Updated repay function
This commit is contained in:
parent
9a4ccde6a2
commit
796dc8ee3f
|
@ -20,7 +20,7 @@ abstract contract FlashLoanReceiverBase is IFlashLoanReceiver {
|
|||
|
||||
receive() external payable {}
|
||||
|
||||
function transferFundsBackInternal(
|
||||
function _transferFundsBack(
|
||||
address reserve,
|
||||
address destination,
|
||||
uint256 amount
|
||||
|
|
|
@ -239,12 +239,14 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool {
|
|||
) external override nonReentrant {
|
||||
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
||||
|
||||
(uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(_onBehalfOf, reserve);
|
||||
|
||||
ReserveLogic.InterestRateMode rateMode = ReserveLogic.InterestRateMode(_rateMode);
|
||||
|
||||
//default to max amount
|
||||
uint256 paybackAmount = rateMode == ReserveLogic.InterestRateMode.STABLE
|
||||
? IERC20(reserve.stableDebtTokenAddress).balanceOf(_onBehalfOf)
|
||||
: IERC20(reserve.variableDebtTokenAddress).balanceOf(_onBehalfOf);
|
||||
? stableDebt
|
||||
: variableDebt;
|
||||
|
||||
if (amount != UINT_MAX_VALUE && amount < paybackAmount) {
|
||||
paybackAmount = amount;
|
||||
|
|
|
@ -217,16 +217,16 @@ library ValidationLogic {
|
|||
* @param reserve the reserve state from which the user is repaying
|
||||
* @param amountSent the amount sent for the repayment. Can be an actual value or uint(-1)
|
||||
* @param onBehalfOf the address of the user msg.sender is repaying for
|
||||
* @param stableBorrowBalance the borrow balance of the user
|
||||
* @param variableBorrowBalance the borrow balance of the user
|
||||
* @param stableDebt the borrow balance of the user
|
||||
* @param variableDebt the borrow balance of the user
|
||||
*/
|
||||
function validateRepay(
|
||||
ReserveLogic.ReserveData storage reserve,
|
||||
uint256 amountSent,
|
||||
ReserveLogic.InterestRateMode rateMode,
|
||||
address onBehalfOf,
|
||||
uint256 stableBorrowBalance,
|
||||
uint256 variableBorrowBalance
|
||||
uint256 stableDebt,
|
||||
uint256 variableDebt
|
||||
) external view {
|
||||
bool isActive = reserve.configuration.getActive();
|
||||
|
||||
|
@ -235,9 +235,9 @@ library ValidationLogic {
|
|||
require(amountSent > 0, 'Amount must be greater than 0');
|
||||
|
||||
require(
|
||||
(stableBorrowBalance > 0 &&
|
||||
(stableDebt > 0 &&
|
||||
ReserveLogic.InterestRateMode(rateMode) == ReserveLogic.InterestRateMode.STABLE) ||
|
||||
(variableBorrowBalance > 0 &&
|
||||
(variableDebt > 0 &&
|
||||
ReserveLogic.InterestRateMode(rateMode) == ReserveLogic.InterestRateMode.VARIABLE),
|
||||
'16'
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user