Summary
The DebtToken::totalSupply
function has incorrect logic for scaling the total supply.
Vulnerability Details
The rayDiv
is used to scale the totalSupply
value, which is incorrect. The rayMul
should be used instead; otherwise, it will return an incorrect value.
as done in the balanceOf
function.
function balanceOf(address account) public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledBalance = super.balanceOf(account);
@>> return scaledBalance.rayMul(ILendingPool(_reservePool).getNormalizedDebt());
}
function totalSupply() public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledSupply = super.totalSupply();
@>> return scaledSupply.rayDiv(ILendingPool(_reservePool).getNormalizedDebt());
}
Impact
The totalSupply
will return an incorrect value if rayDiv
is used instead of rayMul
.
Recommendations
function totalSupply() public view override(ERC20, IERC20) returns (uint256) {
uint256 scaledSupply = super.totalSupply();
- return scaledSupply.rayDiv(ILendingPool(_reservePool).getNormalizedDebt());
+ return scaledSupply.rayMul(ILendingPool(_reservePool).getNormalizedDebt());
}