@hypurrquant/perp-ws 0.0.0-stage → 0.16.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 HypurrQuant
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # Temporary Holding Version
1
+ # @hypurrquant/perp-ws
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Live **market, funding and account WebSocket streams** for perp DEXes — **hyperliquid** (native + HIP-3),
4
+ **pacifica**, **lighter**, **lighter-rh**, **aster** and **arcus** — in the browser or Node, with a
5
+ cross-venue funding comparator. **No dependencies.**
6
+
7
+ This is the standalone build of [`perp-cli/ws`](https://github.com/hypurrquant/perp-cli): the same
8
+ source, the same API, released in lockstep with perp-cli. Use this package in apps and dashboards; use
9
+ `perp-cli/ws` only if perp-cli is already installed.
10
+
11
+ > **@experimental** in 0.15.x (breaking changes only in a minor bump; events carry `schema: 1`),
12
+ > **@stable** from 0.16.0.
13
+
14
+ ## Install
15
+
16
+ ```sh
17
+ npm install @hypurrquant/perp-ws # browser / bundler / Node ≥ 22 with the global WebSocket
18
+ npm install @hypurrquant/perp-ws ws # Node 20+ via the /node entry
19
+ ```
20
+
21
+ | Entry | Runtime | Transport |
22
+ |---|---|---|
23
+ | `@hypurrquant/perp-ws` | browser (any bundler, Next.js, Vite, static page), Node ≥ 22 | native `WebSocket` + `fetch` |
24
+ | `@hypurrquant/perp-ws/node` | Node 20+ | [`ws`](https://www.npmjs.com/package/ws) — an **optional peer dependency** |
25
+
26
+ The `/node` entry loads `ws` lazily: importing it never fails, and creating a stream without `ws`
27
+ installed throws `INVALID_PARAMS` with the install command. It uses `ws` even on Node ≥ 22 for a 16 MiB
28
+ inbound message cap (`createNodeTransport({ maxPayload })`) and protocol ping/pong.
29
+
30
+ ESM only, ES2020, `sideEffects: false`, no top-level await, no global touched at module load (SSR-safe).
31
+ Next.js 13.5+: `transpilePackages: ["@hypurrquant/perp-ws"]`.
32
+
33
+ ## Example
34
+
35
+ ```ts
36
+ import { createFundingComparator, createVenueStream, hyperliquid, lighter, pacifica, toApr } from "@hypurrquant/perp-ws";
37
+
38
+ const streams = [hyperliquid, pacifica, lighter].map((c) => createVenueStream(c));
39
+ const cmp = createFundingComparator({ streams, kind: "next", minVenues: 2 });
40
+ cmp.subscribe((rows) => {
41
+ for (const row of rows) {
42
+ console.log(row.canonical, row.legs.map((l) => [l.venue, toApr(l.rate, l.funding.rateIntervalHours)]));
43
+ }
44
+ });
45
+ ```
46
+
47
+ Unknown values are `null`, never `0`. Rates are raw per the venue's interval; annualize with `toApr`.
48
+
49
+ ## Documentation
50
+
51
+ The full guide (streams, event fields and nullability, comparator, user channels with a
52
+ `CredentialProvider`, errors, limits, capability matrix):
53
+ [`skills/perp-cli/references/ws-library.md`](https://github.com/hypurrquant/perp-cli/blob/main/skills/perp-cli/references/ws-library.md).
54
+
55
+ ## License
56
+
57
+ MIT