Define the rules.
Let the circuit enforce them.
Verifiable trading policies for Uniswap v4 pools: compiled to a NAND circuit, published once on TapeOut, and checked on every swap on X Layer.
The hook evaluates the circuit with a read-only call. Anyone can regenerate the circuit from its parameters and compare it byte-for-byte with what is on-chain.
Launch Guard · ≤ 100 units for 15 min, then ≤ 5,000
Swap rejected
- not met:size 500 ≤ launch-window cap 100
- not met:3 min since creation ≥ 15
- met:size 500 ≤ post-launch cap 5,000
34 inputs · 141 NAND gates · depth 41 · 1 output · 84 gates carry 1. Columns are logic depth; the last gate is the output.
Launch rules are hard to check.
Token launches attract bots that buy the first blocks in size. Launch teams respond with rules: per-swap caps, launch windows, direction limits. Those rules usually live in a platform's settings or in a bespoke contract. A trader rarely knows what the rule really is, or whether someone can change it in the middle of the launch.
CircuitPolicy makes the rule a published object: one immutable binding per pool, readable on-chain, and reproducible by anyone from a short list of parameters. A size cap limits how much one swap can move. It does not stop every form of sniping or manipulation: many small swaps, or many addresses, still get through.
From parameters to enforcement in four steps
Configure
Pick a template and set its limits in token units. The Studio shows the exact rule in plain language.
Policy StudioCompile & publish
The browser compiles the policy to a NAND netlist and publishes it with tapeout() on your TapeOut processor.
Publish & BindBind & create
One call to the shared hook stores the binding and creates the pool. Nobody, including you, can rebind it.
Publish & BindEnforce & verify
Every swap is checked by a read-only STATICCALL to the circuit. Anyone can recompile the template and compare bytes.
Circuit Inspector
Three policies, each a real circuit
Gate counts are for the example parameters; the Studio compiles your own values live.
Size Cap
42 NANDConfigureEvery swap's specified amount stays at or below a fixed cap.
Pools that want a simple per-trade ceiling. Inputs: size.
Directional Cap
46 NANDConfigureOnly exact-input swaps in one direction, each at or below a cap.
One-sided distribution or buy-only phases. Inputs: size · direction · swap type.
Launch Guard
141 NANDConfigureSmall swaps only during the launch window, then a larger cap.
Token launches that want a published, time-boxed limit. Inputs: size · direction · type · minutes since creation.
What has been tested, and where
Every number below comes from this repository's test suites, run on a local fork of X Layer mainnet (block 77,561,888). It is reproducible evidence, not an audit.
- contract tests
- 72
- Foundry, against forked X Layer state: hook, binding, fail-closed paths, Uniswap periphery
- unit tests
- 46
- TypeScript compiler byte-identical to the Solidity reference; encoding; liquidity maths
- fork integration tests
- 16
- App code against the fork: circuit reads, publish and bind, and the official Uniswap v4 periphery
- gas per policed swap
- 259,331
- A cost, not a score: 42-gate Size Cap circuit, vs 120,938 for a configurable Solidity hook (local fork)
The browser suite also drives the full flow on the fork: publish, bind and create the pool, add and remove liquidity, allowed and rejected swaps, through a signing browser wallet. Local fork results are not mainnet activity.
What is different from a configurable Solidity hook, and what it costs
A well-written configurable Solidity hook can also serve many pools with different parameters and also be immutable. The difference is where the rule's logic lives and how it is checked.
| Aspect | CircuitPolicy | Configurable Solidity hook |
|---|---|---|
| New parameters | Compile and publish a new circuit; same hook | Store new parameters; same contract |
| New rule shape | A new circuit, if it fits 34 input bits and 1,000 gates; same hook | New or upgraded contract code, and its review |
| What a trader checks | The circuit bytes, regenerated from the template and compared | The contract source plus the stored parameters |
| Rule execution | Stateless NAND netlist via STATICCALL: no calls, storage or funds; any failure rejects | Arbitrary Solidity, as written |
| Gas per swap (measured, fork) | 259,331 | 120,938 |
| Cost per swap at 0.02 gwei | ≈ $0.0004 (OKB = $85.60 at measurement) | ≈ $0.0002 |
The circuit evaluation costs roughly 1,000× the gas of the same comparison in Solidity; on X Layer that is still a fraction of a cent. Publishing a circuit cost 0.0013 OKB plus BEM for gates.
Who it is for
- Token launch teams
- Commit to a launch rule in public, before trading opens, without writing or auditing a new contract.
- Launchpads on X Layer
- Offer configurable, checkable launch rules from one shared hook.
- Traders
- See the exact rule, who bound it and when, and verify it yourself in the browser or with Foundry.
- Pool creators generally
- Any per-swap rule that fits a 34-bit input and a 1,000-gate budget uses the same mechanism.
Trust assumptions
- Nothing here has been audited. The hook is deployed on X Layer mainnet at 0x05792e95d53a1f9f0856b8590097C96A6409E080 as a small, unaudited demonstration; keep any liquidity at demonstration size.
- The TapeOut factory is an upgradeable proxy owned by a 3-of-5 Safe. It answers
isCPU(“is this a TapeOut processor?”), which the hook uses when a policy is bound. - Deployed processors point to a beacon whose owner is the zero address, so their logic appears frozen. This is bytecode-level evidence; the source is not verified.
- The hook has no owner and no setters. A binding cannot change after the pool is created. Anyone can be the first to create a given pool key, so traders should check the recorded creator.
- Matching circuit bytes proves the on-chain rule is the rule described. It says nothing about the token, the pool's liquidity, or the price.
Write the rule once. Let anyone check it.
Configure a policy, simulate it against real swap conditions, then publish and bind it on the local fork.