mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
refactor: changed the behavior of mintToTreasury
This commit is contained in:
parent
6230f2b034
commit
5f0fb4bec9
|
@ -167,6 +167,16 @@ interface ILendingPool {
|
|||
uint256 variableBorrowIndex
|
||||
);
|
||||
|
||||
/**
|
||||
* @dev Emitted when the protocol treasury receives minted aTokens from the accrued interest.
|
||||
* @param reserve the address of the reserve
|
||||
* @param amountMinted the amount minted to the treasury
|
||||
**/
|
||||
event TreasuryUpdated(
|
||||
address indexed reserve,
|
||||
uint256 amountMinted
|
||||
);
|
||||
|
||||
/**
|
||||
* @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
|
||||
* - E.g. User deposits 100 USDC and gets in return 100 aUSDC
|
||||
|
|
|
@ -479,6 +479,26 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Mints the assets accrued through the reserve factor to the treasury in the form of aTokens
|
||||
**/
|
||||
function mintToTreasury() public {
|
||||
for (uint256 i = 0; i < _reservesCount; i++) {
|
||||
address reserveAddress = _reservesList[i];
|
||||
DataTypes.ReserveData storage reserve = _reserves[reserveAddress];
|
||||
uint256 accruedToTreasury = reserve.accruedToTreasury;
|
||||
|
||||
if (accruedToTreasury != 0) {
|
||||
uint256 normalizedIncome = reserve.getNormalizedIncome();
|
||||
uint256 amountToMint = accruedToTreasury.rayMul(normalizedIncome);
|
||||
IAToken(reserve.aTokenAddress).mintToTreasury(amountToMint, normalizedIncome);
|
||||
|
||||
reserve.accruedToTreasury = 0;
|
||||
emit TreasuryUpdated(reserveAddress, amountToMint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the state and configuration of the reserve
|
||||
* @param asset The address of the underlying asset of the reserve
|
||||
|
|
|
@ -320,7 +320,7 @@ library ReserveLogic {
|
|||
vars.amountToMint = vars.totalDebtAccrued.percentMul(vars.reserveFactor);
|
||||
|
||||
if (vars.amountToMint != 0) {
|
||||
IAToken(reserve.aTokenAddress).mintToTreasury(vars.amountToMint, newLiquidityIndex);
|
||||
reserve.accruedToTreasury = reserve.accruedToTreasury.add(vars.amountToMint.rayDiv(newLiquidityIndex));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ library DataTypes {
|
|||
address interestRateStrategyAddress;
|
||||
//the id of the reserve. Represents the position in the list of the active reserves
|
||||
uint8 id;
|
||||
//the current treasury balance, scaled
|
||||
uint256 accruedToTreasury;
|
||||
}
|
||||
|
||||
struct ReserveConfigurationMap {
|
||||
|
|
Loading…
Reference in New Issue
Block a user