In _beforeSwap the hook correctly selects a fee variable (fee = buyFee for buys, fee = sellFee for sells) and returns it with the override flag, but only the sell branch computes and emits a numeric feeAmount in the ReFiSold event. The buy branch emits ReFiBought(sender, swapAmount) with no feeAmount or token-denomination information. Two problems arise:
Observability: buys do not report the fee amount in events, so off‑chain systems cannot verify what fee was applied at runtime.
Semantics correctness: _beforeSwap uses swapAmount = abs(params.amountSpecified), but for buys that value may represent the input amount (ETH) rather than the ReFi output amount (the quantity on which a buy-side fee likely should be calculated). This means computing a buy fee in _beforeSwap by applying buyFee to swapAmount can be incorrect for exact-input buys. The current code neither documents nor handles this ambiguity.
Likelihood:
Whenever the admin sets buyFee to a non-zero value (via ChangeFee) and a user performs a ReFi buy.
Whenever a buy uses exact-input semantics (negative amountSpecified), which is common for native-token buys (ETH → ReFi) in your tests and router helpers. In that case swapAmount equals the input ETH, not the ReFi output.
When off‑chain tooling relies on the emitted event to display or reconcile fee amounts for buys — it will find no fee data for buys.
Impact:
buys produce no fee amount in logs, preventing audit/reconciliation and causing UIs/analytics to be unable to show the applied buy fee.
Set buy fee non-zero:
Owner: ChangeFee(true, 1000, false, 0) (for example 1% with appropriate basis).
Perform ETH→ReFi exact-input buy (the test already does this).
Observe logs:
ReFiSold events include a computed feeAmount when sells occur.
ReFiBought events contain only sender and swapAmount with no fee amount.
Off‑chain systems cannot determine the numeric fee paid on the buy from events, and swapAmount is ambiguous (ETH vs ReFi).
Compute and emit a buy-side feeAmount using the same formula as sell, but document limitation (fee computed on swapAmount which may be input token):
Add:
Change ReFiBought event declaration to include fee:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.