Description: The graduateAndUpgrade() function in the LevelOne contract attempts to distribute 35% of the bursary to teachers and 5% to the principal. However, the calculation of payPerTeacher does not divide the teacher allocation by the number of teachers. As a result, each teacher receives 35% of the bursary, instead of 35% being split across all teachers.
This leads to an overpayment that exceeds the available bursary, potentially draining the contract or causing safeTransfer calls to revert due to insufficient funds.
Impact: If there are n teachers, the total teacher payout becomes n * (35% of bursary), rather than 35%. This results in:
Up to n * 35% of the bursary being transferred.
Contract reverts due to insufficient balance if n > 2.
Principal may not be paid if the contract balance is exhausted prematurely.
Proof of Concept: Paste the following test in LevelOneIAndGraduateTest.t.sol
Log Output:
Recommended Mitigation:
Split the teacher allocation evenly by dividing by the number of teachers:
`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.