Skip to content
Business logic Audit finding Intermediate

CLFactory ignores dynamic fees above 10% and silently falls back to default

The CLFactory contract ignores dynamic swap fees above 10% and silently falls back to the default tick-spacing fee, so governance can set a higher fee that is never applied. Traders pay less than intended, defeating protective or revenue objectives.

niffylord Follow with JuggerNaut63, ljj and 2 others

Originally disclosed on Code4rena

Submitted by niffylord, also found by JuggerNaut63, ljj, Nexarion, and ZanyBonzy

CLFactory.sol [#L176-L189[(https://github.com/code-423n4/2025-10-hybra-finance/blob/main/cl/contracts/core/CLFactory.sol#L176-L189)

Summary

Governance can configure DynamicSwapFeeModule with fees up to 50%, but CLFactory.getSwapFee discards any value above 100_000 ppm (10%) and falls back to the tick-spacing default (often 500 ppm = 0.05%) without reverting or logging. Operators see the module reporting 20%, yet users continue paying the tiny default fee. The silent fallback misleads governance into believing higher fees are active.

Impact

  • Governance believes a protective high fee is set (e.g., during launch anti-MEV), but the effective fee drops back to the default (e.g., 0.05%).
  • Traders are charged far less than intended, defeating protective or revenue objectives.
  • The misconfiguration has no on-chain signal, so the mistake can persist unnoticed.

Root Cause

  • getSwapFee checks fee <= 100_000; larger values are ignored and the function returns tickSpacingToFee.
  • The module itself allows feeCap up to 500_000 (50%), so governance can set a value the factory immediately discards in favor of the default.

Reference: cl/contracts/core/CLFactory.sol#L176-L189

Mitigation

  • Either revert when the module returns > 100_000 or raise the factory ceiling to match the module’s cap.
  • Emit events or add admin tooling to surface out-of-range configurations so operators can correct them.

Proof of concept

bash cd cl forge test --match-path test/PoC_DynamicFee_ClampToDefault.t.sol -vvv The PoC lifts the module cap, sets a 20% custom fee, and shows that DynamicSwapFeeModule.getFee returns 200_000 while CLFactory.getSwapFee still returns the base 500 ppm.

PoC source (cl/test/PoC_DynamicFee_ClampToDefault.t.sol):


// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma abicoder v2;

import "forge-std/Test.sol";

import {C4PoCTestbed} from "./C4PoCTestbed.t.sol";
import {DynamicSwapFeeModule} from "contracts/core/fees/DynamicSwapFeeModule.sol";

contract PoC_DynamicFee_ClampToDefault is C4PoCTestbed {
    address internal pool;

    function setUp() public override {
        super.setUp();
        pool = poolFactory.createPool(USDC, DAI, 100, uint160(2**96));
        require(pool != address(0), "pool not created");
    }

    function testFactoryClampsFeeAboveTenPercent() public {
        address manager = poolFactory.swapFeeManager();
        vm.prank(manager);
        swapFeeModule.setFeeCap(pool, 500_000); // raise module cap to 50%
        vm.prank(manager);
        swapFeeModule.setScalingFactor(pool, 1); // ensure positive TWAP delta doesn't zero fee

        uint24 highFee = 200_000; // 20%
        vm.prank(manager);
        swapFeeModule.setCustomFee(pool, highFee);

        uint24 moduleFee = swapFeeModule.getFee(pool);
        assertEq(uint256(moduleFee), uint256(highFee), "module reports configured fee");

        uint24 factoryFee = poolFactory.getSwapFee(pool);
        assertEq(uint256(factoryFee), 500, "factory silently clamps to tick-spacing default");
    }
}

Hybra Finance mitigated:

Added setMaxFee() function to make the fee cap configurable by the owner (up to 50%). This replaces the hardcoded limit and allows governance to adjust the maximum dynamic fee when needed.

Status: Mitigation confirmed. Full details in the mitigation review reports from niffylord, rayss, and ZanyBonzy.


The original report as published on Code4rena, by niffylord. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The factory's getSwapFee function checks if the fee is at most 100,000 ppm and otherwise returns the default tick-spacing fee, while the fee module allows setting fees up to 500,000 ppm.

Impact

Governance may believe a protective high fee is active, but the effective fee drops to the default, so traders are charged far less than intended and the misconfiguration has no on-chain signal.

What the attacker needed

Governance sets a dynamic fee above 10%

The fix

The project added a setMaxFee() function to make the fee cap configurable by the owner up to 50%, replacing the hardcoded limit.

How it was found

  1. The manager raises the module's fee cap to 50%.
  2. The manager sets a custom fee of 20% for a pool.
  3. The module reports the 20% fee.
  4. The factory's getSwapFee returns the default 500 ppm (0.05%) instead.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract lets the owner set a swap fee, but the factory contract that actually charges the fee only accepts values up to 10%. If the owner sets a higher fee, the factory quietly uses a much smaller default fee instead. This means the owner thinks a high fee is active, but users are charged almost nothing.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by niffylord

View all

7 more disclosed reports, best first.

More from Hybra Finance

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.