L2ContractMigrationFacet is used to migrate deposits owned by smart contracts.
Problem is that it increases balance of Stalk and Roots associated with migrated deposit, but never updates global balances of Stalk in Roots in Silo.
As you can see it increases only account's balance but never updates global balances during migration
https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/df2dd129a878d16d4adc75049179ac0029d9a96b/protocol/contracts/beanstalk/silo/L2ContractMigrationFacet.sol#L205-L211
Core invariant totalBalance = Sum(userIndividualBalances)
for both Roots and Stalk is broken.
It causes incorrect calculations in all the functions where s.sys.silo.roots
and s.sys.silo.stalk
are used. Such as:
LibSilo.mintActiveStalk()
- incorrect amount of Stalk and Roots is minted for all new deposits.
LibSilo.burnActiveStalk()
- incorrect amount of Stalk and Roots is burned in all withdrawals.
LibSilo.transferStalk()
- incorrect amount of Stalk and Roots is transferred in all transfers.
Manual Review
Increase global balances s.sys.silo.stalk
and s.sys.silo.roots
in L2ContractMigrationFacet.setStalk()
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.