liqproof 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.
Files changed (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +536 -2
  3. package/bugs/README.md +144 -0
  4. package/bugs/coin-gecko-liquidity-report.md +283 -0
  5. package/bugs/collect-ds-aggregate.mjs +213 -0
  6. package/bugs/collect-evidence.mjs +458 -0
  7. package/bugs/collect-gt-aggregate.mjs +215 -0
  8. package/bugs/collect-raw-rpc.mjs +165 -0
  9. package/bugs/collect-sweep-context.mjs +162 -0
  10. package/bugs/dexscreener-fake-liquidity-report.md +310 -0
  11. package/bugs/evidence/aggregator-liquidity-claims.json +648 -0
  12. package/bugs/evidence/aggregator-liquidity-claims.md +103 -0
  13. package/bugs/evidence/bat-native-pool-drained.json +136 -0
  14. package/bugs/evidence/bat-native-pool-drained.md +51 -0
  15. package/bugs/evidence/chz-impersonator-pool-drained.json +136 -0
  16. package/bugs/evidence/chz-impersonator-pool-drained.md +51 -0
  17. package/bugs/evidence/gt-stale-reserve-after-drain.json +141 -0
  18. package/bugs/evidence/gt-stale-reserve-after-drain.md +31 -0
  19. package/bugs/evidence/raw-rpc-transcript.json +683 -0
  20. package/bugs/evidence/raw-rpc-transcript.md +308 -0
  21. package/bugs/evidence/sweep-context.json +325 -0
  22. package/bugs/evidence/sweep-context.md +55 -0
  23. package/bugs/evidence/verified-aggregate.json +526 -0
  24. package/bugs/evidence/verified-aggregate.md +24 -0
  25. package/bugs/evidence/verified-ds-liquidity-usd.json +1197 -0
  26. package/bugs/evidence/verified-ds-liquidity-usd.md +250 -0
  27. package/bugs/evidence/verified-gt-reserve-in-usd.json +1002 -0
  28. package/bugs/evidence/verified-gt-reserve-in-usd.md +218 -0
  29. package/bugs/fix-bundle-titles.mjs +72 -0
  30. package/bugs/geckoterminal-stale-reserve-after-drain.md +137 -0
  31. package/data/dataset-summary.md +103 -0
  32. package/data/impersonators.json +12888 -0
  33. package/data/verified-impersonators.json +725 -0
  34. package/data/wallets.json +23 -0
  35. package/dist/base58.js +70 -0
  36. package/dist/base58.js.map +1 -0
  37. package/dist/canonical.js +372 -0
  38. package/dist/canonical.js.map +1 -0
  39. package/dist/cli.js +830 -0
  40. package/dist/cli.js.map +1 -0
  41. package/dist/curve.js +255 -0
  42. package/dist/curve.js.map +1 -0
  43. package/dist/dashboard.js +485 -0
  44. package/dist/dashboard.js.map +1 -0
  45. package/dist/keccak.js +197 -0
  46. package/dist/keccak.js.map +1 -0
  47. package/dist/mcp.js +604 -0
  48. package/dist/mcp.js.map +1 -0
  49. package/dist/operator.js +180 -0
  50. package/dist/operator.js.map +1 -0
  51. package/dist/pda.js +86 -0
  52. package/dist/pda.js.map +1 -0
  53. package/dist/receipt.js +897 -0
  54. package/dist/receipt.js.map +1 -0
  55. package/dist/render.js +335 -0
  56. package/dist/render.js.map +1 -0
  57. package/dist/rpc.js +377 -0
  58. package/dist/rpc.js.map +1 -0
  59. package/dist/sources.js +599 -0
  60. package/dist/sources.js.map +1 -0
  61. package/dist/store.js +330 -0
  62. package/dist/store.js.map +1 -0
  63. package/dist/tokenmeta.js +424 -0
  64. package/dist/tokenmeta.js.map +1 -0
  65. package/dist/util.js +273 -0
  66. package/dist/util.js.map +1 -0
  67. package/dist/vaults.js +510 -0
  68. package/dist/vaults.js.map +1 -0
  69. package/dist/wallet.js +404 -0
  70. package/dist/wallet.js.map +1 -0
  71. package/dist/warnings.js +41 -0
  72. package/dist/warnings.js.map +1 -0
  73. package/dist/worker.js +857 -0
  74. package/dist/worker.js.map +1 -0
  75. package/dist/x402.js +549 -0
  76. package/dist/x402.js.map +1 -0
  77. package/docs/HACKATHON-SUBMISSION.md +264 -0
  78. package/docs/liqproof-plan.md +221 -0
  79. package/docs/llms.txt +32 -0
  80. package/docs/mcp-registry.md +165 -0
  81. package/docs/screenshots/01-dashboard.png +0 -0
  82. package/docs/screenshots/02-receipt-drained.png +0 -0
  83. package/docs/screenshots/03-receipt-impersonator.png +0 -0
  84. package/docs/screenshots/04-receipt-canonical.png +0 -0
  85. package/docs/x402-pricing.md +171 -0
  86. package/docs/zero-xyz.md +250 -0
  87. package/out/6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw.json +1171 -0
  88. package/out/6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw.md +52 -0
  89. package/out/6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw.svg +25 -0
  90. package/out/BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp.json +3975 -0
  91. package/out/BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp.md +90 -0
  92. package/out/BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp.svg +25 -0
  93. package/out/ENGkoidj2jNs73A7GZuseVmnkRg6EVF9tDtViwPz8o85.json +1446 -0
  94. package/out/ENGkoidj2jNs73A7GZuseVmnkRg6EVF9tDtViwPz8o85.md +66 -0
  95. package/out/ENGkoidj2jNs73A7GZuseVmnkRg6EVF9tDtViwPz8o85.svg +25 -0
  96. package/out/dataset.csv +67 -0
  97. package/out/impersonation-table.md +156 -0
  98. package/out/index.html +1179 -0
  99. package/package.json +78 -4
  100. package/scripts/assert-no-canonical-accusations.mjs +193 -0
  101. package/scripts/backfill.mjs +1063 -0
  102. package/scripts/bundle-evidence.mjs +237 -0
  103. package/scripts/bundle-stale-claim.mjs +417 -0
  104. package/scripts/capture-bch-evidence.mjs +58 -0
  105. package/scripts/check-orientation-fix.mjs +40 -0
  106. package/scripts/check-wallet.mjs +54 -0
  107. package/scripts/daily-refresh.mjs +451 -0
  108. package/scripts/decode-clmm-vaults.mjs +180 -0
  109. package/scripts/falsifiability.mjs +263 -0
  110. package/scripts/impersonator-mining.mjs +156 -0
  111. package/scripts/inspect-matches.mjs +73 -0
  112. package/scripts/operator-sweep.mjs +252 -0
  113. package/scripts/publish-release.mjs +248 -0
  114. package/scripts/refresh-store.mjs +78 -0
  115. package/scripts/survival-miner.mjs +951 -0
  116. package/scripts/test-keccak.mjs +103 -0
  117. package/scripts/verify-bch-1p95b.mjs +124 -0
  118. package/scripts/verify-clmm-1p95b.mjs +127 -0
  119. package/scripts/verify-clmm-control.mjs +84 -0
  120. package/scripts/verify-impersonators.mjs +138 -0
  121. package/scripts/verify-raw.mjs +110 -0
  122. package/scripts/verify-raw2.mjs +99 -0
  123. package/server.json +34 -0
  124. package/src/base58.ts +68 -0
  125. package/src/canonical.ts +447 -0
  126. package/src/cli.ts +941 -0
  127. package/src/curve.ts +349 -0
  128. package/src/dashboard.ts +504 -0
  129. package/src/keccak.ts +228 -0
  130. package/src/mcp.ts +735 -0
  131. package/src/operator.ts +219 -0
  132. package/src/receipt.ts +1219 -0
  133. package/src/render.ts +396 -0
  134. package/src/rpc.ts +435 -0
  135. package/src/sources.ts +714 -0
  136. package/src/store.ts +428 -0
  137. package/src/tokenmeta.ts +460 -0
  138. package/src/util.ts +276 -0
  139. package/src/vaults.ts +574 -0
  140. package/src/wallet.ts +459 -0
  141. package/src/warnings.ts +40 -0
  142. package/src/worker.ts +1086 -0
  143. package/src/x402.ts +717 -0
@@ -0,0 +1,180 @@
1
+ // Decisive vault-location probe for Raydium CLMM pools.
2
+ //
3
+ // Question: for a CLMM pool, WHERE do the real reserves live?
4
+ // The pool state declares token_0_vault / token_1_vault. For the BAT pool
5
+ // those accounts hold the reserves. For the canonical USDT pool they hold
6
+ // dust, yet GeckoTerminal claims $1.97B for it. Either the claim is stale or
7
+ // the reserves live somewhere else (per-bin vaults, bin arrays).
8
+ //
9
+ // Strategy (raw RPC only, no LIQPROOF code):
10
+ // 1. parse the pool state by its known layout
11
+ // 2. read the two declared vaults
12
+ // 3. enumerate EVERY 32-byte pubkey embedded in the pool account and
13
+ // fetch each one — any of them that is a token account with a balance
14
+ // is a candidate reserve
15
+ // 4. for every embedded account owned by the CLMM program (bin arrays),
16
+ // parse ITS data for pubkeys, derive their ATAs and read those too
17
+ //
18
+ // Read-only.
19
+ import { RpcPool } from '../dist/rpc.js';
20
+ import { findProgramAddress } from '../dist/tokenmeta.js';
21
+ import { encodeBase58, decodeBase58 } from '../dist/base58.js';
22
+
23
+ const rpc = new RpcPool({ verbose: false });
24
+ const CLMM_PROGRAM = 'CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK';
25
+ const ATA_PROGRAM = Buffer.from(decodeBase58('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'));
26
+ const TOKEN_PROGRAM = Buffer.from(decodeBase58('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'));
27
+ const TOKEN_2022 = Buffer.from(decodeBase58('TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb'));
28
+ const TOKEN_PROGRAM_IDS = new Set([
29
+ 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA',
30
+ 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
31
+ ]);
32
+
33
+ const CASES = [
34
+ {
35
+ label: 'BAT flagship (raydium-clmm) — our headline claim',
36
+ pool: '9NBCuxsfd8vsfTzNzHHAgoSXoSowgAhemtE3JfpwDTyD',
37
+ },
38
+ {
39
+ label: 'USDT canonical (raydium-clmm) — $1.97B claim, $0 found',
40
+ pool: 'CEvMnd2b79GFzsxSvJntvBZyjwJvrEaXbEfUURkyHg4f',
41
+ },
42
+ ];
43
+
44
+ function pubkeysIn(buf) {
45
+ const out = new Set();
46
+ for (let o = 0; o + 32 <= buf.length; o++) {
47
+ const s = buf.subarray(o, o + 32);
48
+ if (s.every((b) => b === 0)) continue;
49
+ out.add(encodeBase58(s));
50
+ }
51
+ return [...out];
52
+ }
53
+
54
+ async function fetchMany(addrs) {
55
+ const out = [];
56
+ for (let i = 0; i < addrs.length; i += 100) {
57
+ const chunk = addrs.slice(i, i + 100);
58
+ const res = await rpc.callDetailed('getMultipleAccounts', [
59
+ chunk,
60
+ { encoding: 'jsonParsed' },
61
+ ]);
62
+ const values = res.value?.value ?? [];
63
+ for (let j = 0; j < chunk.length; j++) {
64
+ out.push({ address: chunk[j], account: values[j] ?? null });
65
+ }
66
+ await new Promise((x) => setTimeout(x, 250));
67
+ }
68
+ return out;
69
+ }
70
+
71
+ function tokenBalance(account) {
72
+ const tb = account?.data?.parsed?.info?.tokenAmount;
73
+ if (!tb) return null;
74
+ return {
75
+ mint: account.data.parsed.info.mint,
76
+ ui: Number(tb.uiAmount ?? 0),
77
+ raw: tb.amount,
78
+ decimals: tb.decimals,
79
+ };
80
+ }
81
+
82
+ for (const c of CASES) {
83
+ console.log(`\n${'═'.repeat(104)}\n${c.label}\n pool ${c.pool}`);
84
+
85
+ const acct = await rpc.callDetailed('getAccountInfo', [c.pool, { encoding: 'base64' }]);
86
+ const pv = acct.value?.value;
87
+ const buf = Buffer.from(pv?.data?.[0] ?? '', 'base64');
88
+ const at = (o) => encodeBase58(buf.subarray(o, o + 32));
89
+
90
+ // The layout anchor: amm_config is the same constant for every pool.
91
+ const ammConfig = at(9);
92
+ const poolCreator = at(41);
93
+ const mint0 = at(73);
94
+ const mint1 = at(105);
95
+ const vault0 = at(137);
96
+ const vault1 = at(169);
97
+ const lpMint = at(201);
98
+ console.log(` data len ${buf.length} owner program ${pv?.owner}`);
99
+ console.log(` amm_config ${ammConfig}`);
100
+ console.log(` pool_creator ${poolCreator}`);
101
+ console.log(` token_0_mint ${mint0}`);
102
+ console.log(` token_1_mint ${mint1}`);
103
+ console.log(` token_0_vault ${vault0}`);
104
+ console.log(` token_1_vault ${vault1}`);
105
+ console.log(` lp_mint ${lpMint}`);
106
+
107
+ // ── 1. the two declared vaults ───────────────────────────────────────────
108
+ const declared = await fetchMany([vault0, vault1]);
109
+ for (const d of declared) {
110
+ const bal = tokenBalance(d.account);
111
+ console.log(
112
+ ` DECLARED vault ${d.address} owner=${d.account?.owner ?? 'MISSING'} bal=${bal ? `${bal.ui} ${bal.mint.slice(0, 8)}` : 'not a token account'}`,
113
+ );
114
+ }
115
+
116
+ // ── 2. every embedded pubkey ─────────────────────────────────────────────
117
+ const embedded = pubkeysIn(buf);
118
+ console.log(` embedded pubkeys: ${embedded.length}`);
119
+
120
+ const first = await fetchMany(embedded);
121
+ const tokenOwned = [];
122
+ const clmmOwned = [];
123
+ for (const e of first) {
124
+ if (!e.account) continue;
125
+ const bal = tokenBalance(e.account);
126
+ if (TOKEN_PROGRAM_IDS.has(e.account.owner)) {
127
+ tokenOwned.push({ ...e, bal });
128
+ } else if (e.account.owner === CLMM_PROGRAM) {
129
+ clmmOwned.push(e);
130
+ }
131
+ }
132
+ console.log(` token accounts among embedded: ${tokenOwned.length}`);
133
+ for (const t of tokenOwned) {
134
+ console.log(
135
+ ` ${t.address} ${t.bal ? `${t.bal.ui.toLocaleString('en-US', { maximumFractionDigits: 6 })} ${t.bal.mint.slice(0, 8)}` : 'zero'}`,
136
+ );
137
+ }
138
+ console.log(` CLMM-owned accounts among embedded (bin arrays etc): ${clmmOwned.length}`);
139
+
140
+ // ── 3. one level deeper: ATAs of pubkeys inside the CLMM-owned accounts ──
141
+ const deep = [];
142
+ for (const e of clmmOwned) {
143
+ const data = e.account.data;
144
+ const b64 = Array.isArray(data) ? data[0] : data?.data?.[0];
145
+ if (!b64) continue;
146
+ const sub = pubkeysIn(Buffer.from(b64, 'base64'));
147
+ for (const owner of sub) {
148
+ for (const mint of [mint0, mint1]) {
149
+ for (const prog of [TOKEN_PROGRAM, TOKEN_2022]) {
150
+ try {
151
+ const { address } = findProgramAddress(
152
+ [decodeBase58(owner), prog, decodeBase58(mint)],
153
+ ATA_PROGRAM,
154
+ );
155
+ deep.push({ ata: encodeBase58(address), owner, mint, prog: prog === TOKEN_PROGRAM ? 'SPL' : '2022' });
156
+ } catch {
157
+ /* invalid PDA */
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }
163
+ const uniqDeep = [...new Map(deep.map((d) => [d.ata, d])).values()];
164
+ console.log(` deep ATA candidates: ${uniqDeep.length}`);
165
+ if (uniqDeep.length) {
166
+ const res = await fetchMany(uniqDeep.map((d) => d.ata));
167
+ let hits = 0;
168
+ for (let i = 0; i < res.length; i++) {
169
+ const bal = tokenBalance(res[i].account);
170
+ if (!bal || bal.ui <= 0) continue;
171
+ hits++;
172
+ const d = uniqDeep[i];
173
+ console.log(
174
+ ` *** ${d.ata} mint=${d.mint.slice(0, 8)} ${d.prog} ui=${bal.ui.toLocaleString('en-US', { maximumFractionDigits: 6 })} (owner-pda ${d.owner.slice(0, 10)}…)`,
175
+ );
176
+ }
177
+ if (!hits) console.log(' (all deep ATAs empty/missing)');
178
+ }
179
+ await new Promise((x) => setTimeout(x, 900));
180
+ }
@@ -0,0 +1,263 @@
1
+ // Falsifiability harness: run LIQPROOF over a labelled set.
2
+ //
3
+ // A tool that flags everything is worthless. This proves precision AND recall.
4
+ //
5
+ // ── THE MOST IMPORTANT ROW IN THIS FILE ─────────────────────────────────────
6
+ //
7
+ // `6eftxVbSA…` was originally in the TRAP list, labelled "CHZ copycat B".
8
+ // It is the OFFICIAL Chiliz mint — listed in Chiliz's own documentation,
9
+ // mapped by CoinGecko, priced live by Jupiter, with an active custodial
10
+ // mint and freeze authority. A scanner that calls the official Chiliz token
11
+ // fake is a scanner nobody should trust, and publishing that claim would
12
+ // have destroyed the product's credibility on day one.
13
+ //
14
+ // So it now sits here, in the "must NOT be accused" set, with an explicit
15
+ // expected verdict of UNBACKED_LIQUIDITY: the pool's advertised number IS
16
+ // unbacked (that part is real), but we say so about the POOL and never
17
+ // about the TOKEN. That distinction is the whole point.
18
+ //
19
+ // Every case now declares THREE things:
20
+ // expect — the exact verdict we require
21
+ // forbidden — verdicts that would be a failure even if `expect` matched
22
+ // canonical — what the canonical resolver must conclude
23
+ import { RpcPool } from '../dist/rpc.js';
24
+ import { buildReceipt } from '../dist/receipt.js';
25
+
26
+ const rpc = new RpcPool({ verbose: false });
27
+
28
+ /** Verdicts that accuse a token of being fake. */
29
+ const ACCUSATORY = new Set(['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED']);
30
+
31
+ const CASES = [
32
+ // ── the traps: on-chain evidence must catch them ─────────────────────────
33
+ {
34
+ mint: 'BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp',
35
+ label: 'BAT impostor #1 ($136M claim)',
36
+ expect: 'FAKE_LIQUIDITY',
37
+ canonical: 'impersonator',
38
+ set: 'TRAP',
39
+ },
40
+ {
41
+ mint: 'CqjaL6XvobYG8D4Ty3cjtxw3ZyYfmAf3ggWnyyv2S4FB',
42
+ label: 'BAT impostor #2 ($1.09B claim)',
43
+ expect: 'FAKE_LIQUIDITY',
44
+ canonical: 'impersonator',
45
+ set: 'TRAP',
46
+ },
47
+ {
48
+ mint: '9vDguocExRQTPMjvULQCKCyti4ZycqzAQmcBjg8AsHdy',
49
+ label: 'Chiliz impostor ($48.9M claim)',
50
+ expect: 'FAKE_LIQUIDITY',
51
+ canonical: 'impersonator',
52
+ set: 'TRAP',
53
+ },
54
+
55
+ // ── the safety case: a REAL project we must not accuse ───────────────────
56
+ {
57
+ mint: '6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw',
58
+ label: 'CHILIZ (official — must not accuse)',
59
+ expect: 'UNBACKED_LIQUIDITY',
60
+ forbidden: ['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED'],
61
+ canonical: 'canonical',
62
+ set: 'SAFE',
63
+ },
64
+
65
+ // ── the bluechips ────────────────────────────────────────────────────────
66
+ {
67
+ mint: 'JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN',
68
+ label: 'JUP (bluechip)',
69
+ expect: 'CONSISTENT',
70
+ forbidden: ['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED'],
71
+ set: 'CLEAN',
72
+ },
73
+ {
74
+ mint: 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263',
75
+ label: 'BONK (bluechip)',
76
+ expect: 'CONSISTENT',
77
+ forbidden: ['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED'],
78
+ set: 'CLEAN',
79
+ },
80
+ {
81
+ mint: 'HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3',
82
+ label: 'PYTH (bluechip)',
83
+ expect: 'CONSISTENT',
84
+ forbidden: ['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED'],
85
+ set: 'CLEAN',
86
+ },
87
+ {
88
+ mint: 'jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL',
89
+ label: 'JTO (bluechip)',
90
+ expect: 'CONSISTENT',
91
+ forbidden: ['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED'],
92
+ set: 'CLEAN',
93
+ },
94
+ {
95
+ mint: 'Hg5Ja55T5wESq4vyFoiVCMeHXtGyVA69X2UHq8hgpump',
96
+ label: 'baton (real pump.fun)',
97
+ expect: 'CONSISTENT',
98
+ forbidden: ['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED'],
99
+ set: 'CLEAN',
100
+ },
101
+ {
102
+ mint: 'EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz',
103
+ label: 'BAT bridged (Wormhole)',
104
+ expect: 'CONSISTENT',
105
+ forbidden: ['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED'],
106
+ set: 'CLEAN',
107
+ },
108
+
109
+ // ── the hard ones. These used to produce false positives and they now
110
+ // define where the verdict rules stop. ────────────────────────────────
111
+ {
112
+ mint: 'DrZ26cKJDksVRWib3DVVsjo9eeXccc7hKhDJviiYEEZY',
113
+ label: 'YZY (96% self, tradable)',
114
+ expect: 'THIN',
115
+ forbidden: ['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED'],
116
+ set: 'CLEAN',
117
+ },
118
+ {
119
+ mint: 'ousd2mJsPEckLHcSCDxyKD7NDGARZcfLbDZkKiatYHB',
120
+ label: 'OUSD (quote impact max, pool funded)',
121
+ expect: 'CONSISTENT',
122
+ forbidden: ['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED'],
123
+ set: 'CLEAN',
124
+ },
125
+ {
126
+ mint: 'Grass7B4RdKfBCjTKgSqnXkqjwiGvQyFbuSCUJr3XXjs',
127
+ label: 'GRASS (4% coverage, thin)',
128
+ expect: 'THIN',
129
+ forbidden: ['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED'],
130
+ set: 'CLEAN',
131
+ },
132
+ {
133
+ mint: 'A1KLoBrKBde8Ty9qtNQUtq3C2ortoC3u7twggz7sEto6',
134
+ label: 'USDY (stablecoin, healthy)',
135
+ expect: 'CONSISTENT',
136
+ forbidden: ['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED'],
137
+ set: 'CLEAN',
138
+ },
139
+
140
+ // ── the trap we found on 2026-12-04 at 09:25 ──────────────────────────────
141
+ //
142
+ // A Raydium CLMM pool created at 08:58 with 10,000,000 tokens and 5,100
143
+ // USDT, and drained 27 minutes later in ONE transaction. GeckoTerminal
144
+ // still advertised $1.91 BILLION for it; DexScreener showed $0.19.
145
+ //
146
+ // This case needs the transaction history, because the difference between
147
+ // DRAINED and FAKE_LIQUIDITY is exactly the evidence we publish: the
148
+ // signature of the transaction that took the money.
149
+ {
150
+ mint: 'ENGkoidj2jNs73A7GZuseVmnkRg6EVF9tDtViwPz8o85',
151
+ label: 'fake "BCH " ($1.91B drained)',
152
+ expect: 'DRAINED',
153
+ canonical: 'unresolved',
154
+ includeCurve: true,
155
+ set: 'TRAP',
156
+ },
157
+
158
+ // ── the mistake we made and the rule that now prevents it ────────────────
159
+ //
160
+ // We once audited USDT on a pool where USDT was only the QUOTE token — a
161
+ // pool whose reserve had been drained — and published USDT as holding
162
+ // $0.00 of liquidity. The pool was the problem; USDT was the innocent
163
+ // counterparty, and the honest $40-billion USDT market was made to look
164
+ // like a scam.
165
+ //
166
+ // The rule: a receipt audits a pool where the mint is the BASE token.
167
+ // This case asserts the invariant, not a fixed verdict — USDT may be
168
+ // CONSISTENT on one day and UNKNOWN on another (UNKNOWN is the honest
169
+ // answer for an AMM whose vault layout we have not verified), but it must
170
+ // never be accused, and it must never be measured on a counterparty pool.
171
+ {
172
+ mint: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
173
+ label: 'USDT (never accuse, base-side)',
174
+ forbidden: ['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED'],
175
+ expectOrientation: 'base',
176
+ set: 'CLEAN',
177
+ },
178
+ ];
179
+
180
+ console.log('');
181
+ console.log(' LIQPROOF FALSIFIABILITY HARNESS');
182
+ console.log(' ' + '─'.repeat(112));
183
+ console.log(
184
+ ` ${'set'.padEnd(7)} ${'label'.padEnd(34)} ${'verdict'.padEnd(19)} ${'claimed'.padStart(12)} ${'deposited'.padStart(11)} ${'cov'.padStart(10)} ${'self%'.padStart(8)} ${'canonical'.padEnd(12)} ${'orient'.padEnd(6)} ${'flags'}`,
185
+ );
186
+ console.log(' ' + '─'.repeat(112));
187
+
188
+ let tp = 0, fp = 0, tn = 0, fn = 0;
189
+ const rows = [];
190
+
191
+ for (const item of CASES) {
192
+ let verdict = 'ERROR';
193
+ let claimed = 0, deposited = 0, coverage = 0, self = 0, impact = 0;
194
+ let canonical = '?';
195
+ let flags = '';
196
+ let orientation = '?';
197
+ try {
198
+ const r = await buildReceipt(rpc, item.mint, {
199
+ includeCurve: item.includeCurve ?? false,
200
+ });
201
+ verdict = r.verdict;
202
+ claimed = r.claimed.liquidityUsd;
203
+ deposited = r.real.depositedUsd;
204
+ coverage = r.real.coverage;
205
+ self = r.real.selfDenominatedPct;
206
+ impact = r.oracle.buyQuote?.priceImpactPct ?? 1;
207
+ canonical = r.identity.canonical.status;
208
+ flags = r.flags.join(',');
209
+ orientation = r.audited?.orientation ?? '?';
210
+ } catch (e) {
211
+ verdict = `ERR:${String(e.message).slice(0, 24)}`;
212
+ }
213
+
214
+ const expectedOk = item.expect ? verdict === item.expect : true;
215
+ const forbiddenHit = (item.forbidden ?? []).includes(verdict);
216
+ // Every clean case must also resolve to a canonical token — if the
217
+ // resolver cannot place a bluechip, that is a bug in the resolver, not a
218
+ // licence to accuse it.
219
+ const expectedCanonical = item.canonical ?? 'canonical';
220
+ const canonicalOk =
221
+ expectedCanonical === 'any' ? true : canonical === expectedCanonical;
222
+ // …and a receipt must be measured on a pool where the audited mint is the
223
+ // base token. A pool where the mint is only the counterparty says nothing
224
+ // about the mint's own liquidity.
225
+ const orientationOk =
226
+ item.expectOrientation ? orientation === item.expectOrientation : true;
227
+ const correct = expectedOk && !forbiddenHit && canonicalOk && orientationOk;
228
+
229
+ if (item.set === 'TRAP') correct ? tp++ : fn++;
230
+ else correct ? tn++ : fp++;
231
+
232
+ const mark = correct ? '\x1b[32mPASS\x1b[0m' : '\x1b[31mFAIL\x1b[0m';
233
+ const covPct =
234
+ coverage < 0.0001 ? `${(coverage * 100).toPrecision(2)}%` : `${(coverage * 100).toFixed(1)}%`;
235
+ console.log(
236
+ ` ${item.set.padEnd(7)} ${item.label.padEnd(34).slice(0, 34)} ${verdict.padEnd(19)} ${claimed.toFixed(0).padStart(12)} ${deposited.toFixed(2).padStart(11)} ${covPct.padStart(10)} ${(self * 100).toFixed(2).padStart(7)}% ${canonical.padEnd(12)} ${orientation.padEnd(6)} ${flags.padEnd(24).slice(0, 24)} ${mark}`,
237
+ );
238
+ if (!correct) {
239
+ const why = [];
240
+ if (!expectedOk) why.push(`expected ${item.expect}`);
241
+ if (forbiddenHit) why.push(`forbidden verdict ${verdict}`);
242
+ if (!canonicalOk) why.push(`canonical expected ${expectedCanonical}, got ${canonical}`);
243
+ if (!orientationOk) why.push(`orientation expected ${item.expectOrientation}, got ${orientation}`);
244
+ console.log(` ↳ ${why.join('; ')}`);
245
+ }
246
+ rows.push({ ...item, verdict, canonical, orientation, correct });
247
+ }
248
+
249
+ const traps = CASES.filter((c) => c.set === 'TRAP');
250
+ const cleans = CASES.filter((c) => c.set !== 'TRAP');
251
+ console.log(' ' + '─'.repeat(112));
252
+ console.log(` traps caught ${tp}/${traps.length}`);
253
+ console.log(` false positives ${fp}/${cleans.length}`);
254
+ console.log(` clean passed ${tn}/${cleans.length}`);
255
+ console.log(
256
+ ` precision ${tp + tn > 0 ? (((tp / (tp + fp)) * 100).toFixed(1) + '%') : 'n/a'} recall ${((tp / (tp + fn)) * 100).toFixed(1)}%`,
257
+ );
258
+ console.log(
259
+ ` real projects protected ${rows.filter((r) => r.canonical === 'canonical').length} (canonical resolved, never accused)`,
260
+ );
261
+ console.log('');
262
+
263
+ process.exit(fp > 0 ? 1 : 0);
@@ -0,0 +1,156 @@
1
+ // Mine the operator sweep for INDEPENDENTLY PROVEN impersonators.
2
+ //
3
+ // The sweep found 212 creator clusters, but a shared creator is NOT a fraud
4
+ // ring — launchpads and bridges share creators legitimately, and the sweep
5
+ // proved that (Aave, Arcium and AgriDex all sit in one cluster).
6
+ //
7
+ // What IS a proof is this: a mint whose on-chain NAME is already owned by a
8
+ // different, cited canonical mint. That we can check 1,000s of times.
9
+ //
10
+ // So this script joins the two datasets:
11
+ // sweep -> every token we saw, with its name, symbol and advertised $
12
+ // canonical index -> who legitimately owns each name
13
+ //
14
+ // and reports, per creator cluster, the members that are PROVEN
15
+ // impersonators. The cluster size alone proves nothing; the number of
16
+ // PROVEN impersonators inside it does.
17
+ import { readFileSync, writeFileSync } from 'node:fs';
18
+ import { loadCanonicalIndex, resolveCanonical } from '../dist/canonical.js';
19
+
20
+ const registry = JSON.parse(readFileSync('data/operator-registry.json', 'utf8'));
21
+ const index = await loadCanonicalIndex();
22
+ console.log(`canonical index: ${index.entries.length} entries (${JSON.stringify(index.counts)})`);
23
+ console.log(`sweep registry: ${registry.clusters.length} clusters, ${registry.tokensScanned} tokens scanned\n`);
24
+
25
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
26
+
27
+ // ── join: which tokens are proven impersonators? ────────────────────────────
28
+ //
29
+ // Two grades, and we keep them apart everywhere:
30
+ //
31
+ // confirmed — the mint's ON-CHAIN NAME is the registered name of a
32
+ // different, cited canonical mint. A name is an identity
33
+ // claim, so this is a real impersonation.
34
+ // symbol-only — the mint spells a registered TICKER as its own name.
35
+ // That is an observation, not an accusation: 49 CoinGecko
36
+ // coins share the ticker "USDC". These are reported, but
37
+ // they are NOT the headline.
38
+ //
39
+ // Only the `confirmed` set is publishable as "this is an impersonation".
40
+ const proven = new Map(); // mint -> {canonicalName, canonicalMint, proof, confidence}
41
+
42
+ let checked = 0;
43
+ for (const cluster of registry.clusters) {
44
+ for (const m of cluster.members) {
45
+ if (proven.has(m.mint)) continue;
46
+ checked++;
47
+ const res = resolveCanonical(
48
+ m.mint,
49
+ { name: m.name ?? '', symbol: m.symbol ?? '' },
50
+ index,
51
+ );
52
+ if (res.status === 'impersonator' && res.impersonates) {
53
+ proven.set(m.mint, {
54
+ mint: m.mint,
55
+ name: m.name,
56
+ symbol: m.symbol,
57
+ canonicalName: res.impersonates.name,
58
+ canonicalMint: res.impersonates.mint,
59
+ canonicalSymbol: res.impersonates.symbol,
60
+ proof: res.impersonates.proof,
61
+ source: res.impersonates.source,
62
+ confidence: res.confidence,
63
+ liquidity: m.liquidity ?? 0,
64
+ origin: m.origin ?? '',
65
+ });
66
+ }
67
+ }
68
+ }
69
+ const all = [...proven.values()];
70
+ const confirmed = all.filter((p) => p.confidence === 'confirmed');
71
+ const symbolOnly = all.filter((p) => p.confidence !== 'confirmed');
72
+ console.log(
73
+ `checked ${checked} cluster members -> ${all.length} name/ticker collisions ` +
74
+ `(${confirmed.length} confirmed name collisions, ${symbolOnly.length} ticker-only)\n`,
75
+ );
76
+
77
+ // ── group by cluster ────────────────────────────────────────────────────────
78
+ const rows = [];
79
+ for (const cluster of registry.clusters) {
80
+ const members = cluster.members.filter((m) => proven.has(m.mint));
81
+ if (!members.length) continue;
82
+ const claimed = members.reduce((s, m) => s + (m.liquidity ?? 0), 0);
83
+ rows.push({
84
+ cluster: cluster.id,
85
+ kind: cluster.kind,
86
+ creator: cluster.creator,
87
+ prefix: cluster.prefix,
88
+ clusterSize: cluster.members.length,
89
+ provenCount: members.length,
90
+ claimedUsd: claimed,
91
+ members: members.map((m) => ({
92
+ mint: m.mint,
93
+ name: m.name,
94
+ symbol: m.symbol,
95
+ claimedUsd: m.liquidity ?? 0,
96
+ canonicalName: proven.get(m.mint).canonicalName,
97
+ canonicalMint: proven.get(m.mint).canonicalMint,
98
+ confidence: proven.get(m.mint).confidence,
99
+ proof: proven.get(m.mint).proof,
100
+ })),
101
+ });
102
+ }
103
+ rows.sort((a, b) => b.claimedUsd - a.claimedUsd);
104
+
105
+ // ── report ──────────────────────────────────────────────────────────────────
106
+ console.log('═'.repeat(100));
107
+ console.log(' CLUSTERS CONTAINING PROVEN IMPERSONATORS');
108
+ console.log('═'.repeat(100));
109
+ for (const r of rows.slice(0, 18)) {
110
+ const pct = r.clusterSize ? ((r.provenCount / r.clusterSize) * 100).toFixed(1) : '0';
111
+ console.log(
112
+ `\n ${r.cluster} ${r.provenCount}/${r.clusterSize} members proven (${pct}%) advertised $${r.claimedUsd.toLocaleString('en-US', { maximumFractionDigits: 0 })}`,
113
+ );
114
+ for (const m of r.members.slice(0, 8)) {
115
+ console.log(
116
+ ` ${m.mint}\n claims "${m.name}" / ${m.symbol} canonical: ${m.canonicalName} (${m.canonicalMint}) [${m.confidence}] advertised ${m.claimedUsd ? '$' + m.claimedUsd.toLocaleString('en-US', { maximumFractionDigits: 0 }) : 'n/a'}`,
117
+ );
118
+ }
119
+ if (r.members.length > 8) console.log(` … and ${r.members.length - 8} more`);
120
+ }
121
+
122
+ // ── the top impersonators by advertised liquidity ──────────────────────────
123
+ const sorted = [...all].sort((a, b) => b.liquidity - a.liquidity);
124
+ console.log(`\n${'═'.repeat(100)}\n TOP CONFIRMED NAME COLLISIONS BY ADVERTISED LIQUIDITY\n${'═'.repeat(100)}`);
125
+ for (const p of sorted.filter((x) => x.confidence === 'confirmed').slice(0, 25)) {
126
+ console.log(
127
+ ` ${p.mint} "${p.name}/${p.symbol}" claims ${p.canonicalName} (${p.canonicalMint}) advertised $${p.liquidity.toLocaleString('en-US', { maximumFractionDigits: 0 })} [${p.confidence}]`,
128
+ );
129
+ }
130
+
131
+ const totalClaimed = confirmed.reduce((s, p) => s + p.liquidity, 0);
132
+ const symbolClaimed = symbolOnly.reduce((s, p) => s + p.liquidity, 0);
133
+ console.log(
134
+ `\n ${confirmed.length} CONFIRMED name collisions, ${(totalClaimed / 1e9).toFixed(2)}B USD of advertised liquidity across them`,
135
+ );
136
+ console.log(
137
+ ` ${symbolOnly.length} ticker-only collisions (not publishable as impersonations), ${(symbolClaimed / 1e9).toFixed(2)}B USD`,
138
+ );
139
+
140
+ writeFileSync(
141
+ 'data/impersonators.json',
142
+ JSON.stringify(
143
+ {
144
+ generatedAt: new Date().toISOString(),
145
+ tokensScanned: registry.tokensScanned,
146
+ provenImpersonators: sorted,
147
+ confirmedImpersonators: sorted.filter((p) => p.confidence === 'confirmed'),
148
+ tickerOnlyCollisions: sorted.filter((p) => p.confidence !== 'confirmed'),
149
+ clusters: rows,
150
+ },
151
+ null,
152
+ 2,
153
+ ),
154
+ );
155
+ console.log(' wrote data/impersonators.json');
156
+ void sleep;
@@ -0,0 +1,73 @@
1
+ // Inspect the raw impersonation matches and show EXACTLY why each one
2
+ // matched. The point is to design the safety rules from real data rather
3
+ // than from speculation: for every match we print the impostor's own
4
+ // name/symbol, the canonical entry it was matched against, and the
5
+ // normalised forms that made the two collide.
6
+ //
7
+ // Read-only. Uses the cached canonical index.
8
+ import { readFileSync } from 'node:fs';
9
+ import { loadCanonicalIndex, coreName, normalizeName, normalizeSymbol } from '../dist/canonical.js';
10
+
11
+ const index = await loadCanonicalIndex();
12
+ const mining = JSON.parse(readFileSync('data/impersonators.json', 'utf8'));
13
+ const registry = JSON.parse(readFileSync('data/operator-registry.json', 'utf8'));
14
+
15
+ console.log(`canonical index: ${index.entries.length} entries ${JSON.stringify(index.counts)}`);
16
+ console.log(`raw mining rows: ${mining.provenImpersonators.length}\n`);
17
+
18
+ // ── which canonical entries are being leaned on? ────────────────────────────
19
+ const leaned = new Map();
20
+ for (const p of mining.provenImpersonators) {
21
+ const k = `${p.canonicalMint}`;
22
+ if (!leaned.has(k)) leaned.set(k, { ...p, hits: [] });
23
+ leaned.get(k).hits.push(p);
24
+ }
25
+
26
+ const rows = [...leaned.values()].sort((a, b) => b.hits.length - a.hits.length);
27
+
28
+ console.log('═'.repeat(150));
29
+ console.log(' CANONICAL ENTRIES BEING MATCHED AGAINST — grouped by hit count');
30
+ console.log('═'.repeat(150));
31
+ for (const r of rows) {
32
+ const e = index.byMint.get(r.canonicalMint);
33
+ console.log(
34
+ `\n ${r.hits.length} hits → canonical ${r.canonicalName} "${r.canonicalSymbol}" ${r.canonicalMint}`,
35
+ );
36
+ if (e) {
37
+ console.log(
38
+ ` coreName(canonical)=${JSON.stringify(coreName(e.name))} coreName(symbol)=${JSON.stringify(coreName(e.symbol))} coinId=${e.coinId ?? '-'}`,
39
+ );
40
+ }
41
+ const sample = r.hits.slice(0, 4);
42
+ for (const h of sample) {
43
+ console.log(
44
+ ` impostor ${h.mint.slice(0, 12)}… name=${JSON.stringify(h.name)} symbol=${JSON.stringify(h.symbol)} core=${JSON.stringify(coreName(h.name ?? ''))} [${h.confidence}] $${(h.liquidity ?? 0).toLocaleString('en-US', { maximumFractionDigits: 0 })}`,
45
+ );
46
+ }
47
+ if (r.hits.length > sample.length) console.log(` … ${r.hits.length - sample.length} more`);
48
+ }
49
+
50
+ // ── what does the impostor side look like? ──────────────────────────────────
51
+ console.log(`\n${'═'.repeat(150)}\n THE IMPOSTOR SIDE — top 30 by advertised liquidity\n${'═'.repeat(150)}`);
52
+ const top = [...mining.provenImpersonators].sort((a, b) => (b.liquidity ?? 0) - (a.liquidity ?? 0)).slice(0, 30);
53
+ for (const p of top) {
54
+ const e = index.byMint.get(p.canonicalMint);
55
+ const nameCore = coreName(p.name ?? '');
56
+ const canCore = e ? coreName(e.name) : '';
57
+ const sameName = nameCore === canCore;
58
+ const nameIsTicker = normalizeName(p.name ?? '') === normalizeName(p.symbol ?? '');
59
+ console.log(
60
+ ` ${p.mint.slice(0, 12)}… "${p.name}/${p.symbol}" → canonical "${p.canonicalName}" (${p.canonicalSymbol})\n` +
61
+ ` nameCore=${JSON.stringify(nameCore)} canCore=${JSON.stringify(canCore)} sameCore=${sameName} nameIsOwnTicker=${nameIsTicker} conf=${p.confidence} $${(p.liquidity ?? 0).toLocaleString('en-US', { maximumFractionDigits: 0 })}`,
62
+ );
63
+ }
64
+
65
+ // ── how many entries share each hot ticker? ─────────────────────────────────
66
+ console.log(`\n${'═'.repeat(150)}\n TICKER AMBIGUITY for the hot symbols\n${'═'.repeat(150)}`);
67
+ const hotSymbols = [...new Set(mining.provenImpersonators.map((p) => p.canonicalSymbol))];
68
+ for (const s of hotSymbols.slice(0, 40)) {
69
+ const matches = index.bySymbol.get(normalizeSymbol(s)) ?? [];
70
+ console.log(` ${String(s).padEnd(14)} ${String(matches.length).padStart(4)} canonical entries share this ticker`);
71
+ for (const m of matches.slice(0, 6)) console.log(` ${m.mint} "${m.name}" core=${JSON.stringify(coreName(m.name))}`);
72
+ if (matches.length > 6) console.log(` … ${matches.length - 6} more`);
73
+ }