One socket,
many plugs.

Socket builds Uniswap v4 hooks for Robinhood Chain. A pool takes one hook contract that runs before and after swaps and liquidity changes, and its permissions are written into the hook's address. A dynamic fee, a TWAP oracle and range orders are built in, and SOCKET holders decide which other hooks the app routes through.

Drag a plug into the socket, or click its name.Tap a plug to plug it in.

Follow one swap.

2 ETH for USDG in the example pool, with the socket empty. Scroll to run it.

  1. The router names the pool by its key

    A v4 pool is its key: two currencies, the fee, the tick spacing and the hook address. With no hook the address is zero and the swap runs as in a plain pool.

  2. Nothing before the swap

    Empty socket: no hook, no call. The pool runs as a plain v4 pool.

  3. PoolManager runs the swap

    2 ETH in at a 0.30% fee moves the price from 2964.00 to 2952.19 through the pool's concentrated liquidity. No hook runs inside this step.

  4. Nothing after the swap

    Empty socket: no hook, no call. The pool runs as a plain v4 pool.

  5. Deltas settle once

    5,898.43 USDG out. PoolManager settles what each side owes at the end of the unlock. If any hook call had reverted, nothing would move, and the router could take another path.

Example swap · ETH/USDGno hook

In
2.000 ETH
Pool key
0.30% · no hook
Before swap
no call
Fee
0.30% · pool key
Price
2964.00 → 2952.19
After swap
no call
Out
5,898.43 USDG

Settled

Why a socket

A new AMM idea usually ships as its own AMM, with its own contracts, liquidity and router integration. Four ideas mean four adapters on the router's side.

On Uniswap v4 the idea ships as a hook. Every pool lives in one PoolManager, so a router integrates once and reaches every pool, whatever is plugged into it. Socket builds those hooks for Robinhood Chain.

Router integrations to maintain41

Liquidity still sits in separate pools. What changes is the cost of a new idea: a hook to write and review, not a new venue every router has to add. SOCKET holders keep the list of hooks Socket's app routes through.

Routeraggregator PoolManager Dynamic-fee AMMpool · Dynamic fee Oracle AMMpool · TWAP oracle Limit-order AMMpool · Range order Your next AMMpool · Your hook

The pins are the permissions.

On Uniswap v4 a hook's permissions are the last 14 bits of its address, and a pool's hook is part of its key. Neither can change. Six contacts choose where PoolManager calls the hook; two let it set the fee or return a delta. Wire a plug and see the address it needs.

Raises the fee after the price moves, then lets it decay while trading is calm.
before swap after swap before add after add before remove after remove dynamic fee returns delta

Plug face from the front. The socket in the pool is its mirror image.

address010101110000110x…15C3

PoolManager calls it at before swap, after swap, after add, after remove; it sets each swap's LP fee; its calls may return deltas; it sets up each pool after initialization. No other call is made.

Hook points

Powers

Hook contractDynamic fee

Address ends in0x…15C3

Pool key fee0x800000 · dynamic

The hook is deployed at an address mined for these bits, and every pool that names it gets exactly these calls.

Nothing is fixed until the hook is deployed.

Write a hook

Three hooks, built in.

A dynamic fee, a TWAP oracle and range orders ship with Socket as three hook contracts on Robinhood Chain, ready for any new v4 pool. All three run on the same example afternoon of ETH/USDG below. Let it play, or drag the clock.

12:00ETH 2964.00 example

Dynamic fee

After each swap the hook adds how far it moved the price to a running average. Before the next, it lets that average decay for the seconds in between and adds 0.03% per tick of it to the base fee, up to 1.00% . These are this example pool's settings; each pool sets its own.

0.00 % 0.25 % 0.50 % 0.75 % 1.00 % max

0.30%

fee for a swap at 12:00

average move per swap0.0 ticks

Range order

Orders sit in the pool beside everyone else's liquidity. As the price passes through one, it converts; the swap that takes the price all the way through also takes the order out, so it can't convert back. Drag the order.

2800 2820 2840 2860 2880 2900 2920 2940 2960 2980 2964.00 buy 2880

Open. Buy 0.6 ETH from 2880 to 2872 . On this afternoon it fills at 13:44 .

TWAP oracle

Around every swap the hook records the tick (the log of the price), weighted by how long it held, in a ring of 32 observations. Any contract can read a time-weighted mean over the window it needs.

TWAP 2964.00spot 2964.00observations 0

12:0013:0014:0015:0016:0017:0017:59

Bounded by the swap.

Whatever a hook does, the swap runs inside one PoolManager unlock and the swapper's minimum output. If a hook call reverts, or the output falls short, the whole swap reverts and nothing moves, so a router can send the trade elsewhere.

Route around a failing hook

Both pools can fill 2 ETH. The Socket pool quotes more, 5,884.26 USDG, so the router sends the swap there. Flip the switch to make its hook fail. Example quotes.

Hooks spend the swap's gas

Every hook call runs in the swap's transaction and adds to its gas. Routers quote with that gas included, route through listed hooks, and simulate the complete route before sending it.

transaction gassimulated first

Deltas settle once

Inside an unlock, the swap and its hook only record what each side owes. The router settles everything at the end. If any balance is left open, PoolManager reverts the whole transaction.

  1. unlock ends · every delta at zero
  2. take USDG
  3. settle ETH
  4. swap + hook
  5. unlock