LibFertilizer: addUnderlying function calculates the amount of underlying assets that have to be added to Unripe Beans and the Unripe LP. To know how many new deposited Beans will be minted the percentToFill is calculated using as a denominator remainingRecapitalization() but there is no check if remainingRecapitalization() is zero, before using it.
remainingRecapitalization() function which is used in calculating the percentToFill returns zero by construction in case in which: s.recapitalized >= totalDollars see the code:
If the remainingRecapitalization() returns 0 the calculation of the percentToFill would result in a division by zero error, because the denominator. When remainingRecapitalization() is zero, Solidity can’t divide by zero and then the contract will revert with an error.
It impacts ‘addUnderlyingwhich is used in theaddFertilizerfunction which in turn is used inmintFertilizer`
Manual review
Add an appropriate check of remainingRecapitalization() before calculating the division in percentToFill to ensure that is not zero.
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.