mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
refactor: moved check to validateRebalanceStableBorrowRate
This commit is contained in:
parent
0a58e714bf
commit
cce28ab4ea
|
@ -26,7 +26,6 @@ import {ReserveConfiguration} from '../libraries/configuration/ReserveConfigurat
|
||||||
import {UserConfiguration} from '../libraries/configuration/UserConfiguration.sol';
|
import {UserConfiguration} from '../libraries/configuration/UserConfiguration.sol';
|
||||||
import {DataTypes} from '../libraries/types/DataTypes.sol';
|
import {DataTypes} from '../libraries/types/DataTypes.sol';
|
||||||
import {LendingPoolStorage} from './LendingPoolStorage.sol';
|
import {LendingPoolStorage} from './LendingPoolStorage.sol';
|
||||||
import {Address} from '../../dependencies/openzeppelin/contracts/Address.sol';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title LendingPool contract
|
* @title LendingPool contract
|
||||||
|
@ -51,7 +50,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
using PercentageMath for uint256;
|
using PercentageMath for uint256;
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
using ReserveLogic for DataTypes.ReserveCache;
|
using ReserveLogic for DataTypes.ReserveCache;
|
||||||
using Address for address;
|
|
||||||
|
|
||||||
uint256 public constant LENDINGPOOL_REVISION = 0x2;
|
uint256 public constant LENDINGPOOL_REVISION = 0x2;
|
||||||
|
|
||||||
|
@ -329,8 +327,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
**/
|
**/
|
||||||
function rebalanceStableBorrowRate(address asset, address user) external override whenNotPaused {
|
function rebalanceStableBorrowRate(address asset, address user) external override whenNotPaused {
|
||||||
|
|
||||||
require(!address(msg.sender).isContract(), Errors.LP_CALLER_NOT_EOA);
|
|
||||||
|
|
||||||
DataTypes.ReserveData storage reserve = _reserves[asset];
|
DataTypes.ReserveData storage reserve = _reserves[asset];
|
||||||
DataTypes.ReserveCache memory reserveCache = reserve.cache();
|
DataTypes.ReserveCache memory reserveCache = reserve.cache();
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import {IScaledBalanceToken} from '../../../interfaces/IScaledBalanceToken.sol';
|
||||||
import {IAToken} from '../../../interfaces/IAToken.sol';
|
import {IAToken} from '../../../interfaces/IAToken.sol';
|
||||||
import {DataTypes} from '../types/DataTypes.sol';
|
import {DataTypes} from '../types/DataTypes.sol';
|
||||||
import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol';
|
import {IPriceOracleGetter} from '../../../interfaces/IPriceOracleGetter.sol';
|
||||||
|
import {Address} from '../../../dependencies/openzeppelin/contracts/Address.sol';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title ReserveLogic library
|
* @title ReserveLogic library
|
||||||
|
@ -34,6 +35,7 @@ library ValidationLogic {
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
|
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
|
||||||
using UserConfiguration for DataTypes.UserConfigurationMap;
|
using UserConfiguration for DataTypes.UserConfigurationMap;
|
||||||
|
using Address for address;
|
||||||
|
|
||||||
uint256 public constant REBALANCE_UP_LIQUIDITY_RATE_THRESHOLD = 4000;
|
uint256 public constant REBALANCE_UP_LIQUIDITY_RATE_THRESHOLD = 4000;
|
||||||
uint256 public constant REBALANCE_UP_USAGE_RATIO_THRESHOLD = 0.95 * 1e27; //usage ratio of 95%
|
uint256 public constant REBALANCE_UP_USAGE_RATIO_THRESHOLD = 0.95 * 1e27; //usage ratio of 95%
|
||||||
|
@ -283,7 +285,7 @@ library ValidationLogic {
|
||||||
/**
|
/**
|
||||||
* @dev Validates a swap of borrow rate mode.
|
* @dev Validates a swap of borrow rate mode.
|
||||||
* @param reserve The reserve state on which the user is swapping the rate
|
* @param reserve The reserve state on which the user is swapping the rate
|
||||||
* @param reserveCache The cached data of the reserve
|
* @param reserveCache The cached data of the reserve
|
||||||
* @param userConfig The user reserves configuration
|
* @param userConfig The user reserves configuration
|
||||||
* @param stableDebt The stable debt of the user
|
* @param stableDebt The stable debt of the user
|
||||||
* @param variableDebt The variable debt of the user
|
* @param variableDebt The variable debt of the user
|
||||||
|
@ -345,6 +347,10 @@ library ValidationLogic {
|
||||||
IERC20 variableDebtToken,
|
IERC20 variableDebtToken,
|
||||||
address aTokenAddress
|
address aTokenAddress
|
||||||
) external view {
|
) 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);
|
||||||
|
|
||||||
(bool isActive, , , , bool isPaused) = reserveCache.reserveConfiguration.getFlagsMemory();
|
(bool isActive, , , , bool isPaused) = reserveCache.reserveConfiguration.getFlagsMemory();
|
||||||
|
|
||||||
require(isActive, Errors.VL_NO_ACTIVE_RESERVE);
|
require(isActive, Errors.VL_NO_ACTIVE_RESERVE);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user