Summary
In the UnripeFacet.sol
contract, the ChangeUnderlying
event is defined but never emitted within the contract's functions. This omission could lead to issues in tracking changes to the underlying asset of an unripe tokens.
Vulnerability Details
This event must use in addMigratedUnderlying and switchUnderlyingToken function because they are change the state of the contract increases or decreases Unripe Token
* @notice Emitted when the Ripe Token of an Unripe Token increases or decreases.
* @param token The token of which the Underlying changes.
* @param underlying `amount` that has changed.
*/
event ChangeUnderlying(address indexed token, int256 underlying);
function addMigratedUnderlying(
address unripeToken,
uint256 amount
) external payable nonReentrant {
LibDiamond.enforceIsContractOwner();
IERC20(s.u[unripeToken].underlyingToken).safeTransferFrom(
msg.sender,
address(this),
amount
);
LibUnripe.incrementUnderlying(unripeToken, amount);
}
function switchUnderlyingToken(
address unripeToken,
address newUnderlyingToken
) external payable {
LibDiamond.enforceIsContractOwner();
require(s.u[unripeToken].balanceOfUnderlying == 0, "Unripe: Underlying balance > 0");
LibUnripe.switchUnderlyingToken(unripeToken, newUnderlyingToken);
}
Tools Used
Manual Review
Recommendations
Ensure that the ChangeUnderlying
event is emitted in the appropriate functions.
function addMigratedUnderlying(address unripeToken, uint256 amount) external payable nonReentrant {
LibDiamond.enforceIsContractOwner();
IERC20(s.u[unripeToken].underlyingToken).safeTransferFrom(
msg.sender,
address(this),
amount
);
LibUnripe.incrementUnderlying(unripeToken, amount);
// Emit the ChangeUnderlying event
+ emit ChangeUnderlying(unripeToken, int256(amount));
}