Inside the graduateAndUpgrade function, line 302, payPerTeacher calculates the pay for all teachers. It should then be divided by the amount of teachers to get the per teacher pay.
If there are three or more teachers the bursary will not have enough funds and the call will revert. If there are two teachers 75% of the bursary will be used for wages and only 25% will remain for level two.
The bug can be seen below (line 302 in LevelOne.sol). payPerTeacher is calculated for all teachers and then each teacher is sent the amount for all teachers.
This violates the invariants section of the documentation, which states teachers share the 35% and the remaining 60% should be relected after upgrade.
Payment structure is as follows:
principal gets 5% of bursary
teachers share of 35% of bursary
remaining 60% should reflect in the bursary after upgrade
Manual review and confirmation with Foundry tests. By adding a third teacher to the _teachersAdded() helper function you can cause the test_confirm_can_graduate test to fail with a revert.
`payPerTeacher` in `graduateAndUpgrade()` is incorrectly calculated.
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.