Hawk High

First Flight #39
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

Mishandling Of ETH in `LevelOne::graduateAndUpgrade` function

Summary

Mishandling Of ETH is happening as each Teacher is taking 35% bursary funds which will drain all Protocol funds

Vulnerability Details

The total teacher's salary is set as 35% of all funds in bursary. So each Teacher will get total_funds / total_teachers_count as salary. But there is a mistake in the calculation of per teacher salary LevelOne::payPerTeacher in LevelOne::graduateAndUpgrade function.

uint256 payPerTeacher = (bursary * TEACHER_WAGE) / PRECISION;

Impact

All School funds will get drained . Each teacher will take 35 %, that means we will be able to pay only 2 teachers and they both will take 70% total funds.

Recommendations

Correct the formula used for calculating each teacher's pay.

uint256 totalTeachers = listOfTeachers.length;
- uint256 payPerTeacher = (bursary * TEACHER_WAGE) / PRECISION;
+ uint256 payPerTeacher = (bursary * TEACHER_WAGE) / (PRECISION*totalTeachers);
Updates

Lead Judging Commences

yeahchibyke Lead Judge 3 months ago
Submission Judgement Published
Validated
Assigned finding tags:

incorrect teacher pay calculation

`payPerTeacher` in `graduateAndUpgrade()` is incorrectly calculated.

yeahchibyke Lead Judge 3 months ago
Submission Judgement Published
Validated
Assigned finding tags:

incorrect teacher pay calculation

`payPerTeacher` in `graduateAndUpgrade()` is incorrectly calculated.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.