After migration to L2 Fertilizer module will incorrectly calculate amount of debt to repay because during migration it doesn't initialize variable which tracks amount of recapitalized debt.
As a result, it has several consequensec described below.
1st is that Fertilizer can be minted when debt is repaid because following line won't revert. Instead it will continue execution of Barn logic.
https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/df2dd129a878d16d4adc75049179ac0029d9a96b/protocol/contracts/libraries/LibFertilizer.sol#L92
2ns is that Unripe Convert works incorrectly because of incorrect calculation of conversion between UnripeLP and UnripeBean, perticularly it inflates ratio LP/Bean.
LibUnripe.percentLPRecapped()
is used to calculate ratio between UnripeLP and UnripeBean. And as you can see it will overestimate price LP/Bean because LibUnripe.percentLPRecapped()
returns much lower result than expected.
https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/df2dd129a878d16d4adc75049179ac0029d9a96b/protocol/contracts/libraries/LibUnripe.sol#L42-L45
This function is used in the core logic of Unripe Convert:
https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/df2dd129a878d16d4adc75049179ac0029d9a96b/protocol/contracts/libraries/Convert/LibUnripeConvert.sol#L21-L77
This issue will at least cause revert after conversion because Penalty was applied due to disbalance. And will at most cause incorrect conversion and as a result a drain of Beanstalk, however I don't have enough time left to investigate such attack vector.
Fertilizer will remain mintable when in fact debt is recapitalized. It means all minters of that extra Fertilizer will lose money.
And there is another more severe impact: Unripe Convert won't work because it calculates incorrect price between UnripeBean and UnripeLp.
Manual Review
Set s.sys.fert.recapitalized
in ReseedBarn.sol.
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.