Rule Craft

On-chain module

Size-Scaled Fee

Small trades pay the floor fee. As a trade gets large relative to the liquidity in range, the fee climbs toward the ceiling, so size that moves the price pays the LPs for it.

Compose with Size-Scaled Fee On-chain module · in RuleCraftHook (unaudited)

Callbacks

1

Swap gas

~110k

estimate

Touches

buy · sell

Pools

--

see Pools page

How it behaves

  1. 1The pool is created with the v4 dynamic-fee flag, so the hook sets the LP fee per swap.
  2. 2beforeSwap reads in-range liquidity, turns it into the virtual reserve of the input token, scales the fee linearly between floor and ceiling, and returns it with the override bit.
  3. 3All of the fee goes to LPs like any v4 fee; the module itself keeps nothing.

Parameters

ParameterMinDefaultMaxWhat it does
Fee floor0.05 %0.3 %1 %Fee a small trade pays.
Fee ceiling0.1 %1.5 %5 %Fee once a trade reaches the depth threshold.
Depth threshold0.5 %2 %10 %Trade size, as a share of in-range liquidity, where the ceiling applies.

Bounds are enforced on chain by the registry, the launcher and the hook. Values are frozen when the pool is created.

Permission bits

13BI
12AI
11BA
10AA
9BR
8AR
7BS
6AS
5BD
4AD
3BSΔ
2ASΔ
1AAΔ
0ARΔ

BS beforeSwap

mask 0x0080bits 000000100000001/14 on can change amounts
  • beforeSwapSwapRuns before every swap, can override the LP fee. Fees can change per trade. Check the fee range.