Hawk High

First Flight #39
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: medium
Invalid

Precision Loss in 'principalPay'

Description: Standard integer division discards the remainder ("dust"), leaving small amounts of USDC stranded in the contract.

uint256 principalPay = (bursary * PRINCIPAL_WAGE) / PRECISION;

Impact: Tiny balances accumulate and are never distributed, breaking the invariant 'principalPay + teacherTotal == bursary'. Over time, those "lost" tokens can grow significant.

Proof of Concept:

// enroll students so bursary == 101
// PRINCIPAL_WAGE = 5, so principalPay == 5 (101*5/100)
// dust == 101 - 5 - teacherTotal
// assert dust > 0 remains

Recommended Mitigation: Either use full-precision from OpenZeppelin:

Math.mulDiv(bursary, PRINCIPAL_WAGE, PRECISION)

or compute:

uint256 teacherTotal = payPerTeacher * totalTeachers;
uint256 principalPay = bursary - teacherTotal;
Updates

Lead Judging Commences

yeahchibyke Lead Judge 2 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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