Platform: Code4rena
Start Date: 30/04/2024
Pot Size: $112,500 USDC
Total HM: 22
Participants: 122
Period: 8 days
Judge: alcueca
Total Solo HM: 1
Id: 372
League: ETH
Rank: 46/122
Findings: 1
Award: $18.20
🌟 Selected for report: 0
🚀 Solo Findings: 0
18.1958 USDC - $18.20
https://github.com/code-423n4/2024-04-renzo/blob/519e518f2d8dec9acf6482b84a181e403070d22d/contracts/RestakeManager.sol#L243-L259 https://github.com/code-423n4/2024-04-renzo/blob/519e518f2d8dec9acf6482b84a181e403070d22d/contracts/RestakeManager.sol#L294-L326 https://github.com/code-423n4/2024-04-renzo/blob/519e518f2d8dec9acf6482b84a181e403070d22d/contracts/RestakeManager.sol#L564-L569 https://github.com/code-423n4/2024-04-renzo/blob/519e518f2d8dec9acf6482b84a181e403070d22d/contracts/Oracle/RenzoOracle.sol#L123-L149 https://github.com/code-423n4/2024-04-renzo/blob/519e518f2d8dec9acf6482b84a181e403070d22d/contracts/Oracle/RenzoOracle.sol#L152-L163
The removeCollateralToken
function does not check if deposited tokens in the removed collateral token are still present, potentially leading to a denial of service for users attempting to withdraw their tokens. This oversight can result in an increase in minted tokens beyond what should be minted and redemption of fewer tokens than a user would have received before the token was removed. Additionally, the removal of a collateral token affects Total Value Locked (TVL) calculations, as the total TVL decreases without accounting for the collateral tokens in the vault. This discrepancy between TVL and the actual value of EZETH tokens can cause users who mint at that particular time to receive more tokens than they should, as the TVL total is not accurately reflected.
// Calculate how much ezETH to mint uint256 ezETHToMint = renzoOracle.calculateMintAmount( totalTVL, msg.value, ezETH.totalSupply() ); // Mint the ezETH ezETH.mint(msg.sender, ezETHToMint);
Let's illustrate the impact with some numbers:
function calculateMintAmount( uint256 _currentValueInProtocol, uint256 _newValueAdded, uint256 _existingEzETHSupply ) external pure returns (uint256) { // For first mint, just return the new value added. // Checking both current value and existing supply to guard against gaming the initial mint if (_currentValueInProtocol == 0 || _existingEzETHSupply == 0) { return _newValueAdded; // value is priced in base units, so divide by scale factor } // Calculate the percentage of value after the deposit uint256 inflationPercentaage = (SCALE_FACTOR * _newValueAdded) / (_currentValueInProtocol + _newValueAdded); // Calculate the new supply uint256 newEzETHSupply = (_existingEzETHSupply * SCALE_FACTOR) / (SCALE_FACTOR - inflationPercentaage); // Subtract the old supply from the new supply to get the amount to mint uint256 mintAmount = newEzETHSupply - _existingEzETHSupply;
Without impact:
With impact:
For redemption:
function calculateRedeemAmount( uint256 _ezETHBeingBurned, uint256 _existingEzETHSupply, uint256 _currentValueInProtocol ) external pure returns (uint256) { // This is just returning the percentage of TVL that matches the percentage of ezETH being burned uint256 redeemAmount = (_currentValueInProtocol * _ezETHBeingBurned) / _existingEzETHSupply; // Sanity check if (redeemAmount == 0) revert("Invalid token amount"); return redeemAmount; }
Manual code analysis
Prevent the admin from removing a collateral token if there are still tokens available in them, or trigger a withdrawal of all funds in the token, ensuring corresponding EZETH is burnt and users can decide to restake using another allowed token.
Error
#0 - c4-judge
2024-05-17T14:00:31Z
alcueca marked the issue as not a duplicate
#1 - c4-judge
2024-05-17T14:00:40Z
alcueca marked the issue as duplicate of #464
#2 - c4-judge
2024-05-17T14:03:49Z
alcueca changed the severity to 3 (High Risk)
#3 - c4-judge
2024-05-17T14:04:08Z
alcueca marked the issue as duplicate of #97
#4 - c4-judge
2024-05-17T14:05:46Z
alcueca marked the issue as unsatisfactory: Invalid
#5 - c4-judge
2024-05-20T04:34:14Z
alcueca changed the severity to 2 (Med Risk)
#6 - c4-judge
2024-05-20T04:41:21Z
alcueca marked the issue as satisfactory