Hawk High

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

The protocol pays each teacher 35% of the bursary instead of sharing the percentage across all teachers

Summary

The protocol pays each teacher 35% of the bursary instead of sharing the percentage evenly among teachers

Impact

Messes up the accounting of the protocol bursary

Tools Used

Manual Review

Recommendations

Divide the percentage based on the number of teachers in the protocol:

function graduateAndUpgrade(
address _levelTwo,
bytes memory
) public onlyPrincipal {
if (_levelTwo == address(0)) {
revert HH__ZeroAddress();
}
uint256 totalTeachers = listOfTeachers.length;
+ require(totalTeachers > 0, "There are no teachers in the system");
+ uint256 teacherCut = (bursary * TEACHER_WAGE) / PRECISION;
+ uint256 payPerTeacher = teacherCut / totalTeachers;
+ uint256 principalPay = (bursary * PRINCIPAL_WAGE) / PRECISION;
_authorizeUpgrade(_levelTwo);
for (uint256 n = 0; n < totalTeachers; n++) {
+ usdc.safeTransfer(listOfTeachers[n], payPerTeacher);
}
usdc.safeTransfer(principal, principalPay);
}
Updates

Lead Judging Commences

yeahchibyke Lead Judge 6 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.