BlockReq
Back to all articles

Rpc Tutorials

ETH StablePair Hook listen tool: peg / fee / LP

Uniswap StablePair Hook live on Ethereum USDC/USDG · USDC/USDT: public WSS eth_subscribe PoolManager Swap / ModifyLiquidity + hook logs — peg drift, dynamic fee, LP flow. Register for 3M free requests monthly.

BlockReq EngineeringSeptember 12, 20265 min read

ETH StablePair Hook listen tool: peg / fee / LP

Uniswap official ships StablePair Hook on mainnet for USDC/USDG · USDC/USDT—this post watches PoolManager Swap / ModifyLiquidity + hook logs: peg drift, dynamic fee, LP flow on one alert panel. Base stock-token Swap watch watches whitelist big prints; here we watch the Ethereum StablePair stable-pool layer.

Run on the public endpoint · blockreq.com register for 3M free requests monthly.

UseEndpoint
Public HTTPShttps://ethereum-rpc.blockreq.com/v1/rpc/public
Public WSSwss://ethereum-rpc.blockreq.com/v1/rpc/public
PrivateTrailing public{API_KEY} (keys stay local)

Chain: Ethereum Mainnet EVM chainId = 0x1 (1). Public endpoints · eth_subscribe · Plans · Register.

1. Hook: StablePair × peg / fee / LP

Tape feelOn-chain signalWatch
Stable-pool printsPoolManager Swap · poolId ∈ tablesqrtPrice · fee · amount0/1
Peg driftpost-trade tick / sqrtPriceX96distance from 1:1 reference
Dynamic feeSwap fee field / hook getFeefeeE6 per direction
LP flowModifyLiquidity · liquidityDeltaadd / withdraw size

Same family, different grain: Base stock-token converges on Swap big prints; this ETH post converges on StablePair peg + fee + LP cards.

2. Event: PoolManager Swap / ModifyLiquidity + hook

Keep local JSON:

envDefault (editable)
POOL_MANAGER0x000000000004444c5dc75cB358380D2e3dE08A90
STABLEPAIR_HOOK0x0000113dCf4ADd69999Fad8F20F2b63F979bfcC0
POOL_ID_LISTUSDC/USDT · USDC/USDG poolIds (official deployment table)
PEG_BPS / LP_DELTA_MINdrift and withdraw thresholds

One Ethereum public WSS: subscribe PoolManager Swap + ModifyLiquidity, filter topics[1] = poolId; optionally parallel-subscribe hook-address logs.

Step A · Subscribe PoolManager Swap

{
  "jsonrpc": "2.0", "id": 1, "method": "eth_subscribe",
  "params": ["logs", {
    "address": "0x000000000004444c5dc75cB358380D2e3dE08A90",
    "topics": [
      "0x40e9cecb9f5f1f1c5b9c97dec2917b7ee92e57ba5563708daca94dd84ad7112f",
      ["POOL_ID_USDC_USDT", "POOL_ID_USDC_USDG"]
    ]
  }]
}
  • topics[0]: V4 Swap(bytes32,address,int128,int128,uint160,uint128,int24,uint24).
  • topics[1]: indexed PoolId; decode amount0/1 · sqrtPriceX96 · liquidity · tick · fee → peg-drift and fee cards.

Step B · Subscribe ModifyLiquidity (parallel OK)

{
  "jsonrpc": "2.0", "id": 2, "method": "eth_subscribe",
  "params": ["logs", {
    "address": "0x000000000004444c5dc75cB358380D2e3dE08A90",
    "topics": [
      "0xf208f4912782fd25c7f114ca3723a2d5dd6f3bcc3ac8db5af63baa85f711d5ec",
      ["POOL_ID_USDC_USDT", "POOL_ID_USDC_USDG"]
    ]
  }]
}
  • topics[0]: V4 ModifyLiquidity(bytes32,address,int24,int24,int256,bytes32).
  • liquidityDelta < 0 and size ≥ LP_DELTA_MIN → LP-withdraw card; positive → add card.

Step C · Stable-pool card fields

{ chain: "ethereum", pad: "stablepair-hook", kind: "swap|peg|fee|lp", poolId, hook, sqrtPriceX96, tick, fee, pegBps, liquidityDelta, txHash, blockNumber, ts }

Dedupe on txHash + logIndex; demo knobs: poolId table and thresholds. Official reference poolIds (confirm against the deployment page):

  • USDC/USDT · 0x2b21c65d9a7dc6926ee330a1c6e5a8037fd81774f3dc066536f800128e39f634
  • USDC/USDG · 0xeda62d2906d0edf26d40c793d581609552a44a87f618a98ff76ebe8dde4b7edb

3. Browser demo (StackBlitz)

Default Ethereum public WSS; paste PoolManager / StablePair hook / poolId table + peg·LP thresholds, hit Start, stream stable-pool cards. Code lives in StackBlitz — the post only embeds the preview:

Repo: blockreq/blog-demosexamples/ethereum-uniswap-v4-stablepair-hook-listen (Vite+React+viem; open repo root in StackBlitz).

Product page: ZH · EN

WSS  → wss://ethereum-rpc.blockreq.com/v1/rpc/public
HTTPS→ https://ethereum-rpc.blockreq.com/v1/rpc/public
env  → POOL_MANAGER · STABLEPAIR_HOOK · POOL_ID_LIST · PEG_BPS · LP_DELTA_MIN

Keyed: swap trailing public for {API_KEY}. Quota: blockreq.com register for 3M free requests monthly.

4. Alert rhythm

  1. Swap arrives → decode poolId · sqrtPrice · fee · amounts → pegBps / fee card.
  2. ModifyLiquidity arrives → liquidityDelta threshold → LP add / withdraw card.
  3. OutboundETH StablePair · kind=… · pool=… · pegBps=… · fee=… · blk=….
  4. Dedupe → one push per txHash + logIndex.

On disconnect: reconnect and re-subscribe; gap-fill with HTTPS eth_getLogs on the same PoolManager. POST → https://ethereum-rpc.blockreq.com/v1/rpc/public.

5. Summary + CTA

  1. Grain: ETH StablePair watch = peg drift + dynamic fee + LP flow.
  2. Recipe: PoolManager + Swap/ModifyLiquidity topics + poolId table + thresholds → stable-pool card.
  3. Runnable: browser on BlockReq Ethereum public WSS; demos1 paths above.
  4. Start: Public endpoints + blockreq.com register for 3M free requests monthly.

Next: pin poolId / threshold JSON → webhook → stack on-screen with Base stock-token Swap print cards. Docs · Pricing · Register.