hood-alerts 0.1.0 → 0.2.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.
Files changed (204) hide show
  1. package/.env.example +90 -0
  2. package/Dockerfile +65 -0
  3. package/LICENSE +15 -14
  4. package/README.md +253 -309
  5. package/dist/scripts/capture-fixtures.d.ts +2 -0
  6. package/dist/scripts/capture-fixtures.js +143 -0
  7. package/dist/scripts/capture-fixtures.js.map +1 -0
  8. package/dist/scripts/grant-premium.d.ts +2 -0
  9. package/dist/scripts/grant-premium.js +70 -0
  10. package/dist/scripts/grant-premium.js.map +1 -0
  11. package/dist/scripts/live-probe.d.ts +2 -0
  12. package/dist/scripts/live-probe.js +51 -0
  13. package/dist/scripts/live-probe.js.map +1 -0
  14. package/dist/src/commands/commands.d.ts +42 -0
  15. package/dist/src/commands/commands.js +246 -0
  16. package/dist/src/commands/commands.js.map +1 -0
  17. package/dist/src/config.d.ts +69 -0
  18. package/dist/src/config.js +72 -0
  19. package/dist/src/config.js.map +1 -0
  20. package/dist/src/db/deliveries.d.ts +17 -0
  21. package/dist/src/db/deliveries.js +41 -0
  22. package/dist/src/db/deliveries.js.map +1 -0
  23. package/dist/src/db/entitlements.d.ts +41 -0
  24. package/dist/src/db/entitlements.js +73 -0
  25. package/dist/src/db/entitlements.js.map +1 -0
  26. package/dist/src/db/index.d.ts +4 -0
  27. package/dist/src/db/index.js +63 -0
  28. package/dist/src/db/index.js.map +1 -0
  29. package/dist/src/db/subscribers.d.ts +44 -0
  30. package/dist/src/db/subscribers.js +124 -0
  31. package/dist/src/db/subscribers.js.map +1 -0
  32. package/dist/src/engine/detectors/holders.d.ts +16 -0
  33. package/dist/src/engine/detectors/holders.js +33 -0
  34. package/dist/src/engine/detectors/holders.js.map +1 -0
  35. package/dist/src/engine/detectors/liquidity.d.ts +24 -0
  36. package/dist/src/engine/detectors/liquidity.js +62 -0
  37. package/dist/src/engine/detectors/liquidity.js.map +1 -0
  38. package/dist/src/engine/detectors/live.d.ts +52 -0
  39. package/dist/src/engine/detectors/live.js +420 -0
  40. package/dist/src/engine/detectors/live.js.map +1 -0
  41. package/dist/src/engine/detectors/premium-ladder.d.ts +14 -0
  42. package/dist/src/engine/detectors/premium-ladder.js +61 -0
  43. package/dist/src/engine/detectors/premium-ladder.js.map +1 -0
  44. package/dist/src/engine/detectors/prices.d.ts +15 -0
  45. package/dist/src/engine/detectors/prices.js +45 -0
  46. package/dist/src/engine/detectors/prices.js.map +1 -0
  47. package/dist/src/engine/detectors/whale-classify.d.ts +18 -0
  48. package/dist/src/engine/detectors/whale-classify.js +69 -0
  49. package/dist/src/engine/detectors/whale-classify.js.map +1 -0
  50. package/dist/src/engine/digest.d.ts +31 -0
  51. package/dist/src/engine/digest.js +48 -0
  52. package/dist/src/engine/digest.js.map +1 -0
  53. package/dist/src/engine/engine.d.ts +40 -0
  54. package/dist/src/engine/engine.js +175 -0
  55. package/dist/src/engine/engine.js.map +1 -0
  56. package/dist/src/engine/eth-price.d.ts +18 -0
  57. package/dist/src/engine/eth-price.js +85 -0
  58. package/dist/src/engine/eth-price.js.map +1 -0
  59. package/dist/src/engine/events.d.ts +94 -0
  60. package/dist/src/engine/events.js +37 -0
  61. package/dist/src/engine/events.js.map +1 -0
  62. package/dist/src/engine/gate.d.ts +35 -0
  63. package/dist/src/engine/gate.js +35 -0
  64. package/dist/src/engine/gate.js.map +1 -0
  65. package/dist/src/engine/token-meta.d.ts +17 -0
  66. package/dist/src/engine/token-meta.js +44 -0
  67. package/dist/src/engine/token-meta.js.map +1 -0
  68. package/dist/src/engine/topics.d.ts +60 -0
  69. package/dist/src/engine/topics.js +120 -0
  70. package/dist/src/engine/topics.js.map +1 -0
  71. package/dist/src/format/cards.d.ts +46 -0
  72. package/dist/src/format/cards.js +193 -0
  73. package/dist/src/format/cards.js.map +1 -0
  74. package/dist/{service/main.d.cts → src/index.d.ts} +1 -0
  75. package/dist/src/index.js +133 -0
  76. package/dist/src/index.js.map +1 -0
  77. package/dist/src/logger.d.ts +5 -0
  78. package/dist/src/logger.js +16 -0
  79. package/dist/src/logger.js.map +1 -0
  80. package/dist/src/premium/paywall.d.ts +40 -0
  81. package/dist/src/premium/paywall.js +105 -0
  82. package/dist/src/premium/paywall.js.map +1 -0
  83. package/dist/src/server.d.ts +14 -0
  84. package/dist/src/server.js +57 -0
  85. package/dist/src/server.js.map +1 -0
  86. package/dist/src/transports/console.d.ts +14 -0
  87. package/dist/src/transports/console.js +24 -0
  88. package/dist/src/transports/console.js.map +1 -0
  89. package/dist/src/transports/discord.d.ts +28 -0
  90. package/dist/src/transports/discord.js +145 -0
  91. package/dist/src/transports/discord.js.map +1 -0
  92. package/dist/src/transports/telegram.d.ts +22 -0
  93. package/dist/src/transports/telegram.js +101 -0
  94. package/dist/src/transports/telegram.js.map +1 -0
  95. package/dist/src/transports/types.d.ts +14 -0
  96. package/dist/src/transports/types.js +2 -0
  97. package/dist/src/transports/types.js.map +1 -0
  98. package/dist/src/transports/x.d.ts +58 -0
  99. package/dist/src/transports/x.js +155 -0
  100. package/dist/src/transports/x.js.map +1 -0
  101. package/package.json +80 -112
  102. package/dist/bot/index.cjs +0 -1008
  103. package/dist/bot/index.cjs.map +0 -1
  104. package/dist/bot/index.d.cts +0 -241
  105. package/dist/bot/index.d.ts +0 -241
  106. package/dist/bot/index.js +0 -30
  107. package/dist/bot/index.js.map +0 -1
  108. package/dist/chunk-32GS6XVE.js +0 -732
  109. package/dist/chunk-32GS6XVE.js.map +0 -1
  110. package/dist/chunk-3LHCQA4Z.js +0 -76
  111. package/dist/chunk-3LHCQA4Z.js.map +0 -1
  112. package/dist/chunk-3NHLSKZE.js +0 -1
  113. package/dist/chunk-3NHLSKZE.js.map +0 -1
  114. package/dist/chunk-6JQK5G3Z.js +0 -72
  115. package/dist/chunk-6JQK5G3Z.js.map +0 -1
  116. package/dist/chunk-CBNZ6AZT.js +0 -598
  117. package/dist/chunk-CBNZ6AZT.js.map +0 -1
  118. package/dist/chunk-CIURPPOW.js +0 -1
  119. package/dist/chunk-CIURPPOW.js.map +0 -1
  120. package/dist/chunk-IUOEGBF6.js +0 -49
  121. package/dist/chunk-IUOEGBF6.js.map +0 -1
  122. package/dist/chunk-NBMINJ5E.js +0 -230
  123. package/dist/chunk-NBMINJ5E.js.map +0 -1
  124. package/dist/chunk-O2RY2SWN.js +0 -1
  125. package/dist/chunk-O2RY2SWN.js.map +0 -1
  126. package/dist/chunk-PLMVKTQM.js +0 -1
  127. package/dist/chunk-PLMVKTQM.js.map +0 -1
  128. package/dist/chunk-RSTLW7XH.js +0 -130
  129. package/dist/chunk-RSTLW7XH.js.map +0 -1
  130. package/dist/chunk-SOBZ2FPP.js +0 -355
  131. package/dist/chunk-SOBZ2FPP.js.map +0 -1
  132. package/dist/chunk-VC5MKEY2.js +0 -170
  133. package/dist/chunk-VC5MKEY2.js.map +0 -1
  134. package/dist/chunk-W2GUAWUR.js +0 -147
  135. package/dist/chunk-W2GUAWUR.js.map +0 -1
  136. package/dist/chunk-Y2M3USWZ.js +0 -355
  137. package/dist/chunk-Y2M3USWZ.js.map +0 -1
  138. package/dist/chunk-Z4DJPESQ.js +0 -1216
  139. package/dist/chunk-Z4DJPESQ.js.map +0 -1
  140. package/dist/chunk-ZDM5VNWB.js +0 -1
  141. package/dist/chunk-ZDM5VNWB.js.map +0 -1
  142. package/dist/events/index.cjs +0 -820
  143. package/dist/events/index.cjs.map +0 -1
  144. package/dist/events/index.d.cts +0 -58
  145. package/dist/events/index.d.ts +0 -58
  146. package/dist/events/index.js +0 -69
  147. package/dist/events/index.js.map +0 -1
  148. package/dist/format-6RG4OcyE.d.ts +0 -57
  149. package/dist/format-B7d40f65.d.cts +0 -57
  150. package/dist/index.cjs +0 -4122
  151. package/dist/index.cjs.map +0 -1
  152. package/dist/index.d.cts +0 -21
  153. package/dist/index.d.ts +0 -21
  154. package/dist/index.js +0 -274
  155. package/dist/index.js.map +0 -1
  156. package/dist/logger-3phvV_fl.d.cts +0 -185
  157. package/dist/logger-CYza_0eU.d.ts +0 -185
  158. package/dist/logs-D7sYBvSy.d.cts +0 -66
  159. package/dist/logs-D7sYBvSy.d.ts +0 -66
  160. package/dist/notifiers/index.cjs +0 -620
  161. package/dist/notifiers/index.cjs.map +0 -1
  162. package/dist/notifiers/index.d.cts +0 -186
  163. package/dist/notifiers/index.d.ts +0 -186
  164. package/dist/notifiers/index.js +0 -70
  165. package/dist/notifiers/index.js.map +0 -1
  166. package/dist/pricing-BumgLpvB.d.cts +0 -79
  167. package/dist/pricing-BumgLpvB.d.ts +0 -79
  168. package/dist/ratelimit-BKVQG2oY.d.cts +0 -42
  169. package/dist/ratelimit-CGLlXNIS.d.ts +0 -42
  170. package/dist/registry-D3We8Lg6.d.ts +0 -50
  171. package/dist/registry-DePA3IyS.d.cts +0 -50
  172. package/dist/rules/index.cjs +0 -614
  173. package/dist/rules/index.cjs.map +0 -1
  174. package/dist/rules/index.d.cts +0 -166
  175. package/dist/rules/index.d.ts +0 -166
  176. package/dist/rules/index.js +0 -60
  177. package/dist/rules/index.js.map +0 -1
  178. package/dist/schema-DuDMPqpq.d.ts +0 -183
  179. package/dist/schema-NnIdKFl2.d.cts +0 -183
  180. package/dist/service/index.cjs +0 -3774
  181. package/dist/service/index.cjs.map +0 -1
  182. package/dist/service/index.d.cts +0 -262
  183. package/dist/service/index.d.ts +0 -262
  184. package/dist/service/index.js +0 -45
  185. package/dist/service/index.js.map +0 -1
  186. package/dist/service/main.cjs +0 -3759
  187. package/dist/service/main.cjs.map +0 -1
  188. package/dist/service/main.d.ts +0 -1
  189. package/dist/service/main.js +0 -60
  190. package/dist/service/main.js.map +0 -1
  191. package/dist/sources-CAaQR6-N.d.ts +0 -159
  192. package/dist/sources-CpDOUlzx.d.cts +0 -159
  193. package/dist/telegram-CpodYJrP.d.cts +0 -64
  194. package/dist/telegram-pvphmBwn.d.ts +0 -64
  195. package/dist/tiers/index.cjs +0 -471
  196. package/dist/tiers/index.cjs.map +0 -1
  197. package/dist/tiers/index.d.cts +0 -231
  198. package/dist/tiers/index.d.ts +0 -231
  199. package/dist/tiers/index.js +0 -34
  200. package/dist/tiers/index.js.map +0 -1
  201. package/dist/types-C0ETog04.d.ts +0 -109
  202. package/dist/types-CcoKpStA.d.cts +0 -109
  203. package/dist/types-DFPpTMWo.d.cts +0 -186
  204. package/dist/types-DFPpTMWo.d.ts +0 -186
