Skip to content
04 / MECHANISM

One event, three chains, one fee

Parallax has two on-chain halves, both EIP-2535 diamonds. The reactive diamond on Lasna turns Base Sepolia swaps into callbacks. The hook diamond on Unichain Sepolia turns callbacks into a fee that follows the cross-chain gap.

  1. 01
    Base Sepolia
    200 ms blocks
    Uniswap v4 PoolManager

    Reference pool pETH/pUSD · static 0.05% fee, no hook

    emits Swap(id, sender, …, sqrtPriceX96, liquidity, tick, fee)
  2. 02
    Reactive Lasna
    ~1 s blocks, instant finality
    Parallax reactive diamond

    Subscribed to Swap with topic1 = reference pool id. react() normalises the tick, applies a 10-tick threshold, derives the origin time in ms from the block number

    requestCallbackV_1_0 → onReference(seq, tick, origin block, origin ms, origin tx, …)
  3. 03
    Unichain Sepolia
    1 s blocks
    Parallax hook diamond

    Callback proxy → CallbackReceiverFacet checks the proxy and the injected reactive sender, stores the reference

    beforeSwap: arbitrage toward the reference pays base + surge; other flow pays the base fee

Who pays the surge

Prices are compared as canonical ticks: the tick of pETH quoted in pUSD, whichever token sorts first on either chain. One tick is about one basis point. In beforeSwap the hook reads the pool tick from the PoolManager and the direction from zeroForOne:

  • A swap that moves the pool toward the reference is the arbitrage leg. It pays base + gap × capture × decay.
  • A swap that moves the pool away from the reference, or any swap inside a 5-tick deadband, pays the base fee.
  • The control pool records the same decision but always charges the base fee.

The fee goes back to the PoolManager as fee | OVERRIDE_FEE_FLAG, so it applies only to that swap. Pools without a dynamic fee are rejected in afterInitialize.

Decay is 2^(−t / 20 s), where t is time since the callback landed, read from Unichain's block.timestamp. It never depends on block counts or on clocks agreeing across chains. As the fee falls, arbitrageurs effectively bid for the right to rebalance, and LPs collect most of the gap as fees.

0%1%2%3%4%0%1%2%3%4%divergence, pool vs referencearbitrage break-event = 0 sbase fee 0.05%

Surge = divergence × 90% capture × 2−t/20s, on top of the base fee, capped at 10%. The grey curve is t = 0. Time is measured with block timestamps, never block counts, because a Base Sepolia block is 200 ms.

Diamonds on both chains

Reactive diamond

Reactive Lasna · 5318007
Called by
→System contract 0x8888…8888react(LogRecord), pay()
→OwnerdiamondCut, config
fallback → delegatecall → facet
ReactFacet
react · pay · _SERVICE_PROVIDER
ReactiveConfigFacet
subscribe · unsubscribe · setDestination · setThreshold · setClock · setPaused · coverDebt · views
DiamondCutFacet
diamondCut
DiamondLoupeFacet
facets · facetAddress · supportsInterface …
OwnershipFacet
owner · transferOwnership
storage · LibReactive.Storage: origin, destination, clock, state, threshold

Hook diamond

Unichain Sepolia · 1301
Called by
→v4 PoolManagerafterInitialize, beforeSwap
→Reactive callback proxyonReference, pay
fallback → delegatecall → facet
HookFacet
afterInitialize · beforeSwap · previewFee
CallbackReceiverFacet
onReference · pay · coverDebt · withdraw
ShieldConfigFacet
setConfig · setPoolShielded · setReactiveSender · setPaused · views
TelemetryFacet
currentReference · telemetry · referenceAge
DiamondCutFacet · DiamondLoupeFacet · OwnershipFacet
EIP-2535 core
storage · LibShield.Storage: config, reference, pools, telemetry, trust anchors

Reactive diamond (Lasna)

  • The initializer subscribes the diamond to Swap on the Base Sepolia PoolManager, with topic1 = poolId.
  • ReactFacet.react() runs behind delegatecall. Reactive Omni runs react() as an ordinary transaction on the contract's own state, so facets work as on any EVM chain, and the system contract sees the diamond as both subscriber and requester.
  • Forwards only moves of 10 or more ticks. It derives the origin time in milliseconds from the Base block number (200 ms blocks) because a LogRecord carries no timestamp.
  • AbstractReactive from reactive-lib-omni provides onlySystem and pay(). Its immutable sits in the facet bytecode and survives delegatecall.

Hook diamond (Unichain Sepolia)

  • Deployed with CREATE2 at a mined address whose low bits are exactly AFTER_INITIALIZE | BEFORE_SWAP.
  • The PoolManager calls the diamond. The fallback delegates to HookFacet, where msg.sender is still the PoolManager.
  • onReference requires the Reactive callback proxy as caller and our reactive diamond as the injected first argument. Callbacks that arrive out of order never move the reference backwards.
  • Storage follows the diamond-storage pattern, so facets can be upgraded without moving the hook address.