LibUnripe:percentBeansRecapped
& LibUnripe:percentLPRecapped
functions calculate the percentage of Unripe Beans and Unripe LPs that have been recapitalized, respectively. These percentages are calculated based on the underlying balance of the Unripe Tokens and their total supply. There is no check if the totalSupply
is zero which is used as division in the calculation.
See the following code for both the functions:
If the totalSupply
in these two functions becomes zero, the calculation of the percentage of recapitalized Unripe Beans or LP tokens would result in a division by zero error. This is because of the denominator in the calculation. When the total supply is zero, dividing by zero is not defined in Solidity, and the contract would revert with an error.
These functions are used widely across the different contracts at crucial places. So they will effect a lot of functionalities.
Manual Review
To handle this scenario, appropriate checks should be added to ensure that the totalSupply
of Unripe Beans or LP tokens is non-zero before performing the division operation.
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.