robinhood-chain-x402 0.1.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 +21 -0
- package/README.md +135 -0
- package/dist/index.d.ts +154 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +212 -0
- package/dist/index.js.map +1 -0
- package/dist/stream.d.ts +72 -0
- package/dist/stream.d.ts.map +1 -0
- package/dist/stream.js +217 -0
- package/dist/stream.js.map +1 -0
- package/dist/types.d.ts +541 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MadeOnSol
|
|
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
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# robinhood-chain-x402
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/robinhood-chain-x402)
|
|
4
|
+
[](https://www.npmjs.com/package/robinhood-chain-x402)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
> ๐ **[Examples](./examples/)** ยท ๐ **[API docs](https://madeonsol.com/api-docs)** ยท ๐ค **[Robinhood Chain](https://madeonsol.com/robinhood)** ยท ๐ฐ **[Free API key](https://madeonsol.com/pricing)**
|
|
9
|
+
|
|
10
|
+
**TypeScript SDK for the [MadeOnSol](https://madeonsol.com/robinhood) Robinhood Chain API โ EVM-native on-chain trading intelligence for Robinhood Chain, chain id 4663.**
|
|
11
|
+
|
|
12
|
+
Robinhood Chain is an Arbitrum Orbit L2. This SDK gives you the same intel you get on Solana โ live KOL trades, a DEX trade tape, token discovery, launch-bundle detection, early-buyer quality, deployer reputation and smart-money wallets โ but EVM-native: lowercase `0x` addresses, `eth_amount`, `tx_hash`, `block_number`, `net_flow_eth`. Data comes from our **self-hosted RHC node**. The KOLโEVM mapping is recovered by tracing each Solana KOL's bridge deposits (deBridge / Relay / Mayan / Wormhole) โ a dataset unique to MadeOnSol.
|
|
13
|
+
|
|
14
|
+
RHC coverage is **bundled into every tier at no extra cost** โ same API key, same base URL. Get a free key (200 req/day, no card) at [madeonsol.com/pricing](https://madeonsol.com/pricing).
|
|
15
|
+
|
|
16
|
+
> **Key-mode only.** This package authenticates with an `msk_` Bearer API key. The x402 pay-per-call micropayment rail is Solana-native and is **not** ported here โ for keyless USDC-per-call on the Solana API, use [`madeonsol-x402`](https://www.npmjs.com/package/madeonsol-x402).
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install robinhood-chain-x402
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
> Zero required runtime dependencies. The live stream will use the optional [`ws`](https://www.npmjs.com/package/ws) package on Node when present (recommended on Node โฅ 22 for a clean process exit); the browser uses the native `WebSocket`.
|
|
25
|
+
|
|
26
|
+
## Quick start (10 seconds)
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { createClient } from "robinhood-chain-x402";
|
|
30
|
+
|
|
31
|
+
const client = createClient("msk_your_api_key_here"); // free tier at madeonsol.com/pricing
|
|
32
|
+
|
|
33
|
+
// Live KOL buys/sells on Robinhood Chain (chain id 4663)
|
|
34
|
+
const { trades } = await client.kolFeed({ limit: 10, action: "buy" });
|
|
35
|
+
console.log(trades);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Advanced initialization
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { RobinhoodChainX402 } from "robinhood-chain-x402";
|
|
42
|
+
|
|
43
|
+
const client = new RobinhoodChainX402({
|
|
44
|
+
apiKey: "msk_...",
|
|
45
|
+
baseUrl: "https://madeonsol.com", // optional override
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Endpoints โ all 14 Robinhood Chain routes
|
|
50
|
+
|
|
51
|
+
Every method maps 1:1 to a GET /api/v1/rhc/โฆ route. Fields are EVM-native.
|
|
52
|
+
|
|
53
|
+
### KOL intelligence
|
|
54
|
+
|
|
55
|
+
| Method | Route | Tier | Description |
|
|
56
|
+
|---|---|---|---|
|
|
57
|
+
| `kolFeed(params?)` | `/api/v1/rhc/kol/feed` | BASIC | Real-time KOL trade feed โ every buy/sell from tracked KOLs' verified EVM wallets, enriched with MC/peak and `mc_multiple_since_trade` |
|
|
58
|
+
| `kolLeaderboard(params?)` | `/api/v1/rhc/kol/leaderboard` | BASIC | KOLs ranked by trade count then net ETH flow over `24h`/`7d`/`30d` |
|
|
59
|
+
| `kolHotTokens(params?)` | `/api/v1/rhc/kol/hot-tokens` | BASIC | Consensus tokens bought by 2+ distinct KOLs in the window |
|
|
60
|
+
| `kol(wallet)` | `/api/v1/rhc/kol/{wallet}` | BASIC | Single KOL profile โ aggregate stats + 50 most recent trades |
|
|
61
|
+
|
|
62
|
+
### DEX trade tape
|
|
63
|
+
|
|
64
|
+
| Method | Route | Tier | Description |
|
|
65
|
+
|---|---|---|---|
|
|
66
|
+
| `trades(params?)` | `/api/v1/rhc/trades` | PRO+ | Every Uniswap v2/v3/v4 swap with the real `trader_eoa`, gas/ordering for MEV, and KOL/deployer flags |
|
|
67
|
+
|
|
68
|
+
### Token discovery + intelligence
|
|
69
|
+
|
|
70
|
+
| Method | Route | Tier | Description |
|
|
71
|
+
|---|---|---|---|
|
|
72
|
+
| `tokens(params?)` | `/api/v1/rhc/tokens` | PRO+ | Live-priced token discovery โ MC, liquidity, peak MC + drawdown, launchpad, deployer tier |
|
|
73
|
+
| `token(address)` | `/api/v1/rhc/tokens/{address}` | BASIC | Full token snapshot โ price/MC/FDV, graduation, deployer block, KOL activity, pools |
|
|
74
|
+
| `tokenCandles(address, params?)` | `/api/v1/rhc/tokens/{address}/candles` | PRO+ | 1-minute OHLC candles โ price + MC OHLC, close liquidity, volume with buy/sell split |
|
|
75
|
+
| `tokenKolConsensus(address)` | `/api/v1/rhc/tokens/{address}/kol-consensus` | PRO+ | KOL positioning โ buyers vs sellers, exit rate, `net_flow_eth`, median entry MC (ULTRA adds wallet lists) |
|
|
76
|
+
| `tokenBuyerQuality(address)` | `/api/v1/rhc/tokens/{address}/buyer-quality` | BASIC | 0โ100 early-buyer quality with bundle-buyer + dump-cluster legs |
|
|
77
|
+
| `tokenBundle(address)` | `/api/v1/rhc/tokens/{address}/bundle` | BASIC | Launch-bundle detection (`same_block`) + how much the cohort still holds |
|
|
78
|
+
|
|
79
|
+
### Deployer hunter + smart money
|
|
80
|
+
|
|
81
|
+
| Method | Route | Tier | Description |
|
|
82
|
+
|---|---|---|---|
|
|
83
|
+
| `deployerLeaderboard(params?)` | `/api/v1/rhc/deployer-hunter/leaderboard` | BASIC | Deployers ranked by reputation โ `graduation_rate` ($40K+ peak MC), `runner_rate` ($100K+) |
|
|
84
|
+
| `deployer(address)` | `/api/v1/rhc/deployer-hunter/{address}` | BASIC | Single deployer profile + 50 most recent tokens (unknown wallets โ `is_deployer: false`) |
|
|
85
|
+
| `alphaWallets(params?)` | `/api/v1/rhc/alpha-wallets` | PRO+ | Smart-money wallets ranked by realized performance โ `net_eth`, `win_rate`, `memecoin_share`, `likely_bot` |
|
|
86
|
+
|
|
87
|
+
### Examples
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
// Deployer reputation leaderboard โ elite deployers first
|
|
91
|
+
const { deployers } = await client.deployerLeaderboard({ sort: "runner_rate", tier: "elite" });
|
|
92
|
+
|
|
93
|
+
// Is this token's early cohort a launch bundle that's still holding?
|
|
94
|
+
const { bundle } = await client.tokenBundle("0xToken...");
|
|
95
|
+
console.log(bundle.bundle_kind, bundle.held_pct_of_supply);
|
|
96
|
+
|
|
97
|
+
// Smart-money memecoin traders only, biggest net ETH first
|
|
98
|
+
const { wallets } = await client.alphaWallets({ classification: "smart_money", min_memecoin_share: 0.7 });
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Streaming
|
|
102
|
+
|
|
103
|
+
Managed WebSocket stream over ws-streaming (`wss://madeonsol.com/stream`). Handles the token fetch + 24h refresh, auto-reconnect with backoff, and heartbeat liveness. Two RHC channels: `rhc:kol_trades` (the KOL tape) and `rhc:trades` (the full DEX firehose). PRO/ULTRA.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
const stream = client.stream();
|
|
107
|
+
|
|
108
|
+
stream.on("rhc:kol_trade", (t) => console.log("KOL trade", t));
|
|
109
|
+
stream.on("rhc:trade", (t) => console.log("DEX trade", t));
|
|
110
|
+
stream.on("open", () => console.log("connected to chain 4663"));
|
|
111
|
+
|
|
112
|
+
stream.subscribe(["rhc:kol_trades", "rhc:trades"]);
|
|
113
|
+
|
|
114
|
+
// later
|
|
115
|
+
stream.close();
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Rate limits
|
|
119
|
+
|
|
120
|
+
Every successful response updates `client.lastRateLimit` from the `X-RateLimit-*` headers:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
await client.kolFeed({ limit: 5 });
|
|
124
|
+
console.log(client.lastRateLimit); // { limit, remaining, reset, requestId }
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Links
|
|
128
|
+
|
|
129
|
+
- ๐ค Robinhood Chain overview โ https://madeonsol.com/robinhood
|
|
130
|
+
- ๐ฐ Pricing & free API key โ https://madeonsol.com/pricing
|
|
131
|
+
- ๐ API docs โ https://madeonsol.com/api-docs
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
MIT ยฉ MadeOnSol
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* robinhood-chain-x402 โ TypeScript client for the MadeOnSol Robinhood Chain
|
|
3
|
+
* (chain id 4663) API.
|
|
4
|
+
*
|
|
5
|
+
* Robinhood Chain is an Arbitrum Orbit L2. This package is **key-mode only**:
|
|
6
|
+
* it authenticates with an `msk_` Bearer API key against the Robinhood Chain
|
|
7
|
+
* (/api/v1/rhc/โฆ) endpoints. The x402 pay-per-call rail is Solana-native and is NOT ported here
|
|
8
|
+
* โ see the Solana `madeonsol-x402` package for on-chain USDC micropayments.
|
|
9
|
+
*
|
|
10
|
+
* Get a free API key (200 req/day, no card) at https://madeonsol.com/pricing โ
|
|
11
|
+
* RHC coverage is bundled into every tier at no extra cost.
|
|
12
|
+
*/
|
|
13
|
+
import type { KolFeedParams, KolFeedResponse, KolLeaderboardParams, KolLeaderboardResponse, KolHotTokensParams, KolHotTokensResponse, RhcKolProfileResponse, TradesParams, TradesResponse, TokensParams, TokensResponse, RhcTokenDetailResponse, CandlesParams, CandlesResponse, RhcKolConsensusResponse, RhcBuyerQualityResponse, RhcBundleResponse, DeployerLeaderboardParams, DeployerLeaderboardResponse, RhcDeployerProfileResponse, AlphaWalletsParams, AlphaWalletsResponse, StreamToken } from "./types.js";
|
|
14
|
+
import { RobinhoodChainStream } from "./stream.js";
|
|
15
|
+
import type { StreamClientOptions } from "./stream.js";
|
|
16
|
+
export { RobinhoodChainStream } from "./stream.js";
|
|
17
|
+
export type { StreamClientOptions, StreamChannel, StreamEventName, StreamEvent, StreamLifecycleEvent, } from "./stream.js";
|
|
18
|
+
export type { Chain, TradeAction, DeployerTier, Dex, RhcError, KolFeedParams, RhcKolTrade, KolFeedResponse, KolLeaderboardPeriod, KolLeaderboardParams, RhcKolLeaderboardEntry, KolLeaderboardResponse, KolHotTokensWindow, KolHotTokensParams, RhcHotToken, KolHotTokensResponse, RhcKolProfileStats, RhcKolProfileTrade, RhcKolProfileResponse, TradesParams, RhcTrade, TradesResponse, TokensSort, TokensParams, RhcTokenListItem, TokensResponse, RhcTokenDeployer, RhcTokenKolActivity, RhcTokenDetailResponse, CandlesParams, RhcCandle, CandlesResponse, RhcKolConsensus, RhcKolConsensusResponse, BuyerQualityConfidence, BuyerQualitySignal, RhcBuyerQualityBreakdown, RhcBuyerQuality, RhcBuyerQualityCoverage, RhcBuyerQualityResponse, BundleKind, RhcBundleSummary, RhcBundleWallet, RhcBundleResponse, DeployerLeaderboardSort, DeployerLeaderboardParams, RhcDeployer, DeployerLeaderboardResponse, RhcDeployerProfile, RhcDeployerRecentToken, RhcDeployerProfileResponse, AlphaClassificationFilter, AlphaIdentityFilter, AlphaSort, AlphaOrder, AlphaWalletClassification, AlphaWalletsParams, RhcAlphaWallet, AlphaWalletsResponse, StreamToken, } from "./types.js";
|
|
19
|
+
export interface RobinhoodChainOptions {
|
|
20
|
+
/** MadeOnSol API key (`msk_...`) โ get one free at https://madeonsol.com/pricing. */
|
|
21
|
+
apiKey: string;
|
|
22
|
+
/** API base URL (default: https://madeonsol.com). */
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
/** Rate-limit headers exposed alongside every successful response. */
|
|
26
|
+
export interface RateLimitInfo {
|
|
27
|
+
limit: number | null;
|
|
28
|
+
remaining: number | null;
|
|
29
|
+
reset: number | null;
|
|
30
|
+
requestId: string | null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Key-mode client for the Robinhood Chain (chain id 4663) API surface โ live KOL
|
|
34
|
+
* trades, the DEX trade tape, token discovery/bundles/candles, deployer
|
|
35
|
+
* reputation, and smart-money wallets. Every method maps 1:1 to a
|
|
36
|
+
* GET /api/v1/rhc/โฆ endpoint. RHC coverage is bundled into every tier.
|
|
37
|
+
*/
|
|
38
|
+
export declare class RobinhoodChainX402 {
|
|
39
|
+
private baseUrl;
|
|
40
|
+
private headers;
|
|
41
|
+
/** Last response's rate-limit headers (X-RateLimit-*, X-Request-Id). */
|
|
42
|
+
lastRateLimit: RateLimitInfo;
|
|
43
|
+
constructor(opts: RobinhoodChainOptions);
|
|
44
|
+
private request;
|
|
45
|
+
/**
|
|
46
|
+
* Real-time KOL trade feed on Robinhood Chain โ every buy/sell from tracked
|
|
47
|
+
* Solana KOLs' verified EVM wallets, attributed via tx.from. Tier: **BASIC**.
|
|
48
|
+
* `GET /rhc/kol/feed`
|
|
49
|
+
*/
|
|
50
|
+
kolFeed(params?: KolFeedParams): Promise<KolFeedResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* KOL activity leaderboard โ RHC KOLs ranked by trade count then net ETH flow
|
|
53
|
+
* over the window. Tier: **BASIC**. `GET /rhc/kol/leaderboard`
|
|
54
|
+
*/
|
|
55
|
+
kolLeaderboard(params?: KolLeaderboardParams): Promise<KolLeaderboardResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Consensus tokens โ bought by 2+ distinct tracked KOLs inside the window.
|
|
58
|
+
* Tier: **BASIC**. `GET /rhc/kol/hot-tokens`
|
|
59
|
+
*/
|
|
60
|
+
kolHotTokens(params?: KolHotTokensParams): Promise<KolHotTokensResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* Single KOL profile โ aggregate stats over one KOL's last 200 RHC trades plus
|
|
63
|
+
* their 50 most recent trades. Tier: **BASIC**. `GET /rhc/kol/{wallet}`
|
|
64
|
+
* @param wallet KOL EVM wallet address (0x, 40 hex).
|
|
65
|
+
*/
|
|
66
|
+
kol(wallet: string): Promise<RhcKolProfileResponse>;
|
|
67
|
+
/**
|
|
68
|
+
* Robinhood Chain DEX trade tape โ every Uniswap v2/v3/v4 swap, each row
|
|
69
|
+
* carrying the real trader wallet (`trader_eoa`), gas/ordering for MEV
|
|
70
|
+
* analysis, and KOL/deployer flags. Cursor via `next_before`. Tier: **PRO+**.
|
|
71
|
+
* `GET /rhc/trades`
|
|
72
|
+
*/
|
|
73
|
+
trades(params?: TradesParams): Promise<TradesResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Robinhood Chain token discovery โ live-priced tokens with MC, liquidity,
|
|
76
|
+
* peak MC + drawdown, launchpad, and deployer tier. Tier: **PRO+**.
|
|
77
|
+
* `GET /rhc/tokens`
|
|
78
|
+
*/
|
|
79
|
+
tokens(params?: TokensParams): Promise<TokensResponse>;
|
|
80
|
+
/**
|
|
81
|
+
* Full token snapshot โ metadata, live price/MC/FDV, peak MC + drawdown,
|
|
82
|
+
* graduation, deployer reputation, KOL activity, and pool inventory.
|
|
83
|
+
* Tier: **BASIC**. `GET /rhc/tokens/{address}`
|
|
84
|
+
* @param address Token address (0x, 40 hex).
|
|
85
|
+
*/
|
|
86
|
+
token(address: string): Promise<RhcTokenDetailResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* 1-minute OHLC candles โ price + market-cap OHLC, close liquidity, volume
|
|
89
|
+
* with buy/sell split, and trade/buy/sell counts. Tier: **PRO+**.
|
|
90
|
+
* `GET /rhc/tokens/{address}/candles`
|
|
91
|
+
*/
|
|
92
|
+
tokenCandles(address: string, params?: CandlesParams): Promise<CandlesResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* KOL consensus on a token โ distinct KOL buyers vs sellers, exit rate, net
|
|
95
|
+
* ETH flow (`net_flow_eth`), median entry MC, and first-touch. ULTRA adds the
|
|
96
|
+
* `buyers`/`exited` wallet lists. Tier: **PRO+**.
|
|
97
|
+
* `GET /rhc/tokens/{address}/kol-consensus`
|
|
98
|
+
*/
|
|
99
|
+
tokenKolConsensus(address: string): Promise<RhcKolConsensusResponse>;
|
|
100
|
+
/**
|
|
101
|
+
* Early-buyer quality โ a 0โ100 read on a token's first-20 buyer cohort:
|
|
102
|
+
* win-rate, KOL-presence, bot-domination, bundle-buyer, and the informational
|
|
103
|
+
* dump-cluster ensemble. Tier: **BASIC**.
|
|
104
|
+
* `GET /rhc/tokens/{address}/buyer-quality`
|
|
105
|
+
*/
|
|
106
|
+
tokenBuyerQuality(address: string): Promise<RhcBuyerQualityResponse>;
|
|
107
|
+
/**
|
|
108
|
+
* Launch-bundle detection โ flags a `same_block` bundle in the earliest-buyer
|
|
109
|
+
* cohort and reports how much of what it bought it still holds. Field-gated by
|
|
110
|
+
* tier: BASIC scalar `bundle`; PRO top-10 wallets; ULTRA full cohort with
|
|
111
|
+
* identity. Tier: **BASIC**. `GET /rhc/tokens/{address}/bundle`
|
|
112
|
+
*/
|
|
113
|
+
tokenBundle(address: string): Promise<RhcBundleResponse>;
|
|
114
|
+
/**
|
|
115
|
+
* Deployer reputation leaderboard โ RHC deployers ranked by reputation over
|
|
116
|
+
* every indexed launchpad token (40k+ deployers). `graduation_rate` = share at
|
|
117
|
+
* $40K+ peak MC; `runner_rate` = share at $100K+. Tier: **BASIC**.
|
|
118
|
+
* `GET /rhc/deployer-hunter/leaderboard`
|
|
119
|
+
*/
|
|
120
|
+
deployerLeaderboard(params?: DeployerLeaderboardParams): Promise<DeployerLeaderboardResponse>;
|
|
121
|
+
/**
|
|
122
|
+
* Single deployer profile โ full reputation row plus the 50 most recent tokens
|
|
123
|
+
* enriched with live MC and peak MC. Unknown wallets return 200 with
|
|
124
|
+
* `is_deployer: false`. Tier: **BASIC**. `GET /rhc/deployer-hunter/{address}`
|
|
125
|
+
* @param address Deployer EVM wallet address (0x, 40 hex).
|
|
126
|
+
*/
|
|
127
|
+
deployer(address: string): Promise<RhcDeployerProfileResponse>;
|
|
128
|
+
/**
|
|
129
|
+
* Smart-money wallet ranking โ RHC trader wallets ranked by realized on-chain
|
|
130
|
+
* performance (`net_eth`, `win_rate`, `memecoin_share`, `likely_bot`). Tier:
|
|
131
|
+
* **PRO+**. `GET /rhc/alpha-wallets`
|
|
132
|
+
*/
|
|
133
|
+
alphaWallets(params?: AlphaWalletsParams): Promise<AlphaWalletsResponse>;
|
|
134
|
+
/** Generate a 24h WebSocket streaming token (PRO/ULTRA). */
|
|
135
|
+
getStreamToken(): Promise<StreamToken>;
|
|
136
|
+
/**
|
|
137
|
+
* Open a managed real-time Robinhood Chain WebSocket stream. Handles token
|
|
138
|
+
* fetch + refresh, auto-reconnect with backoff, heartbeat liveness, and typed
|
|
139
|
+
* events for you. Channels: `rhc:kol_trades`, `rhc:trades`.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* const stream = client.stream();
|
|
143
|
+
* stream.on("rhc:kol_trade", (t) => console.log(t));
|
|
144
|
+
* stream.subscribe(["rhc:kol_trades"]);
|
|
145
|
+
*/
|
|
146
|
+
stream(opts?: Omit<StreamClientOptions, "getToken">): RobinhoodChainStream;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Create a Robinhood Chain client with API-key auth.
|
|
150
|
+
* @param apiKey Your `msk_` API key โ get one free at https://madeonsol.com/pricing.
|
|
151
|
+
* @param baseUrl Optional API base URL override.
|
|
152
|
+
*/
|
|
153
|
+
export declare function createClient(apiKey: string, baseUrl?: string): RobinhoodChainX402;
|
|
154
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,cAAc,EACd,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,yBAAyB,EACzB,2BAA2B,EAC3B,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EACV,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,WAAW,EACX,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,KAAK,EACL,WAAW,EACX,YAAY,EACZ,GAAG,EACH,QAAQ,EACR,aAAa,EACb,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,SAAS,EACT,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,EACf,uBAAuB,EACvB,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|
2
|
+
import { VERSION } from "./version.js";
|
|
3
|
+
export { RobinhoodChainStream } from "./stream.js";
|
|
4
|
+
const DEFAULT_BASE_URL = "https://madeonsol.com";
|
|
5
|
+
/**
|
|
6
|
+
* Key-mode client for the Robinhood Chain (chain id 4663) API surface โ live KOL
|
|
7
|
+
* trades, the DEX trade tape, token discovery/bundles/candles, deployer
|
|
8
|
+
* reputation, and smart-money wallets. Every method maps 1:1 to a
|
|
9
|
+
* GET /api/v1/rhc/โฆ endpoint. RHC coverage is bundled into every tier.
|
|
10
|
+
*/
|
|
11
|
+
export class RobinhoodChainX402 {
|
|
12
|
+
baseUrl;
|
|
13
|
+
headers;
|
|
14
|
+
/** Last response's rate-limit headers (X-RateLimit-*, X-Request-Id). */
|
|
15
|
+
lastRateLimit = { limit: null, remaining: null, reset: null, requestId: null };
|
|
16
|
+
constructor(opts) {
|
|
17
|
+
this.baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
18
|
+
if (!opts.apiKey) {
|
|
19
|
+
console.error("\n[robinhood-chain-x402] Missing apiKey.\n" +
|
|
20
|
+
" โ Get a free API key (200 req/day, no card) at https://madeonsol.com/pricing\n" +
|
|
21
|
+
" โ RHC coverage is bundled into every tier at no extra cost.\n");
|
|
22
|
+
throw new Error("Provide apiKey. Get a free API key at https://madeonsol.com/pricing");
|
|
23
|
+
}
|
|
24
|
+
this.headers = {
|
|
25
|
+
"User-Agent": `robinhood-chain-x402/${VERSION}`,
|
|
26
|
+
Authorization: `Bearer ${opts.apiKey}`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async request(path, params) {
|
|
30
|
+
const url = new URL(`/api/v1${path}`, this.baseUrl);
|
|
31
|
+
if (params) {
|
|
32
|
+
for (const [k, v] of Object.entries(params)) {
|
|
33
|
+
if (v !== undefined)
|
|
34
|
+
url.searchParams.set(k, String(v));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const res = await fetch(url.toString(), { headers: this.headers });
|
|
38
|
+
this.lastRateLimit = {
|
|
39
|
+
limit: numHeader(res, "x-ratelimit-limit"),
|
|
40
|
+
remaining: numHeader(res, "x-ratelimit-remaining"),
|
|
41
|
+
reset: numHeader(res, "x-ratelimit-reset"),
|
|
42
|
+
requestId: res.headers.get("x-request-id"),
|
|
43
|
+
};
|
|
44
|
+
if (!res.ok) {
|
|
45
|
+
const body = await res.text().catch(() => "");
|
|
46
|
+
throw new Error(`Robinhood Chain API error ${res.status}: ${body}`);
|
|
47
|
+
}
|
|
48
|
+
return res.json();
|
|
49
|
+
}
|
|
50
|
+
/* โโ KOL intelligence โโ */
|
|
51
|
+
/**
|
|
52
|
+
* Real-time KOL trade feed on Robinhood Chain โ every buy/sell from tracked
|
|
53
|
+
* Solana KOLs' verified EVM wallets, attributed via tx.from. Tier: **BASIC**.
|
|
54
|
+
* `GET /rhc/kol/feed`
|
|
55
|
+
*/
|
|
56
|
+
async kolFeed(params) {
|
|
57
|
+
return this.request("/rhc/kol/feed", params);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* KOL activity leaderboard โ RHC KOLs ranked by trade count then net ETH flow
|
|
61
|
+
* over the window. Tier: **BASIC**. `GET /rhc/kol/leaderboard`
|
|
62
|
+
*/
|
|
63
|
+
async kolLeaderboard(params) {
|
|
64
|
+
return this.request("/rhc/kol/leaderboard", params);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Consensus tokens โ bought by 2+ distinct tracked KOLs inside the window.
|
|
68
|
+
* Tier: **BASIC**. `GET /rhc/kol/hot-tokens`
|
|
69
|
+
*/
|
|
70
|
+
async kolHotTokens(params) {
|
|
71
|
+
return this.request("/rhc/kol/hot-tokens", params);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Single KOL profile โ aggregate stats over one KOL's last 200 RHC trades plus
|
|
75
|
+
* their 50 most recent trades. Tier: **BASIC**. `GET /rhc/kol/{wallet}`
|
|
76
|
+
* @param wallet KOL EVM wallet address (0x, 40 hex).
|
|
77
|
+
*/
|
|
78
|
+
async kol(wallet) {
|
|
79
|
+
return this.request(`/rhc/kol/${encodeURIComponent(wallet)}`);
|
|
80
|
+
}
|
|
81
|
+
/* โโ DEX trade tape โโ */
|
|
82
|
+
/**
|
|
83
|
+
* Robinhood Chain DEX trade tape โ every Uniswap v2/v3/v4 swap, each row
|
|
84
|
+
* carrying the real trader wallet (`trader_eoa`), gas/ordering for MEV
|
|
85
|
+
* analysis, and KOL/deployer flags. Cursor via `next_before`. Tier: **PRO+**.
|
|
86
|
+
* `GET /rhc/trades`
|
|
87
|
+
*/
|
|
88
|
+
async trades(params) {
|
|
89
|
+
return this.request("/rhc/trades", params);
|
|
90
|
+
}
|
|
91
|
+
/* โโ Token discovery + intelligence โโ */
|
|
92
|
+
/**
|
|
93
|
+
* Robinhood Chain token discovery โ live-priced tokens with MC, liquidity,
|
|
94
|
+
* peak MC + drawdown, launchpad, and deployer tier. Tier: **PRO+**.
|
|
95
|
+
* `GET /rhc/tokens`
|
|
96
|
+
*/
|
|
97
|
+
async tokens(params) {
|
|
98
|
+
return this.request("/rhc/tokens", params);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Full token snapshot โ metadata, live price/MC/FDV, peak MC + drawdown,
|
|
102
|
+
* graduation, deployer reputation, KOL activity, and pool inventory.
|
|
103
|
+
* Tier: **BASIC**. `GET /rhc/tokens/{address}`
|
|
104
|
+
* @param address Token address (0x, 40 hex).
|
|
105
|
+
*/
|
|
106
|
+
async token(address) {
|
|
107
|
+
return this.request(`/rhc/tokens/${encodeURIComponent(address)}`);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 1-minute OHLC candles โ price + market-cap OHLC, close liquidity, volume
|
|
111
|
+
* with buy/sell split, and trade/buy/sell counts. Tier: **PRO+**.
|
|
112
|
+
* `GET /rhc/tokens/{address}/candles`
|
|
113
|
+
*/
|
|
114
|
+
async tokenCandles(address, params) {
|
|
115
|
+
return this.request(`/rhc/tokens/${encodeURIComponent(address)}/candles`, params);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* KOL consensus on a token โ distinct KOL buyers vs sellers, exit rate, net
|
|
119
|
+
* ETH flow (`net_flow_eth`), median entry MC, and first-touch. ULTRA adds the
|
|
120
|
+
* `buyers`/`exited` wallet lists. Tier: **PRO+**.
|
|
121
|
+
* `GET /rhc/tokens/{address}/kol-consensus`
|
|
122
|
+
*/
|
|
123
|
+
async tokenKolConsensus(address) {
|
|
124
|
+
return this.request(`/rhc/tokens/${encodeURIComponent(address)}/kol-consensus`);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Early-buyer quality โ a 0โ100 read on a token's first-20 buyer cohort:
|
|
128
|
+
* win-rate, KOL-presence, bot-domination, bundle-buyer, and the informational
|
|
129
|
+
* dump-cluster ensemble. Tier: **BASIC**.
|
|
130
|
+
* `GET /rhc/tokens/{address}/buyer-quality`
|
|
131
|
+
*/
|
|
132
|
+
async tokenBuyerQuality(address) {
|
|
133
|
+
return this.request(`/rhc/tokens/${encodeURIComponent(address)}/buyer-quality`);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Launch-bundle detection โ flags a `same_block` bundle in the earliest-buyer
|
|
137
|
+
* cohort and reports how much of what it bought it still holds. Field-gated by
|
|
138
|
+
* tier: BASIC scalar `bundle`; PRO top-10 wallets; ULTRA full cohort with
|
|
139
|
+
* identity. Tier: **BASIC**. `GET /rhc/tokens/{address}/bundle`
|
|
140
|
+
*/
|
|
141
|
+
async tokenBundle(address) {
|
|
142
|
+
return this.request(`/rhc/tokens/${encodeURIComponent(address)}/bundle`);
|
|
143
|
+
}
|
|
144
|
+
/* โโ Deployer hunter โโ */
|
|
145
|
+
/**
|
|
146
|
+
* Deployer reputation leaderboard โ RHC deployers ranked by reputation over
|
|
147
|
+
* every indexed launchpad token (40k+ deployers). `graduation_rate` = share at
|
|
148
|
+
* $40K+ peak MC; `runner_rate` = share at $100K+. Tier: **BASIC**.
|
|
149
|
+
* `GET /rhc/deployer-hunter/leaderboard`
|
|
150
|
+
*/
|
|
151
|
+
async deployerLeaderboard(params) {
|
|
152
|
+
return this.request("/rhc/deployer-hunter/leaderboard", params);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Single deployer profile โ full reputation row plus the 50 most recent tokens
|
|
156
|
+
* enriched with live MC and peak MC. Unknown wallets return 200 with
|
|
157
|
+
* `is_deployer: false`. Tier: **BASIC**. `GET /rhc/deployer-hunter/{address}`
|
|
158
|
+
* @param address Deployer EVM wallet address (0x, 40 hex).
|
|
159
|
+
*/
|
|
160
|
+
async deployer(address) {
|
|
161
|
+
return this.request(`/rhc/deployer-hunter/${encodeURIComponent(address)}`);
|
|
162
|
+
}
|
|
163
|
+
/* โโ Smart money โโ */
|
|
164
|
+
/**
|
|
165
|
+
* Smart-money wallet ranking โ RHC trader wallets ranked by realized on-chain
|
|
166
|
+
* performance (`net_eth`, `win_rate`, `memecoin_share`, `likely_bot`). Tier:
|
|
167
|
+
* **PRO+**. `GET /rhc/alpha-wallets`
|
|
168
|
+
*/
|
|
169
|
+
async alphaWallets(params) {
|
|
170
|
+
return this.request("/rhc/alpha-wallets", params);
|
|
171
|
+
}
|
|
172
|
+
/* โโ Streaming โโ */
|
|
173
|
+
/** Generate a 24h WebSocket streaming token (PRO/ULTRA). */
|
|
174
|
+
async getStreamToken() {
|
|
175
|
+
const url = new URL("/api/v1/stream/token", this.baseUrl);
|
|
176
|
+
const res = await fetch(url.toString(), { method: "POST", headers: this.headers });
|
|
177
|
+
if (!res.ok) {
|
|
178
|
+
const body = await res.text().catch(() => "");
|
|
179
|
+
throw new Error(`Robinhood Chain API error ${res.status}: ${body}`);
|
|
180
|
+
}
|
|
181
|
+
return res.json();
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Open a managed real-time Robinhood Chain WebSocket stream. Handles token
|
|
185
|
+
* fetch + refresh, auto-reconnect with backoff, heartbeat liveness, and typed
|
|
186
|
+
* events for you. Channels: `rhc:kol_trades`, `rhc:trades`.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* const stream = client.stream();
|
|
190
|
+
* stream.on("rhc:kol_trade", (t) => console.log(t));
|
|
191
|
+
* stream.subscribe(["rhc:kol_trades"]);
|
|
192
|
+
*/
|
|
193
|
+
stream(opts) {
|
|
194
|
+
return new RobinhoodChainStream({ ...opts, getToken: () => this.getStreamToken() });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function numHeader(res, name) {
|
|
198
|
+
const v = res.headers.get(name);
|
|
199
|
+
if (v == null)
|
|
200
|
+
return null;
|
|
201
|
+
const n = Number(v);
|
|
202
|
+
return Number.isFinite(n) ? n : null;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Create a Robinhood Chain client with API-key auth.
|
|
206
|
+
* @param apiKey Your `msk_` API key โ get one free at https://madeonsol.com/pricing.
|
|
207
|
+
* @param baseUrl Optional API base URL override.
|
|
208
|
+
*/
|
|
209
|
+
export function createClient(apiKey, baseUrl) {
|
|
210
|
+
return new RobinhoodChainX402({ apiKey, baseUrl });
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAwEnD,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAmBjD;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IACrB,OAAO,CAAS;IAChB,OAAO,CAAyB;IACxC,wEAAwE;IACxE,aAAa,GAAkB,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EA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AY,CAAC,MAAc,EAAE,OAAgB;IAC3D,OAAO,IAAI,kBAAkB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AACrD,CAAC"}
|
package/dist/stream.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real-time Robinhood Chain WebSocket streaming client.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the connect โ token โ subscribe โ event loop with auto-reconnect,
|
|
5
|
+
* 24h-token auto-refresh, heartbeat liveness, and typed events, so consumers
|
|
6
|
+
* never hand-roll connection management. Obtain one via `client.stream()`.
|
|
7
|
+
*
|
|
8
|
+
* Channels are RHC-scoped: `rhc:kol_trades` (the KOL tape) and `rhc:trades`
|
|
9
|
+
* (the full DEX firehose). Same wire protocol as the Solana stream client.
|
|
10
|
+
*
|
|
11
|
+
* Works in Node (uses the global `WebSocket` on Node 22+, else lazily imports
|
|
12
|
+
* the optional `ws` package) and the browser (native WebSocket). Zero required
|
|
13
|
+
* dependencies.
|
|
14
|
+
*/
|
|
15
|
+
import type { StreamToken } from "./types";
|
|
16
|
+
/** Robinhood Chain channels you can subscribe to. */
|
|
17
|
+
export type StreamChannel = "rhc:kol_trades" | "rhc:trades";
|
|
18
|
+
/** Event names delivered on those channels. */
|
|
19
|
+
export type StreamEventName = "rhc:kol_trade" | "rhc:trade";
|
|
20
|
+
/** Lifecycle events you can also listen for. */
|
|
21
|
+
export type StreamLifecycleEvent = "open" | "close" | "reconnect" | "subscribed" | "heartbeat" | "error";
|
|
22
|
+
export interface StreamEvent<T = unknown> {
|
|
23
|
+
channel: StreamChannel;
|
|
24
|
+
event: StreamEventName;
|
|
25
|
+
data: T;
|
|
26
|
+
ts: number;
|
|
27
|
+
}
|
|
28
|
+
export interface StreamClientOptions {
|
|
29
|
+
/** Returns a fresh 24h stream token (the SDK wires this to getStreamToken()). */
|
|
30
|
+
getToken: () => Promise<StreamToken>;
|
|
31
|
+
/** Reconnect automatically on drop (default: true). */
|
|
32
|
+
autoReconnect?: boolean;
|
|
33
|
+
/** Max reconnect backoff in ms (default: 30000). */
|
|
34
|
+
maxBackoffMs?: number;
|
|
35
|
+
/** Reconnect if no server heartbeat arrives within this window (default: 90000). */
|
|
36
|
+
heartbeatTimeoutMs?: number;
|
|
37
|
+
/** Override the WebSocket implementation (e.g. inject `ws` explicitly). */
|
|
38
|
+
WebSocketImpl?: unknown;
|
|
39
|
+
}
|
|
40
|
+
type Listener = (data: unknown, evt?: StreamEvent) => void;
|
|
41
|
+
export declare class RobinhoodChainStream {
|
|
42
|
+
private opts;
|
|
43
|
+
private ws;
|
|
44
|
+
private listeners;
|
|
45
|
+
private desired;
|
|
46
|
+
private closedByUser;
|
|
47
|
+
private attempt;
|
|
48
|
+
private hbTimer;
|
|
49
|
+
private reconnectTimer;
|
|
50
|
+
private connecting;
|
|
51
|
+
constructor(opts: StreamClientOptions);
|
|
52
|
+
/** Register a handler. Use an event name, `"*"` for every event, or a lifecycle event. */
|
|
53
|
+
on(event: StreamEventName | StreamLifecycleEvent | "*", fn: Listener): this;
|
|
54
|
+
/** Remove a handler (or all handlers for an event when `fn` is omitted). */
|
|
55
|
+
off(event: string, fn?: Listener): this;
|
|
56
|
+
private emit;
|
|
57
|
+
/** Subscribe to one or more channels (connects on first call). Optional server-side filters. */
|
|
58
|
+
subscribe(channels: StreamChannel[], filters?: Record<string, unknown>): this;
|
|
59
|
+
/** Stop receiving the given channels. */
|
|
60
|
+
unsubscribe(channels: StreamChannel[]): this;
|
|
61
|
+
/** Open the connection (also called implicitly by subscribe). */
|
|
62
|
+
connect(): Promise<void>;
|
|
63
|
+
/** Close the connection and stop reconnecting. */
|
|
64
|
+
close(): void;
|
|
65
|
+
private sendSubscribe;
|
|
66
|
+
private handleMessage;
|
|
67
|
+
private scheduleReconnect;
|
|
68
|
+
private resetHeartbeat;
|
|
69
|
+
private clearHeartbeat;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=st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