The hook is designed to incentivise buying ReFi by charging little/no fee on ReFi purchases and a higher fee when users sell ReFi.
_isReFiBuy determines whether the current swap direction is a ReFi purchase. It returns true when the user is receiving ReFi (buy) and false when the user is sending ReFi (sell).
Due to the logic being inverted in both branches, the function returns the opposite value in every possible pool configuration, causing _beforeSwap to apply the sell fee and emit ReFiSold whenever a user buys ReFi, and vice-versa.
Likelihood:
Every swap executed on any pool that contains ReFi triggers the bug
The inversion affects 100% of buy and sell transactions regardless of token ordering
Impact:
Users are charged the higher “sell” fee when they buy ReFi — directly contradicting the core product incentive
The ReFiSold event is emitted on buys instead of sells, making on-chain analytics and rebate accounting completely backwards
Add the following code snippet to the RebateFiHookTest.t.sol test file.
This snippet of code is to demonstrate that on ReFi buy the _beforeSwap function will apply fee on ReFi token buy and emit the ReFiSold event.
Possible mitigation is to modify the _isReFiBuy function according.
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.