Rule Craft

Composer

Draft the rules. Read the hook.

Switch modules on, set their numbers, and watch the permission bits, the callback list and the worst-case take update as you go. Everything here runs in your browser; nothing is signed or sent.

Start from
Draft saved in this browser

Rule set

TOKEN / ETH · Uniswap v4 · 1% fee · 0 modules

Hook permission bits

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

BI beforeInitialize · BS beforeSwap · AS afterSwap · ASΔ afterSwapReturnDelta

mask 0x20c4bits 100000110001004/14 on can change amounts

Where each rule runs

  1. ·

    Pool opens

    Untouched.

  2. ·

    Liquidity in

    Untouched.

  3. ·

    Before swap

    Untouched.

  4. v4

    v4 swap math

    Concentrated-liquidity math in the PoolManager. No rule runs inside it.

  5. ·

    After swap

    Untouched.

  6. ·

    Liquidity out

    Untouched.

What a trader reads

  • 1% LP fee on every swap, all of it to liquidity in range.

Most a trade can give up

Buy
1%
Sell
1%
Opening buy
1%

Play a buy

ETH in
LP fee1.00%0.00500 ETH
Rules and fees1.00%0.00500 ETH

Before price impact. Size-scaled fees assume opening liquidity equal to the valuation set on the right.

Callbacks this hook needs

  • beforeInitializeInitRuns before the pool's starting price is set. Can refuse to open the pool or check who opens it.
  • beforeSwapSwapRuns before every swap, can override the LP fee. Fees can change per trade. Check the fee range.
  • afterSwapSwapRuns after every swap with the final amounts. Reacts to trades: burns, pots, reward accounting.
  • afterSwapReturnDeltaDeltaLets afterSwap take a cut of the output. The hook can change what you receive. Taxes and burns live here.

Checks

  • No rules yet. This pool would be a plain v4 pool paying a 1% fee to LPs.

Generated config

{
  "name": "Untitled rule set",
  "chainId": 4663,
  "poolKey": {
    "currency0": "ETH (address(0))",
    "currency1": "<token>",
    "fee": 10000,
    "tickSpacing": 200,
    "hooks": "<RuleCraftHook address ending in mask 0x20c4>"
  },
  "permissions": {
    "beforeInitialize": true,
    "afterInitialize": false,
    "beforeAddLiquidity": false,
    "afterAddLiquidity": false,
    "beforeRemoveLiquidity": false,
    "afterRemoveLiquidity": false,
    "beforeSwap": true,
    "afterSwap": true,
    "beforeDonate": false,
    "afterDonate": false,
    "beforeSwapReturnDelta": false,
    "afterSwapReturnDelta": true,
    "afterAddLiquidityReturnDelta": false,
    "afterRemoveLiquidityReturnDelta": false
  },
  "modules": [],
  "royaltyPctOfAddOns": 5,
  "protocolSharePctOfAddOns": 10,
  "maxTakePct": {
    "buy": 1,
    "sell": 1,
    "buyDuringGuard": 1
  },
  "frozenAtCreation": true
}
A

Risk read

Light rules

score 10 / 100 · higher means the rules can move a trade further from a plain pool

  • Hook permissions10/354 of 14 callbacks enabled.
  • Steady take per buy0/25Up to 1% of a buy goes to fees and rules (1% is the plain LP fee).
  • Opening window0/15No extra charge at opening.
  • Fee movement0/10Fee is fixed for the life of the pool.
  • LP exits0/10Every LP can leave at any time.
  • Unreleased code0/5Only on-chain modules.

A heuristic read of permissions and settings. It is not an audit and does not check the code itself.

Next

Launch with these rules

Name the rule set above to publish it.

Pick at least one rule module.

The launch form checks everything again before anything is signed.