@hypelens/hypelens-agent-rail 0.1.1

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/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ node_modules/
2
+ vendor/
3
+ *.tgz
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # HypeLens Agent Rail
2
+
3
+ **Eyes and hands for AI agents trading Hyperliquid perps.** Real-data liquidation
4
+ intelligence (free) + risk-checked execution (builder-code monetized), as an MCP
5
+ server and a plain Node SDK.
6
+
7
+ - **Real, not estimated**: walls/cascades come from a live crawl of ~1,100 top
8
+ Hyperliquid wallets (union of top-500 by account value and top-700 by weekly
9
+ volume), refreshed every 15 minutes. Every response carries `coverage_pct`
10
+ and `data_age_s` — we tell you exactly how much of open interest we see.
11
+ - **Risk-checked execution**: `hl_place_order` computes your liquidation price
12
+ and *refuses* orders whose liq lands inside a crowded wall (override
13
+ available). SL/TP ship in the same atomic order group.
14
+ - **Testnet-first**: mainnet placement is hard-blocked in code until the
15
+ operator's testnet money-path sign-off — the same gate as the HypeLens
16
+ extension's Module 3.
17
+
18
+ ## Quickstart (MCP)
19
+
20
+ ```bash
21
+ # Claude Code
22
+ claude mcp add hypelens -- npx hypelens-agent-rail
23
+
24
+ # any MCP client — stdio server:
25
+ npx hypelens-agent-rail
26
+ ```
27
+
28
+ Tools: `hl_walls`, `hl_cascade`, `hl_pretrade_check`, `hl_whale_book`,
29
+ `hl_exchange_status`, `hl_new_agent_wallet`, `hl_approve_payloads`,
30
+ `hl_place_order`.
31
+
32
+ ## Quickstart (SDK)
33
+
34
+ ```js
35
+ import { walls, pretradeCheck, placeOrder } from 'hypelens-agent-rail';
36
+
37
+ const w = await walls('BTC'); // real liq walls + magnet flag
38
+ const r = await pretradeCheck({ coin: 'BTC', dir: 'long', leverage: 20 });
39
+ if (r.verdict !== 'danger') {
40
+ await placeOrder({ coin: 'BTC', isBuy: true, size: 0.01, entryPx: r.entryPx,
41
+ slPx: r.liqPx * 1.02, leverage: 20 }); // testnet until enabled
42
+ }
43
+ ```
44
+
45
+ Execution env: `HYPELENS_AGENT_PK` (agent wallet key you generate with
46
+ `hl_new_agent_wallet`; the master wallet signs two one-time EIP-712 approvals —
47
+ agent + 0.01% builder fee — via `hl_approve_payloads`). `HYPELENS_NET=testnet`
48
+ (default).
49
+
50
+ ## How it's built
51
+
52
+ The rail evals the exact modules the HypeLens Chrome extension ships —
53
+ `viewmodel.js` (liq math, cascade model), `hl-actions.js` (wire-format action
54
+ builders, builder fee pinned), `hl-signer.js` + vendored signing SDK
55
+ (deterministic-hash-gated) — never a reimplementation. Same data, same model,
56
+ same safety gates as the extension overlay on app.hyperliquid.xyz.
57
+
58
+ ## Economics, stated plainly
59
+
60
+ Risk tools are free, forever. Execution routed through the rail carries the
61
+ HypeLens builder code at **1 basis point (0.01%)** — $0.10 per $1,000 traded —
62
+ approved explicitly by the user's master wallet with a hard `maxFeeRate`, and
63
+ revocable on-chain at any time.
64
+
65
+ ## Test
66
+
67
+ ```bash
68
+ npm test # 13 tests: model load, wire format, mainnet block, risk gate
69
+ ```
70
+
71
+ MIT. Part of [HypeLens](https://github.com/polyparlay/hypelens).
package/ROLLOUT.md ADDED
@@ -0,0 +1,67 @@
1
+ # Agent Rail — rollout plan (2026-07-22)
2
+
3
+ No "post on CT and pray." Every channel below is a named registry, community, or
4
+ direct counterparty with a concrete submission mechanic. Revenue ground truth is
5
+ on-chain: builder-fee receipts at 0x9548…7c88 + count of distinct wallets that
6
+ signed `approveBuilderFee`.
7
+
8
+ ## Wave 1 — publish + registries (this week; mostly Claude-executable)
9
+
10
+ | # | Venue | Mechanic | Who |
11
+ |---|---|---|---|
12
+ | 1 | **npm** (`hypelens-agent-rail`) — makes `npx` quickstart real; npm search is a discovery surface itself | `npm publish` from agent-rail/ (prepack bundles vendor) | **Operator**: npm account/token. Claude: everything else |
13
+ | 2 | **Official MCP Registry** (registry.modelcontextprotocol.io) — what Claude/Cursor/clients browse | add `server.json`, publish via `mcp-publisher` CLI (GitHub auth) | Claude preps; operator authorizes GitHub auth |
14
+ | 3 | **Smithery.ai** — largest MCP directory, shows install counts (our adoption KPI) | GitHub sign-in + add repo (one click) + `smithery.yaml` | Claude preps yaml; **operator**: one-click connect |
15
+ | 4 | **Glama / PulseMCP / mcp.so** MCP directories | submission forms / PRs | Claude |
16
+ | 5 | **awesome-mcp-servers** + **awesome-hyperliquid** GitHub lists | PRs | Claude |
17
+ | 6 | Split to standalone repo `polyparlay/agent-rail`? | better star/discovery surface than a subdir | Operator decision; Claude executes |
18
+
19
+ ## Wave 2 — where HL agent devs actually are (next week)
20
+
21
+ | # | Venue | Mechanic | Who |
22
+ |---|---|---|---|
23
+ | 7 | **Hyperliquid Discord** #api-traders / #builder-codes — where HL routes every bot dev asking API questions | working demo post + answer threads; this is support-driven distribution, not broadcast | Claude drafts; operator posts (account) |
24
+ | 8 | **Hyper Foundation builder grants / ecosystem page** — funding AND official listing; grantees get promoted by HL itself | application; reuse `marketing/pitch/PITCH-CORE.md` grant skin (Jul 17) | Claude drafts full application; operator submits |
25
+ | 9 | **ElizaOS plugin registry** (elizaos-plugins org) — the largest open agent framework; an existing `plugin-hyperliquid` proves demand and has NO risk tools and NO real liq data | thin plugin wrapping the SDK; PR to registry index | Claude |
26
+ | 10 | **Bankr skills catalog** (BankrBot/skills, ~5 entries) | SKILL.md PR teaching Bankr agents `pretrade_check` | Claude (already scoped) |
27
+ | 11 | **Coinbase AgentKit** action provider | PR adding HL risk actions | Claude (secondary) |
28
+
29
+ ## Wave 3 — direct B2B (the % of real volume; starts as soon as Wave 1 is live)
30
+
31
+ Named counterparties, each with a specific ask — data licensing for platforms
32
+ that already have their own builder codes, rail integration for those that don't:
33
+
34
+ | Target | Why them | Ask |
35
+ |---|---|---|
36
+ | **pvp.trade, Insilico, Dexari, Mizar** (established HL frontends/terminals) | have builder-code flow, have NO real-position liq data (all use estimates or nothing) | license the feed/pretrade-check as white-label API ($/mo) — they keep their code, we sell the eyes |
37
+ | **Capacitr, Hypurr, Nexus Trading Labs** (Bankr's HL-adjacent agents, measured small but live) | free rail integration = instant differentiation for them | integrate free risk tools; execution via our rail where they lack their own |
38
+ | **Top HL vault leaders / copy-trade operators** — addresses already in our feed | they route size programmatically; our whale drill-down IS their risk profile | direct note: "here's your own liq exposure on our map" + rail/API |
39
+ | **HL trading-bot OSS maintainers** (hyperliquid-python-sdk ecosystem, ccxt-hyperliquid users) | devs who wire bots by hand | PR examples + README links |
40
+
41
+ Reuse `marketing/pitch/OUTREACH-SENDS.md` (partner skin) for all of the above.
42
+
43
+ ## Gate to revenue
44
+
45
+ Builder fees only accrue on **mainnet** flow. The one blocking item is the
46
+ standing Module 3 gate: **operator testnet money-path proof → explicit sign-off
47
+ → flip `MAINNET_PLACEMENT_ENABLED`** in `extension/exchange/hl-actions.js`
48
+ (rail inherits it automatically). Wave 1-2 proceed regardless — risk tools are
49
+ mainnet-real today and are the acquisition hook.
50
+
51
+ ## Pre-registered adoption gates (no dust)
52
+
53
+ - **Week 2** (from npm publish): ≥25 installs (Smithery + npm downloads) OR ≥2
54
+ live integration conversations from Wave 3 → continue. Below both → the
55
+ problem is packaging/pitch; iterate THAT, don't add features.
56
+ - **Week 6**: ≥1 platform integration signed OR ≥$50/wk builder-fee revenue
57
+ on-chain OR ≥200 weekly `pretrade_check` calls → invest (Eliza-native vault
58
+ product, alerts). Below all three → write the verdict to memory, keep the
59
+ rail published at zero marginal cost, stop investing.
60
+
61
+ ## Operator one-time checklist (~2h total)
62
+ 1. npm account + `npm publish` (or hand Claude a token)
63
+ 2. Smithery GitHub connect (one click)
64
+ 3. MCP-registry GitHub auth for `mcp-publisher`
65
+ 4. Decide: split `polyparlay/agent-rail` repo?
66
+ 5. HL Discord + grant submission (Claude drafts everything)
67
+ 6. Testnet proof session (~30 min with testnet USDC) → mainnet sign-off
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { main } from '../src/mcp.js';
3
+ main().catch((e) => { console.error('hypelens-rail-mcp fatal:', e); process.exit(1); });