@valve-tech/gas-oracle 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +66 -0
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,25 @@ All notable changes to `@valve-tech/gas-oracle` are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
+ ## [0.2.5] — 2026-05-03
9
+
10
+ ### Added
11
+ - README **RPC transport modes** section covering all four caller-side
12
+ configurations the package supports: HTTP-only, WS-only, both (via viem's
13
+ `fallback`), and "neither" (driving the pure `reducePollInputs` reducer
14
+ with pre-fetched `OraclePollInputs` — no live `PublicClient` needed).
15
+ - `examples/06-reducer-only.ts` exercising the offline path end-to-end with
16
+ synthetic fixture inputs, surfacing the `fetchOracleInputs` /
17
+ `reducePollInputs` export split that enables it.
18
+
19
+ ### Notes
20
+ - Documentation-only release. No API changes; behavior identical to v0.2.4.
21
+ - Picking WS today buys nothing functional over HTTP — the oracle never
22
+ opens a subscription. The functional case for WS arrives when
23
+ subscription-using features (e.g., tx-tracking via `newHeads` /
24
+ `newPendingTransactions`) land. Choose WS now only if upstream is cheaper
25
+ or lower-latency on it.
26
+
8
27
  ## [0.2.4] — 2026-05-02
9
28
 
10
29
  ### Added
package/README.md CHANGED
@@ -267,6 +267,72 @@ careful to avoid.
267
267
  synthesizing a historical-percentile array from oracle state is its
268
268
  own design problem. Always passes through to upstream.
269
269
 
270
+ ## RPC transport modes
271
+
272
+ The package only ever calls `client.request({ method, params })` and
273
+ never opens a subscription. That makes it transport-agnostic — any
274
+ viem `Transport` works, and the four caller-side configurations below
275
+ all run unchanged:
276
+
277
+ ### HTTP only
278
+
279
+ ```ts
280
+ import { http } from 'viem'
281
+
282
+ const client = createPublicClient({ chain: mainnet, transport: http(rpcUrl) })
283
+ const oracle = createGasOracle({ client, chainId: 1 })
284
+ ```
285
+
286
+ ### WebSocket only
287
+
288
+ ```ts
289
+ import { webSocket } from 'viem'
290
+
291
+ const client = createPublicClient({ chain: mainnet, transport: webSocket(wsUrl) })
292
+ const oracle = createGasOracle({ client, chainId: 1 })
293
+ ```
294
+
295
+ WS works because the three RPCs the oracle issues (`eth_feeHistory`,
296
+ `eth_getBlockByNumber`, `txpool_content`) are all request/response;
297
+ viem's `webSocket` transport implements the same `request` interface
298
+ as `http`. **Picking WS today buys nothing functional over HTTP** —
299
+ the oracle still polls on its `pollIntervalMs`. The functional case
300
+ for WS arrives when subscription-using features land (tx-tracking
301
+ `newHeads` / `newPendingTransactions`); choose WS now only if your
302
+ upstream is cheaper or lower-latency on it.
303
+
304
+ ### Both — `fallback` for resilience
305
+
306
+ ```ts
307
+ import { fallback, http, webSocket } from 'viem'
308
+
309
+ const transport = fallback([webSocket(wsUrl), http(rpcUrl)])
310
+ const client = createPublicClient({ chain: mainnet, transport })
311
+ const oracle = createGasOracle({ client, chainId: 1 })
312
+ ```
313
+
314
+ viem handles failover transparently — if the WS drops, requests fall
315
+ to HTTP without the oracle noticing.
316
+
317
+ ### Neither — pure reducer, no live RPC
318
+
319
+ The oracle's I/O surface (`fetchOracleInputs`) and its math
320
+ (`reducePollInputs`) are exported as separate top-level entries. That
321
+ split is what enables the offline path: drive the reducer with
322
+ `OraclePollInputs` from any source — fixture file, snapshot store,
323
+ Kafka log, another service's API — and never touch a `PublicClient`.
324
+
325
+ ```ts
326
+ import { reducePollInputs, type OraclePollInputs } from '@valve-tech/gas-oracle'
327
+
328
+ const inputs: OraclePollInputs = await loadFromYourQueue()
329
+ const state = reducePollInputs({ inputs, chainId: 1, prev: priorState })
330
+ ```
331
+
332
+ Use cases: serverless / edge handlers, backtest harnesses replaying
333
+ historical RPC payloads, tests asserting state shape from fixtures.
334
+ See `examples/06-reducer-only.ts`.
335
+
270
336
  ## Wire format
271
337
 
272
338
  Every fee field is a `bigint`. Callers serializing across HTTP / Redis
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valve-tech/gas-oracle",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Multi-tier gas-fee oracle for EVM chains. Computes slow/standard/fast/instant tier recommendations from block-included tips, mempool pending tips, and base-fee trend, with a configurable downside-decay cap and a chain-aware EIP-1559 priority cutoff. viem-native — pass it a PublicClient and it does the rest. Ships viem-actions and viem-transport subpaths for drop-in client extension and transport-wrapping.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/valve-tech/gas-oracle#readme",