oculon 0.1.6 → 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.
- package/README.md +93 -17
- package/dist/cli/main.js +397 -0
- package/dist/core/calls.d.ts +63 -0
- package/dist/core/calls.js +120 -0
- package/dist/core/der.d.ts +2 -0
- package/dist/core/der.js +17 -0
- package/dist/core/http.d.ts +30 -1
- package/dist/core/http.js +133 -29
- package/dist/core/pdf.d.ts +51 -0
- package/dist/core/pdf.js +211 -0
- package/dist/core/qr.d.ts +23 -0
- package/dist/core/qr.js +577 -0
- package/dist/core/quota.js +5 -0
- package/dist/core/raster.d.ts +6 -0
- package/dist/core/raster.js +298 -0
- package/dist/core/safeurl.d.ts +5 -0
- package/dist/core/safeurl.js +26 -0
- package/dist/core/verdict.d.ts +30 -0
- package/dist/core/verdict.js +164 -0
- package/dist/core/zip.d.ts +9 -0
- package/dist/core/zip.js +46 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +128 -0
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.js +256 -6
- package/dist/modules/address.d.ts +6 -2
- package/dist/modules/address.js +32 -5
- package/dist/modules/apk.d.ts +37 -0
- package/dist/modules/apk.js +191 -0
- package/dist/modules/approvals.d.ts +40 -0
- package/dist/modules/approvals.js +155 -0
- package/dist/modules/archive.d.ts +21 -0
- package/dist/modules/archive.js +94 -0
- package/dist/modules/checks.d.ts +59 -0
- package/dist/modules/checks.js +167 -0
- package/dist/modules/contract.d.ts +56 -0
- package/dist/modules/contract.js +167 -0
- package/dist/modules/deployer.d.ts +42 -0
- package/dist/modules/deployer.js +90 -0
- package/dist/modules/doc.d.ts +83 -0
- package/dist/modules/doc.js +841 -0
- package/dist/modules/eml.d.ts +46 -0
- package/dist/modules/eml.js +175 -0
- package/dist/modules/hashcheck.d.ts +19 -3
- package/dist/modules/hashcheck.js +28 -4
- package/dist/modules/image.d.ts +32 -0
- package/dist/modules/image.js +276 -0
- package/dist/modules/invite.d.ts +27 -0
- package/dist/modules/invite.js +69 -0
- package/dist/modules/job.d.ts +33 -0
- package/dist/modules/job.js +64 -0
- package/dist/modules/meerkat.d.ts +1 -1
- package/dist/modules/meerkat.js +35 -2
- package/dist/modules/monitor.js +14 -0
- package/dist/modules/poisoning.d.ts +43 -0
- package/dist/modules/poisoning.js +114 -0
- package/dist/modules/qrcheck.d.ts +24 -0
- package/dist/modules/qrcheck.js +136 -0
- package/dist/modules/repo.d.ts +61 -0
- package/dist/modules/repo.js +162 -0
- package/dist/modules/report.d.ts +32 -0
- package/dist/modules/report.js +108 -0
- package/dist/modules/signature.d.ts +35 -0
- package/dist/modules/signature.js +283 -0
- package/dist/modules/site.d.ts +62 -0
- package/dist/modules/site.js +191 -0
- package/dist/modules/stocktoken.d.ts +48 -0
- package/dist/modules/stocktoken.js +99 -0
- package/dist/modules/trace.d.ts +37 -0
- package/dist/modules/trace.js +150 -0
- package/dist/modules/txexplain.d.ts +40 -0
- package/dist/modules/txexplain.js +135 -0
- package/dist/modules/urlcheck.js +15 -1
- package/dist/modules/utility.d.ts +27 -1
- package/dist/modules/utility.js +108 -11
- package/dist/modules/where.d.ts +63 -0
- package/dist/modules/where.js +165 -0
- package/dist/report-pdf.d.ts +7 -0
- package/dist/report-pdf.js +84 -0
- package/dist/sources/cfurlscan.d.ts +24 -0
- package/dist/sources/cfurlscan.js +46 -0
- package/dist/sources/chainabuse.d.ts +17 -0
- package/dist/sources/chainabuse.js +19 -0
- package/dist/sources/evm.d.ts +135 -0
- package/dist/sources/evm.js +260 -0
- package/dist/sources/phishlists.d.ts +20 -0
- package/dist/sources/phishlists.js +90 -0
- package/dist/telegram.d.ts +17 -0
- package/dist/telegram.js +151 -4
- package/dist/web/card.d.ts +28 -0
- package/dist/web/card.js +75 -0
- package/dist/web/docs.html +1 -1
- package/dist/web/index.html +213 -5
- package/dist/web/landing.html +1 -1
- package/dist/web/legal.html +3 -1
- package/dist/web/mcp.html +1 -1
- package/dist/web/openapi.js +15 -0
- package/dist/web/pages.d.ts +24 -0
- package/dist/web/pages.js +139 -0
- package/dist/web/public.js +16 -1
- package/dist/web/server.d.ts +13 -0
- package/dist/web/server.js +152 -13
- package/dist/web/token.html +25 -4
- package/dist/web/token.json +12 -1
- package/dist/web/utility.html +40 -14
- package/package.json +2 -2
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Ctx } from '../core/context.js';
|
|
2
|
+
import { type CallEntry } from '../core/calls.js';
|
|
3
|
+
import { type Verdict } from '../core/verdict.js';
|
|
4
|
+
export interface SeenBefore {
|
|
5
|
+
id: string;
|
|
6
|
+
at: string;
|
|
7
|
+
verdict: string | null;
|
|
8
|
+
/** Plain-word changes since that check; empty when nothing changed. */
|
|
9
|
+
changes: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface CheckMeta {
|
|
12
|
+
id: string;
|
|
13
|
+
kind: string;
|
|
14
|
+
seenBefore: SeenBefore | null;
|
|
15
|
+
replay: string;
|
|
16
|
+
report: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CheckRecord {
|
|
19
|
+
id: string;
|
|
20
|
+
kind: string;
|
|
21
|
+
label: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
durationMs: number;
|
|
24
|
+
verdict: Verdict;
|
|
25
|
+
calls: CallEntry[];
|
|
26
|
+
seenBefore: SeenBefore | null;
|
|
27
|
+
/** The full result as returned, or null when it was too large to keep. */
|
|
28
|
+
result: unknown;
|
|
29
|
+
}
|
|
30
|
+
export declare const targetKey: (kind: string, target: string) => string;
|
|
31
|
+
/** Long inputs (a pasted message, raw headers) are shown by their start only. */
|
|
32
|
+
export declare function labelFor(target: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Run a check, keep its verdict and source calls, and compare it with the last check of the same target.
|
|
35
|
+
* `target` identifies what was checked (it is hashed for matching); `label` is what pages show.
|
|
36
|
+
*/
|
|
37
|
+
export declare function recordCheck<T>(ctx: Ctx, kind: string, target: string, run: () => Promise<T>, opts?: {
|
|
38
|
+
label?: string;
|
|
39
|
+
}): Promise<{
|
|
40
|
+
value: T;
|
|
41
|
+
check: CheckMeta;
|
|
42
|
+
}>;
|
|
43
|
+
export declare function getCheck(ctx: Ctx, id: string): CheckRecord | null;
|
|
44
|
+
/** Earlier checks of the same target, newest first (for "history" on the replay page). */
|
|
45
|
+
export declare function checkHistory(ctx: Ctx, id: string, limit?: number): {
|
|
46
|
+
id: string;
|
|
47
|
+
at: string;
|
|
48
|
+
verdict: string | null;
|
|
49
|
+
risk: number | null;
|
|
50
|
+
}[];
|
|
51
|
+
/** Checks Oculon records, by web route and by MCP tool, with how to read the target from the input. */
|
|
52
|
+
export declare const CHECK_ROUTES: Record<string, {
|
|
53
|
+
kind: string;
|
|
54
|
+
param: string;
|
|
55
|
+
}>;
|
|
56
|
+
export declare const CHECK_TOOLS: Record<string, {
|
|
57
|
+
kind: string;
|
|
58
|
+
arg: string;
|
|
59
|
+
}>;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check history: every check (scam, link, IBAN, document, token...) is stored with its verdict and the source calls
|
|
3
|
+
* it made. That gives three features:
|
|
4
|
+
* - seen before: checking the same thing again says what changed since last time;
|
|
5
|
+
* - replay log: /replay/<id> shows every source called, when, how long it took and what it answered;
|
|
6
|
+
* - PDF report: /report/<id>.pdf is one investigation as a file to send on.
|
|
7
|
+
* Ids are random (96 bits) so a replay link is only known to whoever ran the check. Kept for 90 days.
|
|
8
|
+
*/
|
|
9
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
10
|
+
import { withCallLog } from '../core/calls.js';
|
|
11
|
+
import { verdictChanges, verdictOf } from '../core/verdict.js';
|
|
12
|
+
const KEEP_DAYS = 90;
|
|
13
|
+
const MAX_RESULT = 300_000;
|
|
14
|
+
const ensured = new WeakSet();
|
|
15
|
+
function db(ctx) {
|
|
16
|
+
const d = ctx.store.db;
|
|
17
|
+
if (!ensured.has(d)) {
|
|
18
|
+
d.exec(`CREATE TABLE IF NOT EXISTS checks (id TEXT PRIMARY KEY, kind TEXT NOT NULL, target_key TEXT NOT NULL, label TEXT NOT NULL, created_at INTEGER NOT NULL, duration_ms INTEGER NOT NULL, verdict TEXT NOT NULL, calls TEXT NOT NULL, seen_before TEXT, result TEXT);
|
|
19
|
+
CREATE INDEX IF NOT EXISTS checks_target ON checks (target_key, created_at);`);
|
|
20
|
+
ensured.add(d);
|
|
21
|
+
}
|
|
22
|
+
return d;
|
|
23
|
+
}
|
|
24
|
+
export const targetKey = (kind, target) => createHash('sha256').update(`${kind}\n${target.trim().toLowerCase().replace(/\s+/g, ' ')}`).digest('hex').slice(0, 32);
|
|
25
|
+
/** Long inputs (a pasted message, raw headers) are shown by their start only. */
|
|
26
|
+
export function labelFor(target) {
|
|
27
|
+
const t = target.replace(/\s+/g, ' ').trim();
|
|
28
|
+
return t.length > 90 ? `${t.slice(0, 87)}...` : t;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Run a check, keep its verdict and source calls, and compare it with the last check of the same target.
|
|
32
|
+
* `target` identifies what was checked (it is hashed for matching); `label` is what pages show.
|
|
33
|
+
*/
|
|
34
|
+
export async function recordCheck(ctx, kind, target, run, opts = {}) {
|
|
35
|
+
const t0 = Date.now();
|
|
36
|
+
const { value, calls } = await withCallLog(run);
|
|
37
|
+
const durationMs = Date.now() - t0;
|
|
38
|
+
const d = db(ctx);
|
|
39
|
+
const key = targetKey(kind, target);
|
|
40
|
+
const label = opts.label ?? labelFor(target);
|
|
41
|
+
const verdict = verdictOf(value, label);
|
|
42
|
+
const nowMs = ctx.now().getTime();
|
|
43
|
+
const prev = d.prepare('SELECT id, created_at, verdict FROM checks WHERE target_key = ? ORDER BY created_at DESC LIMIT 1').get(key);
|
|
44
|
+
let seenBefore = null;
|
|
45
|
+
if (prev) {
|
|
46
|
+
const was = JSON.parse(prev.verdict);
|
|
47
|
+
seenBefore = { id: prev.id, at: new Date(prev.created_at).toISOString(), verdict: was.verdict, changes: verdictChanges(was, verdict) };
|
|
48
|
+
}
|
|
49
|
+
const id = randomBytes(12).toString('base64url');
|
|
50
|
+
let result = JSON.stringify(value);
|
|
51
|
+
if (result.length > MAX_RESULT)
|
|
52
|
+
result = null;
|
|
53
|
+
d.prepare('INSERT INTO checks (id, kind, target_key, label, created_at, duration_ms, verdict, calls, seen_before, result) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)').run(id, kind, key, label, nowMs, durationMs, JSON.stringify(verdict), JSON.stringify(calls), seenBefore ? JSON.stringify(seenBefore) : null, result);
|
|
54
|
+
if (Math.random() < 0.02)
|
|
55
|
+
d.prepare('DELETE FROM checks WHERE created_at < ?').run(nowMs - KEEP_DAYS * 86_400_000);
|
|
56
|
+
return { value, check: { id, kind, seenBefore, replay: `/replay/${id}`, report: `/report/${id}.pdf` } };
|
|
57
|
+
}
|
|
58
|
+
export function getCheck(ctx, id) {
|
|
59
|
+
if (!/^[A-Za-z0-9_-]{10,40}$/.test(id))
|
|
60
|
+
return null;
|
|
61
|
+
const r = db(ctx).prepare('SELECT * FROM checks WHERE id = ?').get(id);
|
|
62
|
+
if (!r)
|
|
63
|
+
return null;
|
|
64
|
+
return {
|
|
65
|
+
id: String(r.id),
|
|
66
|
+
kind: String(r.kind),
|
|
67
|
+
label: String(r.label),
|
|
68
|
+
createdAt: new Date(Number(r.created_at)).toISOString(),
|
|
69
|
+
durationMs: Number(r.duration_ms),
|
|
70
|
+
verdict: JSON.parse(String(r.verdict)),
|
|
71
|
+
calls: JSON.parse(String(r.calls)),
|
|
72
|
+
seenBefore: r.seen_before ? JSON.parse(String(r.seen_before)) : null,
|
|
73
|
+
result: r.result ? JSON.parse(String(r.result)) : null,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** Earlier checks of the same target, newest first (for "history" on the replay page). */
|
|
77
|
+
export function checkHistory(ctx, id, limit = 10) {
|
|
78
|
+
const d = db(ctx);
|
|
79
|
+
const row = d.prepare('SELECT target_key FROM checks WHERE id = ?').get(id);
|
|
80
|
+
if (!row)
|
|
81
|
+
return [];
|
|
82
|
+
const rows = d.prepare('SELECT id, created_at, verdict FROM checks WHERE target_key = ? ORDER BY created_at DESC LIMIT ?').all(row.target_key, limit);
|
|
83
|
+
return rows.map((r) => {
|
|
84
|
+
const v = JSON.parse(r.verdict);
|
|
85
|
+
return { id: r.id, at: new Date(r.created_at).toISOString(), verdict: v.verdict, risk: v.risk };
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/** Checks Oculon records, by web route and by MCP tool, with how to read the target from the input. */
|
|
89
|
+
export const CHECK_ROUTES = {
|
|
90
|
+
'/api/scam': { kind: 'scam', param: 'message' },
|
|
91
|
+
'/api/url': { kind: 'url', param: 'url' },
|
|
92
|
+
'/api/iban': { kind: 'iban', param: 'iban' },
|
|
93
|
+
'/api/lookalike': { kind: 'lookalike', param: 'domain' },
|
|
94
|
+
'/api/honeypot': { kind: 'honeypot', param: 'address' },
|
|
95
|
+
'/api/address': { kind: 'address', param: 'address' },
|
|
96
|
+
'/api/phone': { kind: 'phone', param: 'number' },
|
|
97
|
+
'/api/ip': { kind: 'ip', param: 'ip' },
|
|
98
|
+
'/api/hash': { kind: 'hash', param: 'hash' },
|
|
99
|
+
'/api/emailsec': { kind: 'emailsec', param: 'domain' },
|
|
100
|
+
'/api/company': { kind: 'company', param: 'q' },
|
|
101
|
+
'/api/token': { kind: 'token', param: 'address' },
|
|
102
|
+
'/api/rhtoken': { kind: 'rhtoken', param: 'address' },
|
|
103
|
+
'/api/wallet': { kind: 'wallet', param: 'address' },
|
|
104
|
+
'/api/sanctions': { kind: 'sanctions', param: 'q' },
|
|
105
|
+
'/api/factcheck': { kind: 'factcheck', param: 'claim' },
|
|
106
|
+
'/api/recall': { kind: 'recall', param: 'q' },
|
|
107
|
+
'/api/travel': { kind: 'travel', param: 'place' },
|
|
108
|
+
'/api/cve': { kind: 'cve', param: 'id' },
|
|
109
|
+
'/api/exposure': { kind: 'exposure', param: 'domain' },
|
|
110
|
+
'/api/approvals': { kind: 'approvals', param: 'address' },
|
|
111
|
+
'/api/contract': { kind: 'contract', param: 'address' },
|
|
112
|
+
'/api/poisoning': { kind: 'poisoning', param: 'address' },
|
|
113
|
+
'/api/trace': { kind: 'trace', param: 'address' },
|
|
114
|
+
'/api/repo': { kind: 'repo', param: 'repo' },
|
|
115
|
+
'/api/report/domain': { kind: 'domainreport', param: 'domain' },
|
|
116
|
+
'/api/report/wallet': { kind: 'walletreport', param: 'address' },
|
|
117
|
+
'/api/site': { kind: 'site', param: 'url' },
|
|
118
|
+
'/api/tx': { kind: 'tx', param: 'hash' },
|
|
119
|
+
'/api/creator': { kind: 'creator', param: 'address' },
|
|
120
|
+
'/api/archive': { kind: 'archive', param: 'url' },
|
|
121
|
+
'/api/invite': { kind: 'invite', param: 'link' },
|
|
122
|
+
'/api/stocktoken': { kind: 'stocktoken', param: 'q' },
|
|
123
|
+
};
|
|
124
|
+
export const CHECK_TOOLS = {
|
|
125
|
+
oculon_scam_check: { kind: 'scam', arg: 'message' },
|
|
126
|
+
oculon_url_check: { kind: 'url', arg: 'url' },
|
|
127
|
+
oculon_iban_check: { kind: 'iban', arg: 'iban' },
|
|
128
|
+
oculon_email_headers: { kind: 'headers', arg: 'headers' },
|
|
129
|
+
oculon_lookalike_domains: { kind: 'lookalike', arg: 'domain' },
|
|
130
|
+
oculon_honeypot_check: { kind: 'honeypot', arg: 'address' },
|
|
131
|
+
oculon_address_check: { kind: 'address', arg: 'address' },
|
|
132
|
+
oculon_phone_check: { kind: 'phone', arg: 'number' },
|
|
133
|
+
oculon_ip_check: { kind: 'ip', arg: 'ip' },
|
|
134
|
+
oculon_hash_check: { kind: 'hash', arg: 'hash' },
|
|
135
|
+
oculon_email_security: { kind: 'emailsec', arg: 'domain' },
|
|
136
|
+
oculon_company_lookup: { kind: 'company', arg: 'query' },
|
|
137
|
+
oculon_token: { kind: 'token', arg: 'address' },
|
|
138
|
+
oculon_robinhood_token: { kind: 'rhtoken', arg: 'address' },
|
|
139
|
+
oculon_wallet: { kind: 'wallet', arg: 'address' },
|
|
140
|
+
oculon_sanctions: { kind: 'sanctions', arg: 'query' },
|
|
141
|
+
oculon_fact_check: { kind: 'factcheck', arg: 'claim' },
|
|
142
|
+
oculon_recall: { kind: 'recall', arg: 'query' },
|
|
143
|
+
oculon_travel: { kind: 'travel', arg: 'place' },
|
|
144
|
+
oculon_cve: { kind: 'cve', arg: 'id' },
|
|
145
|
+
oculon_exposure: { kind: 'exposure', arg: 'domain' },
|
|
146
|
+
oculon_doc_check: { kind: 'doc', arg: 'name' },
|
|
147
|
+
oculon_approvals: { kind: 'approvals', arg: 'address' },
|
|
148
|
+
oculon_contract_risk: { kind: 'contract', arg: 'address' },
|
|
149
|
+
oculon_signature_check: { kind: 'signature', arg: 'request' },
|
|
150
|
+
oculon_address_poisoning: { kind: 'poisoning', arg: 'address' },
|
|
151
|
+
oculon_trace_funds: { kind: 'trace', arg: 'address' },
|
|
152
|
+
oculon_image_check: { kind: 'image', arg: 'name' },
|
|
153
|
+
oculon_qr_check: { kind: 'qr', arg: 'name' },
|
|
154
|
+
oculon_repo_check: { kind: 'repo', arg: 'repo' },
|
|
155
|
+
oculon_domain_report: { kind: 'domainreport', arg: 'domain' },
|
|
156
|
+
oculon_wallet_report: { kind: 'walletreport', arg: 'address' },
|
|
157
|
+
oculon_site_check: { kind: 'site', arg: 'url' },
|
|
158
|
+
oculon_tx_explain: { kind: 'tx', arg: 'hash' },
|
|
159
|
+
oculon_token_creator: { kind: 'creator', arg: 'address' },
|
|
160
|
+
oculon_email_file: { kind: 'eml', arg: 'name' },
|
|
161
|
+
oculon_apk_check: { kind: 'apk', arg: 'name' },
|
|
162
|
+
oculon_job_check: { kind: 'job', arg: 'message' },
|
|
163
|
+
oculon_photo_location: { kind: 'where', arg: 'name' },
|
|
164
|
+
oculon_archive: { kind: 'archive', arg: 'url' },
|
|
165
|
+
oculon_invite_check: { kind: 'invite', arg: 'link' },
|
|
166
|
+
oculon_stock_token: { kind: 'stocktoken', arg: 'query' },
|
|
167
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract risk: what the people behind a token can still do to holders.
|
|
3
|
+
* Code: the verified ABI (Sourcify, then Etherscan), or for unverified contracts the function selectors found
|
|
4
|
+
* in the deployed bytecode, decoded through the public signature databases. Owner-only powers are grouped:
|
|
5
|
+
* minting, blacklists, trading switches, tax changes, wallet limits, balance changes, withdrawals, upgrades.
|
|
6
|
+
* Control: who owns it now (owner() on chain; renounced when it is the zero or dead address), and for proxies
|
|
7
|
+
* the implementation and admin from the EIP-1967 storage slots.
|
|
8
|
+
* Market: holder concentration and locked liquidity (GoPlus, keyless), the main pool and its age (DexScreener).
|
|
9
|
+
* Works on Ethereum, Base, BNB Chain, Arbitrum and Polygon. A function existing is not proof it will be used;
|
|
10
|
+
* the report says what is possible, not what will happen.
|
|
11
|
+
*/
|
|
12
|
+
import type { Ctx } from '../core/context.js';
|
|
13
|
+
import type { ModuleResult } from '../core/types.js';
|
|
14
|
+
export interface Power {
|
|
15
|
+
power: string;
|
|
16
|
+
functions: string[];
|
|
17
|
+
weight: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ContractReport {
|
|
20
|
+
address: string;
|
|
21
|
+
chain: string;
|
|
22
|
+
name: string | null;
|
|
23
|
+
symbol: string | null;
|
|
24
|
+
verified: boolean;
|
|
25
|
+
verifiedBy: string | null;
|
|
26
|
+
contractName: string | null;
|
|
27
|
+
verdict: 'dangerous contract' | 'risky contract' | 'caution' | 'no major risks found';
|
|
28
|
+
risk: number;
|
|
29
|
+
owner: string | null;
|
|
30
|
+
ownerRenounced: boolean | null;
|
|
31
|
+
proxy: {
|
|
32
|
+
implementation: string | null;
|
|
33
|
+
admin: string | null;
|
|
34
|
+
} | null;
|
|
35
|
+
powers: Power[];
|
|
36
|
+
holders: {
|
|
37
|
+
count: number | null;
|
|
38
|
+
top10Percent: number | null;
|
|
39
|
+
creatorPercent: number | null;
|
|
40
|
+
ownerPercent: number | null;
|
|
41
|
+
} | null;
|
|
42
|
+
liquidity: {
|
|
43
|
+
usd: number | null;
|
|
44
|
+
pair: string | null;
|
|
45
|
+
dex: string | null;
|
|
46
|
+
createdAt: string | null;
|
|
47
|
+
lockedPercent: number | null;
|
|
48
|
+
} | null;
|
|
49
|
+
reasons: string[];
|
|
50
|
+
notes: string[];
|
|
51
|
+
advice: string[];
|
|
52
|
+
}
|
|
53
|
+
export declare function powersOf(names: string[]): Power[];
|
|
54
|
+
export declare function contractRisk(ctx: Ctx, input: string, opts?: {
|
|
55
|
+
chain?: string;
|
|
56
|
+
}): Promise<ModuleResult<ContractReport>>;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { enc } from '../core/context.js';
|
|
2
|
+
import { signalId } from '../core/text.js';
|
|
3
|
+
import { bytecodeSelectors, codeAt, DEAD, ethCall, etherscanSource, evmChain, isAddr, rpcCall, sourcify, tokenMeta, wordAddr } from '../sources/evm.js';
|
|
4
|
+
import { dexPairs } from '../sources/onchain.js';
|
|
5
|
+
import { decodeSelectors, methodName } from '../sources/signatures.js';
|
|
6
|
+
const POWERS = [
|
|
7
|
+
['can mint new tokens', /^(mint|_mint|mintto|minttokens|issue|mintfor|createtokens)$/, 25],
|
|
8
|
+
['can block wallets (blacklist)', /blacklist|blocklist|denylist|^(addbots?|setbots?|blockbots?|markbots?|setbot|ban|banaddress|freeze|freezeaccount|setsniper|addsniper|setblocked|block)$/, 25],
|
|
9
|
+
['can stop trading or transfers', /^(pause|setpaused|settradingenabled|settradingopen|enabletrading|disabletrading|settrading|toggletrading|setswapenabled|stoptrading|lock|settransferenabled)$/, 15],
|
|
10
|
+
['can change buy and sell taxes', /^(setfees?|settax(es)?|updatefees?|setbuyfees?|setsellfees?|setbuytax|setselltax|updatebuyfees|updatesellfees|settaxfee|setliquidityfee|setmarketingfee|setswapfee|settotalfees?|setfeepercent|setreflectionfee)$/, 20],
|
|
11
|
+
['can limit how much a wallet holds or sells', /^(setmaxtx(amount|percent)?|setmaxwallet(size|amount|percent)?|setmaxtransaction(amount)?|updatemaxtx(amount)?|updatemaxwallet(amount)?|setlimits|setmaxsell|setmaxbuy|setmaxtxpercent)$/, 10],
|
|
12
|
+
['can exempt chosen wallets from taxes and limits', /^(excludefromfees?|setexcluded(fromfee)?|includeinfee|setisfeeexempt|setfeeexempt|excludefrommaxtransaction|setiswhitelisted|whitelist|addtowhitelist|setwhitelist)$/, 5],
|
|
13
|
+
['can change balances directly', /^(setbalance|setbalances|rebase|burnfrom?owner|adminburn|wipe|destroyblackfunds|reflect|setrebase)$/, 30],
|
|
14
|
+
['can withdraw tokens or ETH held by the contract', /^(withdraw|withdrawall|withdrawtokens?|rescue(tokens?|eth|erc20)?|recover(tokens?|eth|erc20)?|sweep|clearstucktokens?|claimstuck(tokens|balance)?|emergencywithdraw|manualswap|manualsend)$/, 5],
|
|
15
|
+
['can replace the contract code (upgradeable)', /^(upgradeto|upgradetoandcall|setimplementation|upgrade|changeimplementation)$/, 25],
|
|
16
|
+
['can self-destruct', /^(selfdestruct|kill|destroy|destruct)$/, 25],
|
|
17
|
+
];
|
|
18
|
+
const OWNER_FNS = /^(owner|getowner|renounceownership|transferownership|acceptownership)$/;
|
|
19
|
+
const IMPL_SLOT = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc';
|
|
20
|
+
const ADMIN_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103';
|
|
21
|
+
const writeFns = (abi) => abi.filter((x) => x.type === 'function' && x.stateMutability !== 'view' && x.stateMutability !== 'pure').map((x) => x.name ?? '').filter(Boolean);
|
|
22
|
+
export function powersOf(names) {
|
|
23
|
+
const out = [];
|
|
24
|
+
for (const [power, re, weight] of POWERS) {
|
|
25
|
+
const fns = [...new Set(names.filter((n) => re.test(n.toLowerCase())))];
|
|
26
|
+
if (fns.length)
|
|
27
|
+
out.push({ power, functions: fns.slice(0, 6), weight });
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
export async function contractRisk(ctx, input, opts = {}) {
|
|
32
|
+
const address = input.trim().toLowerCase();
|
|
33
|
+
if (!isAddr(address))
|
|
34
|
+
throw new Error('give a contract address: 0x followed by 40 hex characters');
|
|
35
|
+
const c = evmChain(opts.chain);
|
|
36
|
+
const provenance = [];
|
|
37
|
+
const code = await codeAt(ctx, c, address);
|
|
38
|
+
if (code === null)
|
|
39
|
+
throw new Error(`could not read the contract from ${c.label}`);
|
|
40
|
+
if (code === '0x')
|
|
41
|
+
throw new Error(`${address} is not a contract on ${c.label} (no code at this address)`);
|
|
42
|
+
const reasons = [], notes = [];
|
|
43
|
+
// Verified code, also for the implementation behind a proxy.
|
|
44
|
+
let v = (await sourcify(ctx, c, address).then((r) => (provenance.push(r.prov), r.data)));
|
|
45
|
+
if (!v)
|
|
46
|
+
v = await etherscanSource(ctx, c, address).then((r) => (provenance.push(r.prov), r.data));
|
|
47
|
+
const [implSlot, adminSlot] = await Promise.all([rpcCall(ctx, c, 'eth_getStorageAt', [address, IMPL_SLOT, 'latest'], 600), rpcCall(ctx, c, 'eth_getStorageAt', [address, ADMIN_SLOT, 'latest'], 600)]);
|
|
48
|
+
const slotAddr = (h) => (h && /[1-9a-f]/i.test(h.slice(2)) ? wordAddr(h, 0) : null);
|
|
49
|
+
const impl = v?.proxy?.implementations[0]?.address?.toLowerCase() ?? slotAddr(implSlot.data);
|
|
50
|
+
const admin = slotAddr(adminSlot.data);
|
|
51
|
+
let names = [];
|
|
52
|
+
if (v)
|
|
53
|
+
names.push(...writeFns(v.abi));
|
|
54
|
+
if (impl) {
|
|
55
|
+
let iv = (await sourcify(ctx, c, impl)).data;
|
|
56
|
+
if (!iv)
|
|
57
|
+
iv = (await etherscanSource(ctx, c, impl)).data;
|
|
58
|
+
if (iv)
|
|
59
|
+
names.push(...writeFns(iv.abi));
|
|
60
|
+
else {
|
|
61
|
+
const icode = await codeAt(ctx, c, impl);
|
|
62
|
+
if (icode && icode !== '0x')
|
|
63
|
+
names.push(...await selectorNames(ctx, icode));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (!v) {
|
|
67
|
+
names.push(...await selectorNames(ctx, code));
|
|
68
|
+
reasons.push('source code is not verified: nobody can read what it does (functions below come from its bytecode)');
|
|
69
|
+
}
|
|
70
|
+
names = [...new Set(names)];
|
|
71
|
+
const powers = powersOf(names);
|
|
72
|
+
if (impl || v?.proxy?.isProxy) {
|
|
73
|
+
if (!powers.some((p) => p.power.startsWith('can replace')))
|
|
74
|
+
powers.push({ power: 'can replace the contract code (upgradeable)', functions: ['proxy'], weight: 25 });
|
|
75
|
+
}
|
|
76
|
+
// Ownership.
|
|
77
|
+
const [o1, o2] = await Promise.all([ethCall(ctx, c, address, '0x8da5cb5b', 300), ethCall(ctx, c, address, '0x893d20e8', 300)]);
|
|
78
|
+
const ownRaw = [o1.data, o2.data].find((d) => d && d.length >= 66) ?? null;
|
|
79
|
+
const owner = ownRaw ? wordAddr(ownRaw, 0) : null;
|
|
80
|
+
const hasOwnerFns = names.some((n) => OWNER_FNS.test(n.toLowerCase()));
|
|
81
|
+
const ownerRenounced = owner ? DEAD.test(owner) : hasOwnerFns ? null : null;
|
|
82
|
+
const ownerActive = Boolean(owner && !DEAD.test(owner)) || Boolean(admin && !DEAD.test(admin));
|
|
83
|
+
// Market: holders and liquidity.
|
|
84
|
+
let holders = null, lockedPercent = null;
|
|
85
|
+
if (c.key !== 'robinhood') {
|
|
86
|
+
const g = await ctx.http.get(`https://api.gopluslabs.io/api/v1/token_security/${c.id}?contract_addresses=${enc(address)}`, { source: 'goplus', ttlSec: 1800 });
|
|
87
|
+
provenance.push(g.prov);
|
|
88
|
+
const d = g.data?.result?.[address];
|
|
89
|
+
if (d) {
|
|
90
|
+
const top = (d.holders ?? []).filter((h) => !h.is_locked && !DEAD.test(h.address) && !/lock|burn|dead|pair|pool/i.test(h.tag ?? '')).slice(0, 10);
|
|
91
|
+
holders = { count: d.holder_count ? Number(d.holder_count) : null, top10Percent: top.length ? Math.round(top.reduce((s, h) => s + Number(h.percent), 0) * 1000) / 10 : null, creatorPercent: d.creator_percent ? Math.round(Number(d.creator_percent) * 1000) / 10 : null, ownerPercent: d.owner_percent ? Math.round(Number(d.owner_percent) * 1000) / 10 : null };
|
|
92
|
+
const lp = d.lp_holders ?? [];
|
|
93
|
+
if (lp.length)
|
|
94
|
+
lockedPercent = Math.round(lp.filter((h) => h.is_locked || DEAD.test(h.address)).reduce((s, h) => s + Number(h.percent), 0) * 1000) / 10;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const pairs = await dexPairs(ctx, address, c.key);
|
|
98
|
+
provenance.push(pairs.prov);
|
|
99
|
+
const main = pairs.data?.[0] ?? null;
|
|
100
|
+
const liquidity = main || lockedPercent !== null ? { usd: main?.liquidityUsd ?? null, pair: main?.pair ?? null, dex: main?.dex ?? null, createdAt: main?.createdAt ?? null, lockedPercent } : null;
|
|
101
|
+
// Score.
|
|
102
|
+
let risk = 0;
|
|
103
|
+
const live = ownerActive || !v;
|
|
104
|
+
for (const p of powers) {
|
|
105
|
+
const w = live ? p.weight : Math.round(p.weight / 4);
|
|
106
|
+
risk += w;
|
|
107
|
+
reasons.push(`${p.power}: ${p.functions.join(', ')}${live ? '' : ' (owner renounced)'}`);
|
|
108
|
+
}
|
|
109
|
+
if (!v)
|
|
110
|
+
risk += 25;
|
|
111
|
+
if (owner && !DEAD.test(owner))
|
|
112
|
+
notes.push(`Owner ${owner} still controls the owner-only functions.`);
|
|
113
|
+
if (ownerRenounced)
|
|
114
|
+
notes.push('Ownership is renounced: owner-only functions can no longer be called, unless another role or a proxy admin exists.');
|
|
115
|
+
if (admin && !DEAD.test(admin))
|
|
116
|
+
reasons.push(`proxy admin ${admin} can upgrade the code at any time`);
|
|
117
|
+
if (holders?.top10Percent !== null && holders?.top10Percent !== undefined && holders.top10Percent >= 50) {
|
|
118
|
+
risk += holders.top10Percent >= 80 ? 25 : 15;
|
|
119
|
+
reasons.push(`top 10 wallets hold ${holders.top10Percent}% of the supply`);
|
|
120
|
+
}
|
|
121
|
+
if (holders?.creatorPercent && holders.creatorPercent >= 10) {
|
|
122
|
+
risk += 10;
|
|
123
|
+
reasons.push(`the creator still holds ${holders.creatorPercent}%`);
|
|
124
|
+
}
|
|
125
|
+
if (liquidity) {
|
|
126
|
+
if (liquidity.usd !== null && liquidity.usd < 10_000) {
|
|
127
|
+
risk += 15;
|
|
128
|
+
reasons.push(`thin liquidity: about $${Math.round(liquidity.usd).toLocaleString('en-US')} in the main pool`);
|
|
129
|
+
}
|
|
130
|
+
// LP locks only mean something for young, small pools (big V3 pools hold no LP tokens at all).
|
|
131
|
+
if (lockedPercent !== null && lockedPercent < 50 && (liquidity.usd ?? 0) < 1_000_000) {
|
|
132
|
+
risk += 15;
|
|
133
|
+
reasons.push(`only ${lockedPercent}% of the pool tokens are locked or burned: liquidity can be pulled`);
|
|
134
|
+
}
|
|
135
|
+
if (liquidity.createdAt && Date.now() - Date.parse(liquidity.createdAt) < 3 * 86_400_000) {
|
|
136
|
+
risk += 10;
|
|
137
|
+
reasons.push(`the main pool is less than 3 days old`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else
|
|
141
|
+
notes.push('No DEX pool found for this token.');
|
|
142
|
+
risk = Math.min(100, risk);
|
|
143
|
+
// Stablecoins and wrapped assets are built with mint, freeze and upgrade powers on purpose.
|
|
144
|
+
if ((holders?.count ?? 0) >= 50_000 && (liquidity?.usd ?? 0) >= 5_000_000 && risk >= 40) {
|
|
145
|
+
risk = 39;
|
|
146
|
+
notes.push('Large, established token: owner powers like these are typical of a centrally issued token (stablecoins, wrapped assets). They still mean the issuer can mint, freeze or upgrade.');
|
|
147
|
+
}
|
|
148
|
+
const verdict = risk >= 70 ? 'dangerous contract' : risk >= 40 ? 'risky contract' : risk >= 15 ? 'caution' : 'no major risks found';
|
|
149
|
+
const meta = await tokenMeta(ctx, c, address);
|
|
150
|
+
const advice = verdict === 'no major risks found'
|
|
151
|
+
? ['No owner powers or market red flags found. That does not make it a good investment; it only means the code and market look ordinary.']
|
|
152
|
+
: ['Do not buy more than you can lose. Owner powers listed above can be used at any time without warning.', 'Check whether you can sell: oculon honeypot <address>', 'Set a limited approval instead of unlimited when you trade it.'];
|
|
153
|
+
const now = ctx.now().toISOString();
|
|
154
|
+
const signals = risk >= 70 ? [{ id: signalId('contract', address, c.key), module: 'contract', title: `${meta.symbol ?? address.slice(0, 10)} on ${c.label}: ${verdict}`, score: risk, entity: `token:${address}`, evidence: reasons.slice(0, 4).map((t) => ({ source: v?.source ?? 'bytecode', text: t })), createdAt: now }] : [];
|
|
155
|
+
return {
|
|
156
|
+
module: 'contract', input: address, generatedAt: now,
|
|
157
|
+
result: { address, chain: c.label, name: meta.name, symbol: meta.symbol, verified: Boolean(v), verifiedBy: v?.source ?? null, contractName: v?.name ?? null, verdict, risk, owner, ownerRenounced, proxy: impl || admin ? { implementation: impl, admin } : null, powers, holders, liquidity, reasons, notes, advice },
|
|
158
|
+
signals, provenance,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
async function selectorNames(ctx, code) {
|
|
162
|
+
const sels = bytecodeSelectors(code).slice(0, 160);
|
|
163
|
+
if (!sels.length)
|
|
164
|
+
return [];
|
|
165
|
+
const d = await decodeSelectors(ctx, sels).catch(() => ({}));
|
|
166
|
+
return Object.values(d).map((s) => methodName(s)).filter((s) => Boolean(s));
|
|
167
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deployer record: who created this token, what else they created, and how much of it is dead.
|
|
3
|
+
* Creator and creation transaction from Etherscan, the creator's other contract deployments from its
|
|
4
|
+
* transaction list, and for each token its main pool today (DexScreener): no pool or under $1,000 of
|
|
5
|
+
* liquidity counts as dead. The wallet that first funded the creator is named when it is labeled (an exchange,
|
|
6
|
+
* a mixer) in the open eth-labels dataset.
|
|
7
|
+
* Tokens made through a launchpad factory are created by the factory, not the wallet; those deployments are
|
|
8
|
+
* not in the creator's own list, and the report says so when it finds none.
|
|
9
|
+
* Ethereum, Arbitrum and Polygon (the chains Etherscan's free plan covers).
|
|
10
|
+
*/
|
|
11
|
+
import type { Ctx } from '../core/context.js';
|
|
12
|
+
import type { ModuleResult } from '../core/types.js';
|
|
13
|
+
export interface Deployment {
|
|
14
|
+
address: string;
|
|
15
|
+
symbol: string | null;
|
|
16
|
+
name: string | null;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
liquidityUsd: number | null;
|
|
19
|
+
dead: boolean;
|
|
20
|
+
isToken: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface DeployerReport {
|
|
23
|
+
token: string;
|
|
24
|
+
chain: string;
|
|
25
|
+
deployer: string | null;
|
|
26
|
+
createdAt: string | null;
|
|
27
|
+
verdict: 'serial rug deployer' | 'many dead tokens' | 'new deployer' | 'no bad record found' | 'deployer not found';
|
|
28
|
+
risk: number;
|
|
29
|
+
deployments: Deployment[];
|
|
30
|
+
tokens: number;
|
|
31
|
+
dead: number;
|
|
32
|
+
fundedBy: {
|
|
33
|
+
address: string;
|
|
34
|
+
label: string | null;
|
|
35
|
+
} | null;
|
|
36
|
+
reasons: string[];
|
|
37
|
+
notes: string[];
|
|
38
|
+
advice: string[];
|
|
39
|
+
}
|
|
40
|
+
export declare function deployerCheck(ctx: Ctx, input: string, opts?: {
|
|
41
|
+
chain?: string;
|
|
42
|
+
}): Promise<ModuleResult<DeployerReport>>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { signalId } from '../core/text.js';
|
|
2
|
+
import { esTxList, etherscan, evmChain, isAddr, labelOf, tokenMeta } from '../sources/evm.js';
|
|
3
|
+
import { DEX_CHAIN } from '../sources/onchain.js';
|
|
4
|
+
import { describeLabels, ensureLabels, labelsFor } from '../sources/labels.js';
|
|
5
|
+
export async function deployerCheck(ctx, input, opts = {}) {
|
|
6
|
+
const token = input.trim().toLowerCase();
|
|
7
|
+
if (!isAddr(token))
|
|
8
|
+
throw new Error('give a token contract address: 0x followed by 40 hex characters');
|
|
9
|
+
const c = evmChain(opts.chain, 'creation');
|
|
10
|
+
const provenance = [];
|
|
11
|
+
const cr = await etherscan(ctx, c, { module: 'contract', action: 'getcontractcreation', contractaddresses: token }, 86_400);
|
|
12
|
+
provenance.push(cr.prov);
|
|
13
|
+
const row = cr.data?.[0];
|
|
14
|
+
const now = ctx.now();
|
|
15
|
+
const base = { token, chain: c.label };
|
|
16
|
+
if (!row?.contractCreator) {
|
|
17
|
+
return { module: 'deployer', input: token, generatedAt: now.toISOString(), signals: [], provenance, result: { ...base, deployer: null, createdAt: null, verdict: 'deployer not found', risk: 0, deployments: [], tokens: 0, dead: 0, fundedBy: null, reasons: [], notes: ['Etherscan has no creator for this address: it may not be a contract on this chain.'], advice: [] } };
|
|
18
|
+
}
|
|
19
|
+
const deployer = row.contractCreator.toLowerCase();
|
|
20
|
+
const createdAt = row.timestamp ? new Date(Number(row.timestamp) * 1000).toISOString() : null;
|
|
21
|
+
const txs = await esTxList(ctx, c, deployer, 1000, 'asc');
|
|
22
|
+
provenance.push(txs.prov);
|
|
23
|
+
const list = txs.data ?? [];
|
|
24
|
+
const created = list.filter((t) => !t.to && t.contractAddress && t.from.toLowerCase() === deployer).map((t) => ({ address: t.contractAddress.toLowerCase(), at: new Date(Number(t.timeStamp) * 1000).toISOString() }));
|
|
25
|
+
if (!created.some((x) => x.address === token))
|
|
26
|
+
created.push({ address: token, at: createdAt ?? now.toISOString() });
|
|
27
|
+
const recent = created.slice(-30);
|
|
28
|
+
// Pools today, 30 tokens per DexScreener call.
|
|
29
|
+
const liq = new Map();
|
|
30
|
+
for (let i = 0; i < recent.length; i += 30) {
|
|
31
|
+
const r = await ctx.http.get(`https://api.dexscreener.com/tokens/v1/${DEX_CHAIN[c.key] ?? c.key}/${recent.slice(i, i + 30).map((x) => x.address).join(',')}`, { source: 'dexscreener', ttlSec: 900 });
|
|
32
|
+
if (i === 0)
|
|
33
|
+
provenance.push(r.prov);
|
|
34
|
+
for (const p of Array.isArray(r.data) ? r.data : []) {
|
|
35
|
+
const a = p.baseToken?.address?.toLowerCase();
|
|
36
|
+
if (a)
|
|
37
|
+
liq.set(a, Math.max(liq.get(a) ?? 0, p.liquidity?.usd ?? 0));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const deployments = [];
|
|
41
|
+
for (const d of recent) {
|
|
42
|
+
const m = await tokenMeta(ctx, c, d.address);
|
|
43
|
+
const isToken = Boolean(m.symbol && m.decimals !== null);
|
|
44
|
+
const l = liq.has(d.address) ? liq.get(d.address) : null;
|
|
45
|
+
deployments.push({ address: d.address, symbol: m.symbol, name: m.name, createdAt: d.at, liquidityUsd: l, dead: isToken && (l === null || l < 1000), isToken });
|
|
46
|
+
}
|
|
47
|
+
const tokens = deployments.filter((d) => d.isToken), dead = tokens.filter((d) => d.dead && d.address !== token);
|
|
48
|
+
const others = tokens.filter((d) => d.address !== token);
|
|
49
|
+
// Who funded the deployer first.
|
|
50
|
+
let fundedBy = null;
|
|
51
|
+
const first = list.find((t) => t.to?.toLowerCase() === deployer && BigInt(t.value || '0') > 0n);
|
|
52
|
+
if (first) {
|
|
53
|
+
try {
|
|
54
|
+
provenance.push(await ensureLabels(ctx));
|
|
55
|
+
}
|
|
56
|
+
catch { }
|
|
57
|
+
const a = first.from.toLowerCase();
|
|
58
|
+
fundedBy = { address: a, label: labelOf(a) ?? describeLabels(labelsFor(ctx, a)) };
|
|
59
|
+
}
|
|
60
|
+
const reasons = [], notes = [];
|
|
61
|
+
let risk = 0;
|
|
62
|
+
if (others.length) {
|
|
63
|
+
const share = dead.length / others.length;
|
|
64
|
+
reasons.push(`the deployer made ${others.length} other token${others.length > 1 ? 's' : ''}; ${dead.length} ${dead.length === 1 ? 'has' : 'have'} no pool or under $1,000 of liquidity today`);
|
|
65
|
+
if (others.length >= 3 && share >= 0.7)
|
|
66
|
+
risk += 70;
|
|
67
|
+
else if (dead.length >= 2)
|
|
68
|
+
risk += 35;
|
|
69
|
+
}
|
|
70
|
+
const age = list[0] ? (now.getTime() - Number(list[0].timeStamp) * 1000) / 86_400_000 : null;
|
|
71
|
+
if (age !== null && age < 7) {
|
|
72
|
+
risk += 15;
|
|
73
|
+
reasons.push(`the deployer wallet is ${Math.max(0, Math.round(age))} days old`);
|
|
74
|
+
}
|
|
75
|
+
if (fundedBy?.label && /tornado|mixer|railgun/i.test(fundedBy.label)) {
|
|
76
|
+
risk += 30;
|
|
77
|
+
reasons.push(`the deployer was first funded from a mixer (${fundedBy.label})`);
|
|
78
|
+
}
|
|
79
|
+
else if (fundedBy?.label)
|
|
80
|
+
notes.push(`First funded by ${fundedBy.label}.`);
|
|
81
|
+
if (!others.length)
|
|
82
|
+
notes.push('No other deployments in the creator\'s own transactions. Tokens made through a launchpad factory are created by the factory and do not show here.');
|
|
83
|
+
if (list.length >= 1000)
|
|
84
|
+
notes.push('The deployer has more than 1,000 transactions; only the first 1,000 were read.');
|
|
85
|
+
risk = Math.min(100, risk);
|
|
86
|
+
const verdict = risk >= 70 ? 'serial rug deployer' : risk >= 35 ? 'many dead tokens' : age !== null && age < 7 ? 'new deployer' : 'no bad record found';
|
|
87
|
+
const advice = risk >= 35 ? ['Most of this deployer\'s earlier tokens are dead. Expect the same unless something is clearly different this time.', 'Check what the owner can still do: oculon contract <token>'] : ['Nothing in the deployer\'s record stands out. Check the contract too: oculon contract <token>'];
|
|
88
|
+
const signals = risk >= 70 ? [{ id: signalId('deployer', deployer, c.key), module: 'deployer', title: `Deployer ${deployer.slice(0, 10)}: ${dead.length} of ${others.length} earlier tokens dead`, score: risk, entity: `deployer:${deployer}`, evidence: [{ source: 'etherscan', text: reasons[0] ?? '' }], createdAt: now.toISOString() }] : [];
|
|
89
|
+
return { module: 'deployer', input: token, generatedAt: now.toISOString(), signals, provenance, result: { ...base, deployer, createdAt, verdict, risk, deployments: deployments.reverse(), tokens: tokens.length, dead: dead.length, fundedBy, reasons, notes, advice } };
|
|
90
|
+
}
|