Reading live X Layer mainnet. Mainnet transactions are enabled.
Skip to content
CircuitPolicy

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

runs in your browser

Swap rejected

The circuit outputs 0; the hook reverts the swap.
  • not met:size 500 ≤ launch-window cap 100
  • not met:3 min since creation ≥ 15
  • met:size 500 ≤ post-launch cap 5,000
  • Allowed if the first condition holds, or both of the last two.
  • size[0–15]
  • zeroForOne[16]
  • exactInput[17]
  • minutes[18–33]
  • carries 1
Circuit diagram: 34 inputs (size, zeroForOne, exactInput, minutes), 141 NAND gates over 41 levels of logic, 1 output. For the simulated swap 84 gates output 1 and the circuit outputs 0 (reject).sizezeroForOneexactInputminutes0 reject

34 inputs · 141 NAND gates · depth 41 · 1 output · 84 gates carry 1. Columns are logic depth; the last gate is the output.

A local simulation of the actual 141-gate netlist the compiler publishes. Agrees with the reference rule.

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

  1. 01

    Configure

    Pick a template and set its limits in token units. The Studio shows the exact rule in plain language.

    Policy Studio
  2. 02

    Compile & publish

    The browser compiles the policy to a NAND netlist and publishes it with tapeout() on your TapeOut processor.

    Publish & Bind
  3. 03

    Bind & create

    One call to the shared hook stores the binding and creates the pool. Nobody, including you, can rebind it.

    Publish & Bind
  4. 04

    Enforce & 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.

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.

CircuitPolicy compared with a configurable Solidity hook
AspectCircuitPolicyConfigurable Solidity hook
New parametersCompile and publish a new circuit; same hookStore new parameters; same contract
New rule shapeA new circuit, if it fits 34 input bits and 1,000 gates; same hookNew or upgraded contract code, and its review
What a trader checksThe circuit bytes, regenerated from the template and comparedThe contract source plus the stored parameters
Rule executionStateless NAND netlist via STATICCALL: no calls, storage or funds; any failure rejectsArbitrary Solidity, as written
Gas per swap (measured, fork)259,331120,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.