SocketDocs

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#

  1. Find pools

    PoolManager doesn't store pool keys. Its Initialize event carries the full key of every new pool: currency0, currency1, fee, tickSpacing and hooks. Index those events, or take keys from your own v4 indexer.

  2. Check the hook

    A pool with hook address(0) has no hook and is always routable. Otherwise, route only if HookRegistry.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.

  3. Quote

    Call the Quoter: quoteExactInputSingle or quoteExactOutputSingle for one pool, quoteExactInput or quoteExactOutput for a path. The quote functions aren't view: they run the real swap, hooks included, inside a call that reverts, and return the result. Call them with eth_call. Each returns the amount and a gasEstimate.

  4. Execute

    Call the Universal Router's execute(commands, inputs, deadline) with a V4_SWAP command. Its actions are a swap (SWAP_EXACT_IN_SINGLE, SWAP_EXACT_IN, or their exact-output forms), then SETTLE_ALL for the input and TAKE_ALL for 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_PERMIT command in the same execute. Native ETH input is sent as the transaction's value.

  5. Set limits

    Exact input: set the minimum output, with amountOutMinimum or the minimum in TAKE_ALL. Exact output: set the maximum input in SETTLE_ALL. Less output, or more input, reverts the swap. Add a deadline.

Hooks a router meets#

PoolWhat differs from a pool with no hook
No hookNothing.
Dynamic feeThe LP fee is set per swap. It rises after the price moves and decays every second. The Quoter includes it.
TWAP oracleGas only.
Range orderGas only. A swap that fills orders costs more gas, which the Quoter's estimate includes.
Listed external hookWhatever its flags allow, within v4's rules. The Quoter runs it like any other hook.
Unlisted hookSocket'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.

Public documentation snapshot · 9 October 2026 · Original page ↗
LOCAL REPLICA · DOCUMENTATION SNAPSHOT