In `LevelOne.sol` the graduateAndUpgrade
function contains a logical error in calculating the payment for teachers. Specifically, the payPerTeacher
value is calculated without dividing the total amount allocated to teachers by the number of teachers. This results in incorrect payouts where each teacher receives the entire allocated amount instead of their fair share.
The graduateAndUpgrade
function is designed to distribute payments from the bursary to both the principal and the teachers. However, the teacher payment calculation does not account for the number of teachers (totalTeachers).
Currently, the payPerTeacher
variable is computed as follows:
This value represents the total amount allocated for teacher payments, but it is incorrectly interpreted as the payment per teacher. The function then distributes this amount to each teacher in the loop:
This logic results in an overpayment to teachers, as every teacher receives the entire allocated amount instead of their share.
For example:
If bursary is 1000 USDC, TEACHER\_WAGE
is 0.35 (35%), and there are 5 teachers, the intended payment per teacher should be 70 USDC. However, with the current logic, each teacher receives the full 350 USDC, leading to a total payout of 1750 USDC, exceeding the allocated bursary.
Excessive Funds Usage: The contract overpays teachers, which can deplete the bursary and disrupt the expected financial flows.
Financial Discrepancy: The principal may receive less than their allocated amount due to insufficient remaining funds.
System Instability: Repeated execution of this flawed logic may cause financial imbalance and undermine trust in the system.
Manual Code Review
Example-based Testing for Payment Logic
Update the calculation of payPerTeacher
to divide the total teacher payment by the number of teachers:
Ensure proper validation for totalTeachers
to avoid division by zero.
Write additional test cases to validate the correctness of payment distribution for both the principal and teachers.
Conduct a thorough review of similar payment logic in the codebase to identify any other potential issues.
`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.