DeFiHardhat
21,000 USDC
View results
Submission Details
Severity: low
Invalid

Lack of return value

Summary

The function getConvertedUnderlyingOut does not explicitly return a value despite declaring a return type. This oversight can lead to compilation errors or unexpected behavior in the contract's execution.

Vulnerability Details

The function is intended to calculate and return the amount of ripe assets converted from its unripe counterpart. However, it fails to explicitly use the return statement to output the calculated value.

https://github.com/Cyfrin/2024-05-Beanstalk-3/blob/662d26f12ee219ee92dc485c06e01a4cb5ee8dfb/protocol/contracts/libraries/Convert/LibChopConvert.sol#L53-L61

function getConvertedUnderlyingOut(address tokenIn, uint256 amountIn) internal view returns(uint256 amount) {
// tokenIn == unripe bean address
amount = LibUnripe.getPenalizedUnderlying(
tokenIn,
amountIn,
IBean(tokenIn).totalSupply()
);
}

The function signature indicates that it returns a uint256, but the function body lacks a return statement. This is crucial in Solidity, as functions that are expected to return a value must explicitly do so.

Tools Used

Manual review

Recommendations

function getConvertedUnderlyingOut(address tokenIn, uint256 amountIn) internal view returns(uint256) {
// tokenIn == unripe bean address
uint256 amount = LibUnripe.getPenalizedUnderlying(
tokenIn,
amountIn,
IBean(tokenIn).totalSupply()
);
+ return amount;
}
Updates

Lead Judging Commences

giovannidisiena Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.