package/.env.example ADDED
@@ -0,0 +1,90 @@
1
+ # hood-alerts configuration. Copy to .env and fill in what you use.
2
+ # Everything is optional: with zero env vars the engine runs with the console
3
+ # transport only (alerts printed as structured logs), which is the self-host
4
+ # smoke-test mode.
5
+
6
+ # ---- chain ----
7
+ # Custom RPC (e.g. Alchemy: https://robinhood-mainnet.g.alchemy.com/v2/KEY).
8
+ # Defaults to the public RPC from viem's official `robinhood` chain definition.
9
+ HOOD_ALERTS_RPC_URL=
10
+
11
+ # ---- storage ----
12
+ # SQLite database path (subscriptions, entitlements, dedup, delivery log).
13
+ HOOD_ALERTS_DB=./data/hood-alerts.db
14
+
15
+ # ---- HTTP server ----
16
+ # Cloud Run injects PORT. /healthz + the premium x402 endpoints live here.
17
+ PORT=8080
18
+ # Public base URL of this instance (used in payment challenges + bot replies).
19
+ HOOD_ALERTS_PUBLIC_URL=
20
+
21
+ # ---- Telegram bot ----
22
+ # Create with @BotFather -> /newbot. Leave empty to disable the transport.
23
+ HOOD_ALERTS_TELEGRAM_TOKEN=
24
+
25
+ # ---- Discord bot ----
26
+ # Create at https://discord.com/developers/applications (Bot token + App ID).
27
+ # Leave empty to disable the transport.
28
+ HOOD_ALERTS_DISCORD_TOKEN=
29
+ HOOD_ALERTS_DISCORD_APP_ID=
30
+
31
+ # ---- X (Twitter) auto-posting: pick ONE mode ----
32
+ # Leave empty to disable. X has no inbound bot (no watch/unwatch DMs), so what
33
+ # it posts is fixed at startup via HOOD_ALERTS_X_TOPICS below.
34
+ HOOD_ALERTS_X_MODE= # official | xactions
35
+
36
+ # official mode: the real X API v2, POST /2/tweets, OAuth1 user context.
37
+ # Requires a developer.x.com app with a posting-capable tier (check current
38
+ # pricing at https://developer.x.com/en/portal/products/buy before relying on
39
+ # this; it has changed before and may change again). Create an app, generate
40
+ # a consumer key/secret, then generate an access token/secret with
41
+ # read+write permissions.
42
+ HOOD_ALERTS_X_API_KEY=
43
+ HOOD_ALERTS_X_API_SECRET=
44
+ HOOD_ALERTS_X_ACCESS_TOKEN=
45
+ HOOD_ALERTS_X_ACCESS_SECRET=
46
+
47
+ # xactions mode: free, self-hosted browser-automation posting via your own X
48
+ # session cookie instead of the official API. See
49
+ # https://github.com/nirholas/XActions to run your own instance. Not the
50
+ # official API: carries ToS risk. Posting is async (queued, not confirmed
51
+ # synchronously).
52
+ HOOD_ALERTS_XACTIONS_URL=
53
+ HOOD_ALERTS_XACTIONS_TOKEN=
54
+
55
+ # Topics the X broadcast auto-posts (comma-separated; parsed the same way a
56
+ # `watch` command target is). Premium-tier topics (premiums, rugs) only post
57
+ # if the x/public subscriber has been granted premium (see grant-premium).
58
+ HOOD_ALERTS_X_TOPICS=launches,graduations,whales
59
+
60
+ # ---- premium (x402 USDG on Robinhood Chain via hood402) ----
61
+ # Rail selector. `hood402` (USDG on chain 4663) is implemented end-to-end.
62
+ # `x402-usdc` is a documented alternative (see README) and is rejected at
63
+ # startup until wired to your own facilitator.
64
+ HOOD_ALERTS_PREMIUM_RAIL=hood402
65
+ # Address that receives premium payments. Premium purchase endpoints stay
66
+ # disabled (503 + guidance) until this is set.
67
+ HOOD402_PAY_TO=
68
+ # Settlement mode A: a hood402 facilitator base URL (recommended; no gas key
69
+ # on this box).
70
+ HOOD402_FACILITATOR_URL=
71
+ # Settlement mode B: self-settle with a gas key. READ THE WARNING in the
72
+ # README before putting a key here.
73
+ HOOD402_SETTLER_KEY=
74
+ # Price + duration of one premium purchase.
75
+ HOOD_ALERTS_PREMIUM_PRICE_USDG=5
76
+ HOOD_ALERTS_PREMIUM_DAYS=30
77
+
78
+ # ---- detector tuning (defaults shown) ----
79
+ # Floor below which whale trades are not even emitted engine-side (USD).
80
+ HOOD_ALERTS_WHALE_FLOOR_USD=1000
81
+ # Default per-subscription whale threshold when none is given (USD).
82
+ HOOD_ALERTS_WHALE_DEFAULT_USD=5000
83
+ # Price-move window (seconds) and default threshold (percent).
84
+ HOOD_ALERTS_PRICE_WINDOW_S=900
85
+ HOOD_ALERTS_PRICE_DEFAULT_PCT=2
86
+ # Stock premium/discount poll interval (seconds) and default threshold (%).
87
+ HOOD_ALERTS_PREMIUM_POLL_S=60
88
+ HOOD_ALERTS_PREMIUM_DEFAULT_PCT=2
89
+ # Liquidity-pull default threshold (percent of pool quote reserves).
90
+ HOOD_ALERTS_RUG_DEFAULT_PCT=30
package/Dockerfile ADDED
@@ -0,0 +1,65 @@
1
+ # syntax=docker/dockerfile:1
2
+ #
3
+ # hood-alerts: one long-running process runs the detection engine, the HTTP
4
+ # server (/healthz + premium x402), and both bots (env-gated). Min-instances 1
5
+ # on Cloud Run; this is a service, not a job.
6
+ #
7
+ # The build context MUST be the parent `robinhood/` directory so the local
8
+ # file: siblings (robinhood-chain-sdk, hoodkit, hood402) resolve:
9
+ #
10
+ # docker build -f hood-alerts/Dockerfile -t hood-alerts . # run from robinhood/
11
+ #
12
+ # Once those packages are published to npm, switch the file: specs in
13
+ # package.json to the published versions and the app builds from its own dir.
14
+
15
+ # ---- build: full install (better-sqlite3 needs a toolchain) + tsc ----
16
+ FROM node:22-slim AS build
17
+ RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ \
18
+ && rm -rf /var/lib/apt/lists/*
19
+ WORKDIR /build
20
+ # Prebuilt sibling packages (manifest + dist) for the file: links.
21
+ COPY robinhood-chain-sdk/package.json ./robinhood-chain-sdk/package.json
22
+ COPY robinhood-chain-sdk/dist ./robinhood-chain-sdk/dist
23
+ COPY hoodkit/package.json ./hoodkit/package.json
24
+ COPY hoodkit/dist ./hoodkit/dist
25
+ COPY hood402/package.json ./hood402/package.json
26
+ COPY hood402/dist ./hood402/dist
27
+ WORKDIR /build/hood-alerts
28
+ COPY hood-alerts/package.json ./package.json
29
+ # --install-links copies the file: siblings into node_modules as real packages
30
+ # (not symlinks), so their `viem` dependency hoists and resolves at runtime.
31
+ RUN npm install --install-links --no-audit --no-fund
32
+ COPY hood-alerts/tsconfig.json ./tsconfig.json
33
+ COPY hood-alerts/src ./src
34
+ COPY hood-alerts/scripts ./scripts
35
+ RUN npm run build
36
+
37
+ # ---- prod-deps: runtime node_modules only (no tsc/tsx/vitest) ----
38
+ FROM node:22-slim AS prod-deps
39
+ RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ \
40
+ && rm -rf /var/lib/apt/lists/*
41
+ WORKDIR /build
42
+ COPY robinhood-chain-sdk/package.json ./robinhood-chain-sdk/package.json
43
+ COPY robinhood-chain-sdk/dist ./robinhood-chain-sdk/dist
44
+ COPY hoodkit/package.json ./hoodkit/package.json
45
+ COPY hoodkit/dist ./hoodkit/dist
46
+ COPY hood402/package.json ./hood402/package.json
47
+ COPY hood402/dist ./hood402/dist
48
+ WORKDIR /build/hood-alerts
49
+ COPY hood-alerts/package.json ./package.json
50
+ RUN npm install --omit=dev --install-links --no-audit --no-fund
51
+
52
+ # ---- runtime ----
53
+ FROM node:22-slim AS runtime
54
+ ENV NODE_ENV=production
55
+ ENV PORT=8080
56
+ ENV HOOD_ALERTS_DB=/data/hood-alerts.db
57
+ WORKDIR /app
58
+ COPY --from=prod-deps /build/hood-alerts/node_modules ./node_modules
59
+ COPY --from=build /build/hood-alerts/dist ./dist
60
+ COPY --from=build /build/hood-alerts/package.json ./package.json
61
+ # SQLite lives on a mounted volume so subscriptions survive restarts.
62
+ RUN mkdir -p /data
63
+ VOLUME ["/data"]
64
+ EXPOSE 8080
65
+ CMD ["node", "dist/src/index.js"]
package/LICENSE CHANGED
@@ -1,20 +1,21 @@
1
- Copyright 2026 nirholas
1
+ MIT License
2
2
 
3
- All rights reserved.
3
+ Copyright (c) 2026 nirholas
4
4
 
5
- This software is proprietary and may not be used, copied, modified, distributed,
6
- translated, or made available to any third party without the express written
7
- permission of the copyright owner.
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:
8
11
 
9
- No rights are granted by implication, estoppel, or otherwise. Use of this
10
- software is subject to the terms of a separate license agreement with the
11
- copyright owner.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
12
14
 
13
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
16
-
17
- IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY CLAIM, DAMAGES, OR
18
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE,
19
- ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20
- DEALINGS IN THE SOFTWARE.
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.