The _isReFiBuy helper should return true when the swap results in the trader receiving ReFi (i.e., the user is buying ReFi), and false when the trader is sending/receiving the opposite direction (selling ReFi). The function needs to interpret zeroForOne consistently with token ordering: when ReFi is currency0, zeroForOne == false (moving token1→token0) should indicate buying token0 (ReFi); when ReFi is currency1, zeroForOne == true indicates buying ReFi.
The implementation inlines an inverted mapping:
if ReFi == currency0 it returns zeroForOne, otherwise it returns !zeroForOne.
This inverts the correct mapping — for ReFi == currency0 a zeroForOne swap actually removes token0 (i.e., sells ReFi), but the function currently treats that as a buy. As a result, _beforeSwap uses sellFee on actual buys (and vice versa), and emits ReFiSold for buy swaps (observed in PoC tests).
Likelihood:
the faulty code runs on every swap for pools containing ReFi
Impact:
the hook misclassifies swap direction, selecting the wrong fee branch and emitting incorrect events
Sell ReFi in a swap and observe the emission of RefiBought or vice versa
Replace IsReFiCurrency0 with !IsReFiCurrency0
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.