RebateFi Hook

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

Incorrect Fee Event Emissions Cause Fee Mismatches in Logs

Description

  • Accurate event logging is crucial for on-chain transparency and off-chain data analysis. Currently, the protocol emits incorrect fee data in logs for sell transactions and omits fee information entirely for buy transactions.

  • For buy transactions, no fee value is emitted despite the fee variable being potentially non-zero in the future (currently zero).

  • For sell transactions, the emitted event records the calculated feeAmount rather than the actual fee returned by the function, causing discrepancies between on-chain state and event logs.

function _beforeSwap(
address sender,
PoolKey calldata key,
SwapParams calldata params,
bytes calldata
) internal override returns (bytes4, BeforeSwapDelta, uint24) {
bool isReFiBuy = _isReFiBuy(key, params.zeroForOne);
uint256 swapAmount = params.amountSpecified < 0
? uint256(-params.amountSpecified)
: uint256(params.amountSpecified);
uint24 fee;
if (isReFiBuy) {
fee = buyFee;
@> emit ReFiBought(sender, swapAmount);
} else {
fee = sellFee;
uint256 feeAmount = (swapAmount * sellFee) / 100000;
@> emit ReFiSold(sender, swapAmount, feeAmount);
}
return (
BaseHook.beforeSwap.selector,
BeforeSwapDeltaLibrary.ZERO_DELTA,
@> fee | LPFeeLibrary.OVERRIDE_FEE_FLAG
);
}

Risk

Likelihood: High

  • Every transaction logs inaccurate fee values, creating persistent mismatches.

Impact: High

  • Discrepancies between emitted events and actual on-chain fee state reduce transparency and trust. This affects protocol analytics, auditing, and third-party integrations reliant on event data.

Proof of Concept

For a sell transaction with a fee of 3,000 units, the event incorrectly logs a much higher fee amount calculated via feeAmount. This results in misleading on-chain logs that conflict with the actual fee applied by the contract.

Recommended Mitigation

Update the event emissions to consistently reflect the actual fee variable being returned by the function, ensuring logs accurately represent the state changes:

- emit ReFiBought(sender, swapAmount);
+ emit ReFiBought(sender, swapAmount, fee);
- emit ReFiSold(sender, swapAmount, feeAmount);
+ emit ReFiSold(sender, swapAmount, fee);
Updates

Lead Judging Commences

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