One socket,
many plugs.

Socket is a concentrated-liquidity AMM on Solana. Every pool can take one hook program that runs before and after swaps and liquidity changes, inside limits fixed when the pool is created. A dynamic fee, a TWAP oracle and range orders are built in. Anything else can be written as a new hook instead of a new AMM.

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

Follow one swap.

40 SOL for USD in the example pool, with the socket empty. Scroll to run it.

  1. The router reads the pool's account list

    Every swap has the same 10 accounts. With no hook the pool's list is empty and the swap runs as in a plain pool.

  2. Nothing before the swap

    Empty socket: no hook, no call. The pool runs like a plain CLMM.

  3. The CLMM math runs

    40 SOL in at a 0.30% fee moves the price from 148.20 to 147.61 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 like a plain CLMM.

  5. Tokens settle once

    5,898.43 USD out. If any hook call had failed, the whole swap would revert, nothing would move, and the router could take another path.

Example swap · SOL/USDno hook

In
40.000 SOL
Accounts
10
Before swap
no call
Fee
0.30% · pool · max 1.00%
Price
148.20 → 147.61
After swap
no call
Out
5,898.43 USD

Settled

Why a socket

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

On Socket the idea ships as a hook. Pools share one program and one way of listing accounts, so a router integrates once and can reach every pool, whatever is plugged into it.

Router integrations to maintain41

Liquidity still sits in separate pools. What changes is the cost of a new idea: a hook to write and audit, not a new venue every router has to add.

RouteraggregatorSocket programDynamic-fee AMMpool · Dynamic feeOracle AMMpool · TWAP oracleLimit-order AMMpool · Range orderYour next AMMpool · Your hook

The pins are the permissions.

A pool stores its hook program and a six-bit permission mask, both fixed when the pool is created. Four bits choose where the hook runs; two let it set the fee or add a surcharge. Wire a plug and see what it may do.

Raises the fee after the price moves, then lets it decay while trading is calm.
before swapafter swapbefore addafter addbefore removeafter removefee overrideinput surcharge

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

permissions010011= 19

Runs before swap, after swap; may set the fee up to 1.00%. Everything else is refused.

Hook points

Powers

Hook programDynamic fee

Each pool sets its own max fee and surcharge cap, up to 10% each.

Nothing is fixed until the pool is created.

Create a real pool in the app

Three hooks, built in.

A dynamic fee, a TWAP oracle and range orders ship with Socket in one hooks program, ready to plug into any new pool. All three run on the same example afternoon of SOL/USD below. Let it play, or drag the clock.

12:00SOL 148.20 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

A range order is a pool of its own whose only liquidity is one owner's order. As the price passes through, it converts; once through, the hook refuses swaps that would undo it. Drag the order.

140141142143144145146147148149148.20buy 144.0

Open. Buy 12 SOL from 144.0 to 143.6. 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 program can read a time-weighted mean over the window it needs.

TWAP 148.20spot 148.20observations 0

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

Bounded by the pool.

A hook runs inside limits its pool fixed at creation: a max fee, a surcharge cap, a compute limit and a fixed list of accounts. If a hook crosses one, the whole swap fails and nothing moves, so a router can send the trade elsewhere.

Route around a failing hook

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

Hooks spend the swap's compute

A hook call comes out of the swap's compute budget. Each pool sets the most one call may use, and Socket fails the swap if a call goes over. Socket can't reserve compute in advance, so routers should still simulate.

swap budgethook compute limit, set per pool

Hooks stay shallow

A router calls Socket, Socket calls the hook, and the hook may call another program. That chain uses most of Solana's call depth, and the pool is locked while its hook runs, so a hook can't call back into it.

  1. Solana's CPI depth limit
  2. the hook's own call
  3. hook
  4. Socket
  5. router