Summary
The RToken::mint
function return incorrect value when amountToMint == 0
Vulnerability Details
As stated in the comments above, the function's third return parameter should be:
"The new total supply after minting."
If no amount is minted, the total supply won't become zero as returned in the function; it will remain totalSupply()
.
* @return A tuple containing:
* - bool: True if this is the first mint for the recipient, false otherwise
* - uint256: The amount of scaled tokens minted
@> * - uint256: The new total supply after minting
* - uint256: The amount of underlying tokens minted
*/
function mint(
address caller,
address onBehalfOf,
uint256 amountToMint,
uint256 index
) external override onlyReservePool returns (bool, uint256, uint256, uint256) {
@>> if (amountToMint == 0) {
@>> return (false, 0, 0, 0);
`````
`````
`````
}
Impact
The return value used in any function will be inconsistent.
Recommendations
* @return A tuple containing:
* - bool: True if this is the first mint for the recipient, false otherwise
* - uint256: The amount of scaled tokens minted
* - uint256: The new total supply after minting
* - uint256: The amount of underlying tokens minted
*/
function mint(
address caller,
address onBehalfOf,
uint256 amountToMint,
uint256 index
) external override onlyReservePool returns (bool, uint256, uint256, uint256) {
if (amountToMint == 0) {
- return (false, 0, 0, 0);
+ return (false, 0, totalSupply(), 0);
`````
`````
`````
}