DatingDapp

First Flight #33
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

Incorrect Fee Calculation in matchingFees Due to Precision Loss and Misinterpretation of FIXEDFEE

Summary

The calculation of matchingFees in the contract contains two key issues
Solidity performs integer division, meaning any fractional result is truncated (rounded down).

  • If totalRewards is a small value (e.g., less than 100) and FIXEDFEE = 10, the calculated fee will incorrectly round to zero, causing fees to be bypassed.

Vulnerability Details

Suppose totalRewards = 5 and FIXEDFEE = 10

matchingFees = (5 * 10) / 100 = 50 / 100 = 0; // Fee incorrectly rounds to zero

Since Solidity truncates decimal values, small totalRewards values will result in a zero fee. making the contrat having no earning.

Impact

incorrect fee deductions, leading to revenue loss or incorrect charges to users.

Tools Used

manual review

Recommendations

Use Basis Points for More Precise Fee Calculation
Modify the calculation to use basis points (1/10,000) instead of percent (1/100):

uint256 matchingFees = (totalRewards * FIXEDFEE) / 10_000; // FIXEDFEE = 1000 means 10%
Updates

Appeal created

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

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