In both convertLPToBeans()
and convertBeansToLP()
functions, there's a calculation for minAmountOut
, which represents the minimum amount of the output token that should be received based on the provided input. This value is calculated based on the minimum acceptable amount of the other token (either beans
or LP tokens
), ensuring that the conversion meets certain requirements.
convertBeansToLP()
https://github.com/Cyfrin/2024-04-beanstalk-2/blob/27ff8c87c9164c1fbff054be5f22e56f86cdf127/protocol/contracts/libraries/Convert/LibUnripeConvert.sol#L59-L94
convertLPToBeans()
https://github.com/Cyfrin/2024-04-beanstalk-2/blob/27ff8c87c9164c1fbff054be5f22e56f86cdf127/protocol/contracts/libraries/Convert/LibUnripeConvert.sol#L22-L57
After calculating minAmountOut
, the functions proceed to execute the conversion by calling appropriate liquidity-related functions (_wellRemoveLiquidityTowardsPeg() in convertLPToBeans() and _wellAddLiquidityTowardsPeg() in convertBeansToLP()
). These functions interact with the liquidity pools to perform the conversion operation.
The critical part here is the subsequent minting operation:
This line mints the output token (tokenOut
) to the current contract (address(this)
) with the calculated amountOut
. However, there's no explicit comparison between amountOut
and minAmountOut
before proceeding with this minting operation.
The absence of a comparison between amountOut
and minAmountOut
means there's no check to ensure that the actual output amount (amountOut
) meets the minimum required output (minAmountOut
).
Loss of Funds:
If the actual output amount is lower than the minimum required amount, the amount minted would be lower than the expected output, potentially resulting in financial losses.
Manual Review
Include a comparison between amountOut
and minAmountOut
before proceeding with the minting operation. If amountOut
is less than minAmountOut
, appropriate actions should be taken, such as reverting the transaction.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.