oculon 0.0.0-stage → 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 +344 -2
- package/dist/agent.d.ts +47 -0
- package/dist/agent.js +104 -0
- package/dist/cases.d.ts +68 -0
- package/dist/cases.js +158 -0
- package/dist/cli/main.d.ts +12 -0
- package/dist/cli/main.js +1999 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +15 -0
- package/dist/core/context.d.ts +19 -0
- package/dist/core/context.js +19 -0
- package/dist/core/features.d.ts +22 -0
- package/dist/core/features.js +28 -0
- package/dist/core/graph.d.ts +38 -0
- package/dist/core/graph.js +81 -0
- package/dist/core/http.d.ts +42 -0
- package/dist/core/http.js +266 -0
- package/dist/core/keys.d.ts +8 -0
- package/dist/core/keys.js +22 -0
- package/dist/core/llm.d.ts +93 -0
- package/dist/core/llm.js +180 -0
- package/dist/core/merkle.d.ts +15 -0
- package/dist/core/merkle.js +46 -0
- package/dist/core/paths.d.ts +2 -0
- package/dist/core/paths.js +6 -0
- package/dist/core/png.d.ts +17 -0
- package/dist/core/png.js +101 -0
- package/dist/core/quota.d.ts +15 -0
- package/dist/core/quota.js +90 -0
- package/dist/core/stats.d.ts +24 -0
- package/dist/core/stats.js +67 -0
- package/dist/core/store.d.ts +20 -0
- package/dist/core/store.js +213 -0
- package/dist/core/text.d.ts +9 -0
- package/dist/core/text.js +30 -0
- package/dist/core/types.d.ts +38 -0
- package/dist/core/types.js +1 -0
- package/dist/index.d.ts +342 -0
- package/dist/index.js +495 -0
- package/dist/live.d.ts +53 -0
- package/dist/live.js +236 -0
- package/dist/mcp.d.ts +43 -0
- package/dist/mcp.js +651 -0
- package/dist/modules/airport.d.ts +60 -0
- package/dist/modules/airport.js +111 -0
- package/dist/modules/audit.d.ts +73 -0
- package/dist/modules/audit.js +211 -0
- package/dist/modules/bgp.d.ts +147 -0
- package/dist/modules/bgp.js +206 -0
- package/dist/modules/blackout.d.ts +41 -0
- package/dist/modules/blackout.js +98 -0
- package/dist/modules/brief.d.ts +26 -0
- package/dist/modules/brief.js +99 -0
- package/dist/modules/calendar.d.ts +27 -0
- package/dist/modules/calendar.js +145 -0
- package/dist/modules/calibrate.d.ts +46 -0
- package/dist/modules/calibrate.js +92 -0
- package/dist/modules/cloud.d.ts +32 -0
- package/dist/modules/cloud.js +94 -0
- package/dist/modules/condor.d.ts +66 -0
- package/dist/modules/condor.js +214 -0
- package/dist/modules/connect.d.ts +47 -0
- package/dist/modules/connect.js +114 -0
- package/dist/modules/contradictions.d.ts +27 -0
- package/dist/modules/contradictions.js +76 -0
- package/dist/modules/country.d.ts +82 -0
- package/dist/modules/country.js +136 -0
- package/dist/modules/cricket.d.ts +34 -0
- package/dist/modules/cricket.js +166 -0
- package/dist/modules/darkships.d.ts +219 -0
- package/dist/modules/darkships.js +400 -0
- package/dist/modules/defi.d.ts +237 -0
- package/dist/modules/defi.js +512 -0
- package/dist/modules/emailsec.d.ts +47 -0
- package/dist/modules/emailsec.js +146 -0
- package/dist/modules/exposure.d.ts +43 -0
- package/dist/modules/exposure.js +89 -0
- package/dist/modules/factcheck.d.ts +39 -0
- package/dist/modules/factcheck.js +127 -0
- package/dist/modules/falcon.d.ts +58 -0
- package/dist/modules/falcon.js +219 -0
- package/dist/modules/feedback.d.ts +24 -0
- package/dist/modules/feedback.js +37 -0
- package/dist/modules/fence.d.ts +52 -0
- package/dist/modules/fence.js +128 -0
- package/dist/modules/ferret.d.ts +47 -0
- package/dist/modules/ferret.js +220 -0
- package/dist/modules/filings.d.ts +86 -0
- package/dist/modules/filings.js +166 -0
- package/dist/modules/fires.d.ts +56 -0
- package/dist/modules/fires.js +150 -0
- package/dist/modules/hazards.d.ts +37 -0
- package/dist/modules/hazards.js +83 -0
- package/dist/modules/health.d.ts +24 -0
- package/dist/modules/health.js +82 -0
- package/dist/modules/heron.d.ts +68 -0
- package/dist/modules/heron.js +184 -0
- package/dist/modules/hound.d.ts +100 -0
- package/dist/modules/hound.js +301 -0
- package/dist/modules/impact.d.ts +39 -0
- package/dist/modules/impact.js +63 -0
- package/dist/modules/launches.d.ts +24 -0
- package/dist/modules/launches.js +61 -0
- package/dist/modules/listen.d.ts +48 -0
- package/dist/modules/listen.js +125 -0
- package/dist/modules/lynx.d.ts +43 -0
- package/dist/modules/lynx.js +127 -0
- package/dist/modules/magpie.d.ts +70 -0
- package/dist/modules/magpie.js +174 -0
- package/dist/modules/meerkat.d.ts +42 -0
- package/dist/modules/meerkat.js +293 -0
- package/dist/modules/monitor.d.ts +27 -0
- package/dist/modules/monitor.js +105 -0
- package/dist/modules/narratives.d.ts +33 -0
- package/dist/modules/narratives.js +136 -0
- package/dist/modules/owl.d.ts +71 -0
- package/dist/modules/owl.js +290 -0
- package/dist/modules/papers.d.ts +46 -0
- package/dist/modules/papers.js +135 -0
- package/dist/modules/personal.d.ts +54 -0
- package/dist/modules/personal.js +153 -0
- package/dist/modules/pulse.d.ts +19 -0
- package/dist/modules/pulse.js +59 -0
- package/dist/modules/raven.d.ts +80 -0
- package/dist/modules/raven.js +147 -0
- package/dist/modules/recall.d.ts +44 -0
- package/dist/modules/recall.js +123 -0
- package/dist/modules/regs.d.ts +88 -0
- package/dist/modules/regs.js +142 -0
- package/dist/modules/rewind.d.ts +22 -0
- package/dist/modules/rewind.js +68 -0
- package/dist/modules/sanctions.d.ts +62 -0
- package/dist/modules/sanctions.js +173 -0
- package/dist/modules/scam.d.ts +43 -0
- package/dist/modules/scam.js +111 -0
- package/dist/modules/scoop.d.ts +31 -0
- package/dist/modules/scoop.js +74 -0
- package/dist/modules/ships.d.ts +33 -0
- package/dist/modules/ships.js +113 -0
- package/dist/modules/sky.d.ts +47 -0
- package/dist/modules/sky.js +183 -0
- package/dist/modules/squawk.d.ts +46 -0
- package/dist/modules/squawk.js +106 -0
- package/dist/modules/tortoise.d.ts +40 -0
- package/dist/modules/tortoise.js +104 -0
- package/dist/modules/travel.d.ts +94 -0
- package/dist/modules/travel.js +241 -0
- package/dist/modules/urlcheck.d.ts +63 -0
- package/dist/modules/urlcheck.js +223 -0
- package/dist/modules/vulns.d.ts +142 -0
- package/dist/modules/vulns.js +276 -0
- package/dist/plugins.d.ts +41 -0
- package/dist/plugins.js +70 -0
- package/dist/report.d.ts +12 -0
- package/dist/report.js +90 -0
- package/dist/scheduler.d.ts +22 -0
- package/dist/scheduler.js +139 -0
- package/dist/sources/aircraft.d.ts +76 -0
- package/dist/sources/aircraft.js +107 -0
- package/dist/sources/airports.d.ts +28 -0
- package/dist/sources/airports.js +100 -0
- package/dist/sources/ais.d.ts +32 -0
- package/dist/sources/ais.js +111 -0
- package/dist/sources/apify.d.ts +28 -0
- package/dist/sources/apify.js +80 -0
- package/dist/sources/arxiv.d.ts +13 -0
- package/dist/sources/arxiv.js +27 -0
- package/dist/sources/certs.d.ts +12 -0
- package/dist/sources/certs.js +23 -0
- package/dist/sources/corp.d.ts +46 -0
- package/dist/sources/corp.js +60 -0
- package/dist/sources/earth.d.ts +39 -0
- package/dist/sources/earth.js +76 -0
- package/dist/sources/fda.d.ts +77 -0
- package/dist/sources/fda.js +121 -0
- package/dist/sources/finance.d.ts +181 -0
- package/dist/sources/finance.js +270 -0
- package/dist/sources/gdelt.d.ts +19 -0
- package/dist/sources/gdelt.js +33 -0
- package/dist/sources/github.d.ts +17 -0
- package/dist/sources/github.js +33 -0
- package/dist/sources/hackernews.d.ts +20 -0
- package/dist/sources/hackernews.js +37 -0
- package/dist/sources/labels.d.ts +21 -0
- package/dist/sources/labels.js +87 -0
- package/dist/sources/launch.d.ts +16 -0
- package/dist/sources/launch.js +41 -0
- package/dist/sources/ofac.d.ts +29 -0
- package/dist/sources/ofac.js +86 -0
- package/dist/sources/onchain.d.ts +77 -0
- package/dist/sources/onchain.js +189 -0
- package/dist/sources/opentimestamps.d.ts +44 -0
- package/dist/sources/opentimestamps.js +131 -0
- package/dist/sources/polymarket.d.ts +36 -0
- package/dist/sources/polymarket.js +70 -0
- package/dist/sources/predict.d.ts +18 -0
- package/dist/sources/predict.js +59 -0
- package/dist/sources/press.d.ts +30 -0
- package/dist/sources/press.js +111 -0
- package/dist/sources/resend.d.ts +14 -0
- package/dist/sources/resend.js +29 -0
- package/dist/sources/robinhood.d.ts +109 -0
- package/dist/sources/robinhood.js +129 -0
- package/dist/sources/sec.d.ts +67 -0
- package/dist/sources/sec.js +129 -0
- package/dist/sources/sentinel.d.ts +13 -0
- package/dist/sources/sentinel.js +63 -0
- package/dist/sources/signatures.d.ts +14 -0
- package/dist/sources/signatures.js +103 -0
- package/dist/sources/social.d.ts +22 -0
- package/dist/sources/social.js +56 -0
- package/dist/sources/space.d.ts +160 -0
- package/dist/sources/space.js +230 -0
- package/dist/sources/usgs.d.ts +17 -0
- package/dist/sources/usgs.js +24 -0
- package/dist/sources/wayback.d.ts +10 -0
- package/dist/sources/wayback.js +28 -0
- package/dist/sources/websec.d.ts +19 -0
- package/dist/sources/websec.js +40 -0
- package/dist/sources/wikidata.d.ts +11 -0
- package/dist/sources/wikidata.js +30 -0
- package/dist/sources/wikimedia.d.ts +28 -0
- package/dist/sources/wikimedia.js +52 -0
- package/dist/telegram.d.ts +104 -0
- package/dist/telegram.js +927 -0
- package/dist/web/assets/favicon-32.png +0 -0
- package/dist/web/assets/fx.js +178 -0
- package/dist/web/assets/icon-192.png +0 -0
- package/dist/web/assets/icon-512.png +0 -0
- package/dist/web/assets/icon-maskable-512.png +0 -0
- package/dist/web/assets/night-americas.jpg +0 -0
- package/dist/web/assets/night-emea.jpg +0 -0
- package/dist/web/assets/og.png +0 -0
- package/dist/web/assets/redsea-bm.jpg +0 -0
- package/dist/web/docs.html +263 -0
- package/dist/web/index.html +1828 -0
- package/dist/web/insights.d.ts +100 -0
- package/dist/web/insights.js +134 -0
- package/dist/web/landing.html +1143 -0
- package/dist/web/legal.html +176 -0
- package/dist/web/manifest.webmanifest +20 -0
- package/dist/web/mcp.html +104 -0
- package/dist/web/mcphttp.d.ts +10 -0
- package/dist/web/mcphttp.js +67 -0
- package/dist/web/openapi.d.ts +1 -0
- package/dist/web/openapi.js +51 -0
- package/dist/web/public.d.ts +45 -0
- package/dist/web/public.js +135 -0
- package/dist/web/server.d.ts +69 -0
- package/dist/web/server.js +750 -0
- package/dist/web/share.d.ts +35 -0
- package/dist/web/share.js +132 -0
- package/dist/web/sw.js +28 -0
- package/package.json +60 -4
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { key, noKey } from '../core/keys.js';
|
|
2
|
+
import { signalId } from '../core/text.js';
|
|
3
|
+
import { geocode } from '../sources/earth.js';
|
|
4
|
+
/** FIRMS near-real-time products, best first: VIIRS (375 m) before MODIS (1 km). */
|
|
5
|
+
export const FIRMS_PRODUCTS = {
|
|
6
|
+
VIIRS_NOAA21_NRT: 'NOAA-21',
|
|
7
|
+
VIIRS_NOAA20_NRT: 'NOAA-20',
|
|
8
|
+
VIIRS_SNPP_NRT: 'Suomi NPP',
|
|
9
|
+
MODIS_NRT: 'MODIS',
|
|
10
|
+
LANDSAT_NRT: 'Landsat',
|
|
11
|
+
};
|
|
12
|
+
const DEFAULT_PRODUCTS = ['VIIRS_NOAA21_NRT', 'VIIRS_NOAA20_NRT', 'VIIRS_SNPP_NRT', 'MODIS_NRT'];
|
|
13
|
+
export function parseFirmsCsv(csv, satellite) {
|
|
14
|
+
const [head, ...rows] = csv.trim().split('\n');
|
|
15
|
+
if (!head?.startsWith('latitude'))
|
|
16
|
+
return [];
|
|
17
|
+
const cols = head.split(',');
|
|
18
|
+
const at = (name) => cols.indexOf(name);
|
|
19
|
+
return rows
|
|
20
|
+
.map((r) => r.split(','))
|
|
21
|
+
.filter((c) => c.length >= cols.length)
|
|
22
|
+
.map((c) => {
|
|
23
|
+
const conf = (c[at('confidence')] ?? '').trim().toLowerCase();
|
|
24
|
+
const t = (c[at('acq_time')] ?? '0000').padStart(4, '0');
|
|
25
|
+
// MODIS reports confidence as 0-100 (FIRMS: <30 low, 30-79 nominal, >=80 high); VIIRS and Landsat as letters.
|
|
26
|
+
const pct = /^\d+$/.test(conf) ? Number(conf) : null;
|
|
27
|
+
const level = pct !== null ? (pct >= 80 ? 'high' : pct < 30 ? 'low' : 'nominal') : conf === 'h' || conf === 'high' ? 'high' : conf === 'l' || conf === 'low' ? 'low' : 'nominal';
|
|
28
|
+
// MODIS rows name the platform (Terra / Aqua); keep it so passes can be told apart.
|
|
29
|
+
const platform = satellite === 'MODIS' ? (c[at('satellite')] ?? '').trim() : '';
|
|
30
|
+
return {
|
|
31
|
+
lat: Number(c[at('latitude')]),
|
|
32
|
+
lon: Number(c[at('longitude')]),
|
|
33
|
+
time: `${c[at('acq_date')]}T${t.slice(0, 2)}:${t.slice(2)}:00Z`,
|
|
34
|
+
satellite: platform ? `MODIS ${platform}` : satellite,
|
|
35
|
+
confidence: level,
|
|
36
|
+
frp: Number(c[at('frp')]) || 0,
|
|
37
|
+
daynight: (c[at('daynight')] === 'N' ? 'N' : 'D'),
|
|
38
|
+
};
|
|
39
|
+
})
|
|
40
|
+
.filter((h) => Number.isFinite(h.lat) && Number.isFinite(h.lon));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Merge detections from several FIRMS products: exact duplicates dropped, and a MODIS (1 km at nadir, up to ~2 km
|
|
44
|
+
* off-nadir) detection dropped when a VIIRS (375 m) detection lies within `km` and `minutes` of it, since both saw
|
|
45
|
+
* the same fire on the same pass.
|
|
46
|
+
*/
|
|
47
|
+
export function dedupeHotspots(hs, km = 2, minutes = 30) {
|
|
48
|
+
const exact = new Set();
|
|
49
|
+
const unique = [];
|
|
50
|
+
for (const h of hs) {
|
|
51
|
+
const k = `${h.lat.toFixed(4)},${h.lon.toFixed(4)},${h.time}`;
|
|
52
|
+
if (exact.has(k))
|
|
53
|
+
continue;
|
|
54
|
+
exact.add(k);
|
|
55
|
+
unique.push(h);
|
|
56
|
+
}
|
|
57
|
+
const viirs = unique.filter((h) => !h.satellite.startsWith('MODIS'));
|
|
58
|
+
return unique.filter((h) => {
|
|
59
|
+
if (!h.satellite.startsWith('MODIS'))
|
|
60
|
+
return true;
|
|
61
|
+
const t = Date.parse(h.time);
|
|
62
|
+
return !viirs.some((v) => Math.abs(Date.parse(v.time) - t) <= minutes * 60_000 && Math.hypot((v.lat - h.lat) * 111, (v.lon - h.lon) * 111 * Math.cos((h.lat * Math.PI) / 180)) <= km);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** FIRMS products with near-real-time data up to `sinceDay` (YYYY-MM-DD), from the data_availability endpoint. */
|
|
66
|
+
export function parseAvailability(csv, sinceDay) {
|
|
67
|
+
const [head, ...rows] = csv.trim().split('\n');
|
|
68
|
+
if (!head?.startsWith('data_id'))
|
|
69
|
+
return [];
|
|
70
|
+
return rows
|
|
71
|
+
.map((r) => r.trim().split(','))
|
|
72
|
+
.filter((c) => c[0]?.endsWith('_NRT') && (c[2] ?? '') >= sinceDay)
|
|
73
|
+
.map((c) => c[0]);
|
|
74
|
+
}
|
|
75
|
+
export function clusterHotspots(hs, km = 3) {
|
|
76
|
+
const out = [];
|
|
77
|
+
for (const h of [...hs].sort((a, b) => b.frp - a.frp)) {
|
|
78
|
+
const c = out.find((x) => Math.hypot((x.lat - h.lat) * 111, (x.lon - h.lon) * 111 * Math.cos((h.lat * Math.PI) / 180)) <= km);
|
|
79
|
+
if (c) {
|
|
80
|
+
c.count++;
|
|
81
|
+
c.frp += h.frp;
|
|
82
|
+
if (h.time > c.last)
|
|
83
|
+
c.last = h.time;
|
|
84
|
+
}
|
|
85
|
+
else
|
|
86
|
+
out.push({ lat: h.lat, lon: h.lon, count: 1, frp: h.frp, last: h.time });
|
|
87
|
+
}
|
|
88
|
+
return out.map((c) => ({ ...c, frp: Math.round(c.frp) })).sort((a, b) => b.frp - a.frp);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* `opts.products` overrides the FIRMS products queried (default: every VIIRS NRT product with current data plus
|
|
92
|
+
* MODIS_NRT; add LANDSAT_NRT for 30 m detections over the US and Canada, which carry no FRP).
|
|
93
|
+
*/
|
|
94
|
+
export async function fires(ctx, placeQuery, days = 2, opts = {}) {
|
|
95
|
+
const now = ctx.now();
|
|
96
|
+
const provenance = [];
|
|
97
|
+
const d = Math.max(1, Math.min(5, Math.round(days)));
|
|
98
|
+
const g = await geocode(ctx, placeQuery, 1);
|
|
99
|
+
provenance.push(g.prov);
|
|
100
|
+
const place = g.data?.[0] ?? null;
|
|
101
|
+
const empty = (p) => ({ module: 'fires', input: placeQuery, generatedAt: now.toISOString(), result: { place, days: d, hotspots: [], high: 0, totalFrp: 0, clusters: [] }, signals: [], provenance: [...provenance, p] });
|
|
102
|
+
const k = key('FIRMS_MAP_KEY');
|
|
103
|
+
if (!k)
|
|
104
|
+
return empty(noKey('firms', 'FIRMS_MAP_KEY').prov);
|
|
105
|
+
if (!place)
|
|
106
|
+
return empty({ source: 'nominatim', url: '', status: 'UNAVAILABLE', fetchedAt: now.toISOString(), note: `place not found: ${placeQuery}` });
|
|
107
|
+
// At least ~1 degree around the place so a town's surroundings are included; at most ~6 degrees.
|
|
108
|
+
let [s, n, w, e] = place.bbox;
|
|
109
|
+
const pad = (lo, hi, c) => (hi - lo < 1 ? [c - 0.5, c + 0.5] : hi - lo > 6 ? [c - 3, c + 3] : [lo, hi]);
|
|
110
|
+
[s, n] = pad(s, n, place.lat);
|
|
111
|
+
[w, e] = pad(w, e, place.lon);
|
|
112
|
+
const area = [w, s, e, n].map((x) => x.toFixed(3)).join(',');
|
|
113
|
+
// Skip products whose feed has stopped (e.g. a satellite in safe mode): ask FIRMS what is current, once a day.
|
|
114
|
+
let products = opts.products?.length ? opts.products.filter((p) => p in FIRMS_PRODUCTS) : DEFAULT_PRODUCTS;
|
|
115
|
+
if (!opts.products?.length) {
|
|
116
|
+
const av = await ctx.http.get(`https://firms.modaps.eosdis.nasa.gov/api/data_availability/csv/${k}/all`, { source: 'firms', as: 'text', ttlSec: 6 * 3600, timeoutMs: 30_000 });
|
|
117
|
+
provenance.push(av.prov);
|
|
118
|
+
const current = av.data ? parseAvailability(av.data, new Date(now.getTime() - (d + 1) * 86_400_000).toISOString().slice(0, 10)) : [];
|
|
119
|
+
if (current.length)
|
|
120
|
+
products = DEFAULT_PRODUCTS.filter((p) => current.includes(p));
|
|
121
|
+
}
|
|
122
|
+
const raw = [];
|
|
123
|
+
const results = await Promise.all(products.map(async (src) => ({ src, r: await ctx.http.get(`https://firms.modaps.eosdis.nasa.gov/api/area/csv/${k}/${src}/${area}/${d}`, { source: 'firms', as: 'text', ttlSec: 1800, timeoutMs: 60_000 }) })));
|
|
124
|
+
for (const { src, r } of results) {
|
|
125
|
+
provenance.push(r.prov);
|
|
126
|
+
if (r.data)
|
|
127
|
+
raw.push(...parseFirmsCsv(r.data, FIRMS_PRODUCTS[src]).map((h) => ({ ...h, product: src })));
|
|
128
|
+
}
|
|
129
|
+
const hotspots = dedupeHotspots(raw);
|
|
130
|
+
hotspots.sort((a, b) => b.time.localeCompare(a.time));
|
|
131
|
+
const high = hotspots.filter((h) => h.confidence === 'high').length;
|
|
132
|
+
const totalFrp = Math.round(hotspots.reduce((t, h) => t + h.frp, 0));
|
|
133
|
+
const clusters = clusterHotspots(hotspots);
|
|
134
|
+
const signals = [];
|
|
135
|
+
const big = clusters.filter((c) => c.count >= 10 || c.frp >= 500);
|
|
136
|
+
if (big.length) {
|
|
137
|
+
const top = big[0];
|
|
138
|
+
signals.push({
|
|
139
|
+
id: signalId('fires', place.name, now.toISOString().slice(0, 10)),
|
|
140
|
+
module: 'fires',
|
|
141
|
+
title: `Large fire activity near ${place.name.split(',')[0]}: ${big.length} cluster(s), largest ${top.count} detections, ${top.frp} MW`,
|
|
142
|
+
score: Math.min(85, 55 + big.length * 3 + Math.min(15, Math.round(top.frp / 200))),
|
|
143
|
+
evidence: big.slice(0, 3).map((c) => ({ source: 'nasa-firms', text: `${c.count} hotspots at ${c.lat.toFixed(3)}, ${c.lon.toFixed(3)} totaling ${c.frp} MW, last ${c.last.slice(0, 16).replace('T', ' ')} UTC`, url: `https://firms.modaps.eosdis.nasa.gov/map/#d:24hrs;@${c.lon.toFixed(3)},${c.lat.toFixed(3)},11z` })),
|
|
144
|
+
createdAt: now.toISOString(),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
for (const sig of signals)
|
|
148
|
+
ctx.graph.saveSignal(sig);
|
|
149
|
+
return { module: 'fires', input: placeQuery, generatedAt: now.toISOString(), result: { place, days: d, hotspots, high, totalFrp, clusters }, signals, provenance };
|
|
150
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hazards: official orange and red disaster alerts from GDACS (the UN / European Commission Global Disaster
|
|
3
|
+
* Alert and Coordination System, no key): earthquakes, tropical cyclones, floods, volcanoes, droughts and
|
|
4
|
+
* wildfires, each with its severity and affected countries. Red alerts and new orange alerts become signals.
|
|
5
|
+
*/
|
|
6
|
+
import type { Ctx } from '../core/context.js';
|
|
7
|
+
import type { ModuleResult } from '../core/types.js';
|
|
8
|
+
export interface Hazard {
|
|
9
|
+
id: string;
|
|
10
|
+
type: string;
|
|
11
|
+
name: string;
|
|
12
|
+
level: 'Red' | 'Orange' | 'Green';
|
|
13
|
+
countries: string;
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
current: boolean;
|
|
17
|
+
severity: string;
|
|
18
|
+
lat: number | null;
|
|
19
|
+
lon: number | null;
|
|
20
|
+
url: string;
|
|
21
|
+
}
|
|
22
|
+
export interface Bulletin {
|
|
23
|
+
source: 'NTWC' | 'PTWC' | 'NWS';
|
|
24
|
+
title: string;
|
|
25
|
+
category: string;
|
|
26
|
+
area: string;
|
|
27
|
+
issued: string;
|
|
28
|
+
url: string;
|
|
29
|
+
}
|
|
30
|
+
/** Tsunami bulletins (US warning centers) and extreme or severe US weather alerts (NWS). */
|
|
31
|
+
export declare function bulletins(ctx: Ctx, days?: number): Promise<{
|
|
32
|
+
data: Bulletin[];
|
|
33
|
+
prov: import('../core/types.js').Provenance[];
|
|
34
|
+
}>;
|
|
35
|
+
export declare function hazards(ctx: Ctx, days?: number): Promise<ModuleResult<Hazard[] & {
|
|
36
|
+
bulletins?: Bulletin[];
|
|
37
|
+
}>>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { signalId } from '../core/text.js';
|
|
2
|
+
const TYPES = { EQ: 'earthquake', TC: 'tropical cyclone', FL: 'flood', VO: 'volcano', DR: 'drought', WF: 'wildfire' };
|
|
3
|
+
const TSUNAMI_FEEDS = [
|
|
4
|
+
['NTWC', 'https://www.tsunami.gov/events/xml/PAAQAtom.xml'],
|
|
5
|
+
['PTWC', 'https://www.tsunami.gov/events/xml/PHEBAtom.xml'],
|
|
6
|
+
];
|
|
7
|
+
const NWS_SIGNAL = /^(Tsunami Warning|Hurricane Warning|Typhoon Warning|Extreme Wind Warning|Tornado Emergency|Flash Flood Emergency|Storm Surge Warning)/;
|
|
8
|
+
/** Tsunami bulletins (US warning centers) and extreme or severe US weather alerts (NWS). */
|
|
9
|
+
export async function bulletins(ctx, days = 2) {
|
|
10
|
+
const since = ctx.now().getTime() - days * 86_400_000;
|
|
11
|
+
const out = [];
|
|
12
|
+
const prov = [];
|
|
13
|
+
for (const [src, url] of TSUNAMI_FEEDS) {
|
|
14
|
+
const r = await ctx.http.get(url, { source: 'tsunami-gov', as: 'text', ttlSec: 600 });
|
|
15
|
+
prov.push(r.prov);
|
|
16
|
+
for (const e of (r.data ?? '').split('<entry>').slice(1)) {
|
|
17
|
+
const updated = /<updated>([^<]+)<\/updated>/.exec(e)?.[1] ?? '';
|
|
18
|
+
if (!updated || Date.parse(updated) < since)
|
|
19
|
+
continue;
|
|
20
|
+
const category = /Category:<\/strong>\s*([^<]+)/.exec(e)?.[1]?.trim() ?? 'Information';
|
|
21
|
+
const link = /<link[^>]*href="([^"]+)"/.exec(e)?.[1] ?? 'https://www.tsunami.gov';
|
|
22
|
+
out.push({ source: src, title: (/<title>([^<]+)<\/title>/.exec(e)?.[1] ?? '').trim(), category, area: (/Affected Region:\s*<\/strong>\s*([^<]+)/.exec(e)?.[1] ?? '').trim(), issued: updated, url: link });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const nws = await ctx.http.get('https://api.weather.gov/alerts/active?severity=Extreme,Severe&status=actual&message_type=alert', { source: 'nws', ttlSec: 600, headers: { accept: 'application/geo+json' } });
|
|
26
|
+
prov.push(nws.prov);
|
|
27
|
+
for (const f of nws.data?.features ?? []) {
|
|
28
|
+
const p = f.properties;
|
|
29
|
+
out.push({ source: 'NWS', title: p.event, category: p.severity, area: p.areaDesc.slice(0, 160), issued: p.sent, url: p.id ?? 'https://alerts.weather.gov' });
|
|
30
|
+
}
|
|
31
|
+
return { data: out, prov };
|
|
32
|
+
}
|
|
33
|
+
export async function hazards(ctx, days = 7) {
|
|
34
|
+
const now = ctx.now();
|
|
35
|
+
const from = new Date(now.getTime() - days * 86_400_000).toISOString().slice(0, 10);
|
|
36
|
+
const r = await ctx.http.get(`https://www.gdacs.org/gdacsapi/api/events/geteventlist/SEARCH?alertlevel=Orange;Red&eventlist=EQ;TC;FL;VO;DR;WF&fromDate=${from}`, { source: 'gdacs', ttlSec: 1800, timeoutMs: 45_000 });
|
|
37
|
+
const list = (r.data?.features ?? []).map((f) => {
|
|
38
|
+
const p = f.properties;
|
|
39
|
+
return {
|
|
40
|
+
id: `${p.eventtype}-${p.eventid}`,
|
|
41
|
+
type: TYPES[p.eventtype] ?? p.eventtype,
|
|
42
|
+
name: p.name,
|
|
43
|
+
level: (['Red', 'Orange', 'Green'].includes(p.alertlevel) ? p.alertlevel : 'Orange'),
|
|
44
|
+
countries: p.country ?? '',
|
|
45
|
+
from: p.fromdate,
|
|
46
|
+
to: p.todate,
|
|
47
|
+
current: p.iscurrent === true || p.iscurrent === 'true',
|
|
48
|
+
severity: p.severitydata?.severitytext ?? '',
|
|
49
|
+
lat: f.geometry?.coordinates?.[1] ?? null,
|
|
50
|
+
lon: f.geometry?.coordinates?.[0] ?? null,
|
|
51
|
+
url: p.url?.report ?? 'https://www.gdacs.org',
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
list.sort((a, b) => Number(b.level === 'Red') - Number(a.level === 'Red') || b.to.localeCompare(a.to));
|
|
55
|
+
const signals = list
|
|
56
|
+
.filter((h) => h.current || now.getTime() - Date.parse(`${h.to}Z`) < 2 * 86_400_000)
|
|
57
|
+
.map((h) => ({
|
|
58
|
+
id: signalId('hazards', h.id, h.level),
|
|
59
|
+
module: 'hazards',
|
|
60
|
+
title: `GDACS ${h.level.toLowerCase()} alert: ${h.name}${h.countries ? ` (${h.countries})` : ''}`,
|
|
61
|
+
score: h.level === 'Red' ? 82 : 66,
|
|
62
|
+
evidence: [{ source: 'gdacs', text: `${h.type}${h.severity ? `, ${h.severity}` : ''}, ${h.from.slice(0, 10)} to ${h.to.slice(0, 10)}`, url: h.url }],
|
|
63
|
+
createdAt: now.toISOString(),
|
|
64
|
+
}));
|
|
65
|
+
const b = await bulletins(ctx, 2);
|
|
66
|
+
for (const x of b.data) {
|
|
67
|
+
const tsunamiThreat = x.source !== 'NWS' && /warning|advisory|watch|threat/i.test(x.category);
|
|
68
|
+
if (!tsunamiThreat && !(x.source === 'NWS' && NWS_SIGNAL.test(x.title)))
|
|
69
|
+
continue;
|
|
70
|
+
signals.push({
|
|
71
|
+
id: signalId('hazards', x.source, x.title, x.area.slice(0, 60), x.issued.slice(0, 13)),
|
|
72
|
+
module: 'hazards',
|
|
73
|
+
title: x.source === 'NWS' ? `${x.title}: ${x.area.split(';').slice(0, 3).join(';')}` : `Tsunami ${x.category.toLowerCase()}: ${x.title}`,
|
|
74
|
+
score: tsunamiThreat && /warning/i.test(x.category) ? 88 : 72,
|
|
75
|
+
evidence: [{ source: x.source === 'NWS' ? 'nws' : 'tsunami-gov', text: `${x.category}, issued ${x.issued.slice(0, 16).replace('T', ' ')} UTC${x.area ? `, ${x.area.slice(0, 120)}` : ''}`, url: x.url }],
|
|
76
|
+
createdAt: now.toISOString(),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
for (const s of signals)
|
|
80
|
+
ctx.graph.saveSignal(s);
|
|
81
|
+
const result = Object.assign(list, { bulletins: b.data });
|
|
82
|
+
return { module: 'hazards', input: `${days}d`, generatedAt: now.toISOString(), result, signals, provenance: [r.prov, ...b.prov] };
|
|
83
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Company early-warning score: one 0-100 number from hiring momentum, new lawsuits, insider selling, news tone,
|
|
3
|
+
* GitHub activity and today's stock move, each part shown with its contribution. Scored daily; a sharp drop
|
|
4
|
+
* against the company's own recent average is a signal.
|
|
5
|
+
*/
|
|
6
|
+
import { type Ctx } from '../core/context.js';
|
|
7
|
+
import type { ModuleResult } from '../core/types.js';
|
|
8
|
+
export interface HealthPart {
|
|
9
|
+
name: string;
|
|
10
|
+
points: number;
|
|
11
|
+
why: string;
|
|
12
|
+
}
|
|
13
|
+
export interface HealthResult {
|
|
14
|
+
company: string;
|
|
15
|
+
score: number;
|
|
16
|
+
parts: HealthPart[];
|
|
17
|
+
history: {
|
|
18
|
+
day: string;
|
|
19
|
+
score: number;
|
|
20
|
+
}[];
|
|
21
|
+
change: number | null;
|
|
22
|
+
}
|
|
23
|
+
export declare function lexiconTone(titles: string[]): number;
|
|
24
|
+
export declare function health(ctx: Ctx, company: string): Promise<ModuleResult<HealthResult>>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Company early-warning score: one 0-100 number from hiring momentum, new lawsuits, insider selling, news tone,
|
|
3
|
+
* GitHub activity and today's stock move, each part shown with its contribution. Scored daily; a sharp drop
|
|
4
|
+
* against the company's own recent average is a signal.
|
|
5
|
+
*/
|
|
6
|
+
import { DAY_MS } from '../core/context.js';
|
|
7
|
+
import { availableProviders, chat } from '../core/llm.js';
|
|
8
|
+
import { clamp, mean } from '../core/stats.js';
|
|
9
|
+
import { signalId } from '../core/text.js';
|
|
10
|
+
import { hound } from './hound.js';
|
|
11
|
+
const NEG = /\b(lawsuit|sued|probe|investigation|resign|ousted|layoff|layoffs|fraud|plunge|slump|falls|fell|recall|breach|outage|fine|fined|scandal|downgrade|crisis|warning|ban|banned|delay|delayed)\b/i;
|
|
12
|
+
const POS = /\b(record|beats|surge|soar|launch|launches|partnership|deal|wins|approval|approved|upgrade|growth|expands|raises|profit)\b/i;
|
|
13
|
+
export function lexiconTone(titles) {
|
|
14
|
+
if (!titles.length)
|
|
15
|
+
return 0;
|
|
16
|
+
return mean(titles.map((t) => (NEG.test(t) ? -1 : 0) + (POS.test(t) ? 1 : 0)));
|
|
17
|
+
}
|
|
18
|
+
/** Mean tone of headlines in [-1, 1]: LLM when available, a word list otherwise. */
|
|
19
|
+
async function tone(titles) {
|
|
20
|
+
if (!titles.length)
|
|
21
|
+
return { value: 0, method: 'none' };
|
|
22
|
+
if (availableProviders().length) {
|
|
23
|
+
try {
|
|
24
|
+
const r = await chat([
|
|
25
|
+
{ role: 'system', content: 'Rate each headline for how good or bad it is for the company: -1 bad, 0 neutral, 1 good. Reply JSON {"scores":[numbers in order]}.' },
|
|
26
|
+
{ role: 'user', content: titles.map((t, i) => `${i}. ${t}`).join('\n') },
|
|
27
|
+
], { json: true, temperature: 0, maxTokens: 600 });
|
|
28
|
+
const s = (JSON.parse(r.message.content ?? '{}').scores ?? []).map(Number).filter((x) => Number.isFinite(x));
|
|
29
|
+
if (s.length)
|
|
30
|
+
return { value: clamp(mean(s), -1, 1), method: 'llm' };
|
|
31
|
+
}
|
|
32
|
+
catch { }
|
|
33
|
+
}
|
|
34
|
+
return { value: lexiconTone(titles), method: 'lexicon' };
|
|
35
|
+
}
|
|
36
|
+
export async function health(ctx, company) {
|
|
37
|
+
const nowMs = ctx.now().getTime();
|
|
38
|
+
const r = await hound(ctx, company);
|
|
39
|
+
const d = r.result;
|
|
40
|
+
const parts = [];
|
|
41
|
+
const openings = d.hiring ? d.hiring.reduce((a, h) => a + h.openings, 0) : null;
|
|
42
|
+
if (d.hiring?.change != null) {
|
|
43
|
+
const p = Math.round(clamp(d.hiring.change * 40, -12, 12));
|
|
44
|
+
parts.push({ name: 'hiring', points: p, why: `job openings ${d.hiring.change >= 0 ? '+' : ''}${Math.round(d.hiring.change * 100)}% since last check (${openings})` });
|
|
45
|
+
}
|
|
46
|
+
else if (openings !== null)
|
|
47
|
+
parts.push({ name: 'hiring', points: 0, why: `${openings} open roles (no earlier check to compare)` });
|
|
48
|
+
const recentCases = d.court?.cases.filter((c) => Date.parse(c.filed) >= nowMs - 14 * DAY_MS).length ?? 0;
|
|
49
|
+
if (d.court)
|
|
50
|
+
parts.push({ name: 'legal', points: -Math.min(15, recentCases * 4), why: `${recentCases} federal case(s) filed in 14 days` });
|
|
51
|
+
const sells = d.stock?.insiders.filter((t) => t.code === 'S' && Date.parse(t.date) >= nowMs - 30 * DAY_MS).length ?? 0;
|
|
52
|
+
const buys = d.stock?.insiders.filter((t) => t.code === 'P' && Date.parse(t.date) >= nowMs - 30 * DAY_MS).length ?? 0;
|
|
53
|
+
if (d.stock)
|
|
54
|
+
parts.push({ name: 'insiders', points: clamp(buys * 3 - sells * 2, -12, 8), why: `${sells} open-market sale(s), ${buys} purchase(s) by insiders in 30 days` });
|
|
55
|
+
const titles = d.news.slice(0, 15).map((n) => n.title);
|
|
56
|
+
const t = await tone(titles);
|
|
57
|
+
parts.push({ name: 'news tone', points: Math.round(t.value * 15), why: `${titles.length} recent headlines, mean tone ${t.value.toFixed(2)} (${t.method})` });
|
|
58
|
+
if (d.github)
|
|
59
|
+
parts.push({ name: 'shipping', points: Math.min(6, d.github.repos.length * 2), why: `${d.github.repos.length} new public repo(s) in 14 days` });
|
|
60
|
+
if (d.stock?.quote)
|
|
61
|
+
parts.push({ name: 'stock', points: Math.round(clamp(d.stock.quote.changePct, -10, 10)), why: `${d.stock.symbol} ${d.stock.quote.changePct >= 0 ? '+' : ''}${d.stock.quote.changePct.toFixed(1)}% today` });
|
|
62
|
+
const score = Math.round(clamp(50 + parts.reduce((a, p) => a + p.points, 0), 0, 100));
|
|
63
|
+
const db = ctx.store.db;
|
|
64
|
+
const day = new Date(nowMs).toISOString().slice(0, 10);
|
|
65
|
+
db.prepare('INSERT INTO health (company, day, score, parts) VALUES (?, ?, ?, ?) ON CONFLICT(company, day) DO UPDATE SET score = excluded.score, parts = excluded.parts').run(company.toLowerCase(), day, score, JSON.stringify(parts));
|
|
66
|
+
const history = db.prepare('SELECT day, score FROM health WHERE company = ? ORDER BY day DESC LIMIT 30').all(company.toLowerCase()).reverse();
|
|
67
|
+
const prior = history.filter((h) => h.day !== day).slice(-7).map((h) => h.score);
|
|
68
|
+
const change = prior.length ? score - mean(prior) : null;
|
|
69
|
+
const signals = [];
|
|
70
|
+
if (change !== null && change <= -15) {
|
|
71
|
+
signals.push({
|
|
72
|
+
id: signalId('health', company, day),
|
|
73
|
+
module: 'health',
|
|
74
|
+
title: `${company} health score fell ${Math.round(-change)} points to ${score}`,
|
|
75
|
+
score: clamp(Math.round(55 - change), 0, 90),
|
|
76
|
+
evidence: parts.filter((p) => p.points < 0).map((p) => ({ source: `health:${p.name}`, text: `${p.points} pts: ${p.why}` })),
|
|
77
|
+
createdAt: new Date(nowMs).toISOString(),
|
|
78
|
+
});
|
|
79
|
+
signals.forEach((s) => ctx.graph.saveSignal(s));
|
|
80
|
+
}
|
|
81
|
+
return { module: 'health', input: company, generatedAt: new Date(nowMs).toISOString(), result: { company, score, parts, history, change: change === null ? null : Math.round(change) }, signals: [...signals, ...r.signals], provenance: r.provenance };
|
|
82
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heron: Robinhood Chain watcher.
|
|
3
|
+
* overview(): chain activity, trending pools, and pools born in the last hours with quick risk flags.
|
|
4
|
+
* rhTokenCheck(): risk read on one token. GoPlus does not cover chain 4663, so the rules are Oculon's own:
|
|
5
|
+
* unverified contract, top-10 holder concentration, pool age, liquidity, and buys-without-sells (honeypot shape).
|
|
6
|
+
*/
|
|
7
|
+
import type { Ctx } from '../core/context.js';
|
|
8
|
+
import type { ModuleResult } from '../core/types.js';
|
|
9
|
+
import { type ChainStats, type Pool } from '../sources/robinhood.js';
|
|
10
|
+
export interface PoolFlags {
|
|
11
|
+
pool: Pool;
|
|
12
|
+
ageHours: number;
|
|
13
|
+
flags: string[];
|
|
14
|
+
}
|
|
15
|
+
/** Flags that need no extra calls: from pool data alone. */
|
|
16
|
+
export declare function poolFlags(p: Pool, nowMs: number): PoolFlags;
|
|
17
|
+
export interface OverviewResult {
|
|
18
|
+
stats: ChainStats | null;
|
|
19
|
+
trending: PoolFlags[];
|
|
20
|
+
fresh: PoolFlags[];
|
|
21
|
+
}
|
|
22
|
+
export declare function overview(ctx: Ctx): Promise<ModuleResult<OverviewResult>>;
|
|
23
|
+
export interface DeployerProfile {
|
|
24
|
+
deployer: string;
|
|
25
|
+
contracts: number;
|
|
26
|
+
tokens: {
|
|
27
|
+
address: string;
|
|
28
|
+
symbol: string | null;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
reserveUsd: number;
|
|
31
|
+
dead: boolean;
|
|
32
|
+
}[];
|
|
33
|
+
dead: number;
|
|
34
|
+
verdict: 'DANGER' | 'CAUTION' | 'OK' | 'UNKNOWN';
|
|
35
|
+
reasons: string[];
|
|
36
|
+
}
|
|
37
|
+
export declare function deployerVerdict(tokens: DeployerProfile['tokens']): {
|
|
38
|
+
verdict: DeployerProfile['verdict'];
|
|
39
|
+
reasons: string[];
|
|
40
|
+
};
|
|
41
|
+
/** Everything one address deployed on Robinhood Chain, and how those tokens are doing now. Accepts a token or a deployer. */
|
|
42
|
+
export declare function deployerProfile(ctx: Ctx, address: string): Promise<ModuleResult<DeployerProfile>>;
|
|
43
|
+
export interface RhTokenResult {
|
|
44
|
+
address: string;
|
|
45
|
+
deployer: {
|
|
46
|
+
address: string;
|
|
47
|
+
otherTokens: number;
|
|
48
|
+
dead: number;
|
|
49
|
+
};
|
|
50
|
+
name: string | null;
|
|
51
|
+
symbol: string | null;
|
|
52
|
+
holders: number | null;
|
|
53
|
+
verified: boolean | null;
|
|
54
|
+
top10Share: number | null;
|
|
55
|
+
pools: PoolFlags[];
|
|
56
|
+
verdict: 'DANGER' | 'CAUTION' | 'OK' | 'UNKNOWN';
|
|
57
|
+
reasons: string[];
|
|
58
|
+
}
|
|
59
|
+
export declare function rhVerdict(input: {
|
|
60
|
+
verified: boolean | null;
|
|
61
|
+
top10Share: number | null;
|
|
62
|
+
holders: number | null;
|
|
63
|
+
pools: PoolFlags[];
|
|
64
|
+
}): {
|
|
65
|
+
verdict: RhTokenResult['verdict'];
|
|
66
|
+
reasons: string[];
|
|
67
|
+
};
|
|
68
|
+
export declare function rhTokenCheck(ctx: Ctx, address: string): Promise<ModuleResult<RhTokenResult>>;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { clamp } from '../core/stats.js';
|
|
2
|
+
import { signalId } from '../core/text.js';
|
|
3
|
+
import { addressInfo, chainStats, contractCreator, createdContracts, isVerified, launchesVia, txParties, newPools, rhToken, tokenPools, tokensMarket, topHolderShare, trendingPools } from '../sources/robinhood.js';
|
|
4
|
+
/** Flags that need no extra calls: from pool data alone. */
|
|
5
|
+
export function poolFlags(p, nowMs) {
|
|
6
|
+
const ageHours = Math.max(0, (nowMs - Date.parse(p.createdAt)) / 3_600_000);
|
|
7
|
+
const flags = [];
|
|
8
|
+
if (p.liquidityUsd < 5_000)
|
|
9
|
+
flags.push(`thin liquidity $${Math.round(p.liquidityUsd).toLocaleString('en-US')}`);
|
|
10
|
+
if (p.buys24h >= 20 && p.sells24h === 0)
|
|
11
|
+
flags.push(`${p.buys24h} buys and no sells (honeypot shape)`);
|
|
12
|
+
else if (p.buys24h >= 30 && p.sells24h / p.buys24h < 0.05)
|
|
13
|
+
flags.push(`sells only ${p.sells24h} vs ${p.buys24h} buys`);
|
|
14
|
+
if (p.change1h !== null && p.change1h <= -60)
|
|
15
|
+
flags.push(`price ${p.change1h.toFixed(0)}% in 1h (possible rug)`);
|
|
16
|
+
if (p.fdvUsd && p.liquidityUsd && p.liquidityUsd < 100_000 && p.fdvUsd / p.liquidityUsd > 200)
|
|
17
|
+
flags.push('valuation far above liquidity');
|
|
18
|
+
return { pool: p, ageHours, flags };
|
|
19
|
+
}
|
|
20
|
+
export async function overview(ctx) {
|
|
21
|
+
const nowMs = ctx.now().getTime();
|
|
22
|
+
const nowIso = new Date(nowMs).toISOString();
|
|
23
|
+
const [st, tr, nw] = await Promise.all([chainStats(ctx), trendingPools(ctx), newPools(ctx)]);
|
|
24
|
+
const trending = (tr.data ?? []).slice(0, 15).map((p) => poolFlags(p, nowMs));
|
|
25
|
+
const fresh = (nw.data ?? []).slice(0, 20).map((p) => poolFlags(p, nowMs));
|
|
26
|
+
const signals = [];
|
|
27
|
+
// A trending pool that moves hard with real liquidity is worth a signal; so is a fresh pool with real traction.
|
|
28
|
+
for (const t of trending) {
|
|
29
|
+
const ch = t.pool.change24h ?? 0;
|
|
30
|
+
if (Math.abs(ch) >= 40 && t.pool.liquidityUsd >= 50_000) {
|
|
31
|
+
signals.push({
|
|
32
|
+
id: signalId('heron', t.pool.address, nowIso.slice(0, 10)),
|
|
33
|
+
module: 'heron',
|
|
34
|
+
title: `${t.pool.name} ${ch > 0 ? '+' : ''}${ch.toFixed(0)}% in 24h on Robinhood Chain`,
|
|
35
|
+
score: clamp(Math.round(45 + Math.abs(ch) / 4), 0, 85),
|
|
36
|
+
evidence: [{ source: 'geckoterminal', text: `liquidity $${Math.round(t.pool.liquidityUsd).toLocaleString('en-US')}, volume $${Math.round(t.pool.volume24h).toLocaleString('en-US')}${t.flags.length ? `; ${t.flags.join(', ')}` : ''}`, url: t.pool.url }],
|
|
37
|
+
createdAt: nowIso,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
for (const f of fresh) {
|
|
42
|
+
if (f.ageHours <= 6 && f.pool.volume24h >= 50_000 && f.pool.buyers24h >= 50) {
|
|
43
|
+
signals.push({
|
|
44
|
+
id: signalId('heron', 'fresh', f.pool.address),
|
|
45
|
+
module: 'heron',
|
|
46
|
+
title: `New Robinhood Chain pool ${f.pool.name} drew $${Math.round(f.pool.volume24h).toLocaleString('en-US')} volume in ${f.ageHours.toFixed(1)}h`,
|
|
47
|
+
score: f.flags.length ? 50 : 62,
|
|
48
|
+
evidence: [{ source: 'geckoterminal', text: `${f.pool.buyers24h} buyers, ${f.pool.sellers24h} sellers, liquidity $${Math.round(f.pool.liquidityUsd).toLocaleString('en-US')}${f.flags.length ? `; flags: ${f.flags.join(', ')}` : ''}`, url: f.pool.url }],
|
|
49
|
+
createdAt: nowIso,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
signals.forEach((s) => ctx.graph.saveSignal(s));
|
|
54
|
+
if (st.data)
|
|
55
|
+
ctx.graph.observe(ctx.graph.upsert('event', 'chain:robinhood'), 'heron', 'tx_today', st.data.transactionsToday, 'blockscout');
|
|
56
|
+
return { module: 'heron', input: 'robinhood', generatedAt: nowIso, result: { stats: st.data, trending, fresh }, signals, provenance: [st.prov, tr.prov, nw.prov] };
|
|
57
|
+
}
|
|
58
|
+
/** Pools under $100 of liquidity after a day are treated as dead (abandoned or drained). */
|
|
59
|
+
const DEAD_RESERVE = 100;
|
|
60
|
+
export function deployerVerdict(tokens) {
|
|
61
|
+
const dead = tokens.filter((t) => t.dead).length;
|
|
62
|
+
if (!tokens.length)
|
|
63
|
+
return { verdict: 'UNKNOWN', reasons: ['no traded tokens from this deployer'] };
|
|
64
|
+
if (tokens.length >= 3 && dead / tokens.length >= 0.7)
|
|
65
|
+
return { verdict: 'DANGER', reasons: [`serial launcher: ${dead} of ${tokens.length} tokens from this deployer are dead`] };
|
|
66
|
+
if (dead >= 2)
|
|
67
|
+
return { verdict: 'CAUTION', reasons: [`${dead} of ${tokens.length} earlier tokens from this deployer are dead`] };
|
|
68
|
+
return { verdict: 'OK', reasons: [`${tokens.length} traded token(s), ${dead} dead`] };
|
|
69
|
+
}
|
|
70
|
+
/** Everything one address deployed on Robinhood Chain, and how those tokens are doing now. Accepts a token or a deployer. */
|
|
71
|
+
export async function deployerProfile(ctx, address) {
|
|
72
|
+
const nowMs = ctx.now().getTime();
|
|
73
|
+
const provenance = [];
|
|
74
|
+
const cr = await contractCreator(ctx, address);
|
|
75
|
+
provenance.push(cr.prov);
|
|
76
|
+
let deployer = cr.data?.creator ?? address;
|
|
77
|
+
let via = null;
|
|
78
|
+
// Launchpad tokens are created by a factory contract; the real deployer is the wallet that called it.
|
|
79
|
+
if (cr.data) {
|
|
80
|
+
const info = await addressInfo(ctx, cr.data.creator);
|
|
81
|
+
provenance.push(info.prov);
|
|
82
|
+
if (info.data?.isContract && cr.data.creationTx) {
|
|
83
|
+
const tx = await txParties(ctx, cr.data.creationTx);
|
|
84
|
+
provenance.push(tx.prov);
|
|
85
|
+
if (tx.data?.from && tx.data.to) {
|
|
86
|
+
deployer = tx.data.from;
|
|
87
|
+
via = tx.data.to;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const created = via ? await launchesVia(ctx, deployer, via) : await createdContracts(ctx, deployer);
|
|
92
|
+
provenance.push(created.prov);
|
|
93
|
+
const contracts = created.data ?? [];
|
|
94
|
+
const market = await tokensMarket(ctx, contracts.map((c) => c.address));
|
|
95
|
+
provenance.push(market.prov);
|
|
96
|
+
const tokens = contracts
|
|
97
|
+
.filter((c) => market.data?.has(c.address.toLowerCase()))
|
|
98
|
+
.map((c) => {
|
|
99
|
+
const m = market.data.get(c.address.toLowerCase());
|
|
100
|
+
const ageH = (nowMs - Date.parse(c.createdAt)) / 3_600_000;
|
|
101
|
+
return { address: c.address, symbol: m.symbol, createdAt: c.createdAt, reserveUsd: Math.round(m.reserveUsd), dead: ageH > 24 && m.reserveUsd < DEAD_RESERVE };
|
|
102
|
+
});
|
|
103
|
+
const { verdict, reasons } = deployerVerdict(tokens);
|
|
104
|
+
const id = ctx.graph.upsert('event', `deployer:${deployer.toLowerCase()}`, { verdict, tokens: tokens.length, dead: tokens.filter((t) => t.dead).length, contracts: contracts.length });
|
|
105
|
+
for (const t of tokens)
|
|
106
|
+
ctx.graph.link(id, ctx.graph.upsert('event', `token:robinhood:${t.address.toLowerCase()}`, { symbol: t.symbol }), 'deployed', 'blockscout');
|
|
107
|
+
const nowIso = new Date(nowMs).toISOString();
|
|
108
|
+
const signals = [];
|
|
109
|
+
if (verdict === 'DANGER') {
|
|
110
|
+
signals.push({ id: signalId('heron', 'deployer', deployer), module: 'heron', title: `Robinhood Chain deployer ${deployer.slice(0, 10)}…: ${reasons[0]}`, score: 80, entity: id, evidence: tokens.slice(0, 6).map((t) => ({ source: 'heron', text: `${t.symbol ?? t.address.slice(0, 10)}: liquidity $${t.reserveUsd}${t.dead ? ' (dead)' : ''}` })), createdAt: nowIso });
|
|
111
|
+
signals.forEach((s) => ctx.graph.saveSignal(s));
|
|
112
|
+
}
|
|
113
|
+
return { module: 'heron', input: address, generatedAt: nowIso, result: { deployer, contracts: contracts.length, tokens, dead: tokens.filter((t) => t.dead).length, verdict, reasons }, signals, provenance };
|
|
114
|
+
}
|
|
115
|
+
export function rhVerdict(input) {
|
|
116
|
+
const reasons = [];
|
|
117
|
+
let level = 0;
|
|
118
|
+
if (input.verified === false) {
|
|
119
|
+
reasons.push('contract source not verified on Blockscout');
|
|
120
|
+
level = Math.max(level, 1);
|
|
121
|
+
}
|
|
122
|
+
if (input.top10Share !== null && input.top10Share >= 0.9) {
|
|
123
|
+
reasons.push(`top 10 holders own ${Math.round(input.top10Share * 100)}% of supply`);
|
|
124
|
+
level = Math.max(level, input.top10Share >= 0.97 && (input.holders ?? 0) < 200 ? 2 : 1);
|
|
125
|
+
}
|
|
126
|
+
for (const p of input.pools.slice(0, 3)) {
|
|
127
|
+
for (const f of p.flags) {
|
|
128
|
+
reasons.push(`${p.pool.name}: ${f}`);
|
|
129
|
+
level = Math.max(level, /honeypot|rug/.test(f) ? 2 : 1);
|
|
130
|
+
}
|
|
131
|
+
if (p.ageHours < 24) {
|
|
132
|
+
reasons.push(`${p.pool.name}: pool is ${p.ageHours.toFixed(1)}h old`);
|
|
133
|
+
level = Math.max(level, 1);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (input.verified === null && input.top10Share === null && !input.pools.length)
|
|
137
|
+
return { verdict: 'UNKNOWN', reasons: ['no explorer or pool data'] };
|
|
138
|
+
return { verdict: level === 2 ? 'DANGER' : level === 1 ? 'CAUTION' : 'OK', reasons };
|
|
139
|
+
}
|
|
140
|
+
export async function rhTokenCheck(ctx, address) {
|
|
141
|
+
const nowMs = ctx.now().getTime();
|
|
142
|
+
const nowIso = new Date(nowMs).toISOString();
|
|
143
|
+
const provenance = [];
|
|
144
|
+
const [tok, ver, pl] = await Promise.all([rhToken(ctx, address), isVerified(ctx, address), tokenPools(ctx, address)]);
|
|
145
|
+
provenance.push(tok.prov, ver.prov, pl.prov);
|
|
146
|
+
const share = tok.data ? await topHolderShare(ctx, address, tok.data.totalSupply) : null;
|
|
147
|
+
if (share)
|
|
148
|
+
provenance.push(share.prov);
|
|
149
|
+
const pools = (pl.data ?? []).map((p) => poolFlags(p, nowMs)).sort((a, b) => b.pool.liquidityUsd - a.pool.liquidityUsd);
|
|
150
|
+
const base = rhVerdict({ verified: ver.data, top10Share: share?.data ?? null, holders: tok.data?.holders ?? null, pools });
|
|
151
|
+
// The deployer's track record: other tokens it launched, and how many are dead now.
|
|
152
|
+
const dep = await deployerProfile(ctx, address);
|
|
153
|
+
provenance.push(...dep.provenance);
|
|
154
|
+
const others = dep.result.tokens.filter((t) => t.address.toLowerCase() !== address.toLowerCase());
|
|
155
|
+
const depVerdict = deployerVerdict(others);
|
|
156
|
+
const rank = { UNKNOWN: -1, OK: 0, CAUTION: 1, DANGER: 2 };
|
|
157
|
+
const verdict = others.length && rank[depVerdict.verdict] > rank[base.verdict] ? depVerdict.verdict : base.verdict;
|
|
158
|
+
const reasons = [...base.reasons, ...(others.length && depVerdict.verdict !== 'OK' ? depVerdict.reasons.map((r) => `deployer: ${r}`) : [])];
|
|
159
|
+
const name = tok.data?.symbol || address.slice(0, 10);
|
|
160
|
+
const signals = [];
|
|
161
|
+
if (verdict === 'DANGER') {
|
|
162
|
+
signals.push({ id: signalId('heron', 'token', address, nowIso.slice(0, 10)), module: 'heron', title: `${name} on Robinhood Chain: DANGER (${reasons.slice(0, 2).join(', ')})`, score: 80, evidence: reasons.map((r) => ({ source: 'heron', text: r })), createdAt: nowIso });
|
|
163
|
+
signals.forEach((s) => ctx.graph.saveSignal(s));
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
module: 'heron',
|
|
167
|
+
input: address,
|
|
168
|
+
generatedAt: nowIso,
|
|
169
|
+
result: {
|
|
170
|
+
address,
|
|
171
|
+
name: tok.data?.name ?? null,
|
|
172
|
+
symbol: tok.data?.symbol ?? null,
|
|
173
|
+
holders: tok.data?.holders ?? null,
|
|
174
|
+
verified: ver.data,
|
|
175
|
+
top10Share: share?.data ?? null,
|
|
176
|
+
pools: pools.slice(0, 6),
|
|
177
|
+
deployer: { address: dep.result.deployer, otherTokens: others.length, dead: others.filter((t) => t.dead).length },
|
|
178
|
+
verdict,
|
|
179
|
+
reasons,
|
|
180
|
+
},
|
|
181
|
+
signals,
|
|
182
|
+
provenance,
|
|
183
|
+
};
|
|
184
|
+
}
|