Developers
Route through Socket
For routers and aggregators. Socket's pools are ordinary Uniswap v4 pools; check each pool's hook against HookRegistry, quote with the Quoter, and execute through the Universal Router.
Every pool on a Socket hook is an ordinary Uniswap v4 pool in PoolManager. A router that integrates v4 already reaches it: same pool key, same Quoter, same Universal Router. What Socket adds is a list of hooks to route through, kept on chain by SOCKET holders.
The addresses are on Contract addresses.
The integration#
Find pools
PoolManager doesn't store pool keys. Its
Initializeevent carries the full key of every new pool:currency0,currency1,fee,tickSpacingandhooks. Index those events, or take keys from your own v4 indexer.Check the hook
A pool with hook
address(0)has no hook and is always routable. Otherwise, route only ifHookRegistry.isListed(hooks)returns true.routable.sol interface IHookRegistry { function isListed(address hook) external view returns (bool); } function routable(IHookRegistry registry, PoolKey memory key) view returns (bool) { return address(key.hooks) == address(0) || registry.isListed(address(key.hooks)); }A pool's hook never changes, so the answer only changes when a vote lists or removes the hook.
Quote
Call the Quoter:
quoteExactInputSingleorquoteExactOutputSinglefor one pool,quoteExactInputorquoteExactOutputfor a path. The quote functions aren'tview: they run the real swap, hooks included, inside a call that reverts, and return the result. Call them witheth_call. Each returns the amount and agasEstimate.Execute
Call the Universal Router's
execute(commands, inputs, deadline)with aV4_SWAPcommand. Its actions are a swap (SWAP_EXACT_IN_SINGLE,SWAP_EXACT_IN, or their exact-output forms), thenSETTLE_ALLfor the input andTAKE_ALLfor the output.ERC-20 input goes through Permit2. The swapper approves Permit2 for the token once, then gives the Universal Router a Permit2 allowance, for example with a signed
PERMIT2_PERMITcommand in the sameexecute. Native ETH input is sent as the transaction's value.Set limits
Exact input: set the minimum output, with
amountOutMinimumor the minimum inTAKE_ALL. Exact output: set the maximum input inSETTLE_ALL. Less output, or more input, reverts the swap. Add a deadline.
Hooks a router meets#
| Pool | What differs from a pool with no hook |
|---|---|
| No hook | Nothing. |
| Dynamic fee | The LP fee is set per swap. It rises after the price moves and decays every second. The Quoter includes it. |
| TWAP oracle | Gas only. |
| Range order | Gas only. A swap that fills orders costs more gas, which the Quoter's estimate includes. |
| Listed external hook | Whatever its flags allow, within v4's rules. The Quoter runs it like any other hook. |
| Unlisted hook | Socket's app doesn't route through it. |
None of Socket's built-in hooks has a swap returns-delta flag. Swaps through them get what the pool's curve and fee give, and a range-order pool routes like any other pool.
Between the quote and the swap, the price can move and the dynamic fee keeps decaying. The slippage limit covers both.
Gas#
A hook's gas is paid by the swap's transaction. Set the gas limit from the Quoter's gasEstimate, with headroom.
Multi-hop#
A path is one V4_SWAP with SWAP_EXACT_IN or SWAP_EXACT_OUT. Each hop is a PathKey: the next currency, the pool's fee, tick spacing and hook, and hook data. All hops run inside one unlock; intermediate amounts net out, and only the input and output settle at the end. If any hop reverts, the whole swap reverts. Check every hop's hook.