helius-bot-core 0.0.0-stage → 1.0.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.
Files changed (70) hide show
  1. package/README.md +148 -2
  2. package/dist/index.d.ts +11 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +11 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/middleware/auth.d.ts +15 -0
  7. package/dist/middleware/auth.d.ts.map +1 -0
  8. package/dist/middleware/auth.js +49 -0
  9. package/dist/middleware/auth.js.map +1 -0
  10. package/dist/middleware/dedupe.d.ts +50 -0
  11. package/dist/middleware/dedupe.d.ts.map +1 -0
  12. package/dist/middleware/dedupe.js +89 -0
  13. package/dist/middleware/dedupe.js.map +1 -0
  14. package/dist/notifiers/discord.d.ts +35 -0
  15. package/dist/notifiers/discord.d.ts.map +1 -0
  16. package/dist/notifiers/discord.js +59 -0
  17. package/dist/notifiers/discord.js.map +1 -0
  18. package/dist/notifiers/telegram.d.ts +20 -0
  19. package/dist/notifiers/telegram.d.ts.map +1 -0
  20. package/dist/notifiers/telegram.js +68 -0
  21. package/dist/notifiers/telegram.js.map +1 -0
  22. package/dist/presets/dex-swaps.d.ts +3 -0
  23. package/dist/presets/dex-swaps.d.ts.map +1 -0
  24. package/dist/presets/dex-swaps.js +97 -0
  25. package/dist/presets/dex-swaps.js.map +1 -0
  26. package/dist/presets/error-sentinel.d.ts +3 -0
  27. package/dist/presets/error-sentinel.d.ts.map +1 -0
  28. package/dist/presets/error-sentinel.js +69 -0
  29. package/dist/presets/error-sentinel.js.map +1 -0
  30. package/dist/presets/index.d.ts +11 -0
  31. package/dist/presets/index.d.ts.map +1 -0
  32. package/dist/presets/index.js +23 -0
  33. package/dist/presets/index.js.map +1 -0
  34. package/dist/presets/multisig-guard.d.ts +3 -0
  35. package/dist/presets/multisig-guard.d.ts.map +1 -0
  36. package/dist/presets/multisig-guard.js +42 -0
  37. package/dist/presets/multisig-guard.js.map +1 -0
  38. package/dist/presets/new-pools.d.ts +3 -0
  39. package/dist/presets/new-pools.d.ts.map +1 -0
  40. package/dist/presets/new-pools.js +68 -0
  41. package/dist/presets/new-pools.js.map +1 -0
  42. package/dist/presets/nft-sales.d.ts +3 -0
  43. package/dist/presets/nft-sales.d.ts.map +1 -0
  44. package/dist/presets/nft-sales.js +56 -0
  45. package/dist/presets/nft-sales.js.map +1 -0
  46. package/dist/presets/whale-radar.d.ts +3 -0
  47. package/dist/presets/whale-radar.d.ts.map +1 -0
  48. package/dist/presets/whale-radar.js +93 -0
  49. package/dist/presets/whale-radar.js.map +1 -0
  50. package/dist/server.d.ts +24 -0
  51. package/dist/server.d.ts.map +1 -0
  52. package/dist/server.js +115 -0
  53. package/dist/server.js.map +1 -0
  54. package/dist/services/das.d.ts +16 -0
  55. package/dist/services/das.d.ts.map +1 -0
  56. package/dist/services/das.js +185 -0
  57. package/dist/services/das.js.map +1 -0
  58. package/dist/services/rate-limit-queue.d.ts +17 -0
  59. package/dist/services/rate-limit-queue.d.ts.map +1 -0
  60. package/dist/services/rate-limit-queue.js +43 -0
  61. package/dist/services/rate-limit-queue.js.map +1 -0
  62. package/dist/types/helius.d.ts +144 -0
  63. package/dist/types/helius.d.ts.map +1 -0
  64. package/dist/types/helius.js +6 -0
  65. package/dist/types/helius.js.map +1 -0
  66. package/dist/types/preset.d.ts +42 -0
  67. package/dist/types/preset.d.ts.map +1 -0
  68. package/dist/types/preset.js +5 -0
  69. package/dist/types/preset.js.map +1 -0
  70. package/package.json +35 -4
