The normal behavior should apply 0% fee when users buy ReFi tokens and 0.3% fee when users sell ReFi tokens to incentivize accumulation and discourage dumping.
The _isReFiBuy() function contains inverted logic that incorrectly determines swap direction. When ReFi is currency0 and a user swaps currency0 for currency1 (selling ReFi), the function incorrectly returns true indicating a buy. This causes the protocol to apply buy fees (0%) to sell transactions and sell fees (0.3%) to buy transactions - the complete opposite of intended behavior.
Uniswap V4 Swap Direction Logic:
zeroForOne = true → Swapping currency0 FOR currency1 (SELLING currency0)
zeroForOne = false → Swapping currency1 FOR currency0 (SELLING currency1)
Current Buggy Behavior:
If ReFi is currency0 and zeroForOne=true → Returns true (claims "buy") but user is SELLING ReFi
If ReFi is currency1 and zeroForOne=false → Returns true (claims "buy") but user is SELLING ReFi
Likelihood:
Every single swap through pools using this hook will apply the wrong fee
The bug is deterministic and affects 100% of transactions
All existing test cases pass because they don't verify actual fee amounts charged, only that fees are configured
The protocol will immediately apply opposite fees upon first production swap
Impact:
Protocol completely fails its core economic model - incentivizes selling instead of buying
Users buying ReFi tokens are charged 0.3% fee instead of 0% fee, discouraging accumulation
Users selling ReFi tokens pay 0% fee instead of 0.3% fee, encouraging dumping
Liquidity providers lose 0.3% fee revenue on all sell transactions
ReFi token price likely to crash due to incentivized selling and penalized buying
Protocol revenue model completely broken - no fees collected from sellers
Complete economic collapse of the tokenomics design
Reputational damage and loss of user trust
Running the PoC:
Expected Output:
Explanation:
When ReFi is currency0:
zeroForOne=true → Selling currency0 (ReFi) → isBuy should be FALSE
zeroForOne=false → Buying currency0 (ReFi) → isBuy should be TRUE
When ReFi is currency1:
zeroForOne=true → Buying currency1 (ReFi) → isBuy should be TRUE
zeroForOne=false → Selling currency1 (ReFi) → isBuy should be FALSE
Additional Recommendation:
Add comprehensive integration tests that verify the actual fees charged (not just fee configuration) for both buy and sell scenarios with ReFi as both currency0 and currency1.
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.