RebateFi Hook

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

Incorrect Fee Calculation (Divisor 100,000 Instead of 1,000,000)

Root + Impact

Description

  • Sell fee is calculated as: uint256 feeAmount = (swapAmount * sellFee) / 100000;. Uniswap v4 fees use 1e6 as the precision not 1e5. What this does is it increases the amount by 10 times than intended. Eg - Intended sellFee = 3000 (0.3%), Actual applied = 3% (10× too high).

// Root cause in the codebase with @> marks to highlight the relevant section
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;
// Here, it should be (swapAmount * sellFee) / 1000000
uint256 feeAmount = (swapAmount * sellFee) / 100000;
emit ReFiSold(sender, swapAmount, feeAmount);
}
return (
BaseHook.beforeSwap.selector,
BeforeSwapDeltaLibrary.ZERO_DELTA,
fee | LPFeeLibrary.OVERRIDE_FEE_FLAG
);
}

Risk

Likelihood:

  • This miscalculation occurs for every cell swap. Every user selling ReFi will be systematically overcharged.

Impact:

  • Users are overcharged by 10 times decared fee

Strong incentive to avoid trading → broken markets

  • Users may consider this malicious or deceptive

  • High probability of economic loss for users

  • Potential legal or compliance issues depending on jurisdiction

  • Severe reputational damage to the protocol

Proof of Concept

Recommended Mitigation

    • Severe reputational damage to the protocol. here

- uint256 feeAmount = (swapAmount * sellFee) / 100000
+ uint256 feeAmount = (swapAmount * sellFee) / 1_000_000;
Updates

Lead Judging Commences

chaossr Lead Judge 12 days ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!