mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
fix: improved block on borrow/repay in the same tx
This commit is contained in:
parent
76a141cd36
commit
d62ef92d30
|
@ -781,8 +781,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
vars.releaseUnderlying ? vars.amount : 0
|
||||
);
|
||||
|
||||
_lastBorrower = vars.user;
|
||||
_lastBorrowTimestamp = uint40(block.timestamp);
|
||||
_usersLastBorrowTimestamp[vars.asset][vars.user] = block.timestamp;
|
||||
|
||||
if (vars.releaseUnderlying) {
|
||||
IAToken(reserveCache.aTokenAddress).transferUnderlyingTo(vars.user, vars.amount);
|
||||
|
@ -901,14 +900,14 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
DataTypes.InterestRateMode interestRateMode = DataTypes.InterestRateMode(rateMode);
|
||||
|
||||
ValidationLogic.validateRepay(
|
||||
_lastBorrower,
|
||||
_lastBorrowTimestamp,
|
||||
reserveCache,
|
||||
asset,
|
||||
amount,
|
||||
interestRateMode,
|
||||
onBehalfOf,
|
||||
stableDebt,
|
||||
variableDebt
|
||||
variableDebt,
|
||||
_usersLastBorrowTimestamp
|
||||
);
|
||||
|
||||
uint256 paybackAmount =
|
||||
|
|
|
@ -36,7 +36,6 @@ contract LendingPoolStorage {
|
|||
|
||||
uint256 internal _flashLoanPremiumToProtocol;
|
||||
|
||||
address internal _lastBorrower;
|
||||
mapping(address => mapping(address => uint256)) _usersLastBorrowTimestamp;
|
||||
|
||||
uint40 internal _lastBorrowTimestamp;
|
||||
}
|
||||
|
|
|
@ -249,21 +249,23 @@ library ValidationLogic {
|
|||
/**
|
||||
* @dev Validates a repay action
|
||||
* @param reserveCache The cached data of the reserve
|
||||
* @param asset The asset address
|
||||
* @param amountSent The amount sent for the repayment. Can be an actual value or uint(-1)
|
||||
* @param rateMode the interest rate mode of the debt being repaid
|
||||
* @param onBehalfOf The address of the user msg.sender is repaying for
|
||||
* @param stableDebt The borrow balance of the user
|
||||
* @param variableDebt The borrow balance of the user
|
||||
* @param lastUsersBorrowTimestamp The data structure that keeps track of all the latest borrowings from the users
|
||||
*/
|
||||
function validateRepay(
|
||||
address lastBorrower,
|
||||
uint40 lastBorrowTimestamp,
|
||||
DataTypes.ReserveCache memory reserveCache,
|
||||
address asset,
|
||||
uint256 amountSent,
|
||||
DataTypes.InterestRateMode rateMode,
|
||||
address onBehalfOf,
|
||||
uint256 stableDebt,
|
||||
uint256 variableDebt
|
||||
uint256 variableDebt,
|
||||
mapping(address => mapping(address => uint256)) storage lastUsersBorrowTimestamp
|
||||
) external view {
|
||||
(bool isActive, , , , bool isPaused) = reserveCache.reserveConfiguration.getFlagsMemory();
|
||||
require(isActive, Errors.VL_NO_ACTIVE_RESERVE);
|
||||
|
@ -272,7 +274,7 @@ library ValidationLogic {
|
|||
require(amountSent > 0, Errors.VL_INVALID_AMOUNT);
|
||||
|
||||
require(
|
||||
lastBorrower != onBehalfOf || lastBorrowTimestamp != uint40(block.timestamp),
|
||||
lastUsersBorrowTimestamp[asset][onBehalfOf] != uint40(block.timestamp),
|
||||
Errors.VL_SAME_BLOCK_BORROW_REPAY
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user