mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Removed getters
This commit is contained in:
parent
a7861f8cba
commit
640f30c786
|
@ -315,52 +315,6 @@ interface ILendingPool {
|
|||
bytes calldata params
|
||||
) external;
|
||||
|
||||
/**
|
||||
* @dev accessory functions to fetch data from the core contract
|
||||
**/
|
||||
|
||||
function getReserveConfigurationData(address reserve)
|
||||
external
|
||||
view
|
||||
returns (
|
||||
uint256 decimals,
|
||||
uint256 ltv,
|
||||
uint256 liquidationThreshold,
|
||||
uint256 liquidationBonus,
|
||||
uint256 reserveFactor,
|
||||
address interestRateStrategyAddress,
|
||||
bool usageAsCollateralEnabled,
|
||||
bool borrowingEnabled,
|
||||
bool stableBorrowRateEnabled,
|
||||
bool isActive,
|
||||
bool isFreezed
|
||||
);
|
||||
|
||||
function getReserveTokensAddresses(address reserve)
|
||||
external
|
||||
view
|
||||
returns (
|
||||
address aTokenAddress,
|
||||
address stableDebtTokenAddress,
|
||||
address variableDebtTokenAddress
|
||||
);
|
||||
|
||||
function getReserveData(address reserve)
|
||||
external
|
||||
view
|
||||
returns (
|
||||
uint256 availableLiquidity,
|
||||
uint256 totalStableDebt,
|
||||
uint256 totalVariableDebt,
|
||||
uint256 liquidityRate,
|
||||
uint256 variableBorrowRate,
|
||||
uint256 stableBorrowRate,
|
||||
uint256 averageStableBorrowRate,
|
||||
uint256 liquidityIndex,
|
||||
uint256 variableBorrowIndex,
|
||||
uint40 lastUpdateTimestamp
|
||||
);
|
||||
|
||||
function getUserAccountData(address user)
|
||||
external
|
||||
view
|
||||
|
@ -373,21 +327,6 @@ interface ILendingPool {
|
|||
uint256 healthFactor
|
||||
);
|
||||
|
||||
function getUserReserveData(address reserve, address user)
|
||||
external
|
||||
view
|
||||
returns (
|
||||
uint256 currentATokenBalance,
|
||||
uint256 currentStableDebt,
|
||||
uint256 currentVariableDebt,
|
||||
uint256 principalStableDebt,
|
||||
uint256 scaledVariableDebt,
|
||||
uint256 stableBorrowRate,
|
||||
uint256 liquidityRate,
|
||||
uint40 stableRateLastUpdated,
|
||||
bool usageAsCollateralEnabled
|
||||
);
|
||||
|
||||
/**
|
||||
* @dev initializes a reserve
|
||||
* @param reserve the address of the reserve
|
||||
|
|
|
@ -29,6 +29,7 @@ import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol';
|
|||
import {ILendingPool} from '../interfaces/ILendingPool.sol';
|
||||
import {LendingPoolStorage} from './LendingPoolStorage.sol';
|
||||
import {IReserveInterestRateStrategy} from '../interfaces/IReserveInterestRateStrategy.sol';
|
||||
|
||||
/**
|
||||
* @title LendingPool contract
|
||||
* @notice Implements the actions of the LendingPool, and exposes accessory methods to fetch the users and reserve data
|
||||
|
@ -57,6 +58,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
Errors.CALLER_NOT_LENDING_POOL_CONFIGURATOR
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Function to make a function callable only when the contract is not paused.
|
||||
*
|
||||
|
@ -364,9 +366,8 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
* @param user the address of the user to be rebalanced
|
||||
**/
|
||||
function rebalanceStableBorrowRate(address asset, address user) external override {
|
||||
|
||||
_whenNotPaused();
|
||||
|
||||
|
||||
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
||||
|
||||
IERC20 stableDebtToken = IERC20(reserve.stableDebtTokenAddress);
|
||||
|
@ -376,7 +377,10 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
uint256 stableBorrowBalance = IERC20(stableDebtToken).balanceOf(user);
|
||||
|
||||
//if the utilization rate is below 95%, no rebalances are needed
|
||||
uint256 totalBorrows = stableDebtToken.totalSupply().add(variableDebtToken.totalSupply()).wadToRay();
|
||||
uint256 totalBorrows = stableDebtToken
|
||||
.totalSupply()
|
||||
.add(variableDebtToken.totalSupply())
|
||||
.wadToRay();
|
||||
uint256 availableLiquidity = IERC20(asset).balanceOf(aTokenAddress).wadToRay();
|
||||
uint256 usageRatio = totalBorrows == 0
|
||||
? 0
|
||||
|
@ -394,7 +398,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
|
||||
require(
|
||||
usageRatio >= REBALANCE_UP_USAGE_RATIO_THRESHOLD &&
|
||||
currentLiquidityRate <=
|
||||
currentLiquidityRate <=
|
||||
maxVariableBorrowRate.percentMul(REBALANCE_UP_LIQUIDITY_RATE_THRESHOLD),
|
||||
Errors.INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET
|
||||
);
|
||||
|
@ -402,12 +406,15 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
reserve.updateState();
|
||||
|
||||
IStableDebtToken(address(stableDebtToken)).burn(user, stableBorrowBalance);
|
||||
IStableDebtToken(address(stableDebtToken)).mint(user, stableBorrowBalance, reserve.currentStableBorrowRate);
|
||||
IStableDebtToken(address(stableDebtToken)).mint(
|
||||
user,
|
||||
stableBorrowBalance,
|
||||
reserve.currentStableBorrowRate
|
||||
);
|
||||
|
||||
reserve.updateInterestRates(asset, aTokenAddress, 0, 0);
|
||||
|
||||
emit RebalanceStableBorrowRate(asset, user);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -585,8 +592,8 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
|
||||
emit FlashLoan(receiverAddress, asset, amount, vars.premium, referralCode);
|
||||
} else {
|
||||
//if the user didn't choose to return the funds, the system checks if there
|
||||
//is enough collateral and eventually open a position
|
||||
//if the user didn't choose to return the funds, the system checks if there
|
||||
//is enough collateral and eventually open a position
|
||||
_executeBorrow(
|
||||
ExecuteBorrowParams(
|
||||
asset,
|
||||
|
@ -644,91 +651,13 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
* @dev accessory functions to fetch data from the core contract
|
||||
**/
|
||||
|
||||
function getReserveConfigurationData(address asset)
|
||||
external
|
||||
override
|
||||
view
|
||||
returns (
|
||||
uint256 decimals,
|
||||
uint256 ltv,
|
||||
uint256 liquidationThreshold,
|
||||
uint256 liquidationBonus,
|
||||
uint256 reserveFactor,
|
||||
address interestRateStrategyAddress,
|
||||
bool usageAsCollateralEnabled,
|
||||
bool borrowingEnabled,
|
||||
bool stableBorrowRateEnabled,
|
||||
bool isActive,
|
||||
bool isFreezed
|
||||
)
|
||||
{
|
||||
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
||||
|
||||
return (
|
||||
reserve.configuration.getDecimals(),
|
||||
reserve.configuration.getLtv(),
|
||||
reserve.configuration.getLiquidationThreshold(),
|
||||
reserve.configuration.getLiquidationBonus(),
|
||||
reserve.configuration.getReserveFactor(),
|
||||
reserve.interestRateStrategyAddress,
|
||||
reserve.configuration.getLtv() != 0,
|
||||
reserve.configuration.getBorrowingEnabled(),
|
||||
reserve.configuration.getStableRateBorrowingEnabled(),
|
||||
reserve.configuration.getActive(),
|
||||
reserve.configuration.getFrozen()
|
||||
);
|
||||
}
|
||||
|
||||
function getReserveTokensAddresses(address asset)
|
||||
external
|
||||
override
|
||||
view
|
||||
returns (
|
||||
address aTokenAddress,
|
||||
address stableDebtTokenAddress,
|
||||
address variableDebtTokenAddress
|
||||
)
|
||||
{
|
||||
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
||||
|
||||
return (
|
||||
reserve.aTokenAddress,
|
||||
reserve.stableDebtTokenAddress,
|
||||
reserve.variableDebtTokenAddress
|
||||
);
|
||||
}
|
||||
|
||||
function getReserveData(address asset)
|
||||
external
|
||||
override
|
||||
view
|
||||
returns (
|
||||
uint256 availableLiquidity,
|
||||
uint256 totalStableDebt,
|
||||
uint256 totalVariableDebt,
|
||||
uint256 liquidityRate,
|
||||
uint256 variableBorrowRate,
|
||||
uint256 stableBorrowRate,
|
||||
uint256 averageStableBorrowRate,
|
||||
uint256 liquidityIndex,
|
||||
uint256 variableBorrowIndex,
|
||||
uint40 lastUpdateTimestamp
|
||||
)
|
||||
returns (ReserveLogic.ReserveData memory)
|
||||
{
|
||||
ReserveLogic.ReserveData memory reserve = _reserves[asset];
|
||||
|
||||
return (
|
||||
IERC20(asset).balanceOf(reserve.aTokenAddress),
|
||||
IERC20(reserve.stableDebtTokenAddress).totalSupply(),
|
||||
IERC20(reserve.variableDebtTokenAddress).totalSupply(),
|
||||
reserve.currentLiquidityRate,
|
||||
reserve.currentVariableBorrowRate,
|
||||
reserve.currentStableBorrowRate,
|
||||
IStableDebtToken(reserve.stableDebtTokenAddress).getAverageStableRate(),
|
||||
reserve.liquidityIndex,
|
||||
reserve.variableBorrowIndex,
|
||||
reserve.lastUpdateTimestamp
|
||||
);
|
||||
return _reserves[asset];
|
||||
}
|
||||
|
||||
function getUserAccountData(address user)
|
||||
|
@ -758,7 +687,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
_reservesCount,
|
||||
_addressesProvider.getPriceOracle()
|
||||
);
|
||||
|
||||
|
||||
availableBorrowsETH = GenericLogic.calculateAvailableBorrowsETH(
|
||||
totalCollateralETH,
|
||||
totalBorrowsETH,
|
||||
|
@ -766,36 +695,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
);
|
||||
}
|
||||
|
||||
function getUserReserveData(address asset, address user)
|
||||
external
|
||||
override
|
||||
view
|
||||
returns (
|
||||
uint256 currentATokenBalance,
|
||||
uint256 currentStableDebt,
|
||||
uint256 currentVariableDebt,
|
||||
uint256 principalStableDebt,
|
||||
uint256 scaledVariableDebt,
|
||||
uint256 stableBorrowRate,
|
||||
uint256 liquidityRate,
|
||||
uint40 stableRateLastUpdated,
|
||||
bool usageAsCollateralEnabled
|
||||
)
|
||||
{
|
||||
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
||||
|
||||
currentATokenBalance = IERC20(reserve.aTokenAddress).balanceOf(user);
|
||||
(currentStableDebt, currentVariableDebt) = Helpers.getUserCurrentDebt(user, reserve);
|
||||
principalStableDebt = IStableDebtToken(reserve.stableDebtTokenAddress).principalBalanceOf(user);
|
||||
scaledVariableDebt = IVariableDebtToken(reserve.variableDebtTokenAddress).scaledBalanceOf(user);
|
||||
liquidityRate = reserve.currentLiquidityRate;
|
||||
stableBorrowRate = IStableDebtToken(reserve.stableDebtTokenAddress).getUserStableRate(user);
|
||||
stableRateLastUpdated = IStableDebtToken(reserve.stableDebtTokenAddress).getUserLastUpdated(
|
||||
user
|
||||
);
|
||||
usageAsCollateralEnabled = _usersConfig[user].isUsingAsCollateral(reserve.id);
|
||||
}
|
||||
|
||||
receive() external payable {
|
||||
revert();
|
||||
}
|
||||
|
@ -852,7 +751,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
}
|
||||
|
||||
// internal functions
|
||||
|
||||
struct ExecuteBorrowParams {
|
||||
address asset;
|
||||
address user;
|
||||
|
@ -948,12 +846,11 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
* @dev adds a reserve to the array of the _reserves address
|
||||
**/
|
||||
function _addReserveToList(address asset) internal {
|
||||
|
||||
require(_reservesCount < MAX_NUMBER_RESERVES, Errors.NO_MORE_RESERVES_ALLOWED);
|
||||
|
||||
bool reserveAlreadyAdded = _reserves[asset].id != 0 || _reservesList[0]==asset;
|
||||
|
||||
if(!reserveAlreadyAdded){
|
||||
bool reserveAlreadyAdded = _reserves[asset].id != 0 || _reservesList[0] == asset;
|
||||
|
||||
if (!reserveAlreadyAdded) {
|
||||
_reserves[asset].id = uint8(_reservesCount);
|
||||
_reservesList[_reservesCount] = asset;
|
||||
|
||||
|
@ -1038,7 +935,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
function getReservesList() external override view returns (address[] memory) {
|
||||
address[] memory _activeReserves = new address[](_reservesCount);
|
||||
|
||||
for(uint256 i = 0; i < _reservesCount; i++){
|
||||
for (uint256 i = 0; i < _reservesCount; i++) {
|
||||
_activeReserves[i] = _reservesList[i];
|
||||
}
|
||||
return _activeReserves;
|
||||
|
|
Loading…
Reference in New Issue
Block a user