mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge branch '134-add-check-on-initreserve-that-asset-is-a-valid-contract' into 'master'
Resolve "Add check on initReserve() that asset is a valid contract" Closes #134 See merge request aave-tech/protocol-v2!153
This commit is contained in:
commit
18446c7ecd
|
@ -25,6 +25,7 @@ import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol';
|
||||||
import {SafeERC20} from '../dependencies/openzeppelin/contracts/SafeERC20.sol';
|
import {SafeERC20} from '../dependencies/openzeppelin/contracts/SafeERC20.sol';
|
||||||
import {ILendingPool} from '../interfaces/ILendingPool.sol';
|
import {ILendingPool} from '../interfaces/ILendingPool.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
|
||||||
|
@ -44,16 +45,16 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
uint256 public constant LENDINGPOOL_REVISION = 0x2;
|
uint256 public constant LENDINGPOOL_REVISION = 0x2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev functions marked by this modifier can only be called when the protocol is not paused
|
* @dev functions marked by this modifier can only be called when the protocol is not paused
|
||||||
**/
|
**/
|
||||||
modifier whenNotPaused() {
|
modifier whenNotPaused() {
|
||||||
_whenNotPaused();
|
_whenNotPaused();
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev functions marked by this modifier can only be called by the LendingPoolConfigurator
|
* @dev functions marked by this modifier can only be called by the LendingPoolConfigurator
|
||||||
**/
|
**/
|
||||||
modifier onlyLendingPoolConfigurator() {
|
modifier onlyLendingPoolConfigurator() {
|
||||||
_onlyLendingPoolConfigurator();
|
_onlyLendingPoolConfigurator();
|
||||||
_;
|
_;
|
||||||
|
@ -139,7 +140,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
uint256 amount,
|
uint256 amount,
|
||||||
address to
|
address to
|
||||||
) external override whenNotPaused {
|
) external override whenNotPaused {
|
||||||
|
|
||||||
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
||||||
|
|
||||||
address aToken = reserve.aTokenAddress;
|
address aToken = reserve.aTokenAddress;
|
||||||
|
@ -224,7 +224,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
uint256 rateMode,
|
uint256 rateMode,
|
||||||
address onBehalfOf
|
address onBehalfOf
|
||||||
) external override whenNotPaused {
|
) external override whenNotPaused {
|
||||||
|
|
||||||
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
||||||
|
|
||||||
(uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(onBehalfOf, reserve);
|
(uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(onBehalfOf, reserve);
|
||||||
|
@ -280,7 +279,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
* @param rateMode the rate mode that the user wants to swap
|
* @param rateMode the rate mode that the user wants to swap
|
||||||
**/
|
**/
|
||||||
function swapBorrowRateMode(address asset, uint256 rateMode) external override whenNotPaused {
|
function swapBorrowRateMode(address asset, uint256 rateMode) external override whenNotPaused {
|
||||||
|
|
||||||
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
||||||
|
|
||||||
(uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(msg.sender, reserve);
|
(uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(msg.sender, reserve);
|
||||||
|
@ -335,7 +333,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
* @param user the address of the user to be rebalanced
|
* @param user the address of the user to be rebalanced
|
||||||
**/
|
**/
|
||||||
function rebalanceStableBorrowRate(address asset, address user) external override whenNotPaused {
|
function rebalanceStableBorrowRate(address asset, address user) external override whenNotPaused {
|
||||||
|
|
||||||
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
||||||
|
|
||||||
IERC20 stableDebtToken = IERC20(reserve.stableDebtTokenAddress);
|
IERC20 stableDebtToken = IERC20(reserve.stableDebtTokenAddress);
|
||||||
|
@ -372,8 +369,11 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
* @param useAsCollateral true if the user wants to use the deposit as collateral, false otherwise.
|
* @param useAsCollateral true if the user wants to use the deposit as collateral, false otherwise.
|
||||||
**/
|
**/
|
||||||
function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external override whenNotPaused {
|
function setUserUseReserveAsCollateral(address asset, bool useAsCollateral)
|
||||||
|
external
|
||||||
|
override
|
||||||
|
whenNotPaused
|
||||||
|
{
|
||||||
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
||||||
|
|
||||||
ValidationLogic.validateSetUseReserveAsCollateral(
|
ValidationLogic.validateSetUseReserveAsCollateral(
|
||||||
|
@ -468,7 +468,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
bytes calldata params,
|
bytes calldata params,
|
||||||
uint16 referralCode
|
uint16 referralCode
|
||||||
) external override whenNotPaused {
|
) external override whenNotPaused {
|
||||||
|
|
||||||
FlashLoanLocalVars memory vars;
|
FlashLoanLocalVars memory vars;
|
||||||
|
|
||||||
ValidationLogic.validateFlashloan(assets, amounts);
|
ValidationLogic.validateFlashloan(assets, amounts);
|
||||||
|
@ -704,7 +703,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
uint256 balanceFromBefore,
|
uint256 balanceFromBefore,
|
||||||
uint256 balanceToBefore
|
uint256 balanceToBefore
|
||||||
) external override whenNotPaused {
|
) external override whenNotPaused {
|
||||||
|
|
||||||
require(msg.sender == _reserves[asset].aTokenAddress, Errors.LP_CALLER_MUST_BE_AN_ATOKEN);
|
require(msg.sender == _reserves[asset].aTokenAddress, Errors.LP_CALLER_MUST_BE_AN_ATOKEN);
|
||||||
|
|
||||||
ValidationLogic.validateTransfer(
|
ValidationLogic.validateTransfer(
|
||||||
|
@ -753,7 +751,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
address variableDebtAddress,
|
address variableDebtAddress,
|
||||||
address interestRateStrategyAddress
|
address interestRateStrategyAddress
|
||||||
) external override onlyLendingPoolConfigurator {
|
) external override onlyLendingPoolConfigurator {
|
||||||
|
require(Address.isContract(asset), Errors.LP_NOT_CONTRACT);
|
||||||
_reserves[asset].init(
|
_reserves[asset].init(
|
||||||
aTokenAddress,
|
aTokenAddress,
|
||||||
stableDebtAddress,
|
stableDebtAddress,
|
||||||
|
@ -781,7 +779,11 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
* @param asset the address of the reserve
|
* @param asset the address of the reserve
|
||||||
* @param configuration the configuration map
|
* @param configuration the configuration map
|
||||||
**/
|
**/
|
||||||
function setConfiguration(address asset, uint256 configuration) external override onlyLendingPoolConfigurator {
|
function setConfiguration(address asset, uint256 configuration)
|
||||||
|
external
|
||||||
|
override
|
||||||
|
onlyLendingPoolConfigurator
|
||||||
|
{
|
||||||
_reserves[asset].configuration.data = configuration;
|
_reserves[asset].configuration.data = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -790,7 +792,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
* @param val the boolean value to set the current pause state of LendingPool
|
* @param val the boolean value to set the current pause state of LendingPool
|
||||||
*/
|
*/
|
||||||
function setPause(bool val) external override onlyLendingPoolConfigurator {
|
function setPause(bool val) external override onlyLendingPoolConfigurator {
|
||||||
|
|
||||||
_paused = val;
|
_paused = val;
|
||||||
if (_paused) {
|
if (_paused) {
|
||||||
emit Paused();
|
emit Paused();
|
||||||
|
|
|
@ -97,6 +97,7 @@ library Errors {
|
||||||
string public constant VL_INCONSISTENT_FLASHLOAN_PARAMS = '73';
|
string public constant VL_INCONSISTENT_FLASHLOAN_PARAMS = '73';
|
||||||
string public constant LP_INCONSISTENT_PARAMS_LENGTH = '74';
|
string public constant LP_INCONSISTENT_PARAMS_LENGTH = '74';
|
||||||
string public constant UL_INVALID_INDEX = '77';
|
string public constant UL_INVALID_INDEX = '77';
|
||||||
|
string public constant LP_NOT_CONTRACT = '78';
|
||||||
|
|
||||||
enum CollateralManagerErrors {
|
enum CollateralManagerErrors {
|
||||||
NO_ERROR,
|
NO_ERROR,
|
||||||
|
|
|
@ -1285,4 +1285,4 @@
|
||||||
"address": "0xaDF23b1cAa6a7B3b077c432794FfF80A4b935cdF"
|
"address": "0xaDF23b1cAa6a7B3b077c432794FfF80A4b935cdF"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user