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,458 @@
1
+ // LIQPROOF — evidence collector for the bug-bounty reports.
2
+ //
3
+ // Self-contained on purpose: it uses ONLY node's built-in fetch and the
4
+ // public JSON-RPC endpoint, so a reviewer can run it without installing
5
+ // anything and without a key.
6
+ //
7
+ // node bugs/collect-evidence.mjs
8
+ //
9
+ // It writes (all under bugs/evidence/):
10
+ // aggregator-liquidity-claims.{json,md} — DexScreener vs GeckoTerminal
11
+ // claims vs on-chain vault balances
12
+ // verified-aggregate.{json,md} — the verified name collisions
13
+ //
14
+ // It is READ-ONLY: it only calls GET endpoints and read-only JSON-RPC
15
+ // methods (getTokenAccountsByOwner, getAccountInfo). It signs nothing.
16
+
17
+ import { writeFileSync, mkdirSync, readFileSync } from 'node:fs';
18
+ import { fileURLToPath } from 'node:url';
19
+ import { dirname, join } from 'node:path';
20
+
21
+ const HERE = dirname(fileURLToPath(import.meta.url));
22
+ const OUT = join(HERE, 'evidence');
23
+ mkdirSync(OUT, { recursive: true });
24
+
25
+ const RPC = 'https://api.mainnet-beta.solana.com';
26
+ const USDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
27
+ const TOKEN_PROGRAM = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
28
+ const JUP = 'https://lite-api.jup.ag/swap/v1/quote';
29
+
30
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
31
+ const usd = (n) =>
32
+ '$' +
33
+ Number(n).toLocaleString('en-US', { maximumFractionDigits: 0 });
34
+ const num = (n, d = 2) => Number(n).toLocaleString('en-US', { maximumFractionDigits: d });
35
+
36
+ let rpcId = 1;
37
+ async function rpc(method, params) {
38
+ const res = await fetch(RPC, {
39
+ method: 'POST',
40
+ headers: { 'content-type': 'application/json' },
41
+ body: JSON.stringify({ jsonrpc: '2.0', id: rpcId++, method, params }),
42
+ });
43
+ const body = await res.json();
44
+ if (body.error) throw new Error(`${method}: ${body.error.message}`);
45
+ return body.result;
46
+ }
47
+
48
+ /** Every token account owned by the pool address, with its mint and balance. */
49
+ async function poolTokens(pool) {
50
+ const r = await rpc('getTokenAccountsByOwner', [
51
+ pool,
52
+ { programId: TOKEN_PROGRAM },
53
+ { encoding: 'jsonParsed' },
54
+ ]);
55
+ const out = [];
56
+ for (const t of r?.value ?? []) {
57
+ const i = t.account?.data?.parsed?.info ?? {};
58
+ out.push({
59
+ address: t.pubkey,
60
+ mint: i.mint,
61
+ uiAmount: Number(i.tokenAmount?.uiAmount ?? 0),
62
+ decimals: Number(i.tokenAmount?.decimals ?? 0),
63
+ amountRaw: i.tokenAmount?.amount ?? null,
64
+ });
65
+ }
66
+ return out;
67
+ }
68
+
69
+ async function mintFacts(mint) {
70
+ const r = await rpc('getAccountInfo', [mint, { encoding: 'jsonParsed' }]);
71
+ const i = r?.value?.data?.parsed?.info ?? {};
72
+ return {
73
+ address: mint,
74
+ decimals: i.decimals ?? null,
75
+ supply: i.supply ?? null,
76
+ mintAuthority: i.mintAuthority ?? null,
77
+ freezeAuthority: i.freezeAuthority ?? null,
78
+ };
79
+ }
80
+
81
+ async function dexscreener(mint) {
82
+ const url = `https://api.dexscreener.com/tokens/v1/solana/${mint}`;
83
+ const j = await (await fetch(url)).json();
84
+ const pairs = (Array.isArray(j) ? j : []).filter((p) => p.chainId === 'solana');
85
+ return {
86
+ source: 'dexscreener',
87
+ endpoint: url,
88
+ fetchedAt: new Date().toISOString(),
89
+ pairCount: pairs.length,
90
+ pairs: pairs
91
+ .map((p) => ({
92
+ pairAddress: p.pairAddress,
93
+ dexId: p.dexId,
94
+ labels: p.labels ?? null,
95
+ url: p.url ?? null,
96
+ liquidityUsd: Number(p.liquidity?.usd ?? 0),
97
+ liquidityBase: Number(p.liquidity?.base ?? 0),
98
+ liquidityQuote: Number(p.liquidity?.quote ?? 0),
99
+ priceUsd: Number(p.priceUsd ?? 0),
100
+ volume24hUsd: Number(p.volume?.h24 ?? 0),
101
+ baseToken: { address: p.baseToken?.address, name: p.baseToken?.name, symbol: p.baseToken?.symbol },
102
+ quoteToken: { address: p.quoteToken?.address, name: p.quoteToken?.name, symbol: p.quoteToken?.symbol },
103
+ pairCreatedAt: p.pairCreatedAt ?? null,
104
+ }))
105
+ .sort((a, b) => b.liquidityUsd - a.liquidityUsd),
106
+ };
107
+ }
108
+
109
+ /**
110
+ * GeckoTerminal's free tier is rate limited. A throttled response still
111
+ * parses as JSON but carries no `data`, which would be recorded as "the
112
+ * token has no pools" — a false reading. Retry with backoff so a 429 is
113
+ * never mistaken for an absence of data.
114
+ */
115
+ async function geckoterminal(mint) {
116
+ const url = `https://api.geckoterminal.com/api/v2/networks/solana/tokens/${mint}/pools`;
117
+ let j = null;
118
+ let httpStatus = 0;
119
+ for (let attempt = 0; attempt < 6; attempt++) {
120
+ const res = await fetch(url, { headers: { accept: 'application/json' } });
121
+ httpStatus = res.status;
122
+ j = await res.json().catch(() => null);
123
+ const throttled = res.status === 429 || j?.status?.error_code === 429;
124
+ if (!throttled) break;
125
+ const wait = 20_000 * (attempt + 1);
126
+ console.log(` 429 from GeckoTerminal, retrying in ${wait / 1000}s…`);
127
+ await sleep(wait);
128
+ }
129
+ return {
130
+ source: 'geckoterminal',
131
+ endpoint: url,
132
+ fetchedAt: new Date().toISOString(),
133
+ httpStatus,
134
+ pools: (j?.data ?? []).map((p) => ({
135
+ pool: p.attributes?.address ?? null,
136
+ name: p.attributes?.name ?? null,
137
+ dex: p.relationships?.dex?.data?.id ?? null,
138
+ reserveInUsd: Number(p.attributes?.reserve_in_usd ?? 0),
139
+ baseTokenPriceUsd: Number(p.attributes?.base_token_price_usd ?? 0),
140
+ volume24hUsd: Number(p.attributes?.volume_usd?.h24 ?? 0),
141
+ baseToken: p.relationships?.base_token?.data?.id?.split('_')[1] ?? null,
142
+ quoteToken: p.relationships?.quote_token?.data?.id?.split('_')[1] ?? null,
143
+ })),
144
+ };
145
+ }
146
+
147
+ /**
148
+ * One Jupiter quote.
149
+ *
150
+ * `referencePriceUsd` is the price the OUTPUT token should trade at, when
151
+ * that price is not in dispute. It is null for the impostor tokens: the
152
+ * "fair price" of a token whose only market is the pool being drained is
153
+ * exactly the thing under dispute, which is why the realised impact of
154
+ * those routes cannot be computed even in principle.
155
+ * NOTE: this helper is kept here because the aggregator section below
156
+ * reuses the same quote endpoint for its execution-oracle cross-check.
157
+ * NOTE: this helper is kept here because the aggregator section below
158
+ * reuses the same quote endpoint for its execution-oracle cross-check.
159
+ */
160
+ async function jupiterQuote(inputMint, outputMint, amountRaw, label, opts = {}) {
161
+ const { outputDecimals = 6, inputDecimals = 6, referencePriceUsd = null } = opts;
162
+ const url = `${JUP}?inputMint=${inputMint}&outputMint=${outputMint}&amount=${amountRaw}&slippageBps=100`;
163
+ const res = await fetch(url);
164
+ const j = await res.json();
165
+ const out = {
166
+ label,
167
+ request: { url, inputMint, outputMint, amountRaw, slippageBps: 100 },
168
+ httpStatus: res.status,
169
+ reference: { outputDecimals, inputDecimals, referencePriceUsd },
170
+ raw: {
171
+ inputAmount: j.inputAmount ?? null,
172
+ inAmount: j.inAmount ?? null,
173
+ outAmount: j.outAmount ?? null,
174
+ otherAmountThreshold: j.otherAmountThreshold ?? null,
175
+ priceImpactPct: j.priceImpactPct ?? null,
176
+ contextSlot: j.contextSlot ?? null,
177
+ timeTaken: j.timeTaken ?? null,
178
+ routePlan: (j.routePlan ?? []).map((r) => ({
179
+ percent: r.percent,
180
+ amountIn: r.amountIn ?? null,
181
+ amountOut: r.amountOut ?? null,
182
+ label: r.swapInfo?.label ?? null,
183
+ ammKey: r.swapInfo?.ammKey ?? null,
184
+ tokenIn: r.swapInfo?.tokenIn ?? null,
185
+ tokenOut: r.swapInfo?.tokenOut ?? null,
186
+ })),
187
+ error: j.error ?? null,
188
+ },
189
+ };
190
+
191
+ if (referencePriceUsd !== null && j.outAmount && j.inAmount) {
192
+ const inUsd = Number(j.inAmount) / 10 ** inputDecimals;
193
+ const outTokens = Number(j.outAmount) / 10 ** outputDecimals;
194
+ const outUsdAtReference = outTokens * referencePriceUsd;
195
+ out.realised = {
196
+ inUsd,
197
+ outTokens,
198
+ outUsdAtReference,
199
+ realisedPriceImpactPct: inUsd > 0 ? (1 - outUsdAtReference / inUsd) * 100 : null,
200
+ };
201
+ }
202
+
203
+ await sleep(500);
204
+ return out;
205
+ }
206
+
207
+
208
+ // ─────────────────────────────────────────────────────────────────────────────
209
+ // 1. Aggregator liquidity claims vs on-chain vault balances
210
+ // ─────────────────────────────────────────────────────────────────────────────
211
+ const CASES = [
212
+ {
213
+ slug: 'tether-impostor-pool-286pz',
214
+ label: 'Raydium CLMM pool 286pz…',
215
+ mint: '7ZBzZ6f1i65RzzQ3iJtQWuDXxh3WNgsmT4rVWxkrtA8w',
216
+ pool: '286pzEkNXKjipszXtdjPm62qvDw74Dz8wCjPUEHPpwSF',
217
+ canonicalMint: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
218
+ canonicalName: 'Tether (USDT)',
219
+ quoteMint: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
220
+ },
221
+ {
222
+ slug: 'aave-impostor-pool-bxsws',
223
+ label: 'Raydium pool BXsWs…',
224
+ mint: '83kw8RbTvD3192wYPfb9D3msgV2ABoEnD4hEZrUDyyVh',
225
+ pool: 'BXsWsZe4VUquBNbL3q765Ya8quJyN8Ehqmeb8EJ1ctUp',
226
+ canonicalMint: 'AavE1kKKnesPw4MuRJmJ9jZs9QzEE8CPxQ3ViczUDfc1',
227
+ canonicalName: 'Aave (AAVE)',
228
+ quoteMint: USDC,
229
+ },
230
+ {
231
+ slug: 'paypal-usd-impostor-pool-4ctjd',
232
+ label: 'Raydium pool 4cTJd…',
233
+ mint: '9SuoKpshLWiuDj1rgnLvMJGtPi1TrD4CYgRQgCpTuxF5',
234
+ pool: '4cTJdTayuxa81zCAzLCoTRvvVFmcs8Sj1MiFK1KTMDhf',
235
+ canonicalMint: '2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo',
236
+ canonicalName: 'PayPal USD (PYUSD)',
237
+ quoteMint: USDC,
238
+ },
239
+ {
240
+ slug: 'bat-impostor-pool-9nbcu',
241
+ label: 'Raydium CLMM pool 9NBCu…',
242
+ mint: 'BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp',
243
+ pool: '9NBCuxsfd8vsfTzNzHHAgoSXoSowgAhemtE3JfpwDTyD',
244
+ canonicalMint: 'EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz',
245
+ canonicalName: 'Basic Attention Token (Wormhole bridge)',
246
+ quoteMint: USDC,
247
+ },
248
+ {
249
+ slug: 'ousd-healthy-pool-bqcfm',
250
+ label: 'Orca Whirlpool OUSD/USDC pool BqCfm… — HEALTHY control',
251
+ mint: 'ousd2mJsPEckLHcSCDxyKD7NDGARZcfLbDZkKiatYHB',
252
+ pool: 'BqCfmajD8Z67KrVE8i4XN43vyPS9hppFAt5dPZFFaMfu',
253
+ canonicalMint: 'ousd2mJsPEckLHcSCDxyKD7NDGARZcfLbDZkKiatYHB',
254
+ canonicalName: 'Open USD (OUSD) — the genuine mint',
255
+ quoteMint: USDC,
256
+ },
257
+ {
258
+ slug: 'chiliz-official-meteora-pool-2qmi9',
259
+ label:
260
+ 'OFFICIAL Chiliz mint, Meteora pool 2QMi9… — the POOL claim is unbacked, the TOKEN is genuine',
261
+ mint: '6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw',
262
+ pool: '2QMi9jiqxuQABCLXS5AzpuG3Cp46xG8shUDr5JDGSpRc',
263
+ canonicalMint: '6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw',
264
+ canonicalName: 'Chiliz (CHZ) — the official, canonical mint',
265
+ quoteMint: USDC,
266
+ },
267
+ ];
268
+
269
+ const generatedAt = new Date().toISOString();
270
+ const claimCases = [];
271
+
272
+ for (const c of CASES) {
273
+ console.log(`\n=== ${c.slug}`);
274
+ const ds = await dexscreener(c.mint);
275
+ await sleep(400);
276
+ const gt = await geckoterminal(c.mint);
277
+ await sleep(400);
278
+ const tokens = await poolTokens(c.pool);
279
+ await sleep(1200);
280
+ const mint = await mintFacts(c.mint);
281
+ await sleep(400);
282
+
283
+ const base = tokens.find((t) => t.mint === c.mint) ?? null;
284
+ const quote = tokens.find((t) => t.mint === c.quoteMint) ?? null;
285
+ const usdc = tokens.find((t) => t.mint === USDC) ?? null;
286
+
287
+ const dsPool = ds.pairs.find((p) => p.pairAddress === c.pool) ?? ds.pairs[0] ?? null;
288
+ const gtPool = gt.pools.find((p) => p.pool === c.pool) ?? gt.pools[0] ?? null;
289
+
290
+ const dsClaim = dsPool?.liquidityUsd ?? 0;
291
+ const gtClaim = gtPool?.reserveInUsd ?? 0;
292
+
293
+ const row = {
294
+ slug: c.slug,
295
+ title: `${c.label} — aggregators claim ${usd(Math.max(dsClaim, gtClaim))}, the vault holds ${num(quote?.uiAmount ?? 0, 6)}`,
296
+ generatedAt,
297
+ mint,
298
+ canonical: { name: c.canonicalName, mint: c.canonicalMint },
299
+ pool: c.pool,
300
+ aggregatorClaims: {
301
+ dexscreener: {
302
+ endpoint: ds.endpoint,
303
+ fetchedAt: ds.fetchedAt,
304
+ pairCount: ds.pairCount,
305
+ poolClaimUsd: dsClaim,
306
+ pool: dsPool,
307
+ },
308
+ geckoterminal: {
309
+ endpoint: gt.endpoint,
310
+ fetchedAt: gt.fetchedAt,
311
+ httpStatus: gt.httpStatus,
312
+ poolCount: gt.pools.length,
313
+ poolClaimUsd: gtClaim,
314
+ pool: gtPool,
315
+ },
316
+ },
317
+ onChain: {
318
+ tokenAccountsInPool: tokens,
319
+ baseVault: base,
320
+ quoteVault: quote,
321
+ usdcVault: usdc,
322
+ realQuoteUsd: quote ? quote.uiAmount : 0,
323
+ realUsdcUsd: usdc ? usdc.uiAmount : 0,
324
+ },
325
+ ratios: {
326
+ dexscreenerClaimOverRealQuote: quote && quote.uiAmount > 0 ? dsClaim / quote.uiAmount : null,
327
+ geckoTerminalClaimOverRealQuote: quote && quote.uiAmount > 0 ? gtClaim / quote.uiAmount : null,
328
+ maxClaimOverRealQuote:
329
+ quote && quote.uiAmount > 0
330
+ ? Math.max(dsClaim, gtClaim) / quote.uiAmount
331
+ : null,
332
+ },
333
+ };
334
+ claimCases.push(row);
335
+ console.log(
336
+ ` DS=${usd(dsClaim)} (${ds.pairCount} pairs) GT=${usd(gtClaim)} quote=${num(quote?.uiAmount ?? 0, 6)} base=${num(base?.uiAmount ?? 0, 6)}`,
337
+ );
338
+ }
339
+
340
+ const claimBundle = {
341
+ slug: 'aggregator-liquidity-claims',
342
+ title: 'DexScreener / GeckoTerminal liquidity claims vs on-chain vault balances',
343
+ generatedAt,
344
+ tool: { name: 'LIQPROOF', version: '0.1.0', command: 'node bugs/collect-evidence.mjs' },
345
+ method: {
346
+ claim: 'GET the aggregator endpoint, read liquidity.usd / reserve_in_usd for the pool address.',
347
+ truth:
348
+ 'JSON-RPC getTokenAccountsByOwner(pool, {programId: Tokenkeg…}) on Solana mainnet, then read ' +
349
+ 'the SPL token balance of each vault the pool owns.',
350
+ note: 'Read-only. No key, no account, no signature, no paid API.',
351
+ },
352
+ usdcMint: USDC,
353
+ cases: claimCases,
354
+ };
355
+ writeFileSync(join(OUT, 'aggregator-liquidity-claims.json'), JSON.stringify(claimBundle, null, 2));
356
+
357
+ const cm = [
358
+ `# Evidence — DexScreener / GeckoTerminal liquidity claims vs on-chain vault balances`,
359
+ '',
360
+ `Generated ${generatedAt} by \`node bugs/collect-evidence.mjs\`.`,
361
+ '',
362
+ 'Claim = aggregator endpoint (GET). Truth = `getTokenAccountsByOwner` on Solana mainnet (read-only).',
363
+ '',
364
+ '| case | pool | DexScreener liquidity.usd | GeckoTerminal reserve_in_usd | real quote in vault | overstatement |',
365
+ '|---|---|---:|---:|---:|---:|',
366
+ ];
367
+ for (const r of claimCases) {
368
+ const ratio = r.ratios.maxClaimOverRealQuote;
369
+ cm.push(
370
+ `| ${r.slug} | \`${r.pool}\` | ${r.aggregatorClaims.dexscreener.poolClaimUsd ? usd(r.aggregatorClaims.dexscreener.poolClaimUsd) : 'NO PAIRS'} | ${r.aggregatorClaims.geckoterminal.poolClaimUsd ? usd(r.aggregatorClaims.geckoterminal.poolClaimUsd) : '—'} | ${num(r.onChain.realQuoteUsd, 6)} ${r.onChain.quoteVault?.mint === USDC ? 'USDC' : 'quote'} | ${ratio ? num(ratio, 0) + '×' : '∞'} |`,
371
+ );
372
+ }
373
+ cm.push('');
374
+ for (const r of claimCases) {
375
+ cm.push(`## ${r.title}`, '');
376
+ cm.push(`- mint: \`${r.mint.address}\``);
377
+ cm.push(`- pool: \`${r.pool}\``);
378
+ cm.push(`- DexScreener: ${r.aggregatorClaims.dexscreener.endpoint}`);
379
+ cm.push(` - pairs returned for this mint: **${r.aggregatorClaims.dexscreener.pairCount}**`);
380
+ cm.push(` - claim for this pool: **${usd(r.aggregatorClaims.dexscreener.poolClaimUsd)}**`);
381
+ cm.push(`- GeckoTerminal: ${r.aggregatorClaims.geckoterminal.endpoint}`);
382
+ cm.push(` - pools returned for this mint: **${r.aggregatorClaims.geckoterminal.poolCount}**`);
383
+ cm.push(` - claim for this pool: **${usd(r.aggregatorClaims.geckoterminal.poolClaimUsd)}**`);
384
+ cm.push('- on-chain token accounts owned by the pool:');
385
+ for (const t of r.onChain.tokenAccountsInPool) {
386
+ cm.push(
387
+ ` - \`${t.address}\` — ${num(t.uiAmount, 6)} of \`${t.mint}\` (raw ${t.amountRaw}, ${t.decimals} decimals)`,
388
+ );
389
+ }
390
+ cm.push(
391
+ `- real quote-side value in the vault: **${usd(r.onChain.realQuoteUsd)}** (${num(r.onChain.realQuoteUsd, 6)} tokens)`,
392
+ );
393
+ cm.push('');
394
+ }
395
+ writeFileSync(join(OUT, 'aggregator-liquidity-claims.md'), cm.join('\n'));
396
+
397
+ // ─────────────────────────────────────────────────────────────────────────────
398
+ // 2. The verified name collisions (aggregate)
399
+ // ─────────────────────────────────────────────────────────────────────────────
400
+ const verified = JSON.parse(
401
+ readFileSync(join(HERE, '..', 'data', 'verified-impersonators.json'), 'utf8'),
402
+ );
403
+ let adv = 0;
404
+ let dep = 0;
405
+ const rows = verified.results.map((r) => {
406
+ const advertised = r.claimed ?? r.liquidity ?? 0;
407
+ adv += advertised;
408
+ dep += r.deposited ?? 0;
409
+ return {
410
+ mint: r.mint,
411
+ name: r.name,
412
+ symbol: r.symbol,
413
+ canonicalName: r.canonicalName,
414
+ canonicalMint: r.canonicalMint,
415
+ source: r.source,
416
+ confidence: r.confidence,
417
+ pool: r.pool,
418
+ advertisedUsd: advertised,
419
+ depositedUsd: r.deposited ?? 0,
420
+ coverage: r.coverage ?? null,
421
+ verdict: r.verdict,
422
+ vaults: r.vaults ?? [],
423
+ };
424
+ });
425
+ const agg = {
426
+ slug: 'verified-aggregate',
427
+ title: `${rows.length} independently verified name collisions: advertised liquidity vs money actually deposited`,
428
+ generatedAt,
429
+ source: `data/verified-impersonators.json (generated ${verified.generatedAt})`,
430
+ totals: {
431
+ tokens: rows.length,
432
+ advertisedUsd: adv,
433
+ depositedUsd: dep,
434
+ overstatement: dep > 0 ? adv / dep : null,
435
+ },
436
+ rows,
437
+ };
438
+ writeFileSync(join(OUT, 'verified-aggregate.json'), JSON.stringify(agg, null, 2));
439
+
440
+ const am = [
441
+ `# Evidence — ${rows.length} verified name collisions, advertised vs deposited`,
442
+ '',
443
+ `Generated ${generatedAt}. Source: \`data/verified-impersonators.json\`.`,
444
+ '',
445
+ `**Total advertised: ${usd(adv)}** · **Total deposited: ${usd(dep)}** · overstatement **${num(agg.totals.overstatement, 0)}×**`,
446
+ '',
447
+ '| mint | claims to be | canonical | pool | advertised | deposited | coverage | verdict |',
448
+ '|---|---|---|---|---:|---:|---:|---|',
449
+ ];
450
+ for (const r of rows) {
451
+ am.push(
452
+ `| \`${r.mint}\` | ${r.name} | ${r.canonicalName} | \`${r.pool}\` | ${usd(r.advertisedUsd)} | ${usd(r.depositedUsd)} | ${r.coverage ? num(r.coverage * 100, 9) + '%' : '—'} | ${r.verdict} |`,
453
+ );
454
+ }
455
+ am.push('');
456
+ writeFileSync(join(OUT, 'verified-aggregate.md'), am.join('\n'));
457
+
458
+ console.log('\nwrote 2 evidence bundles to bugs/evidence/');
@@ -0,0 +1,215 @@
1
+ // LIQPROOF — GeckoTerminal-only aggregate over the 16 verified mints.
2
+ //
3
+ // For every row in data/verified-impersonators.json:
4
+ // 1. GET the GeckoTerminal token-pools endpoint and read
5
+ // reserve_in_usd for the pool address the receipt audited.
6
+ // 2. Read the pool's SPL token accounts over JSON-RPC and record the
7
+ // REAL quote-side balance (USDC or USDT) that backs the claim.
8
+ //
9
+ // This produces the table the CoinGecko report needs: what GeckoTerminal
10
+ // publishes, versus what the vault actually holds.
11
+ //
12
+ // node bugs/collect-gt-aggregate.mjs
13
+ //
14
+ // READ-ONLY. No key, no account, no signature, no paid API, no chain mutation.
15
+
16
+ import { writeFileSync, mkdirSync, readFileSync } from 'node:fs';
17
+ import { fileURLToPath } from 'node:url';
18
+ import { dirname, join } from 'node:path';
19
+
20
+ const HERE = dirname(fileURLToPath(import.meta.url));
21
+ const OUT = join(HERE, 'evidence');
22
+ mkdirSync(OUT, { recursive: true });
23
+
24
+ const RPC = 'https://api.mainnet-beta.solana.com';
25
+ const USDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
26
+ const USDT = 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB';
27
+ const TOKEN_PROGRAM = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
28
+
29
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
30
+ const usd = (n) => '$' + Number(n).toLocaleString('en-US', { maximumFractionDigits: 0 });
31
+ const num = (n, d = 2) => Number(n).toLocaleString('en-US', { maximumFractionDigits: d });
32
+
33
+ let rpcId = 1;
34
+ async function rpc(method, params) {
35
+ const res = await fetch(RPC, {
36
+ method: 'POST',
37
+ headers: { 'content-type': 'application/json' },
38
+ body: JSON.stringify({ jsonrpc: '2.0', id: rpcId++, method, params }),
39
+ });
40
+ const body = await res.json();
41
+ if (body.error) throw new Error(`${method}: ${body.error.message}`);
42
+ return body.result;
43
+ }
44
+
45
+ /**
46
+ * GeckoTerminal's free tier is rate limited (we measured HTTP 429 with an
47
+ * error body that still parses as JSON but has no `data`). Retry with
48
+ * backoff so a throttled response is never mistaken for "no pools".
49
+ */
50
+ async function gtJson(url) {
51
+ for (let attempt = 0; attempt < 6; attempt++) {
52
+ const res = await fetch(url, { headers: { accept: 'application/json' } });
53
+ const j = await res.json().catch(() => null);
54
+ const throttled = res.status === 429 || j?.status?.error_code === 429;
55
+ if (!throttled) return { j, status: res.status };
56
+ const wait = 20_000 * (attempt + 1);
57
+ console.log(` 429 from GeckoTerminal, retrying in ${wait / 1000}s…`);
58
+ await sleep(wait);
59
+ }
60
+ return { j: { data: [] }, status: 429 };
61
+ }
62
+
63
+ const verified = JSON.parse(
64
+ readFileSync(join(HERE, '..', 'data', 'verified-impersonators.json'), 'utf8'),
65
+ );
66
+
67
+ const rows = [];
68
+ let gtTotal = 0;
69
+ let depositedTotal = 0;
70
+
71
+ for (const r of verified.results) {
72
+ const url = `https://api.geckoterminal.com/api/v2/networks/solana/tokens/${r.mint}/pools`;
73
+ const { j, status } = await gtJson(url);
74
+ await sleep(2500);
75
+ const pools = (j?.data ?? []).map((p) => ({
76
+ pool: p.attributes?.address ?? null,
77
+ name: p.attributes?.name ?? null,
78
+ dex: p.relationships?.dex?.data?.id ?? null,
79
+ reserveInUsd: Number(p.attributes?.reserve_in_usd ?? 0),
80
+ baseTokenPriceUsd: Number(p.attributes?.base_token_price_usd ?? 0),
81
+ volume24hUsd: Number(p.attributes?.volume_usd?.h24 ?? 0),
82
+ baseToken: p.relationships?.base_token?.data?.id?.split('_')[1] ?? null,
83
+ quoteToken: p.relationships?.quote_token?.data?.id?.split('_')[1] ?? null,
84
+ }));
85
+ const hit = pools.find((p) => p.pool === r.pool) ?? null;
86
+
87
+ const tas = await rpc('getTokenAccountsByOwner', [
88
+ r.pool,
89
+ { programId: TOKEN_PROGRAM },
90
+ { encoding: 'jsonParsed' },
91
+ ]);
92
+ await sleep(1200);
93
+ const accounts = (tas?.value ?? []).map((t) => {
94
+ const i = t.account?.data?.parsed?.info ?? {};
95
+ return {
96
+ address: t.pubkey,
97
+ mint: i.mint,
98
+ uiAmount: Number(i.tokenAmount?.uiAmount ?? 0),
99
+ decimals: Number(i.tokenAmount?.decimals ?? 0),
100
+ amountRaw: i.tokenAmount?.amount ?? null,
101
+ };
102
+ });
103
+ const quote = accounts.find((t) => t.mint === USDC) ?? accounts.find((t) => t.mint === USDT) ?? null;
104
+ const base = accounts.find((t) => t.mint === r.mint) ?? null;
105
+
106
+ const reserve = hit?.reserveInUsd ?? 0;
107
+ const deposited = quote?.uiAmount ?? 0;
108
+ gtTotal += reserve;
109
+ depositedTotal += deposited;
110
+
111
+ rows.push({
112
+ mint: r.mint,
113
+ name: r.name,
114
+ symbol: r.symbol,
115
+ canonicalName: r.canonicalName,
116
+ canonicalMint: r.canonicalMint,
117
+ proof: r.proof,
118
+ pool: r.pool,
119
+ geckoTerminal: {
120
+ endpoint: url,
121
+ fetchedAt: new Date().toISOString(),
122
+ httpStatus: status,
123
+ poolsReturned: pools.length,
124
+ poolListed: !!hit,
125
+ poolName: hit?.name ?? null,
126
+ dex: hit?.dex ?? null,
127
+ reserveInUsd: reserve,
128
+ baseTokenPriceUsd: hit?.baseTokenPriceUsd ?? null,
129
+ volume24hUsd: hit?.volume24hUsd ?? null,
130
+ quoteToken: hit?.quoteToken ?? null,
131
+ },
132
+ onChain: {
133
+ tokenAccountsInPool: accounts,
134
+ baseVault: base,
135
+ quoteVault: quote,
136
+ quoteMint: quote?.mint ?? null,
137
+ quoteSymbol: quote?.mint === USDC ? 'USDC' : quote?.mint === USDT ? 'USDT' : 'unknown',
138
+ realQuoteUsd: deposited,
139
+ },
140
+ ratio: deposited > 0 ? reserve / deposited : null,
141
+ coverage: reserve > 0 ? deposited / reserve : null,
142
+ receiptVerdict: r.verdict,
143
+ receiptDeposited: r.deposited,
144
+ });
145
+
146
+ console.log(
147
+ `${r.mint.slice(0, 10)}… GT=${usd(reserve).padStart(16)} quote=${num(deposited, 6)} ${quote?.mint === USDC ? 'USDC' : quote?.mint === USDT ? 'USDT' : '??'} ratio=${deposited > 0 ? num(reserve / deposited, 0) + 'x' : 'inf'}`,
148
+ );
149
+ }
150
+
151
+ const bundle = {
152
+ slug: 'verified-gt-reserve-in-usd',
153
+ title:
154
+ 'GeckoTerminal reserve_in_usd vs the real quote-side balance, for every verified mint',
155
+ generatedAt: new Date().toISOString(),
156
+ tool: { name: 'LIQPROOF', version: '0.1.0', command: 'node bugs/collect-gt-aggregate.mjs' },
157
+ method: {
158
+ claim: 'GET https://api.geckoterminal.com/api/v2/networks/solana/tokens/{mint}/pools -> attributes.reserve_in_usd',
159
+ truth:
160
+ 'JSON-RPC getTokenAccountsByOwner(pool, {programId: Tokenkeg…}) on Solana mainnet, then the SPL balance of the quote vault.',
161
+ note: 'Read-only. No key, no account, no signature, no paid API.',
162
+ },
163
+ usdcMint: USDC,
164
+ usdtMint: USDT,
165
+ totals: {
166
+ tokens: rows.length,
167
+ geckoTerminalReserveInUsd: gtTotal,
168
+ realDepositedUsd: depositedTotal,
169
+ overstatement: depositedTotal > 0 ? gtTotal / depositedTotal : null,
170
+ coverage: gtTotal > 0 ? depositedTotal / gtTotal : null,
171
+ },
172
+ rows,
173
+ };
174
+ writeFileSync(join(OUT, 'verified-gt-reserve-in-usd.json'), JSON.stringify(bundle, null, 2));
175
+
176
+ const md = [
177
+ '# Evidence — GeckoTerminal `reserve_in_usd` vs the real quote-side balance',
178
+ '',
179
+ `Generated ${bundle.generatedAt} by \`node bugs/collect-gt-aggregate.mjs\`.`,
180
+ '',
181
+ 'Claim = GeckoTerminal `reserve_in_usd`. Truth = the SPL balance of the pool\'s quote vault, read over JSON-RPC.',
182
+ '',
183
+ `**Total GeckoTerminal reserve_in_usd: ${usd(gtTotal)}** · **Total actually deposited: ${usd(depositedTotal)}** · overstatement **${num(bundle.totals.overstatement, 0)}×**`,
184
+ '',
185
+ '| mint | claims to be | pool | GeckoTerminal reserve_in_usd | real quote in vault | overstatement |',
186
+ '|---|---|---|---:|---:|---:|',
187
+ ];
188
+ for (const r of rows) {
189
+ md.push(
190
+ `| \`${r.mint}\` | ${r.name} | \`${r.pool}\` | ${usd(r.geckoTerminal.reserveInUsd)} | ${num(r.onChain.realQuoteUsd, 6)} ${r.onChain.quoteSymbol} | ${r.ratio ? num(r.ratio, 0) + '×' : '∞'} |`,
191
+ );
192
+ }
193
+ md.push('');
194
+ for (const r of rows) {
195
+ md.push(`## ${r.name} — \`${r.mint}\``, '');
196
+ md.push(`- canonical: **${r.canonicalName}** \`${r.canonicalMint}\` — ${r.proof}`);
197
+ md.push(`- pool: \`${r.pool}\``);
198
+ md.push(`- GeckoTerminal: ${r.geckoTerminal.endpoint}`);
199
+ md.push(` - pools listed for this mint: **${r.geckoTerminal.poolsReturned}**`);
200
+ md.push(` - reserve_in_usd for this pool: **${usd(r.geckoTerminal.reserveInUsd)}**`);
201
+ md.push(`- token accounts owned by the pool:`);
202
+ for (const t of r.onChain.tokenAccountsInPool) {
203
+ md.push(
204
+ ` - \`${t.address}\` — ${num(t.uiAmount, 6)} of \`${t.mint}\` (raw ${t.amountRaw}, ${t.decimals} decimals)`,
205
+ );
206
+ }
207
+ md.push(`- real quote-side value in the vault: **${usd(r.onChain.realQuoteUsd)}**`);
208
+ md.push('');
209
+ }
210
+ writeFileSync(join(OUT, 'verified-gt-reserve-in-usd.md'), md.join('\n'));
211
+
212
+ console.log(
213
+ `\nTOTAL GeckoTerminal reserve_in_usd ${usd(gtTotal)} vs deposited ${usd(depositedTotal)} (${num(bundle.totals.overstatement, 0)}x)`,
214
+ );
215
+ console.log('wrote bugs/evidence/verified-gt-reserve-in-usd.{json,md}');