RebateFi Hook

First Flight #53
Beginner FriendlyDeFi
100 EXP
View results
Submission Details
Severity: low
Valid

Incorrect Fee Calculation in Event Emission (Logic Error + Misleading Data)

Description:
In _beforeSwap, the fee amount for the ReFiSold event is calculated as:

uint256 feeAmount = (swapAmount * sellFee) / 100000;

Uniswap V4 fees are typically in pips (1/1,000,000). A fee of 3000 represents 0.3%.
The calculation uses a denominator of 100,000.
3000 / 100,000 = 0.03 = 3%.
The actual fee charged by the pool is 0.3%, but the event logs a fee of 3%.

Impact:

Off-chain indexers and users relying on events will see incorrect fee amounts (10x higher). This can lead to confusion, incorrect analytics, and accounting errors.

Proof of Concept:

function test_Bug_FeeEventCalculation() public {
// sellFee = 3000 (0.3%)
// Event emits: amount * 3000 / 100000 = 3%
uint256 expectedBuggyFee = (amountToSwap * 3000) / 100000;
vm.expectEmit(true, true, true, true);
emit ReFiSwapRebateHook.ReFiSold(address(swapRouter), amountToSwap, expectedBuggyFee);
// Trigger swap...
}

Recommended Mitigation:
Use the correct denominator (1,000,000) or LPFeeLibrary constants if available.

- uint256 feeAmount = (swapAmount * sellFee) / 100000;
+ uint256 feeAmount = (swapAmount * sellFee) / 1000000;
Updates

Lead Judging Commences

chaossr Lead Judge 11 days ago
Submission Judgement Published
Validated
Assigned finding tags:

Incorrect denominator (100000 instead of likely 1000000 or 10000) in fee calculation for ReFiSold event.

Support

FAQs

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

Give us feedback!