mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Rename updateIndexesAndTimestamp to updateState
This commit is contained in:
parent
162c7924a9
commit
fc2852e94e
|
@ -103,7 +103,7 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
|||
|
||||
address aToken = reserve.aTokenAddress;
|
||||
|
||||
reserve.updateCumulativeIndexesAndTimestamp();
|
||||
reserve.updateState();
|
||||
reserve.updateInterestRates(asset, aToken, amount, 0);
|
||||
|
||||
bool isFirstDeposit = IAToken(aToken).balanceOf(onBehalfOf) == 0;
|
||||
|
@ -149,7 +149,7 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
|||
_addressesProvider.getPriceOracle()
|
||||
);
|
||||
|
||||
reserve.updateCumulativeIndexesAndTimestamp();
|
||||
reserve.updateState();
|
||||
|
||||
reserve.updateInterestRates(asset, aToken, 0, amountToWithdraw);
|
||||
|
||||
|
@ -237,7 +237,7 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
|||
variableDebt
|
||||
);
|
||||
|
||||
reserve.updateCumulativeIndexesAndTimestamp();
|
||||
reserve.updateState();
|
||||
|
||||
address debtTokenAddress = interestRateMode == ReserveLogic.InterestRateMode.STABLE
|
||||
? reserve.stableDebtTokenAddress
|
||||
|
@ -284,7 +284,7 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
|||
interestRateMode
|
||||
);
|
||||
|
||||
reserve.updateCumulativeIndexesAndTimestamp();
|
||||
reserve.updateState();
|
||||
|
||||
address debtTokenAddress = interestRateMode == ReserveLogic.InterestRateMode.STABLE
|
||||
? reserve.stableDebtTokenAddress
|
||||
|
@ -346,7 +346,7 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
|||
|
||||
//burn old debt tokens, mint new ones
|
||||
|
||||
reserve.updateCumulativeIndexesAndTimestamp();
|
||||
reserve.updateState();
|
||||
|
||||
_mintToReserveTreasury(reserve, user, address(stableDebtToken));
|
||||
|
||||
|
@ -529,7 +529,7 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
|||
if (debtMode == ReserveLogic.InterestRateMode.NONE) {
|
||||
IERC20(asset).transferFrom(receiverAddress, vars.aTokenAddress, vars.amountPlusPremium);
|
||||
|
||||
reserve.updateCumulativeIndexesAndTimestamp();
|
||||
reserve.updateState();
|
||||
reserve.cumulateToLiquidityIndex(IERC20(vars.aTokenAddress).totalSupply(), vars.premium);
|
||||
reserve.updateInterestRates(asset, vars.aTokenAddress, vars.premium, 0);
|
||||
|
||||
|
@ -818,7 +818,7 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
|||
|
||||
_mintToReserveTreasury(reserve, vars.user, debtTokenAddress);
|
||||
|
||||
reserve.updateCumulativeIndexesAndTimestamp();
|
||||
reserve.updateState();
|
||||
|
||||
//caching the current stable borrow rate
|
||||
uint256 currentStableRate = 0;
|
||||
|
@ -931,27 +931,4 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
|||
function getAddressesProvider() external view returns (ILendingPoolAddressesProvider) {
|
||||
return _addressesProvider;
|
||||
}
|
||||
|
||||
function _mintToReserveTreasury(
|
||||
ReserveLogic.ReserveData storage reserve,
|
||||
address user,
|
||||
address debtTokenAddress
|
||||
) internal {
|
||||
uint256 reserveFactor = reserve.configuration.getReserveFactor();
|
||||
if (reserveFactor == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint256 currentPrincipalBalance = DebtTokenBase(debtTokenAddress).principalBalanceOf(user);
|
||||
//calculating the interest accrued since the last borrow and minting the equivalent amount to the reserve factor
|
||||
if (currentPrincipalBalance > 0) {
|
||||
uint256 balanceIncrease = IERC20(debtTokenAddress).balanceOf(user).sub(
|
||||
currentPrincipalBalance
|
||||
);
|
||||
|
||||
uint256 amountForReserveFactor = balanceIncrease.percentMul(reserveFactor);
|
||||
|
||||
IAToken(reserve.aTokenAddress).mintToReserve(amountForReserveFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ contract LendingPoolLiquidationManager is VersionedInitializable {
|
|||
}
|
||||
|
||||
//update the principal reserve
|
||||
principalReserve.updateCumulativeIndexesAndTimestamp();
|
||||
principalReserve.updateState();
|
||||
|
||||
|
||||
|
||||
|
@ -279,7 +279,7 @@ contract LendingPoolLiquidationManager is VersionedInitializable {
|
|||
//otherwise receives the underlying asset
|
||||
|
||||
//updating collateral reserve
|
||||
collateralReserve.updateCumulativeIndexesAndTimestamp();
|
||||
collateralReserve.updateState();
|
||||
collateralReserve.updateInterestRates(
|
||||
collateral,
|
||||
address(vars.collateralAtoken),
|
||||
|
@ -406,7 +406,7 @@ contract LendingPoolLiquidationManager is VersionedInitializable {
|
|||
vars.actualAmountToLiquidate = vars.principalAmountNeeded;
|
||||
}
|
||||
//updating collateral reserve indexes
|
||||
collateralReserve.updateCumulativeIndexesAndTimestamp();
|
||||
collateralReserve.updateState();
|
||||
|
||||
vars.collateralAtoken.burn(user, receiver, vars.maxCollateralToLiquidate, collateralReserve.liquidityIndex);
|
||||
|
||||
|
@ -426,7 +426,7 @@ contract LendingPoolLiquidationManager is VersionedInitializable {
|
|||
);
|
||||
|
||||
//updating debt reserve
|
||||
debtReserve.updateCumulativeIndexesAndTimestamp();
|
||||
debtReserve.updateState();
|
||||
debtReserve.updateInterestRates(principal, principalAToken, vars.actualAmountToLiquidate, 0);
|
||||
IERC20(principal).transferFrom(receiver, principalAToken, vars.actualAmountToLiquidate);
|
||||
|
||||
|
|
|
@ -125,7 +125,9 @@ library ReserveLogic {
|
|||
* a formal specification.
|
||||
* @param reserve the reserve object
|
||||
**/
|
||||
function updateCumulativeIndexesAndTimestamp(ReserveData storage reserve) internal {
|
||||
function updateState(ReserveData storage reserve) internal {
|
||||
|
||||
|
||||
uint256 currentLiquidityRate = reserve.currentLiquidityRate;
|
||||
|
||||
//only cumulating if there is any income being produced
|
||||
|
|
Loading…
Reference in New Issue
Block a user