package/README.md CHANGED
@@ -1,3 +1,149 @@
1
- # Temporary Holding Version
1
+ <div align="center">
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
+ # ⚔ `create-helius-bot`
4
+
5
+ ### An open-source framework and CLI for building real-time Solana alert bots.
6
+
7
+ Powered by **[Helius Enhanced Webhooks](https://helius.dev)**, **[Helius DAS API](https://docs.helius.dev/compression-and-das-apis/digital-asset-standard-das-api)**, and **[Hono](https://hono.dev)** on **Cloudflare Workers**.
8
+
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
10
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue?logo=typescript)](https://www.typescriptlang.org/)
11
+ [![Hono](https://img.shields.io/badge/Framework-Hono-E36002?logo=hono)](https://hono.dev)
12
+ [![Solana](https://img.shields.io/badge/Network-Solana-9945FF?logo=solana)](https://solana.com)
13
+ [![Helius](https://img.shields.io/badge/Powered%20By-Helius%20Data-F97316)](https://helius.dev)
14
+
15
+ > **Notice:** `create-helius-bot` is an independent, community-driven open-source project designed for developers building on Solana with Helius APIs. It is not an official Helius product.
16
+
17
+ </div>
18
+
19
+ ---
20
+
21
+ ## šŸ’” What Problem Does This Solve?
22
+
23
+ Building production-ready Solana notification bots traditionally required assembling disparate pieces:
24
+ 1. Writing custom webhook parsers for complex DEX instruction layouts (Pump.fun, Raydium, Orca).
25
+ 2. Manually resolving mint addresses into token metadata (symbols, decimals, logos).
26
+ 3. Handling duplicate webhook retries and platform rate limits (Telegram 429, Discord 429).
27
+ 4. Securing webhook endpoints against spoofing attacks.
28
+ 5. Deploying and maintaining 24/7 server infrastructure.
29
+
30
+ **`create-helius-bot` solves this with a turnkey developer experience:**
31
+ - ⚔ **60-Second Setup:** Interactive CLI scaffolder with zero boilerplate.
32
+ - šŸ”„ **Auto Webhook Sync:** Programmatically creates and updates webhooks via Helius REST API.
33
+ - šŸ›”ļø **Timing-Safe Auth:** Constant-time cryptographic verification of Helius `authHeader` tokens.
34
+ - šŸ” **Pluggable Deduplication:** In-memory LRU cache by default, with Cloudflare KV / Redis adapters for multi-instance deployments.
35
+ - šŸ–¼ļø **DAS Metadata Enrichment:** Automated resolution of token symbols, decimals, and logos via Helius `getAsset` and `getAssetBatch` with TTL caching.
36
+ - ā˜ļø **Edge-Native Deployment:** Deploy serverlessly on 300+ global Cloudflare edge locations with zero cold start.
37
+
38
+ ---
39
+
40
+ ## ⚔ 60-Second Quickstart
41
+
42
+ ```bash
43
+ # 1. Run the interactive scaffolder
44
+ npx create-helius-bot my-solana-bot
45
+
46
+ # 2. Navigate into your new bot project
47
+ cd my-solana-bot
48
+
49
+ # 3. Install dependencies
50
+ npm install
51
+
52
+ # 4. Start local development server
53
+ npm run dev
54
+
55
+ # 5. (Optional) Expose local server to Helius via HTTPS tunnel
56
+ npm run dev:tunnel
57
+ ```
58
+
59
+ ---
60
+
61
+ ## šŸ“¦ The 6 Supported Presets
62
+
63
+ | # | Preset | Target Audience | What it Monitors & Delivers |
64
+ | :--- | :--- | :--- | :--- |
65
+ | **1** | **`dex-swaps`** | Traders, token communities | Real-time swaps on **Pump.fun, Raydium (AMM & CPMM), and Orca**. Filters out micro-spam, formats token amounts, and links directly to DexScreener. |
66
+ | **2** | **`whale-radar`** | Funds, analysts, community watchers | Large SOL and SPL token transfers (> `$5,000` or custom threshold). Alerts on movements in and out of watched wallets. |
67
+ | **3** | **`error-sentinel`** | Solana smart contract engineers | Real-time monitoring of any custom program ID. Fires an instant alert whenever a transaction **fails**, decoding custom Anchor/Pinocchio error codes (`0x1770`, `6000`), failed instruction index, and log traces. |
68
+ | **4** | **`new-pools`** | Snipers, DeFi builders, alpha groups | Watches factory programs (Pump.fun mints, Raydium pool initialization). Alerts immediately when a new market is seeded with initial liquidity. |
69
+ | **5** | **`multisig-guard`** | DAOs, dev teams, treasury managers | Monitors Squads v3 & v4 multisig vaults. Alerts channels whenever a proposal is created, signed, or executed. |
70
+ | **6** | **`nft-sales`** | NFT founders, collectors | Sales on Tensor and Magic Eden across standard SPL and compressed NFTs (Bubblegum). Shows buyer, price in SOL/USD, and marketplace link. |
71
+
72
+ ---
73
+
74
+ ## šŸ—ļø Architecture
75
+
76
+ ```mermaid
77
+ flowchart TD
78
+ A["Solana Onchain Activity"] --> B["Helius Enhanced Webhooks"]
79
+ B -->|POST /webhook| C{"Timing-Safe Auth Check"}
80
+ C -- "Invalid Secret" --> D["401 Unauthorized (Drop)"]
81
+ C -- "Valid Secret" --> E{"Signature Deduplication"}
82
+ E -- "Seen Signature" --> F["200 OK (Drop duplicate retry)"]
83
+ E -- "Unseen Signature" --> G{"Preset Event Filter"}
84
+ G -- "Does Not Match Filter" --> H["200 OK (Skip)"]
85
+ G -- "Matches Filter" --> I["Helius DAS API (Metadata & Decimals)"]
86
+ I --> J["Serverless / Async Dispatcher"]
87
+ J --> K["Telegram Bot API (HTML)"]
88
+ J --> L["Discord Webhook (Rich Embeds)"]
89
+ ```
90
+
91
+ ---
92
+
93
+ ## šŸ› ļø CLI Toolkit Commands
94
+
95
+ Besides scaffolding, the CLI provides standalone management tools for your Helius account:
96
+
97
+ ### List Active Webhooks
98
+ ```bash
99
+ npx create-helius-bot webhook list
100
+ ```
101
+
102
+ ### Create a Webhook Programmatically
103
+ ```bash
104
+ npx create-helius-bot webhook create \
105
+ --url https://my-bot.workers.dev/webhook \
106
+ --preset dex-swaps \
107
+ --auth my_secret_token
108
+ ```
109
+
110
+ ### Delete a Webhook
111
+ ```bash
112
+ npx create-helius-bot webhook delete <WEBHOOK_ID>
113
+ ```
114
+
115
+ ---
116
+
117
+ ## ā˜ļø Serverless Deployment (Cloudflare Workers)
118
+
119
+ Every generated bot includes a ready-to-deploy `wrangler.toml`:
120
+
121
+ ```bash
122
+ # Deploy globally in seconds
123
+ npm run deploy
124
+ ```
125
+
126
+ Once deployed, copy your worker URL (e.g. `https://my-solana-bot.workers.dev/webhook`) and register it as your Helius webhook endpoint.
127
+
128
+ ---
129
+
130
+ ## āš ļø Architecture & Known Limitations
131
+
132
+ To make informed architectural decisions, keep the following in mind:
133
+
134
+ 1. **Multi-Instance Deduplication:**
135
+ - The default `MemoryDedupeStore` uses an in-memory LRU cache.
136
+ - In horizontally scaled environments (multiple Cloudflare Worker isolates or container replicas), separate instances do not share memory. If Helius retries hit distinct instances, duplicate processing could occur.
137
+ - For high-volume multi-instance deployments, use the provided `CloudflareKvDedupeStore` adapter or a distributed Redis store (`SETNX` with TTL).
138
+ 2. **Execution Lifecycle on Cloudflare Workers:**
139
+ - Background tasks in Cloudflare Workers must be registered using `c.executionCtx.waitUntil(promise)`. The engine handles this automatically so async dispatches complete before the worker runtime terminates.
140
+ 3. **Queue Durability:**
141
+ - The included rate-limiting queue is an in-process leaky bucket designed to protect against downstream API 429s. It is not a persistent message broker (e.g. Kafka or SQS). If the process crashes during a burst, unhandled in-memory queue items are lost.
142
+ 4. **Data Delivery Model:**
143
+ - Webhooks are push-based and subject to HTTP transport latency. For ultra-low latency (<50ms) transaction ingestion and shred streaming, evaluate **Helius LaserStream gRPC** instead.
144
+
145
+ ---
146
+
147
+ ## šŸ“„ License
148
+
149
+ MIT License. Designed and built by **Pratik Kale** for the Solana developer community.
@@ -0,0 +1,11 @@
1
+ export * from './types/helius.js';
2
+ export * from './types/preset.js';
3
+ export * from './middleware/auth.js';
4
+ export * from './middleware/dedupe.js';
5
+ export * from './services/das.js';
6
+ export * from './services/rate-limit-queue.js';
7
+ export * from './notifiers/telegram.js';
8
+ export * from './notifiers/discord.js';
9
+ export * from './presets/index.js';
10
+ export * from './server.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export * from './types/helius.js';
2
+ export * from './types/preset.js';
3
+ export * from './middleware/auth.js';
4
+ export * from './middleware/dedupe.js';
5
+ export * from './services/das.js';
6
+ export * from './services/rate-limit-queue.js';
7
+ export * from './notifiers/telegram.js';
8
+ export * from './notifiers/discord.js';
9
+ export * from './presets/index.js';
10
+ export * from './server.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Context, Next } from 'hono';
2
+ /**
3
+ * Constant-time string comparison to prevent timing attacks across
4
+ * Node.js, Cloudflare Workers, and Bun runtimes.
5
+ */
6
+ export declare function constantTimeCompare(a: string, b: string): boolean;
7
+ /**
8
+ * Helius Auth Header Middleware
9
+ * Verifies incoming POST requests against configured secret token.
10
+ * Prevents unauthorized users from spoofing webhook transactions.
11
+ */
12
+ export declare function heliusAuth(expectedSecret?: string): (c: Context, next: Next) => Promise<void | (Response & import("hono").TypedResponse<{
13
+ error: string;
14
+ }, 401, "json">)>;
15
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAiBjE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,cAAc,CAAC,EAAE,MAAM,IAClC,GAAG,OAAO,EAAE,MAAM,IAAI;;kBAkCrC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Constant-time string comparison to prevent timing attacks across
3
+ * Node.js, Cloudflare Workers, and Bun runtimes.
4
+ */
5
+ export function constantTimeCompare(a, b) {
6
+ if (typeof a !== 'string' || typeof b !== 'string') {
7
+ return false;
8
+ }
9
+ const aLen = a.length;
10
+ const bLen = b.length;
11
+ let mismatch = aLen === bLen ? 0 : 1;
12
+ const maxLen = Math.max(aLen, bLen);
13
+ for (let i = 0; i < maxLen; i++) {
14
+ const charA = a.charCodeAt(i % aLen);
15
+ const charB = b.charCodeAt(i % bLen);
16
+ mismatch |= charA ^ charB;
17
+ }
18
+ return mismatch === 0;
19
+ }
20
+ /**
21
+ * Helius Auth Header Middleware
22
+ * Verifies incoming POST requests against configured secret token.
23
+ * Prevents unauthorized users from spoofing webhook transactions.
24
+ */
25
+ export function heliusAuth(expectedSecret) {
26
+ return async (c, next) => {
27
+ // If no secret configured, allow (for open testing)
28
+ if (!expectedSecret) {
29
+ return next();
30
+ }
31
+ const rawHeader = c.req.header('authorization') ||
32
+ c.req.header('auth-header') ||
33
+ c.req.header('x-helius-auth');
34
+ if (!rawHeader) {
35
+ return c.json({
36
+ error: 'Unauthorized: Missing webhook authHeader',
37
+ }, 401);
38
+ }
39
+ // Support both "Bearer <token>" and raw "<token>"
40
+ const token = rawHeader.startsWith('Bearer ') ? rawHeader.slice(7) : rawHeader;
41
+ if (!constantTimeCompare(token.trim(), expectedSecret.trim())) {
42
+ return c.json({
43
+ error: 'Unauthorized: Invalid webhook authHeader',
44
+ }, 401);
45
+ }
46
+ await next();
47
+ };
48
+ }
49
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,CAAS,EAAE,CAAS;IACtD,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,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AC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE/E,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YAC9D,OAAO,CAAC,CAAC,IAAI,CACX;gBACE,KAAK,EAAE,0CAA0C;aAClD,EACD,GAAG,CACJ,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { Context, Next } from 'hono';
2
+ export interface DedupeStore {
3
+ /**
4
+ * Returns true if signature was already processed recently.
5
+ * If not seen, records it with TTL and returns false.
6
+ */
7
+ isDuplicate(signature: string): Promise<boolean> | boolean;
8
+ /**
9
+ * Filters an array of transactions, returning only unseen ones.
10
+ */
11
+ filterUnseen<T extends {
12
+ signature: string;
13
+ }>(transactions: T[]): Promise<T[]> | T[];
14
+ }
15
+ /**
16
+ * In-Memory LRU Signature Deduplication Store
17
+ * Best suited for single-instance Node.js/Bun servers and local dev.
18
+ * Note: Multi-instance serverless deployments should use a shared store (e.g. Cloudflare KV or Redis).
19
+ */
20
+ export declare class MemoryDedupeStore implements DedupeStore {
21
+ private cache;
22
+ private ttlMs;
23
+ private maxSize;
24
+ constructor(ttlMs?: number, maxSize?: number);
25
+ isDuplicate(signature: string): boolean;
26
+ filterUnseen<T extends {
27
+ signature: string;
28
+ }>(transactions: T[]): T[];
29
+ }
30
+ /**
31
+ * Cloudflare KV Deduplication Store Adapter
32
+ * Provides shared deduplication across globally distributed Cloudflare Worker edge instances.
33
+ */
34
+ export declare class CloudflareKvDedupeStore implements DedupeStore {
35
+ private kv;
36
+ private ttlSeconds;
37
+ constructor(kvNamespace: any, ttlSeconds?: number);
38
+ isDuplicate(signature: string): Promise<boolean>;
39
+ filterUnseen<T extends {
40
+ signature: string;
41
+ }>(transactions: T[]): Promise<T[]>;
42
+ }
43
+ export declare const defaultDedupeStore: MemoryDedupeStore;
44
+ /**
45
+ * Hono Middleware for Webhook Signature Deduplication
46
+ */
47
+ export declare function deduplicateWebhooks(store?: DedupeStore): (c: Context, next: Next) => Promise<void | (Response & import("hono").TypedResponse<{
48
+ message: string;
49
+ }, 200, "json">)>;
50
+ //# sourceMappingURL=dedupe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dedupe.d.ts","sourceRoot":"","sources":["../../src/middleware/dedupe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG1C,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAE3D;;OAEG;IACH,YAAY,CAAC,CAAC,SAAS;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,YAAY,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;CACtF;AAED;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,WAAW;IACnD,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,OAAO,CAAS;gBAEZ,KAAK,SAAiB,EAAE,OAAO,SAAS;IAK7C,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAiBvC,YAAY,CAAC,CAAC,SAAS;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,YAAY,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE;CAG7E;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,WAAW;IACzD,OAAO,CAAC,EAAE,CAGR;IACF,OAAO,CAAC,UAAU,CAAS;gBAEf,WAAW,EAAE,GAAG,EAAE,UAAU,SAAM;IAKjC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWhD,YAAY,CAAC,CAAC,SAAS;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,YAAY,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;CAU5F;AAED,eAAO,MAAM,kBAAkB,mBAA0B,CAAC;AAE1D;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,GAAE,WAAgC,IAC3D,GAAG,OAAO,EAAE,MAAM,IAAI;;kBAmBrC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * In-Memory LRU Signature Deduplication Store
3
+ * Best suited for single-instance Node.js/Bun servers and local dev.
4
+ * Note: Multi-instance serverless deployments should use a shared store (e.g. Cloudflare KV or Redis).
5
+ */
6
+ export class MemoryDedupeStore {
7
+ cache = new Map();
8
+ ttlMs;
9
+ maxSize;
10
+ constructor(ttlMs = 10 * 60 * 1000, maxSize = 10_000) {
11
+ this.ttlMs = ttlMs;
12
+ this.maxSize = maxSize;
13
+ }
14
+ isDuplicate(signature) {
15
+ const now = Date.now();
16
+ const seenAt = this.cache.get(signature);
17
+ if (seenAt && now - seenAt < this.ttlMs) {
18
+ return true;
19
+ }
20
+ if (this.cache.size >= this.maxSize) {
21
+ const oldestKey = this.cache.keys().next().value;
22
+ if (oldestKey)
23
+ this.cache.delete(oldestKey);
24
+ }
25
+ this.cache.set(signature, now);
26
+ return false;
27
+ }
28
+ filterUnseen(transactions) {
29
+ return transactions.filter((tx) => !this.isDuplicate(tx.signature));
30
+ }
31
+ }
32
+ /**
33
+ * Cloudflare KV Deduplication Store Adapter
34
+ * Provides shared deduplication across globally distributed Cloudflare Worker edge instances.
35
+ */
36
+ export class CloudflareKvDedupeStore {
37
+ kv;
38
+ ttlSeconds;
39
+ constructor(kvNamespace, ttlSeconds = 600) {
40
+ this.kv = kvNamespace;
41
+ this.ttlSeconds = ttlSeconds;
42
+ }
43
+ async isDuplicate(signature) {
44
+ if (!this.kv)
45
+ return false;
46
+ const key = `helius:sig:${signature}`;
47
+ const existing = await this.kv.get(key);
48
+ if (existing) {
49
+ return true;
50
+ }
51
+ await this.kv.put(key, '1', { expirationTtl: this.ttlSeconds });
52
+ return false;
53
+ }
54
+ async filterUnseen(transactions) {
55
+ const results = [];
56
+ for (const tx of transactions) {
57
+ const isDup = await this.isDuplicate(tx.signature);
58
+ if (!isDup) {
59
+ results.push(tx);
60
+ }
61
+ }
62
+ return results;
63
+ }
64
+ }
65
+ export const defaultDedupeStore = new MemoryDedupeStore();
66
+ /**
67
+ * Hono Middleware for Webhook Signature Deduplication
68
+ */
69
+ export function deduplicateWebhooks(store = defaultDedupeStore) {
70
+ return async (c, next) => {
71
+ if (c.req.method !== 'POST') {
72
+ return next();
73
+ }
74
+ try {
75
+ const body = (await c.req.raw.clone().json());
76
+ if (Array.isArray(body)) {
77
+ const unseen = await store.filterUnseen(body);
78
+ if (unseen.length === 0 && body.length > 0) {
79
+ return c.json({ message: 'All signatures already processed (deduplicated)' }, 200);
80
+ }
81
+ }
82
+ }
83
+ catch {
84
+ // Fall through to main body parser if invalid JSON
85
+ }
86
+ await next();
87
+ };
88
+ }
89
+ //# sourceMappingURL=dedupe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dedupe.js","sourceRoot":"","sources":["../../src/middleware/dedupe.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACpB,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClC,KAAK,CAAS;IACd,OAAO,CAAS;IAExB,YAAY,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,OAAO,GAAG,MAAM;QAClD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,WAAW,CAAC,SAAiB;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAA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C,EAAE,OAAO,EAAE,iDAAiD,EAAE,EAAE,GAAG,CAAC,CAAC;gBACrF,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,mDAAmD;QACrD,CAAC;QAED,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { BotAlert } from '../types/preset.js';
2
+ export interface DiscordConfig {
3
+ webhookUrl: string;
4
+ }
5
+ export declare class DiscordNotifier {
6
+ private config;
7
+ constructor(config: DiscordConfig);
8
+ /**
9
+ * Formats a BotAlert into a rich Discord embed
10
+ */
11
+ formatEmbed(alert: BotAlert): {
12
+ title: string;
13
+ description: string | undefined;
14
+ url: string;
15
+ color: number;
16
+ fields: {
17
+ name: string;
18
+ value: string;
19
+ inline: boolean;
20
+ }[];
21
+ thumbnail: {
22
+ url: string;
23
+ } | undefined;
24
+ footer: {
25
+ text: string;
26
+ icon_url: string;
27
+ };
28
+ timestamp: string;
29
+ };
30
+ /**
31
+ * Sends the alert to Discord via Webhook URL
32
+ */
33
+ send(alert: BotAlert): Promise<boolean>;
34
+ }
35
+ //# sourceMappingURL=discord.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord.d.ts","sourceRoot":"","sources":["../../src/notifiers/discord.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,aAAa;IAIjC;;OAEG;IACI,WAAW,CAAC,KAAK,EAAE,QAAQ;;;;;;;;;;;;;;;;;;;IAsBlC;;OAEG;IACU,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;CA6BrD"}
@@ -0,0 +1,59 @@
1
+ export class DiscordNotifier {
2
+ config;
3
+ constructor(config) {
4
+ this.config = config;
5
+ }
6
+ /**
7
+ * Formats a BotAlert into a rich Discord embed
8
+ */
9
+ formatEmbed(alert) {
10
+ const explorerUrl = alert.url || `https://xray.helius.xyz/tx/${alert.signature}`;
11
+ return {
12
+ title: `${alert.emoji} ${alert.title}`,
13
+ description: alert.description || undefined,
14
+ url: explorerUrl,
15
+ color: alert.color || 0xf97316, // Helius orange default
16
+ fields: alert.fields.map((f) => ({
17
+ name: f.name,
18
+ value: f.value,
19
+ inline: f.inline ?? true,
20
+ })),
21
+ thumbnail: alert.imageUrl ? { url: alert.imageUrl } : undefined,
22
+ footer: {
23
+ text: '⚔ Powered by Helius Enhanced Webhooks',
24
+ icon_url: 'https://raw.githubusercontent.com/helius-labs/helius-sdk/main/assets/helius-orange.png',
25
+ },
26
+ timestamp: new Date(alert.timestamp * 1000).toISOString(),
27
+ };
28
+ }
29
+ /**
30
+ * Sends the alert to Discord via Webhook URL
31
+ */
32
+ async send(alert) {
33
+ if (!this.config.webhookUrl) {
34
+ console.warn('[DiscordNotifier] Missing webhookUrl. Alert skipped.');
35
+ return false;
36
+ }
37
+ const embed = this.formatEmbed(alert);
38
+ try {
39
+ const response = await fetch(this.config.webhookUrl, {
40
+ method: 'POST',
41
+ headers: { 'Content-Type': 'application/json' },
42
+ body: JSON.stringify({
43
+ embeds: [embed],
44
+ }),
45
+ });
46
+ if (!response.ok) {
47
+ const errorText = await response.text();
48
+ console.error(`[DiscordNotifier] Failed to send embed: ${response.status}`, errorText);
49
+ return false;
50
+ }
51
+ return true;
52
+ }
53
+ catch (err) {
54
+ console.error('[DiscordNotifier] Network error sending webhook:', err);
55
+ return false;
56
+ }
57
+ }
58
+ }
59
+ //# sourceMappingURL=discord.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord.js","sourceRoot":"","sources":["../../src/notifiers/discord.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,eAAe;IAClB,MAAM,CAAgB;IAE9B,YAAY,MAAqB;QA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AM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;gBACnD,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,MAAM,EAAE,CAAC,KAAK,CAAC;iBAChB,CAAC;aACH,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACxC,OAAO,CAAC,KAAK,CAAC,2CAA2C,QAAQ,CAAC,MAAM,EAAE,EAAE,SAAS,CAAC,CAAC;gBACvF,OAAO,KAAK,CAAC;YACf,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,kDAAkD,EAAE,GAAG,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import type { BotAlert } from '../types/preset.js';
2
+ export interface TelegramConfig {
3
+ botToken: string;
4
+ chatId: string;
5
+ parseMode?: 'HTML' | 'MarkdownV2';
6
+ }
7
+ export declare class TelegramNotifier {
8
+ private config;
9
+ constructor(config: TelegramConfig);
10
+ /**
11
+ * Formats a BotAlert into clean, modern Telegram HTML
12
+ */
13
+ formatHtml(alert: BotAlert): string;
14
+ /**
15
+ * Sends the alert to Telegram via the Bot API
16
+ */
17
+ send(alert: BotAlert): Promise<boolean>;
18
+ private escapeHtml;
19
+ }
20
+ //# sourceMappingURL=telegram.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telegram.d.ts","sourceRoot":"","sources":["../../src/notifiers/telegram.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;CACnC;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,EAAE,cAAc;IAIlC;;OAEG;IACI,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM;IA0B1C;;OAEG;IACU,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAkCpD,OAAO,CAAC,UAAU;CAMnB"}
@@ -0,0 +1,68 @@
1
+ export class TelegramNotifier {
2
+ config;
3
+ constructor(config) {
4
+ this.config = config;
5
+ }
6
+ /**
7
+ * Formats a BotAlert into clean, modern Telegram HTML
8
+ */
9
+ formatHtml(alert) {
10
+ const lines = [];
11
+ // Header
12
+ lines.push(`<b>${alert.emoji} ${this.escapeHtml(alert.title)}</b>\n`);
13
+ // Description (if present)
14
+ if (alert.description) {
15
+ lines.push(`${this.escapeHtml(alert.description)}\n`);
16
+ }
17
+ // Fields
18
+ for (const field of alert.fields) {
19
+ lines.push(`<b>${this.escapeHtml(field.name)}:</b> <code>${this.escapeHtml(field.value)}</code>`);
20
+ }
21
+ // Links & Explorer
22
+ const explorerUrl = alert.url || `https://xray.helius.xyz/tx/${alert.signature}`;
23
+ lines.push(`\nšŸ”— <a href="${explorerUrl}">View on Solana Explorer</a>`);
24
+ // Footer
25
+ lines.push(`<i>⚔ Powered by Helius Webhooks</i>`);
26
+ return lines.join('\n');
27
+ }
28
+ /**
29
+ * Sends the alert to Telegram via the Bot API
30
+ */
31
+ async send(alert) {
32
+ if (!this.config.botToken || !this.config.chatId) {
33
+ console.warn('[TelegramNotifier] Missing botToken or chatId. Alert skipped.');
34
+ return false;
35
+ }
36
+ const text = this.formatHtml(alert);
37
+ const endpoint = `https://api.telegram.org/bot${this.config.botToken}/sendMessage`;
38
+ try {
39
+ const response = await fetch(endpoint, {
40
+ method: 'POST',
41
+ headers: { 'Content-Type': 'application/json' },
42
+ body: JSON.stringify({
43
+ chat_id: this.config.chatId,
44
+ text,
45
+ parse_mode: 'HTML',
46
+ disable_web_page_preview: !alert.imageUrl,
47
+ }),
48
+ });
49
+ if (!response.ok) {
50
+ const errorText = await response.text();
51
+ console.error(`[TelegramNotifier] Failed to send message: ${response.status}`, errorText);
52
+ return false;
53
+ }
54
+ return true;
55
+ }
56
+ catch (err) {
57
+ console.error('[TelegramNotifier] Network error sending message:', err);
58
+ return false;
59
+ }
60
+ }
61
+ escapeHtml(text) {
62
+ return text
63
+ .replace(/&/g, '&amp;')
64
+ .replace(/</g, '&lt;')
65
+ .replace(/>/g, '&gt;');
66
+ }
67
+ }
68
+ //# sourceMappingURL=telegram.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telegram.js","sourceRoot":"","sources":["../../src/notifiers/telegram.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAiB;IAE/B,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,UAAU,CAAC,KAAe;QAC/B,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,SAAS;QACT,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEtE,2BAA2B;QAC3B,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACtB,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACxD,CAAC;QAED,SAAS;QACT,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACjC,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,KAA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C,IAAI,EAAE,CAAC;gBACxC,OAAO,CAAC,KAAK,CAAC,8CAA8C,QAAQ,CAAC,MAAM,EAAE,EAAE,SAAS,CAAC,CAAC;gBAC1F,OAAO,KAAK,CAAC;YACf,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,mDAAmD,EAAE,GAAG,CAAC,CAAC;YACxE,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,IAAY;QAC7B,OAAO,IAAI;aACR,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;aACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;aACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ import type { PresetHandler } from '../types/preset.js';
2
+ export declare const dexSwapsPreset: PresetHandler;
3
+ //# sourceMappingURL=dex-swaps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dex-swaps.d.ts","sourceRoot":"","sources":["../../src/presets/dex-swaps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2B,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEjF,eAAO,MAAM,cAAc,EAAE,aAoG5B,CAAC"}