The graduateAndUpgrade function incorrectly distributes funds from the bursary, violating the invariant that "60% should reflect in the bursary after upgrade." The current implementation distributes 35% to teachers and 5% to the principal but fails to preserve the remaining 60% for the upgraded contract.
The implementation will deplete the entire bursary balance during the upgrade, leaving 0% (instead of the required 60%) for the next level. This completely breaks the financial model of the school system and renders the upgraded contract financially non-functional.
This issue will occur 100% of the time the graduateAndUpgrade function is executed, as it's a flaw in the core logic of fund distribution.
The contract's graduateAndUpgrade function contains the following distribution logic:
Let's break down the calculations:
TEACHER_WAGE is defined as 35, which with PRECISION at 100 means 35% of the bursary is allocated for teachers
PRINCIPAL_WAGE is defined as 5, which with PRECISION at 100 means 5% of the bursary is allocated for the principal
However, the teacher allocation doesn't account for the number of teachers:
Each teacher receives (bursary * 35%) / 100
With N teachers, this totals N * (bursary * 35%) / 100
This equals N * 35% of the bursary, not just 35%
For example, with 10 teachers:
Each teacher gets 35% of the bursary
Total teacher payment = 10 * 35% = 350% of the bursary
Principal payment = 5% of the bursary
Total payment = 355% of the bursary
This not only fails to leave 60% in the bursary but attempts to pay out 3.55x the available funds.
Correct the payment calculation to properly distribute funds according to the 35/5/60 split:
`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.