mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
feat: added storage and check that repayer is not the last borrower of a reserve
This commit is contained in:
parent
6a69a00372
commit
09233d09bf
|
@ -240,7 +240,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
|
||||
///@inheritdoc ILendingPool
|
||||
function rebalanceStableBorrowRate(address asset, address user) external override whenNotPaused {
|
||||
|
||||
DataTypes.ReserveData storage reserve = _reserves[asset];
|
||||
DataTypes.ReserveCache memory reserveCache = reserve.cache();
|
||||
|
||||
|
@ -793,6 +792,9 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
vars.releaseUnderlying ? vars.amount : 0
|
||||
);
|
||||
|
||||
_lastBorrower = vars.user;
|
||||
_lastBorrowTimestamp = uint40(block.timestamp);
|
||||
|
||||
if (vars.releaseUnderlying) {
|
||||
IAToken(reserveCache.aTokenAddress).transferUnderlyingTo(vars.user, vars.amount);
|
||||
}
|
||||
|
@ -908,6 +910,8 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
DataTypes.InterestRateMode interestRateMode = DataTypes.InterestRateMode(rateMode);
|
||||
|
||||
ValidationLogic.validateRepay(
|
||||
_lastBorrower,
|
||||
_lastBorrowTimestamp,
|
||||
reserveCache,
|
||||
amount,
|
||||
interestRateMode,
|
||||
|
|
|
@ -33,4 +33,8 @@ contract LendingPoolStorage {
|
|||
mapping(address => bool) _authorizedFlashBorrowers;
|
||||
|
||||
uint256 internal _flashLoanPremiumToProtocol;
|
||||
|
||||
address internal _lastBorrower;
|
||||
|
||||
uint40 internal _lastBorrowTimestamp;
|
||||
}
|
||||
|
|
|
@ -255,6 +255,8 @@ library ValidationLogic {
|
|||
* @param variableDebt The borrow balance of the user
|
||||
*/
|
||||
function validateRepay(
|
||||
address lastBorrower,
|
||||
uint40 lastBorrowTimestamp,
|
||||
DataTypes.ReserveCache memory reserveCache,
|
||||
uint256 amountSent,
|
||||
DataTypes.InterestRateMode rateMode,
|
||||
|
@ -268,6 +270,8 @@ library ValidationLogic {
|
|||
|
||||
require(amountSent > 0, Errors.VL_INVALID_AMOUNT);
|
||||
|
||||
require(lastBorrower != onBehalfOf || lastBorrowTimestamp != uint40(block.timestamp));
|
||||
|
||||
require(
|
||||
(stableDebt > 0 &&
|
||||
DataTypes.InterestRateMode(rateMode) == DataTypes.InterestRateMode.STABLE) ||
|
||||
|
@ -347,7 +351,6 @@ library ValidationLogic {
|
|||
IERC20 variableDebtToken,
|
||||
address aTokenAddress
|
||||
) external view {
|
||||
|
||||
// to avoid potential abuses using flashloans, the rebalance stable rate must happen through an EOA
|
||||
require(!address(msg.sender).isContract(), Errors.LP_CALLER_NOT_EOA);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user