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,99 @@
|
|
|
1
|
+
import { EVM_CHAINS, ethCall, isAddr, tokenMeta, wordInt } from '../sources/evm.js';
|
|
2
|
+
const API = 'https://api.robinhood.com/rhj';
|
|
3
|
+
const nOrNull = (v) => { const n = Number(v); return v === undefined || v === null || v === '' || !Number.isFinite(n) ? null : n; };
|
|
4
|
+
const ymd = (d) => (d ? `${d.year}-${String(d.month).padStart(2, '0')}-${String(d.day).padStart(2, '0')}` : null);
|
|
5
|
+
const kind = (t) => t.replace(/^CORPORATE_ACTION_TYPE_/, '').toLowerCase().replace(/_/g, ' ');
|
|
6
|
+
const detailOf = (c) => {
|
|
7
|
+
const d = Object.values(c.details ?? {})[0];
|
|
8
|
+
if (!d)
|
|
9
|
+
return null;
|
|
10
|
+
return Object.entries(d).filter(([k]) => k !== 'underlyingSymbol').map(([k, v]) => `${k.replace(/([A-Z])/g, ' $1').toLowerCase()} ${v}`).join(', ') || null;
|
|
11
|
+
};
|
|
12
|
+
export async function stockToken(ctx, input = '') {
|
|
13
|
+
const q = input.trim();
|
|
14
|
+
const provenance = [];
|
|
15
|
+
const [a, c] = await Promise.all([
|
|
16
|
+
ctx.http.get(`${API}/assets`, { source: 'robinhood-rhj', ttlSec: 6 * 3600 }),
|
|
17
|
+
ctx.http.get(`${API}/corporate-actions`, { source: 'robinhood-rhj', ttlSec: 3600 }),
|
|
18
|
+
]);
|
|
19
|
+
provenance.push(a.prov, c.prov);
|
|
20
|
+
const assets = a.data?.assets ?? [];
|
|
21
|
+
if (!assets.length)
|
|
22
|
+
throw new Error(`the Robinhood Stock Token API is not answering (${a.prov.note ?? a.prov.status})`);
|
|
23
|
+
const actions = (c.data?.corpActions ?? []).map((x) => ({ symbol: x.tokenSymbol, type: kind(x.type), date: ymd(x.processDate), status: x.status.replace(/^CORPORATE_ACTION_STATUS_/, '').toLowerCase().replace(/_/g, ' '), detail: detailOf(x) }));
|
|
24
|
+
const base = { query: q, verdict: 'stock tokens overview', risk: 0, symbol: null, name: null, isin: null, contract: null, chain: null, status: null, multiplier: null, pendingMultiplier: null, price: null, sessions: {}, supply: null, corporateActions: [], tokens: assets.length, reasons: [], advice: [] };
|
|
25
|
+
const today = ctx.now().toISOString().slice(0, 10);
|
|
26
|
+
const done = (r) => ({ module: 'stocktoken', input: q || 'overview', generatedAt: ctx.now().toISOString(), signals: [], provenance, result: r });
|
|
27
|
+
if (!q) {
|
|
28
|
+
const upcoming = actions.filter((x) => (x.date ?? '') >= today).sort((x, y) => (x.date ?? '').localeCompare(y.date ?? ''));
|
|
29
|
+
return done({ ...base, corporateActions: upcoming.slice(0, 20), reasons: [`${assets.filter((x) => /ACTIVE/.test(x.status)).length} of ${assets.length} Robinhood Stock Tokens are active`, ...upcoming.slice(0, 5).map((x) => `${x.date}: ${x.symbol} ${x.type}${x.detail ? ` (${x.detail})` : ''}`)], advice: ['Ask about one token: oculon stocktoken TSLA, or check an address someone sent you: oculon stocktoken 0x...'] });
|
|
30
|
+
}
|
|
31
|
+
// An address: official or not.
|
|
32
|
+
if (isAddr(q)) {
|
|
33
|
+
const addr = q.toLowerCase();
|
|
34
|
+
const hit = assets.find((x) => x.deployments.some((d) => d.contractAddress.toLowerCase() === addr));
|
|
35
|
+
if (!hit) {
|
|
36
|
+
const rh = EVM_CHAINS.robinhood;
|
|
37
|
+
let meta = await tokenMeta(ctx, rh, addr);
|
|
38
|
+
let where = rh.label;
|
|
39
|
+
if (!meta.symbol) {
|
|
40
|
+
for (const k of ['eth', 'base', 'arbitrum', 'bsc']) {
|
|
41
|
+
const m = await tokenMeta(ctx, EVM_CHAINS[k], addr);
|
|
42
|
+
if (m.symbol) {
|
|
43
|
+
meta = m;
|
|
44
|
+
where = EVM_CHAINS[k].label;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const sym = (meta.symbol ?? '').toUpperCase().replace(/^(R|X|S|B|D|T)?([A-Z.]{1,6})$/, '$2');
|
|
50
|
+
const copies = assets.find((x) => x.tokenSymbol.toUpperCase() === (meta.symbol ?? '').toUpperCase() || x.tokenSymbol.toUpperCase() === sym);
|
|
51
|
+
const claims = /robinhood/i.test(`${meta.name ?? ''} ${meta.symbol ?? ''}`);
|
|
52
|
+
if (copies || claims) {
|
|
53
|
+
const real = copies ?? null;
|
|
54
|
+
return done({ ...base, verdict: 'fake stock token', risk: 85, symbol: meta.symbol, name: meta.name, contract: addr, chain: where, reasons: [`this token (${meta.symbol ?? '?'}${meta.name ? `, "${meta.name}"` : ''} on ${where}) is not on Robinhood's official Stock Token list`, ...(real ? [`the official ${real.tokenSymbol} Stock Token is ${real.deployments[0]?.contractAddress} on ${real.deployments[0]?.networkName}`] : []), ...(claims ? ['it calls itself a Robinhood token'] : [])], advice: ['Do not buy it as a stock token. Only the contract on the official list is backed by the share.', ...(real ? [`Use the official contract: ${real.deployments[0]?.contractAddress}`] : [])] });
|
|
55
|
+
}
|
|
56
|
+
return done({ ...base, verdict: 'not a stock token', symbol: meta.symbol, name: meta.name, contract: addr, chain: meta.symbol ? where : null, reasons: ['this address is not an official Robinhood Stock Token and does not copy one'], advice: ['For other token risks: oculon contract <address> and oculon honeypot <address>'] });
|
|
57
|
+
}
|
|
58
|
+
return describe(ctx, hit, q, base, actions, provenance, today).then(done);
|
|
59
|
+
}
|
|
60
|
+
const sym = q.toUpperCase().replace(/^\$/, '');
|
|
61
|
+
const hit = assets.find((x) => x.tokenSymbol.toUpperCase() === sym) ?? assets.find((x) => x.tokenName.toLowerCase().startsWith(q.toLowerCase()));
|
|
62
|
+
if (!hit)
|
|
63
|
+
throw new Error(`no Robinhood Stock Token for "${q}" (the list has ${assets.length}; try a ticker like TSLA)`);
|
|
64
|
+
return describe(ctx, hit, q, base, actions, provenance, today).then(done);
|
|
65
|
+
}
|
|
66
|
+
async function describe(ctx, x, q, base, actions, provenance, today) {
|
|
67
|
+
const dep = x.deployments[0];
|
|
68
|
+
const p = await ctx.http.get(`${API}/prices/${encodeURIComponent(x.tokenSymbol)}`, { source: 'robinhood-rhj', ttlSec: 30 });
|
|
69
|
+
provenance.push(p.prov);
|
|
70
|
+
const qt = p.data?.quotes?.[0];
|
|
71
|
+
const mult = nOrNull(x.currentMultiplier) ?? 1;
|
|
72
|
+
const bid = nOrNull(qt?.bid), ask = nOrNull(qt?.ask);
|
|
73
|
+
let supply = null;
|
|
74
|
+
if (dep && dep.chainId === 4663) {
|
|
75
|
+
const s = await ethCall(ctx, EVM_CHAINS.robinhood, dep.contractAddress, '0x18160ddd', 300);
|
|
76
|
+
if (s.data && s.data.length >= 66)
|
|
77
|
+
supply = Number(wordInt(s.data, 0) / 10n ** BigInt(Math.max(0, (x.tokenDecimals ?? 18) - 4))) / 1e4;
|
|
78
|
+
}
|
|
79
|
+
const sessions = {};
|
|
80
|
+
for (const [k, v] of Object.entries(x.tradingCapabilities ?? {}))
|
|
81
|
+
sessions[k] = (v.whole ?? '').replace(/^TRADING_STATUS_/, '').toLowerCase().replace(/_/g, ' ');
|
|
82
|
+
const mine = actions.filter((a) => a.symbol === x.tokenSymbol).sort((a, b) => (b.date ?? '').localeCompare(a.date ?? ''));
|
|
83
|
+
const halted = Boolean(qt?.isTradingHalt);
|
|
84
|
+
const reasons = [
|
|
85
|
+
`official Robinhood Stock Token: ${dep?.contractAddress ?? '?'} on ${dep?.networkName ?? '?'}`,
|
|
86
|
+
...(bid !== null && ask !== null ? [`bid $${(bid * mult).toFixed(2)} / ask $${(ask * mult).toFixed(2)} per token${mult !== 1 ? ` (share price times the ${mult.toFixed(6)} multiplier from past corporate actions)` : ''}`] : []),
|
|
87
|
+
...(halted ? ['trading is halted right now'] : []),
|
|
88
|
+
...(nOrNull(x.pendingMultiplier) ? [`a corporate action will change the multiplier to ${x.pendingMultiplier}`] : []),
|
|
89
|
+
...mine.filter((a) => (a.date ?? '') >= today).slice(0, 3).map((a) => `${a.date}: ${a.type}${a.detail ? ` (${a.detail})` : ''}`),
|
|
90
|
+
];
|
|
91
|
+
return {
|
|
92
|
+
...base, verdict: halted ? 'trading halted' : 'official Robinhood stock token', risk: halted ? 30 : 0,
|
|
93
|
+
symbol: x.tokenSymbol, name: x.tokenName, isin: x.isin ?? null, contract: dep?.contractAddress ?? null, chain: dep?.networkName ?? null, status: x.status.replace(/^ASSET_STATUS_/, '').toLowerCase(),
|
|
94
|
+
multiplier: mult, pendingMultiplier: nOrNull(x.pendingMultiplier),
|
|
95
|
+
price: qt ? { bid, ask, tokenBid: bid !== null ? bid * mult : null, tokenAsk: ask !== null ? ask * mult : null, dailyHigh: nOrNull(qt.dailyHigh), dailyLow: nOrNull(qt.dailyLow), volume: nOrNull(qt.dailyTradingVolume), halted, at: qt.generatedAt ?? null } : null,
|
|
96
|
+
sessions, supply, corporateActions: mine.slice(0, 10), reasons,
|
|
97
|
+
advice: [`Only ${dep?.contractAddress ?? 'the official contract'} is the Robinhood ${x.tokenSymbol} token. Tokens with the same ticker elsewhere are not backed by the share.`],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fund trace: follow where money went from an address, a few hops out.
|
|
3
|
+
* At each hop the largest outgoing flows (native coin and tokens, from Etherscan) are followed. A branch stops
|
|
4
|
+
* when it reaches an exchange, a bridge or a mixer (named by the open eth-labels dataset), a contract, a
|
|
5
|
+
* sanctioned address, or the hop limit. Exchanges are where stolen funds can be frozen: the report lists them
|
|
6
|
+
* first, with the transaction hashes to give the exchange or the police.
|
|
7
|
+
*/
|
|
8
|
+
import type { Ctx } from '../core/context.js';
|
|
9
|
+
import type { ModuleResult } from '../core/types.js';
|
|
10
|
+
export interface TraceNode {
|
|
11
|
+
address: string;
|
|
12
|
+
hop: number;
|
|
13
|
+
label: string | null;
|
|
14
|
+
kind: 'exchange' | 'mixer' | 'bridge' | 'scam' | 'contract' | 'sanctioned' | 'wallet' | 'start';
|
|
15
|
+
receivedFrom: string | null;
|
|
16
|
+
amount: string | null;
|
|
17
|
+
firstTx: string | null;
|
|
18
|
+
at: string | null;
|
|
19
|
+
stop: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface TraceReport {
|
|
22
|
+
address: string;
|
|
23
|
+
chain: string;
|
|
24
|
+
verdict: 'reached sanctioned address' | 'reached mixer' | 'reached exchange' | 'funds still in wallets' | 'no outgoing funds found';
|
|
25
|
+
/** How bad the destinations are: sanctioned or mixer high, scam labels medium; an exchange is where funds can be frozen. */
|
|
26
|
+
risk: number;
|
|
27
|
+
hops: number;
|
|
28
|
+
nodes: TraceNode[];
|
|
29
|
+
exchanges: TraceNode[];
|
|
30
|
+
reasons: string[];
|
|
31
|
+
advice: string[];
|
|
32
|
+
}
|
|
33
|
+
export declare function traceFunds(ctx: Ctx, input: string, opts?: {
|
|
34
|
+
chain?: string;
|
|
35
|
+
hops?: number;
|
|
36
|
+
width?: number;
|
|
37
|
+
}): Promise<ModuleResult<TraceReport>>;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { signalId } from '../core/text.js';
|
|
2
|
+
import { alchemyPrices, codeAt, esTokenTx, esTxList, evmChain, isAddr, labelOf } from '../sources/evm.js';
|
|
3
|
+
import { describeLabels, ensureLabels, labelsFor } from '../sources/labels.js';
|
|
4
|
+
import { screen } from './sanctions.js';
|
|
5
|
+
import { DEX_CHAIN } from '../sources/onchain.js';
|
|
6
|
+
function kindOf(label) {
|
|
7
|
+
if (!label)
|
|
8
|
+
return null;
|
|
9
|
+
if (/tornado|mixer|railgun|samourai|wasabi|sinbad|blender/i.test(label))
|
|
10
|
+
return 'mixer';
|
|
11
|
+
if (/phish|scam|hack|exploit|heist|drainer|fake/i.test(label))
|
|
12
|
+
return 'scam';
|
|
13
|
+
if (/bridge|wormhole|stargate|hop protocol|across|synapse|multichain|layerzero/i.test(label))
|
|
14
|
+
return 'bridge';
|
|
15
|
+
if (/binance|coinbase|kraken|okx|okex|bybit|kucoin|bitfinex|huobi|htx|gate\.?io|crypto\.com|gemini|bitstamp|mexc|bitget|upbit|bithumb|exchange|deposit|hot wallet|cex/i.test(label))
|
|
16
|
+
return 'exchange';
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const WRAPPED = { eth: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', arbitrum: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1', polygon: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270', optimism: '0x4200000000000000000000000000000000000006', base: '0x4200000000000000000000000000000000000006', bsc: '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c' };
|
|
20
|
+
/** USD price and pool liquidity of tokens, 30 per DexScreener call. Tokens without a real pool are spam here. */
|
|
21
|
+
async function prices(ctx, chain, tokens) {
|
|
22
|
+
const out = new Map();
|
|
23
|
+
for (let i = 0; i < tokens.length && i < 60; i += 30) {
|
|
24
|
+
const r = await ctx.http.get(`https://api.dexscreener.com/tokens/v1/${DEX_CHAIN[chain] ?? chain}/${tokens.slice(i, i + 30).join(',')}`, { source: 'dexscreener', ttlSec: 900 });
|
|
25
|
+
for (const p of Array.isArray(r.data) ? r.data : []) {
|
|
26
|
+
const a = p.baseToken?.address?.toLowerCase();
|
|
27
|
+
if (!a || !p.priceUsd)
|
|
28
|
+
continue;
|
|
29
|
+
const liq = p.liquidity?.usd ?? 0;
|
|
30
|
+
if ((out.get(a)?.liq ?? -1) < liq)
|
|
31
|
+
out.set(a, { price: Number(p.priceUsd), liq });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Tokens DexScreener does not know: Alchemy's price feed, which only lists tokens with a real market.
|
|
35
|
+
const missing = tokens.filter((t) => !out.has(t));
|
|
36
|
+
if (missing.length)
|
|
37
|
+
for (const [a, price] of await alchemyPrices(ctx, evmChain(chain), missing))
|
|
38
|
+
out.set(a, { price, liq: 10_000 });
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
async function outflows(ctx, c, a, prov) {
|
|
42
|
+
const [t, k] = await Promise.all([esTxList(ctx, c, a, 200), esTokenTx(ctx, c, a, 300)]);
|
|
43
|
+
if (!prov.length)
|
|
44
|
+
prov.push(t.prov, k.prov);
|
|
45
|
+
const outs = (k.data ?? []).filter((x) => x.from.toLowerCase() === a && x.to && BigInt(x.value || '0') > 0n);
|
|
46
|
+
const px = await prices(ctx, c.key, [...new Set([...outs.map((x) => x.contractAddress.toLowerCase()), WRAPPED[c.key] ?? ''])].filter(Boolean));
|
|
47
|
+
const nativeUsd = px.get(WRAPPED[c.key] ?? '')?.price ?? 0;
|
|
48
|
+
const by = new Map();
|
|
49
|
+
const add = (to, sym, amt, usd, tx, ts) => {
|
|
50
|
+
const e = by.get(to) ?? { score: 0, parts: new Map(), tx, at: ts };
|
|
51
|
+
e.score += usd;
|
|
52
|
+
e.parts.set(sym, (e.parts.get(sym) ?? 0) + amt);
|
|
53
|
+
by.set(to, e);
|
|
54
|
+
};
|
|
55
|
+
for (const x of t.data ?? []) {
|
|
56
|
+
if (x.from.toLowerCase() !== a || x.isError === '1' || !x.to)
|
|
57
|
+
continue;
|
|
58
|
+
const v = Number(BigInt(x.value || '0') / 10n ** 12n) / 1e6;
|
|
59
|
+
if (v > 0)
|
|
60
|
+
add(x.to.toLowerCase(), c.native, v, v * (nativeUsd || 1), x.hash, new Date(Number(x.timeStamp) * 1000).toISOString());
|
|
61
|
+
}
|
|
62
|
+
// Token transfers: spam tokens fake transfers from any wallet, so only tokens with a real pool count.
|
|
63
|
+
for (const x of outs) {
|
|
64
|
+
const p = px.get(x.contractAddress.toLowerCase());
|
|
65
|
+
if (!p || p.liq < 10_000)
|
|
66
|
+
continue;
|
|
67
|
+
const dec = Number(x.tokenDecimal || 18);
|
|
68
|
+
const raw = BigInt(x.value || '0');
|
|
69
|
+
const v = dec >= 6 ? Number(raw / 10n ** BigInt(dec - 6)) / 1e6 : Number(raw) / 10 ** dec;
|
|
70
|
+
const usd = v * p.price;
|
|
71
|
+
if (!(usd >= 1))
|
|
72
|
+
continue;
|
|
73
|
+
add(x.to.toLowerCase(), x.tokenSymbol || 'token', v, usd, x.hash, new Date(Number(x.timeStamp) * 1000).toISOString());
|
|
74
|
+
}
|
|
75
|
+
return [...by].map(([to, e]) => ({ to, score: e.score, amount: [...e.parts].map(([s, v]) => `${v.toLocaleString('en-US', { maximumFractionDigits: 4 })} ${s}`).join(' + ') + (nativeUsd ? ` (about $${Math.round(e.score).toLocaleString('en-US')})` : ''), tx: e.tx, at: e.at }))
|
|
76
|
+
.filter((o) => o.score >= 1)
|
|
77
|
+
.sort((x, y) => y.score - x.score);
|
|
78
|
+
}
|
|
79
|
+
export async function traceFunds(ctx, input, opts = {}) {
|
|
80
|
+
const start = input.trim().toLowerCase();
|
|
81
|
+
if (!isAddr(start))
|
|
82
|
+
throw new Error('give an address: 0x followed by 40 hex characters');
|
|
83
|
+
const c = evmChain(opts.chain, 'transfers');
|
|
84
|
+
const hops = Math.max(1, Math.min(4, Math.round(opts.hops ?? 3)));
|
|
85
|
+
const width = Math.max(1, Math.min(4, Math.round(opts.width ?? 3)));
|
|
86
|
+
const provenance = [];
|
|
87
|
+
try {
|
|
88
|
+
provenance.push(await ensureLabels(ctx));
|
|
89
|
+
}
|
|
90
|
+
catch { }
|
|
91
|
+
const nodes = [{ address: start, hop: 0, label: describeLabels(labelsFor(ctx, start)), kind: 'start', receivedFrom: null, amount: null, firstTx: null, at: null, stop: null }];
|
|
92
|
+
const seen = new Set([start]);
|
|
93
|
+
let frontier = [start];
|
|
94
|
+
const esProv = [];
|
|
95
|
+
let calls = 0;
|
|
96
|
+
for (let h = 1; h <= hops && frontier.length; h++) {
|
|
97
|
+
const next = [];
|
|
98
|
+
for (const from of frontier) {
|
|
99
|
+
if (calls++ > 14)
|
|
100
|
+
break;
|
|
101
|
+
const outs = (await outflows(ctx, c, from, esProv)).filter((o) => !seen.has(o.to)).slice(0, width);
|
|
102
|
+
for (const o of outs) {
|
|
103
|
+
seen.add(o.to);
|
|
104
|
+
const lab = labelOf(o.to) ?? describeLabels(labelsFor(ctx, o.to));
|
|
105
|
+
let kind = kindOf(lab);
|
|
106
|
+
let stop = kind ? `reached ${kind}` : null;
|
|
107
|
+
if (!kind) {
|
|
108
|
+
let sanctioned = false;
|
|
109
|
+
try {
|
|
110
|
+
sanctioned = (await screen(ctx, o.to)).result.verdict === 'SANCTIONED';
|
|
111
|
+
}
|
|
112
|
+
catch { }
|
|
113
|
+
if (sanctioned) {
|
|
114
|
+
kind = 'sanctioned';
|
|
115
|
+
stop = 'on the US OFAC sanctions list';
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (!kind) {
|
|
119
|
+
const code = await codeAt(ctx, c, o.to);
|
|
120
|
+
if (code && code !== '0x' && !/^0xef0100/i.test(code)) {
|
|
121
|
+
kind = 'contract';
|
|
122
|
+
stop = lab ? `contract: ${lab}` : 'contract (swap, pool or app)';
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
kind ??= 'wallet';
|
|
126
|
+
nodes.push({ address: o.to, hop: h, label: lab, kind, receivedFrom: from, amount: o.amount, firstTx: o.tx, at: o.at, stop });
|
|
127
|
+
if (kind === 'wallet')
|
|
128
|
+
next.push(o.to);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
frontier = next;
|
|
132
|
+
}
|
|
133
|
+
provenance.push(...esProv);
|
|
134
|
+
const exchanges = nodes.filter((n) => n.kind === 'exchange');
|
|
135
|
+
const mixers = nodes.filter((n) => n.kind === 'mixer'), sanc = nodes.filter((n) => n.kind === 'sanctioned');
|
|
136
|
+
const reasons = [];
|
|
137
|
+
for (const n of [...sanc, ...mixers, ...exchanges].slice(0, 6))
|
|
138
|
+
reasons.push(`hop ${n.hop}: ${n.amount} to ${n.label ?? n.address} (${n.kind})`);
|
|
139
|
+
const open = nodes.filter((n) => n.kind === 'wallet' && n.hop === hops).length;
|
|
140
|
+
if (open)
|
|
141
|
+
reasons.push(`${open} branch${open > 1 ? 'es' : ''} still in plain wallets after ${hops} hops`);
|
|
142
|
+
const verdict = nodes.length === 1 ? 'no outgoing funds found' : sanc.length ? 'reached sanctioned address' : mixers.length ? 'reached mixer' : exchanges.length ? 'reached exchange' : 'funds still in wallets';
|
|
143
|
+
const advice = exchanges.length
|
|
144
|
+
? [`Report to ${[...new Set(exchanges.map((e) => e.label?.split(' (')[0] ?? 'the exchange'))].join(', ')} right away with the transaction hashes below: exchanges can freeze deposits.`, 'File a police report and keep the replay link of this check as evidence.']
|
|
145
|
+
: mixers.length ? ['Funds went through a mixer: tracing past it is not possible with public data. Report the hashes to the police and to the wallet app you used.']
|
|
146
|
+
: ['Follow the open branches again later: funds often wait in wallets before they move to an exchange.', 'Report the theft to the police with the addresses and hashes in this report.'];
|
|
147
|
+
const now = ctx.now().toISOString();
|
|
148
|
+
const signals = sanc.length ? [{ id: signalId('trace', start, c.key), module: 'trace', title: `Funds from ${start.slice(0, 10)} reached a sanctioned address`, score: 70, entity: `wallet:${start}`, evidence: sanc.slice(0, 2).map((n) => ({ source: 'etherscan', text: `hop ${n.hop}: ${n.address}` })), createdAt: now }] : [];
|
|
149
|
+
return { module: 'trace', input: start, generatedAt: now, result: { address: start, chain: c.label, verdict, risk: sanc.length ? 90 : mixers.length ? 70 : nodes.some((n) => n.kind === 'scam') ? 60 : 0, hops, nodes, exchanges, reasons, advice }, signals, provenance };
|
|
150
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction explainer: paste a transaction hash and read what happened, in plain words.
|
|
3
|
+
* Reads the transaction and its receipt from a public RPC, names the function called (signature databases),
|
|
4
|
+
* decodes every token transfer, approval and NFT approval in its logs, and says who sent what to whom.
|
|
5
|
+
* Flags the patterns behind most "my tokens disappeared" questions: tokens leaving a wallet in a transaction
|
|
6
|
+
* someone else sent (an approval being used), approvals to plain wallets or unverified contracts, and NFT
|
|
7
|
+
* collections handed over with setApprovalForAll.
|
|
8
|
+
*/
|
|
9
|
+
import type { Ctx } from '../core/context.js';
|
|
10
|
+
import type { ModuleResult } from '../core/types.js';
|
|
11
|
+
export interface TxMove {
|
|
12
|
+
kind: 'token' | 'nft' | 'approval' | 'nft approval' | 'native';
|
|
13
|
+
token: string | null;
|
|
14
|
+
symbol: string | null;
|
|
15
|
+
from: string;
|
|
16
|
+
to: string;
|
|
17
|
+
amount: string;
|
|
18
|
+
text: string;
|
|
19
|
+
}
|
|
20
|
+
export interface TxReport {
|
|
21
|
+
hash: string;
|
|
22
|
+
chain: string;
|
|
23
|
+
status: 'success' | 'failed' | 'pending';
|
|
24
|
+
verdict: 'tokens taken by someone else' | 'risky approval given' | 'failed transaction' | 'pending' | 'normal transaction';
|
|
25
|
+
risk: number;
|
|
26
|
+
from: string;
|
|
27
|
+
to: string | null;
|
|
28
|
+
function: string | null;
|
|
29
|
+
value: string;
|
|
30
|
+
fee: string | null;
|
|
31
|
+
time: string | null;
|
|
32
|
+
summary: string[];
|
|
33
|
+
moves: TxMove[];
|
|
34
|
+
reasons: string[];
|
|
35
|
+
advice: string[];
|
|
36
|
+
explorer: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function explainTx(ctx: Ctx, input: string, opts?: {
|
|
39
|
+
chain?: string;
|
|
40
|
+
}): Promise<ModuleResult<TxReport>>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { alchemyPrices, codeAt, EVM_CHAINS, evmChain, formatUnits, labelOf, rpcCall, sourcify, tokenMeta, TOPIC, topicAddr, UNLIMITED, wordInt } from '../sources/evm.js';
|
|
2
|
+
import { decodeSelectors } from '../sources/signatures.js';
|
|
3
|
+
import { DEX_CHAIN } from '../sources/onchain.js';
|
|
4
|
+
const STABLES = /^(USDT|USDC|DAI|WETH|WBTC|USDC\.E|USDE|PYUSD)$/i;
|
|
5
|
+
async function find(ctx, hash, prefer) {
|
|
6
|
+
const order = prefer ? [evmChain(prefer)] : ['eth', 'base', 'arbitrum', 'bsc', 'polygon', 'optimism'].map((k) => EVM_CHAINS[k]);
|
|
7
|
+
for (const c of order) {
|
|
8
|
+
const r = await rpcCall(ctx, c, 'eth_getTransactionByHash', [hash], 60);
|
|
9
|
+
if (r.data)
|
|
10
|
+
return { c, tx: r.data, prov: r.prov };
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
export async function explainTx(ctx, input, opts = {}) {
|
|
15
|
+
const hash = input.trim().toLowerCase().replace(/^.*\/tx\//, '').split(/[?#/]/)[0];
|
|
16
|
+
if (!/^0x[0-9a-f]{64}$/.test(hash))
|
|
17
|
+
throw new Error('give a transaction hash: 0x followed by 64 hex characters (or an explorer link to it)');
|
|
18
|
+
const f = await find(ctx, hash, opts.chain);
|
|
19
|
+
if (!f)
|
|
20
|
+
throw new Error(`transaction ${hash.slice(0, 12)}... not found on ${opts.chain ?? 'Ethereum, Base, Arbitrum, BNB Chain or Polygon'}`);
|
|
21
|
+
const { c, tx } = f;
|
|
22
|
+
const provenance = [f.prov];
|
|
23
|
+
const explorer = `${c.explorer}/tx/${hash}`;
|
|
24
|
+
const from = tx.from.toLowerCase(), to = tx.to?.toLowerCase() ?? null;
|
|
25
|
+
const value = BigInt(tx.value || '0');
|
|
26
|
+
const base = { hash, chain: c.label, from, to, value: `${formatUnits(value, 18)} ${c.native}`, explorer };
|
|
27
|
+
if (!tx.blockNumber)
|
|
28
|
+
return { module: 'tx', input: hash, generatedAt: ctx.now().toISOString(), signals: [], provenance, result: { ...base, status: 'pending', verdict: 'pending', risk: 0, function: null, fee: null, time: null, summary: ['The transaction is waiting to be included in a block.'], moves: [], reasons: [], advice: ['A pending transaction can still be replaced: send a new one with the same nonce and a higher fee to cancel it.'] } };
|
|
29
|
+
const [rc, blk] = await Promise.all([rpcCall(ctx, c, 'eth_getTransactionReceipt', [hash], 3600), rpcCall(ctx, c, 'eth_getBlockByNumber', [tx.blockNumber, false], 86_400)]);
|
|
30
|
+
provenance.push(rc.prov);
|
|
31
|
+
const receipt = rc.data;
|
|
32
|
+
const status = receipt?.status === '0x1' ? 'success' : 'failed';
|
|
33
|
+
const time = blk.data?.timestamp ? new Date(Number(BigInt(blk.data.timestamp)) * 1000).toISOString() : null;
|
|
34
|
+
const fee = receipt ? `${formatUnits(BigInt(receipt.gasUsed) * BigInt(receipt.effectiveGasPrice ?? tx.gasPrice ?? '0'), 18, 6)} ${c.native}` : null;
|
|
35
|
+
const sel = tx.input && tx.input.length >= 10 ? tx.input.slice(0, 10).toLowerCase() : null;
|
|
36
|
+
const fn = sel ? ((await decodeSelectors(ctx, [sel]).catch(() => ({})))[sel] ?? sel) : null;
|
|
37
|
+
const metas = new Map();
|
|
38
|
+
const meta = async (t) => { if (!metas.has(t))
|
|
39
|
+
metas.set(t, await tokenMeta(ctx, c, t)); return metas.get(t); };
|
|
40
|
+
const kinds = new Map();
|
|
41
|
+
const kindOf = async (a) => {
|
|
42
|
+
if (kinds.has(a))
|
|
43
|
+
return kinds.get(a);
|
|
44
|
+
const known = labelOf(a);
|
|
45
|
+
let k = known ?? 'unknown';
|
|
46
|
+
if (!known) {
|
|
47
|
+
const code = await codeAt(ctx, c, a);
|
|
48
|
+
k = code === '0x' || (code && /^0xef0100/i.test(code)) ? 'wallet' : code ? ((await sourcify(ctx, c, a)).data ? 'verified contract' : 'unverified contract') : 'unknown';
|
|
49
|
+
}
|
|
50
|
+
kinds.set(a, k);
|
|
51
|
+
return k;
|
|
52
|
+
};
|
|
53
|
+
const who = (a) => (a === from ? 'you (the sender)' : labelOf(a) ?? `${a.slice(0, 8)}...${a.slice(-4)}`);
|
|
54
|
+
const moves = [];
|
|
55
|
+
const reasons = [];
|
|
56
|
+
const taken = [];
|
|
57
|
+
if (value > 0n && to)
|
|
58
|
+
moves.push({ kind: 'native', token: null, symbol: c.native, from, to, amount: formatUnits(value, 18), text: `${who(from)} sent ${formatUnits(value, 18)} ${c.native} to ${who(to)}` });
|
|
59
|
+
for (const l of (receipt?.logs ?? []).slice(0, 60)) {
|
|
60
|
+
const t0 = l.topics[0]?.toLowerCase();
|
|
61
|
+
const tok = l.address.toLowerCase();
|
|
62
|
+
if (t0 === TOPIC.transfer && l.topics.length === 3) {
|
|
63
|
+
const m = await meta(tok);
|
|
64
|
+
const a = topicAddr(l.topics[1]), b = topicAddr(l.topics[2]);
|
|
65
|
+
const amt = formatUnits(wordInt(l.data, 0), m.decimals);
|
|
66
|
+
moves.push({ kind: 'token', token: tok, symbol: m.symbol, from: a, to: b, amount: amt, text: `${amt} ${m.symbol ?? 'tokens'} moved from ${who(a)} to ${who(b)}` });
|
|
67
|
+
if (a !== from && a !== '0x0000000000000000000000000000000000000000' && to !== a && (await kindOf(a)) === 'wallet')
|
|
68
|
+
taken.push({ token: tok, text: `${amt} ${m.symbol ?? 'tokens'} left ${a} in a transaction that ${a.slice(0, 8)}... did not send: an earlier approval or permit was used` });
|
|
69
|
+
}
|
|
70
|
+
else if (t0 === TOPIC.transfer && l.topics.length === 4) {
|
|
71
|
+
const a = topicAddr(l.topics[1]), b = topicAddr(l.topics[2]);
|
|
72
|
+
const m = await meta(tok);
|
|
73
|
+
const id = BigInt(l.topics[3]).toString();
|
|
74
|
+
moves.push({ kind: 'nft', token: tok, symbol: m.symbol, from: a, to: b, amount: `#${id.slice(0, 20)}`, text: `NFT ${m.symbol ?? tok.slice(0, 10)} #${id.slice(0, 20)} moved from ${who(a)} to ${who(b)}` });
|
|
75
|
+
if (a !== from && a !== '0x0000000000000000000000000000000000000000' && (await kindOf(a)) === 'wallet')
|
|
76
|
+
reasons.push([`an NFT left ${a} in a transaction it did not send`, 40]);
|
|
77
|
+
}
|
|
78
|
+
else if (t0 === TOPIC.approval && l.topics.length === 3) {
|
|
79
|
+
const m = await meta(tok);
|
|
80
|
+
const owner = topicAddr(l.topics[1]), spender = topicAddr(l.topics[2]);
|
|
81
|
+
const v = wordInt(l.data, 0);
|
|
82
|
+
if (v === 0n) {
|
|
83
|
+
moves.push({ kind: 'approval', token: tok, symbol: m.symbol, from: owner, to: spender, amount: '0', text: `${who(owner)} removed the ${m.symbol ?? 'token'} approval of ${who(spender)}` });
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const amt = v >= UNLIMITED ? 'unlimited' : formatUnits(v, m.decimals);
|
|
87
|
+
moves.push({ kind: 'approval', token: tok, symbol: m.symbol, from: owner, to: spender, amount: amt, text: `${who(owner)} allowed ${who(spender)} to take ${amt} ${m.symbol ?? 'tokens'}` });
|
|
88
|
+
const k = await kindOf(spender);
|
|
89
|
+
if (k === 'wallet')
|
|
90
|
+
reasons.push([`the approval goes to a plain wallet (${spender}), not an app contract`, 45]);
|
|
91
|
+
else if (k === 'unverified contract' && v >= UNLIMITED)
|
|
92
|
+
reasons.push([`unlimited approval to a contract with unpublished code (${spender})`, 30]);
|
|
93
|
+
}
|
|
94
|
+
else if (t0 === TOPIC.approvalForAll) {
|
|
95
|
+
const owner = topicAddr(l.topics[1]), op = topicAddr(l.topics[2]);
|
|
96
|
+
const on = wordInt(l.data, 0) !== 0n;
|
|
97
|
+
const m = await meta(tok);
|
|
98
|
+
moves.push({ kind: 'nft approval', token: tok, symbol: m.symbol, from: owner, to: op, amount: on ? 'all' : 'removed', text: on ? `${who(owner)} let ${who(op)} move every ${m.symbol ?? 'NFT'} in the collection` : `${who(owner)} removed ${who(op)} as operator` });
|
|
99
|
+
if (on && (await kindOf(op)) === 'wallet')
|
|
100
|
+
reasons.push([`all NFTs of the collection handed to a plain wallet (${op})`, 50]);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Spam tokens emit fake transfers out of famous wallets; only tokens with a real market count as taken.
|
|
104
|
+
if (taken.length) {
|
|
105
|
+
const toks = [...new Set(taken.map((t) => t.token))].slice(0, 30);
|
|
106
|
+
const r = await ctx.http.get(`https://api.dexscreener.com/tokens/v1/${DEX_CHAIN[c.key] ?? c.key}/${toks.join(',')}`, { source: 'dexscreener', ttlSec: 900 });
|
|
107
|
+
provenance.push(r.prov);
|
|
108
|
+
const liq = new Map();
|
|
109
|
+
for (const p of Array.isArray(r.data) ? r.data : []) {
|
|
110
|
+
const a = p.baseToken?.address?.toLowerCase();
|
|
111
|
+
if (a)
|
|
112
|
+
liq.set(a, Math.max(liq.get(a) ?? 0, p.liquidity?.usd ?? 0));
|
|
113
|
+
}
|
|
114
|
+
// Alchemy prices only tokens with a real market: a price there also counts.
|
|
115
|
+
const unknown = toks.filter((t) => (liq.get(t) ?? 0) < 10_000);
|
|
116
|
+
for (const [a] of await alchemyPrices(ctx, c, unknown))
|
|
117
|
+
liq.set(a, 10_000);
|
|
118
|
+
for (const t of taken) {
|
|
119
|
+
if ((liq.get(t.token) ?? 0) >= 10_000 || STABLES.test(metas.get(t.token)?.symbol ?? ''))
|
|
120
|
+
reasons.push([t.text, 45]);
|
|
121
|
+
else
|
|
122
|
+
reasons.push([`${t.text.split(' left ')[0]} "left" a wallet that did not send this transaction, but the token has no real market: most likely a spam token faking a transfer, not a theft`, 0]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (status === 'failed')
|
|
126
|
+
reasons.push(['the transaction failed: nothing moved except the network fee', 0]);
|
|
127
|
+
const risk = Math.min(100, reasons.reduce((s, [, w]) => s + w, 0));
|
|
128
|
+
const isTaken = reasons.some(([r, w]) => w > 0 && /did not send/.test(r));
|
|
129
|
+
const verdict = status === 'failed' ? 'failed transaction' : isTaken ? 'tokens taken by someone else' : risk >= 30 ? 'risky approval given' : 'normal transaction';
|
|
130
|
+
const summary = [`${who(from)} called ${fn ? fn.split('(')[0] : 'a plain transfer'}${to ? ` on ${who(to)}` : ''}${time ? ` on ${time.slice(0, 16).replace('T', ' ')} UTC` : ''}; ${status}${fee ? `, fee ${fee}` : ''}.`, ...moves.slice(0, 12).map((m) => m.text)];
|
|
131
|
+
const advice = verdict === 'tokens taken by someone else'
|
|
132
|
+
? ['The owner signed an approval or permit earlier. Revoke every approval on that wallet now (oculon approvals <wallet>) and move what is left to a new wallet.', 'Follow the funds: oculon trace <receiving address>']
|
|
133
|
+
: verdict === 'risky approval given' ? ['Revoke this approval unless you meant it: oculon approvals <wallet>'] : ['Nothing unusual in this transaction.'];
|
|
134
|
+
return { module: 'tx', input: hash, generatedAt: ctx.now().toISOString(), signals: [], provenance, result: { ...base, status, verdict, risk, function: fn, fee, time, summary, moves, reasons: reasons.map(([r]) => r), advice } };
|
|
135
|
+
}
|
package/dist/modules/urlcheck.js
CHANGED
|
@@ -2,6 +2,7 @@ import { key } from '../core/keys.js';
|
|
|
2
2
|
import { clamp } from '../core/stats.js';
|
|
3
3
|
import { signalId } from '../core/text.js';
|
|
4
4
|
import { safeBrowsing } from '../sources/websec.js';
|
|
5
|
+
import { ensurePhishLists, phishDomain } from '../sources/phishlists.js';
|
|
5
6
|
const DAY = 86_400_000;
|
|
6
7
|
const TWO_LEVEL = /^(co|com|net|org|gov|ac|edu|or|ne|go|mil|nic)$/;
|
|
7
8
|
const RISKY_TLDS = new Set(['zip', 'mov', 'xyz', 'top', 'click', 'country', 'gq', 'tk', 'ml', 'cf', 'ga', 'work', 'support', 'rest', 'fit', 'loan', 'cam', 'quest', 'cfd', 'sbs', 'icu', 'buzz', 'monster']);
|
|
@@ -143,6 +144,15 @@ export async function urlCheck(ctx, input) {
|
|
|
143
144
|
scanHistory(ctx, host),
|
|
144
145
|
]);
|
|
145
146
|
const provenance = [sb.prov, ...haus.prov, who.prov, scans.prov];
|
|
147
|
+
// Open crypto phishing blocklists (ScamSniffer, MetaMask), stored locally and refreshed daily.
|
|
148
|
+
let blocklisted = [];
|
|
149
|
+
if (!isIp) {
|
|
150
|
+
try {
|
|
151
|
+
provenance.push(...(await ensurePhishLists(ctx)).slice(0, 1));
|
|
152
|
+
blocklisted = phishDomain(ctx, host).listed;
|
|
153
|
+
}
|
|
154
|
+
catch { /* lists are optional */ }
|
|
155
|
+
}
|
|
146
156
|
const heuristics = urlHeuristics(u);
|
|
147
157
|
const reasons = [];
|
|
148
158
|
let risk = 0;
|
|
@@ -151,6 +161,10 @@ export async function urlCheck(ctx, input) {
|
|
|
151
161
|
risk = 100;
|
|
152
162
|
reasons.push(`Google Safe Browsing flags it: ${threats.join(', ')}`);
|
|
153
163
|
}
|
|
164
|
+
if (blocklisted.length) {
|
|
165
|
+
risk = 100;
|
|
166
|
+
reasons.push(`listed as phishing or a wallet drainer by the ${blocklisted.join(' and the ')}`);
|
|
167
|
+
}
|
|
154
168
|
const hu = haus.data?.url;
|
|
155
169
|
if (hu) {
|
|
156
170
|
risk = Math.max(risk, hu.status === 'online' ? 100 : 80);
|
|
@@ -194,7 +208,7 @@ export async function urlCheck(ctx, input) {
|
|
|
194
208
|
if (/^http:\/\//i.test(input.trim()) && !threats.length && !hu)
|
|
195
209
|
reasons.push('no HTTPS in the link as given');
|
|
196
210
|
risk = clamp(Math.round(risk), 0, 100);
|
|
197
|
-
const verdict = threats.length || hu || hostHit ? 'malicious' : risk >= 40 ? 'suspicious' : 'no known threats';
|
|
211
|
+
const verdict = threats.length || hu || hostHit || blocklisted.length ? 'malicious' : risk >= 40 ? 'suspicious' : 'no known threats';
|
|
198
212
|
if (verdict === 'no known threats' && age != null && age > 365)
|
|
199
213
|
reasons.push(`the domain is ${Math.floor(age / 365)} year${age >= 730 ? 's' : ''} old`);
|
|
200
214
|
const nowIso = ctx.now().toISOString();
|
|
@@ -3,12 +3,17 @@ import type { Oculon } from '../index.js';
|
|
|
3
3
|
import { type Rpc } from '../web/burns.js';
|
|
4
4
|
export declare const UTILITY: {
|
|
5
5
|
readonly investigate: 1500000n;
|
|
6
|
-
readonly safety:
|
|
6
|
+
readonly safety: 1000000n;
|
|
7
|
+
readonly holdInvestigate: 1500000n;
|
|
8
|
+
readonly holdSafety: 2000000n;
|
|
7
9
|
readonly holder: 3500000n;
|
|
8
10
|
readonly safetyDays: 30;
|
|
11
|
+
readonly holdInvestigateDays: 30;
|
|
9
12
|
readonly holderMonitors: 30;
|
|
10
13
|
readonly sessionDays: 7;
|
|
11
14
|
};
|
|
15
|
+
/** What a holder signs to spend their holding on an action. The nonce comes from createNonce and works once. */
|
|
16
|
+
export declare function holdMessage(kind: 'investigate' | 'safety', target: string, address: string, nonce: string): string;
|
|
12
17
|
/** Burns before the utility went live (buyback burns, for example) do not count. */
|
|
13
18
|
export declare const UTILITY_START: number;
|
|
14
19
|
/** What the burning wallet signs, so only the wallet that burned can spend its burn. */
|
|
@@ -44,6 +49,10 @@ export interface Investigation {
|
|
|
44
49
|
kind: string;
|
|
45
50
|
status: 'running' | 'done';
|
|
46
51
|
burn: Burn | null;
|
|
52
|
+
heldBy: {
|
|
53
|
+
address: string;
|
|
54
|
+
balance: string;
|
|
55
|
+
} | null;
|
|
47
56
|
parts: InvestigationPart[];
|
|
48
57
|
createdAt: string;
|
|
49
58
|
finishedAt: string | null;
|
|
@@ -62,6 +71,10 @@ export declare function startInvestigation(o: Oculon, tx: string, targetInput: s
|
|
|
62
71
|
id: string;
|
|
63
72
|
burn: Burn;
|
|
64
73
|
}>;
|
|
74
|
+
export declare function startInvestigationHold(o: Oculon, targetInput: string, address: string, nonce: string, signature: string): Promise<{
|
|
75
|
+
id: string;
|
|
76
|
+
nextFree: string;
|
|
77
|
+
}>;
|
|
65
78
|
export declare function getInvestigation(ctx: Ctx, id: string): Investigation | null;
|
|
66
79
|
export declare function listInvestigations(ctx: Ctx, limit?: number): {
|
|
67
80
|
id: string;
|
|
@@ -73,6 +86,7 @@ export interface SafetyState {
|
|
|
73
86
|
token: string;
|
|
74
87
|
active: boolean;
|
|
75
88
|
expiresAt: string | null;
|
|
89
|
+
heldBy: string | null;
|
|
76
90
|
verdict: string | null;
|
|
77
91
|
reasons: string[];
|
|
78
92
|
name: string | null;
|
|
@@ -88,6 +102,16 @@ export declare function startSafety(o: Oculon, tx: string, tokenInput: string, s
|
|
|
88
102
|
state: SafetyState;
|
|
89
103
|
burn: Burn;
|
|
90
104
|
}>;
|
|
105
|
+
/** Hold-backed badge: live while the wallet keeps the balance, re-checked daily. One badge per wallet. */
|
|
106
|
+
export declare function startSafetyHold(o: Oculon, tokenInput: string, address: string, nonce: string, signature: string): Promise<{
|
|
107
|
+
state: SafetyState;
|
|
108
|
+
}>;
|
|
109
|
+
/** Daily: a hold-backed badge stays live two more days while the wallet still holds enough; otherwise it lapses. */
|
|
110
|
+
export declare function refreshHolders(ctx: Ctx): Promise<{
|
|
111
|
+
token: string;
|
|
112
|
+
holder: string;
|
|
113
|
+
ok: boolean;
|
|
114
|
+
}[]>;
|
|
91
115
|
export declare function safetyState(ctx: Ctx, token: string): SafetyState;
|
|
92
116
|
/** Re-checks every active monitor not checked in the last `everyMs` (default 14 minutes). Returns verdict changes. */
|
|
93
117
|
export declare function runSafety(o: Oculon, everyMs?: number): Promise<{
|
|
@@ -102,6 +126,8 @@ export declare function createNonce(domain: string, addressInput: string, now?:
|
|
|
102
126
|
message: string;
|
|
103
127
|
nonce: string;
|
|
104
128
|
};
|
|
129
|
+
/** A nonce works once, for the wallet it was issued to, within ten minutes. */
|
|
130
|
+
export declare function consumeNonce(nonce: string, address: string): void;
|
|
105
131
|
export declare function balanceOf(address: string): Promise<bigint>;
|
|
106
132
|
export interface HolderSession {
|
|
107
133
|
key: string | null;
|