Uniswap v4 · Base

Write the rule.
It runs inside the pool on every swap.

OBRA compiles a few lines of plain words into a Uniswap v4 hook. The rule is bound to the pool before it opens and cannot change after. Every swap is read against it: the fee it pays, whether it is allowed at all, and what part of it goes to the liquidity providers or to you.

a rule

  1. 1fee 1%
  2. 2when sell and age < 10 min: fee 10%
  3. 3when buy and size > 2 ETH: refuse
  4. 4when sell and impact > 3%: take 2% to lps

0x01040001000000271000000000000000000000000000000000000000000200000000000000000001010100000000000002580100000186a000000000000000000000000000000000000000000200000000000000000000040200000000001e848001010000000000000000000000000000000000000000000000000200000000000000000001050200000000000001280102000000c80000000000000000000000000000000000000000

Four lines. A standing fee, a launch fee on sells for ten minutes, a ceiling on buys, and a two-percent share for the liquidity providers whenever a sell moves the price hard. This is the whole program; the bytes under it are what the chain stores.

Try the rule

judged by the contract’s own code
size
pool age
price vs open
  • Nothing dropped yet.

the words

Six things a rule can read, three things it can do.

buy · sellknown before

Which way the swap goes. A buy acquires the token; a sell gives it up.

ageknown before

Time since the pool opened. Seconds, minutes, hours, days, weeks.

priceknown before

The token, against the price it opened at. Down 20%, up 2×, above +50%.

hourknown before

The hour of day, UTC, 0 to 23.

sizeknown after

Ether the swap moves.

impactknown after

How far the swap moved the price.

fee 1%

The rate this swap pays, in place of the standing one. Up to 25%; above 10% only inside a day-long window.

refuse

The swap does not happen. Everything it would have done is undone, takes included.

take 2% to lps

A share of what the swap moves, donated to the liquidity providers, or sent to an address. All takes together: 10% at most.

before and after

A swap has two halves, and so does the rule.

The pool asks for the fee before the swap runs. At that point it knows which way the swap goes, how old the pool is, where the price stands and what time it is. It does not yet know how big the swap is or how far it will move the price: those arrive after.

So a line that sets a fee cannot depend on size or impact, and the compiler says so instead of letting the fee silently never apply. Refusing and taking work at either point.

before the swap

  • buy · sell
  • age
  • price
  • hour
  • fee
  • refuse

after the swap

  • … and
  • size
  • impact
  • refuse
  • take

what will not compile

A hook is welded into the pool. The compiler refuses to build a trap.

17

A refusal that could last forever.

when sell: refuse is a honeypot with a nice syntax. A refusal must be tied to size, to impact, or to an age window of at most thirty days.

15

A fee above ten percent with no end.

Up to twenty-five percent is allowed, but only inside an age window of a day or less. The punitive rate is a launch measure, not a standing one.

16

More than ten percent taken.

All lines together. A take adds up across every line that fires.

13

A fee that depends on size or impact.

It would be decided before those are known. Use take instead.

These are not suggestions. Rulebook.check runs on-chain at every write, so a rule this page will not compile is one the contract would reject too, with the same number.

built on base

The hook stands. Write a rule, bind it to a pool, open it.