RebateFi Hook

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

Small Swap Fee May Round Down to Zero

Root + Impact

Description

  • Normal Behavior:
    The contract calculates fees for ReFi swaps using:

  • Observed Issue:
    For very small swap amounts, integer division causes precision loss, rounding the fee down to zero:

    • swapAmount = 1, sellFee = 3000feeAmount = 0

    • swapAmount = 33, sellFee = 3000feeAmount = 0

    • swapAmount = 34, sellFee = 3000feeAmount = 1

uint256 feeAmount = (swapAmount * sellFee) / 100000;

Risk

Likelihood:

  • Only occurs on very small swaps (<34 wei for a 3% fee).

Real-world swaps are typically much larger.

Impact:

  • Fees may appear as zero for tiny swaps.

No actual protocol loss because Uniswap V4 handles fee collection internally.

  • Could slightly affect event reporting or analytics.

Proof of Concept

uint256 swapAmount = 1;
uint256 sellFee = 3000; // 3%
uint256 feeAmount = (swapAmount * sellFee) / 100000;
// feeAmount = 0 rounded down
swapAmount = 34;
feeAmount = (swapAmount * sellFee) / 100000;
// feeAmount = 1 ✓

Recommended Mitigation

uint256 feeAmount = ((swapAmount * sellFee) + 99999) / 100000; // rounds up
Updates

Lead Judging Commences

chaossr Lead Judge 12 days ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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

Give us feedback!