Capacity of remaining fertilizers will be reached a lot faster than it should because the remaining capacity being returned during the check before minting is further rounded down when it has already been rounded down initially.
The mintFertilizer
function introduces a severe rounding down issue during minting of fertilizers in the FertilizerFacet.sol
contract. The function below enforces a critical check to make sure the capacity of how much should be minted is not breached.
We fetch the remaining capacity from the function call below:
uint128 remaining = uint128(LibFertilizer.remainingRecapitalization().div(1e6));
Then, we proceed to make sure the amount being minted is not breaching capacity with the check that comes right after:
require(fertilizerAmountOut <= remaining, "Fertilizer: Not enough remaining.");
A snippet of the remainingRecapitalization()
function can be seen below from LibFertilizer.sol
:
The end result of this is that the remaining
amount in USDC
that can be minted will not be same figure as the LibFertilizer.remainingRecapitalization()
returns it as. This means for example, for a remaining figure of 1 thousand USDC
returned by LibFertilizer.remainingRecapitalization()
as 1000e6
, we go ahead to further round it down by USDC
6 decimals (1e6
) so that 1000e6
will be 1e3
. With this rough estimation of 1k USDC, we can already see how fast the capitalization will be reached, hence making minting of fertilizers impossible after a while of user mints because the true remaining
figure got adversely rounded down further when it has already been handled in the LibFertilizer.remainingRecapitalization()
function.
Manual Review + foundry
Lose the current excessive rounding in the FertilizerFacet.sol#mintFertilizer
function during a mint of fertilizer where we check that we do not breach capacity for the remaining
amounts as this is already being scaled in the LibFertilizer.remainingRecapitalization()
function.
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.