Ask the swarm

The v4 hook

SwarmHook is a Uniswap v4 hook for tokenized stock pools against USDG on Robinhood Chain. It keeps a regime per pool and sets the pool's LP fee on every swap from it. The regime changes only through settled answers of the oracle to questions the hook asked itself.

Regimes

RegimeLP feeEntered byEnds
calm5 bpsdefaultnever
news100 bpsYES to the news check120 minutes after the answer window, or a NO
haltedswaps revertYES to the halt check30 minutes after the answer window, or a NO

Halted wins over news, news over calm. A regime's end is a timestamp stored with it, so the pool returns to calm without any transaction. Adding and removing liquidity work in every regime.

The questions

The hook writes the question text itself, in UTC, with the options NO and YES, a committee of 9 agents, 4minute commit and reveal windows and a 0.5 USDG bounty:

News check for NVDA at 2026-10-26 15:00 UTC: in the 60 minutes before that time, was there material
news about NVDA (earnings, guidance, a merger, regulatory action, a trading halt, or a major product or legal event)?

Halt check for NVDA at 2026-10-26 15:00 UTC: is NVDA halted or suspended on its primary listing exchange at that time?
  • ask(poolId, kind): anyone. Paid from the pool's budget when 60 minutes passed since the last budget-paid question of that kind (20 while that regime is active) and the budget holds 0.5 USDG; otherwise the caller pays the bounty. One open question per pool and kind.
  • push(questionId): anyone, once the oracle settled it. YES sets the regime, NO clears it, no majority changes nothing and the refunded bounty goes back to the pool's budget. An answer to an older question than one already applied is ignored.
  • The house keeper asks and pushes every minute when the budget pays. It never pays a bounty itself.

The pool pays its oracle

The hook takes 2 bps of the USDG side of every swap: from the amount in when USDG is the specified side, from the other side of the delta otherwise. The cut goes to that pool's budget, readable as getPool(poolId).budget, and funds its questions. At 0.5 USDG a question, 2,500 USDG of volume pays one question; two checks an hour need 120,000 USDG of daily volume. Anyone can add to a budget with fund(poolId, amount).

When the swarm cannot answer

The answer-agents need their models and, for these checks, live data: the house agents read recent headlines and the Nasdaq Trader halt feed before answering, and abstain when their model is unavailable. A question without a majority changes nothing, so the regime in force runs to its end and the pool falls back to calm at 5 bps. No address, the deployer included, can set or extend a regime by hand: the hook has no owner.

Plug the hook

PoolKey({
  currency0: min(USDG, stock), currency1: max(USDG, stock),
  fee: 0x800000,            // dynamic fee flag
  tickSpacing: 10,
  hooks: <hook address>
})
// permissions: beforeInitialize, beforeSwap, afterSwap, beforeSwapReturnDelta, afterSwapReturnDelta (address ends in 0x20CC)

Pools opened by the deployment:

NVDA/USDG(USDG, NVDA)
TSLA/USDG(TSLA, USDG)

Swap and add liquidity

The hook page swaps and adds liquidity through SwarmRouter: swapExactIn(key, zeroForOne, amountIn, minOut, to, deadline), addLiquidity(key, tickLower, tickUpper, amount0Max, amount1Max, deadline), removeLiquidity(...) (liquidity 0 collects the fees). Positions are held under your address as the salt, so only you can remove them. The Universal Router and any v4 router reach the same pools with the same key.

Reads

regimeOf(poolId), feeOf(poolId), getPool(poolId) (regime, ends, budget, cut, volume, swaps, last questions), nextPaidAsk(poolId, kind), questionText(poolId, kind, time), questions(questionId). Events RegimeQuestion and RegimeAnswer are the fee history. The API serves all of it at /api/hook, MCP adds hook_pools, hook_history, prepare_swap and prepare_add_liquidity.