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

`Fertilizer` can be purchased during Migration of the `Barn Raise` to a new `Well`

Summary

The mintFertilizer() function is used to purchase Fertilizer from the Barn Raise with the Barn Raise token. According to Protocol, when beginBarnRaiseMigration() is invoked to begin the process of migration of the Barn Raise to a new Well, the following is required:

Converting, chopping and purchasing Fertilizer will be disabled until the migration is complete.

However, the mintFertilizer() does not implement a check for the status of Barn Raise migration.

Vulnerability Details

function mintFertilizer(
uint256 tokenAmountIn,
uint256 minFertilizerOut,
uint256 minLPTokensOut
) external payable returns (uint256 fertilizerAmountOut) {
fertilizerAmountOut = _getMintFertilizerOut(tokenAmountIn, LibBarnRaise.getBarnRaiseToken());
require(fertilizerAmountOut >= minFertilizerOut, "Fertilizer: Not enough bought.");
require(fertilizerAmountOut > 0, "Fertilizer: None bought.");
uint128 remaining = uint128(LibFertilizer.remainingRecapitalization().div(1e6)); // remaining <= 77_000_000 so downcasting is safe.
require(fertilizerAmountOut <= remaining, "Fertilizer: Not enough remaining.");
uint128 id = LibFertilizer.addFertilizer(
uint128(s.season.current),
tokenAmountIn,
fertilizerAmountOut,
minLPTokensOut
);
C.fertilizer().beanstalkMint(msg.sender, uint256(id), (fertilizerAmountOut).toUint128(), s.bpf);
}

This function facilitates the minting of fertilizer tokens in exchange for LP tokens after adding liquidity with Barn Raise tokens.
As it can be seen, there is no explicit check for migration completion before the function mintFertilizer() proceeds with its execution.

Impact

This omission allows for purchase of Fertilizer during migration which is against protocol.

Tools Used

Manual Review

Recommendations

Add a migration completion check within the function or ensure that migration completion is checked before calling mintFertilizer()

Updates

Lead Judging Commences

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

Informational/Invalid

Support

FAQs

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