Added the total supply on stable debt token

This commit is contained in:
The3D 2020-09-14 11:09:47 +02:00
parent 3c8018fab9
commit 5061aab9cc
3 changed files with 33 additions and 3 deletions

View File

@ -240,6 +240,12 @@ library ReserveLogic {
reserve.liquidityIndex,
reserve.variableBorrowIndex
);
}
function _mintToTreasury(ReserveData storage reserve) internal {
}
function _updateIndexes(ReserveData storage reserve) internal {

View File

@ -21,6 +21,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
uint256 private _avgStableRate;
mapping(address => uint40) _timestamps;
uint40 _totalSupplyTimestamp;
constructor(
address pool,
@ -76,7 +77,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
stableRate,
_timestamps[account]
);
return accountBalance.wadToRay().rayMul(cumulatedInterest).rayToWad();
return accountBalance.rayMul(cumulatedInterest);
}
struct MintLocalVars {
@ -122,7 +123,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
_usersData[user] = vars.newStableRate;
//solium-disable-next-line
_timestamps[user] = uint40(block.timestamp);
_totalSupplyTimestamp = _timestamps[user] = uint40(block.timestamp);
//calculates the updated average stable rate
@ -172,7 +173,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase {
_timestamps[user] = 0;
} else {
//solium-disable-next-line
_timestamps[user] = uint40(block.timestamp);
_totalSupplyTimestamp = _timestamps[user] = uint40(block.timestamp);
}
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);
}
}

View File

@ -84,4 +84,11 @@ interface IStableDebtToken {
* @return the timestamp
**/
function getUserLastUpdated(address user) external view returns (uint40);
/**
* @dev returns the principal total supply
**/
function principalTotalSupply() external view returns (uint40);
}