RebateFi Hook

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

Fee math uses unclear denominator; magic constant 100000 used

Root + Impact

Description

  • Normal behavior: Fee calculations should use named constants and clear scaling (e.g., FEE_DENOMINATOR) so integrators understand units (bps/ppm).

Problem: The contract computes feeAmount = (swapAmount * sellFee) / 100000; but 100000 is a magic number with no documentation, causing ambiguity about fee units.

// Root cause in the codebase with @> marks to highlight the relevant section
if (!isReFiBuy) {
fee = sellFee;
@> uint256 feeAmount = (swapAmount * sellFee) / 100000;
emit ReFiSold(sender, swapAmount, feeAmount);
}

Risk

Likelihood:

  • Any future maintainer or integrator reading the code may assume a different denominator (10,000 bps, 1e6, etc.).

Changing fees or interpreting sellFee = 3000 may lead to misconfiguration.

Impact:

  • Wrong interpretation can cause incorrect displayed percent values or unexpected fee amounts, but not direct reentrancy or theft.

Leads to correctness/financial miscalculation risk rather than immediate security exploit.

Proof of Concept

// Example misinterpretation:
// sellFee = 3000
// If denominator = 100000 -> fee = 3.0%
// If someone expects BPS (10000) -> fee would be interpreted as 30.0%

Recommended Mitigation

Introduce a named constant to document the denominator and use it in math:

+ // fees are represented in units of 1 / FEE_DENOMINATOR
+ uint24 public constant FEE_DENOMINATOR = 100000;
...
- uint256 feeAmount = (swapAmount * sellFee) / 100000;
+ uint256 feeAmount = (swapAmount * sellFee) / FEE_DENOMINATOR;

Also add NatSpec or comment above fee state variables documenting the unit (e.g., // buyFee / sellFee are expressed in 1/FEE_DENOMINATOR units).

Updates

Lead Judging Commences

chaossr Lead Judge 12 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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

Give us feedback!