From ef62299da19f74fa45b3236791c38cb1c0ff8fe0 Mon Sep 17 00:00:00 2001 From: Hadrien Charlanes Date: Tue, 15 Jun 2021 16:46:27 +0200 Subject: [PATCH] refactor: cheaper check first --- contracts/protocol/libraries/logic/ValidationLogic.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/protocol/libraries/logic/ValidationLogic.sol b/contracts/protocol/libraries/logic/ValidationLogic.sol index 6890a278..e9e1663d 100644 --- a/contracts/protocol/libraries/logic/ValidationLogic.sol +++ b/contracts/protocol/libraries/logic/ValidationLogic.sol @@ -269,6 +269,11 @@ library ValidationLogic { require(amountSent > 0, Errors.VL_INVALID_AMOUNT); + require( + amountSent != uint256(-1) || msg.sender == onBehalfOf, + Errors.VL_NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF + ); + if (DataTypes.InterestRateMode(rateMode) == DataTypes.InterestRateMode.STABLE) { require(stableDebt > 0, Errors.VL_NO_DEBT_OF_SELECTED_TYPE); @@ -288,11 +293,6 @@ library ValidationLogic { Errors.VL_NO_DEBT_ACCRUED_BY_CONTRACT ); } - - require( - amountSent != uint256(-1) || msg.sender == onBehalfOf, - Errors.VL_NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF - ); } /**