mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Added the total supply on stable debt token
This commit is contained in:
parent
3c8018fab9
commit
5061aab9cc
|
@ -240,6 +240,12 @@ library ReserveLogic {
|
||||||
reserve.liquidityIndex,
|
reserve.liquidityIndex,
|
||||||
reserve.variableBorrowIndex
|
reserve.variableBorrowIndex
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _mintToTreasury(ReserveData storage reserve) internal {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _updateIndexes(ReserveData storage reserve) internal {
|
function _updateIndexes(ReserveData storage reserve) internal {
|
||||||
|
|
|
@ -21,6 +21,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
|
||||||
|
|
||||||
uint256 private _avgStableRate;
|
uint256 private _avgStableRate;
|
||||||
mapping(address => uint40) _timestamps;
|
mapping(address => uint40) _timestamps;
|
||||||
|
uint40 _totalSupplyTimestamp;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
address pool,
|
address pool,
|
||||||
|
@ -76,7 +77,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
|
||||||
stableRate,
|
stableRate,
|
||||||
_timestamps[account]
|
_timestamps[account]
|
||||||
);
|
);
|
||||||
return accountBalance.wadToRay().rayMul(cumulatedInterest).rayToWad();
|
return accountBalance.rayMul(cumulatedInterest);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MintLocalVars {
|
struct MintLocalVars {
|
||||||
|
@ -122,7 +123,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
|
||||||
_usersData[user] = vars.newStableRate;
|
_usersData[user] = vars.newStableRate;
|
||||||
|
|
||||||
//solium-disable-next-line
|
//solium-disable-next-line
|
||||||
_timestamps[user] = uint40(block.timestamp);
|
_totalSupplyTimestamp = _timestamps[user] = uint40(block.timestamp);
|
||||||
|
|
||||||
|
|
||||||
//calculates the updated average stable rate
|
//calculates the updated average stable rate
|
||||||
|
@ -172,7 +173,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
|
||||||
_timestamps[user] = 0;
|
_timestamps[user] = 0;
|
||||||
} else {
|
} else {
|
||||||
//solium-disable-next-line
|
//solium-disable-next-line
|
||||||
_timestamps[user] = uint40(block.timestamp);
|
_totalSupplyTimestamp = _timestamps[user] = uint40(block.timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (balanceIncrease > amount) {
|
if (balanceIncrease > amount) {
|
||||||
|
@ -208,4 +209,20 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function principalTotalSupply() public override view returns(uint256) {
|
||||||
|
return super.totalSupply();
|
||||||
|
}
|
||||||
|
|
||||||
|
function totalSupply() public override view returns(uint256) {
|
||||||
|
uint256 principalSupply = super.totalSupply();
|
||||||
|
if (principalSupply == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
uint256 cumulatedInterest = MathUtils.calculateCompoundedInterest(
|
||||||
|
_avgStableRate,
|
||||||
|
_totalSupplyTimestamp
|
||||||
|
);
|
||||||
|
return principalSupply.rayMul(cumulatedInterest);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,4 +84,11 @@ interface IStableDebtToken {
|
||||||
* @return the timestamp
|
* @return the timestamp
|
||||||
**/
|
**/
|
||||||
function getUserLastUpdated(address user) external view returns (uint40);
|
function getUserLastUpdated(address user) external view returns (uint40);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev returns the principal total supply
|
||||||
|
**/
|
||||||
|
function principalTotalSupply() external view returns (uint40);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user