RebateFi Hook

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

Fee Calculation Precision Error Leading to Inaccurate Event Logging

Fee Calculation Precision Error Leading to Inaccurate Event Logging

Description

  • In a standard ReFi token sell transaction, the hook contract should accurately compute and record the actual fee amount charged for effective monitoring and data analysis.

  • The _beforeSwap function utilizes an incorrect fee calculation precision (100000 instead of 1000000), resulting in a discrepancy between the fee amount recorded in the event and the actual amount charged.

function _beforeSwap(
address sender,
PoolKey calldata key,
SwapParams calldata params,
bytes calldata
) internal override returns (bytes4, BeforeSwapDelta, uint24) {
// ... other logic ...
} else {
fee = sellFee;
@> uint256 feeAmount = (swapAmount * sellFee) / 100000; // ❌ Error: Using 100000 instead of 1_000_000
emit ReFiSold(sender, swapAmount, feeAmount);
}
}

Risk

Likelihood:

  • This error in calculation is triggered with every user's ReFi token sale.

  • All sell transaction event logs will document incorrect fee amounts.

  • Monitoring systems and data analysis tools will consistently receive inaccurate information.

Impact:

  • Event recording distortion: The feeAmount parameter in the ReFiSold event is 10 times the actual charged amount, leading to completely erroneous monitoring data.

  • Misleading data analysis: Analysis tools based on event logs will significantly overestimate actual fee revenue, impacting decision-making.

  • User experience confusion: If front-end applications display fee data from events, users will see amounts that do not match the actual deductions.

Proof of Concept

  • N/A

Recommended Mitigation

function _beforeSwap(
address sender,
PoolKey calldata key,
SwapParams calldata params,
bytes calldata
) internal override returns (bytes4, BeforeSwapDelta, uint24) {
// ... other logic ...
} else {
fee = sellFee;
- uint256 feeAmount = (swapAmount * sellFee) / 100000;
+ uint256 feeAmount = (swapAmount * sellFee) / 1000000;
emit ReFiSold(sender, swapAmount, feeAmount);
}
}
Updates

Lead Judging Commences

chaossr Lead Judge 12 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!