signaldocs Open Signal

Build with Signal

v4 read-only example

The downloadable example reads one Signal v4 launch from the chain and quotes one exact-input swap. It needs Node.js 22 or newer. It holds no key, sends no approval and broadcasts nothing: every call is an eth_call or a block read.

Download the v4 example

Extract the archive and run these commands inside the signal-v4-example directory:

sh
npm ci --ignore-scripts
npm run example -- 0x1b67a2ac4dc5faab20554d379af5148b8b70f626 buy 0.01

On a buy the amount is in pair-asset units: for this WHYPE-paired token, 0.01 WHYPE, not $0.01. On a sale it is in the launched token's units.

What it does

  1. Checks chain 999 and pins a recent block.
  2. Asks each factory in the v4 deployment record for poolOf(token) and stops if none bore the token.
  3. Reads terms(poolId) from that factory's hook and confirms the links: the factory's hook, the pool's token, the pool key deriving the pool id, and on release 4.2 the token's clone implementation.
  4. Reads what a swap pays now: feeRates, sizeRate, devRate, prices, poolState, and how many seconds each opening rule has left.
  5. Quotes the swap through Uniswap's v4 Quoter. The answer is net of the hook's fees. A refusal is reported in the hook's own word (Gated, WhaleCap, OverBudget, PartialFill).
  6. Rechecks the block hash and prints one JSON object. It makes at most 32 read calls.

Reading the output

FieldMeaning
release, poolId, poolKeyWhich Signal release bore the token, and its pool
birthTermsRates and the division of the fee as fixed at launch, in bps
now.baseRateBps, now.rateWithOpeningBpsThe base rate for this direction and the live rate with any opening fee
now.sizeExtraBps, now.deviationExtraBps, now.totalRateBpsThe extras for this trade and the total, capped as the hook caps it. For a sale the size extra is known only after the fill
now.secondsLeftSeconds left in the opening fee, the Signal-only window, the wallet cap and the per-block budget
quoteThe Quoter's output, or the reason it refused

The result is an indicative quote of the pool. It does not check the user's balance or allowance, it is not a wallet simulation, and for a pair asset that taxes its own transfers it leaves that asset's cut out (see quote and trade). The chosen RPC and the published deployment record remain trust dependencies.

The default public RPC is https://rpc.hypurrscan.io. Set SIGNAL_DOCS_RPC_URL locally for your own HTTPS provider; never commit a credential-bearing URL.

The bundle contains the example, one pinned dependency (ethers), the v4 ABIs and the deployment record. The documentation source repository is maintained privately; repository access is not needed to use this download.

examples/v4-utils.mjs holds the small pure pieces: the pool key and pool id, the swap direction, the rate arithmetic, the opening windows, the hookData shape and an unsigned calldata helper for Signal's router. The helper builds calldata only. Its caller still owns the spender, the allowance, the recipient, a fresh minimum and a simulation from the real wallet.