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.
- package/LICENSE +21 -0
- package/README.md +536 -2
- package/bugs/README.md +144 -0
- package/bugs/coin-gecko-liquidity-report.md +283 -0
- package/bugs/collect-ds-aggregate.mjs +213 -0
- package/bugs/collect-evidence.mjs +458 -0
- package/bugs/collect-gt-aggregate.mjs +215 -0
- package/bugs/collect-raw-rpc.mjs +165 -0
- package/bugs/collect-sweep-context.mjs +162 -0
- package/bugs/dexscreener-fake-liquidity-report.md +310 -0
- package/bugs/evidence/aggregator-liquidity-claims.json +648 -0
- package/bugs/evidence/aggregator-liquidity-claims.md +103 -0
- package/bugs/evidence/bat-native-pool-drained.json +136 -0
- package/bugs/evidence/bat-native-pool-drained.md +51 -0
- package/bugs/evidence/chz-impersonator-pool-drained.json +136 -0
- package/bugs/evidence/chz-impersonator-pool-drained.md +51 -0
- package/bugs/evidence/gt-stale-reserve-after-drain.json +141 -0
- package/bugs/evidence/gt-stale-reserve-after-drain.md +31 -0
- package/bugs/evidence/raw-rpc-transcript.json +683 -0
- package/bugs/evidence/raw-rpc-transcript.md +308 -0
- package/bugs/evidence/sweep-context.json +325 -0
- package/bugs/evidence/sweep-context.md +55 -0
- package/bugs/evidence/verified-aggregate.json +526 -0
- package/bugs/evidence/verified-aggregate.md +24 -0
- package/bugs/evidence/verified-ds-liquidity-usd.json +1197 -0
- package/bugs/evidence/verified-ds-liquidity-usd.md +250 -0
- package/bugs/evidence/verified-gt-reserve-in-usd.json +1002 -0
- package/bugs/evidence/verified-gt-reserve-in-usd.md +218 -0
- package/bugs/fix-bundle-titles.mjs +72 -0
- package/bugs/geckoterminal-stale-reserve-after-drain.md +137 -0
- package/data/dataset-summary.md +103 -0
- package/data/impersonators.json +12888 -0
- package/data/verified-impersonators.json +725 -0
- package/data/wallets.json +23 -0
- package/dist/base58.js +70 -0
- package/dist/base58.js.map +1 -0
- package/dist/canonical.js +372 -0
- package/dist/canonical.js.map +1 -0
- package/dist/cli.js +830 -0
- package/dist/cli.js.map +1 -0
- package/dist/curve.js +255 -0
- package/dist/curve.js.map +1 -0
- package/dist/dashboard.js +485 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/keccak.js +197 -0
- package/dist/keccak.js.map +1 -0
- package/dist/mcp.js +604 -0
- package/dist/mcp.js.map +1 -0
- package/dist/operator.js +180 -0
- package/dist/operator.js.map +1 -0
- package/dist/pda.js +86 -0
- package/dist/pda.js.map +1 -0
- package/dist/receipt.js +897 -0
- package/dist/receipt.js.map +1 -0
- package/dist/render.js +335 -0
- package/dist/render.js.map +1 -0
- package/dist/rpc.js +377 -0
- package/dist/rpc.js.map +1 -0
- package/dist/sources.js +599 -0
- package/dist/sources.js.map +1 -0
- package/dist/store.js +330 -0
- package/dist/store.js.map +1 -0
- package/dist/tokenmeta.js +424 -0
- package/dist/tokenmeta.js.map +1 -0
- package/dist/util.js +273 -0
- package/dist/util.js.map +1 -0
- package/dist/vaults.js +510 -0
- package/dist/vaults.js.map +1 -0
- package/dist/wallet.js +404 -0
- package/dist/wallet.js.map +1 -0
- package/dist/warnings.js +41 -0
- package/dist/warnings.js.map +1 -0
- package/dist/worker.js +857 -0
- package/dist/worker.js.map +1 -0
- package/dist/x402.js +549 -0
- package/dist/x402.js.map +1 -0
- package/docs/HACKATHON-SUBMISSION.md +264 -0
- package/docs/liqproof-plan.md +221 -0
- package/docs/llms.txt +32 -0
- package/docs/mcp-registry.md +165 -0
- package/docs/screenshots/01-dashboard.png +0 -0
- package/docs/screenshots/02-receipt-drained.png +0 -0
- package/docs/screenshots/03-receipt-impersonator.png +0 -0
- package/docs/screenshots/04-receipt-canonical.png +0 -0
- package/docs/x402-pricing.md +171 -0
- package/docs/zero-xyz.md +250 -0
- package/out/6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw.json +1171 -0
- package/out/6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw.md +52 -0
- package/out/6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw.svg +25 -0
- package/out/BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp.json +3975 -0
- package/out/BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp.md +90 -0
- package/out/BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp.svg +25 -0
- package/out/ENGkoidj2jNs73A7GZuseVmnkRg6EVF9tDtViwPz8o85.json +1446 -0
- package/out/ENGkoidj2jNs73A7GZuseVmnkRg6EVF9tDtViwPz8o85.md +66 -0
- package/out/ENGkoidj2jNs73A7GZuseVmnkRg6EVF9tDtViwPz8o85.svg +25 -0
- package/out/dataset.csv +67 -0
- package/out/impersonation-table.md +156 -0
- package/out/index.html +1179 -0
- package/package.json +78 -4
- package/scripts/assert-no-canonical-accusations.mjs +193 -0
- package/scripts/backfill.mjs +1063 -0
- package/scripts/bundle-evidence.mjs +237 -0
- package/scripts/bundle-stale-claim.mjs +417 -0
- package/scripts/capture-bch-evidence.mjs +58 -0
- package/scripts/check-orientation-fix.mjs +40 -0
- package/scripts/check-wallet.mjs +54 -0
- package/scripts/daily-refresh.mjs +451 -0
- package/scripts/decode-clmm-vaults.mjs +180 -0
- package/scripts/falsifiability.mjs +263 -0
- package/scripts/impersonator-mining.mjs +156 -0
- package/scripts/inspect-matches.mjs +73 -0
- package/scripts/operator-sweep.mjs +252 -0
- package/scripts/publish-release.mjs +248 -0
- package/scripts/refresh-store.mjs +78 -0
- package/scripts/survival-miner.mjs +951 -0
- package/scripts/test-keccak.mjs +103 -0
- package/scripts/verify-bch-1p95b.mjs +124 -0
- package/scripts/verify-clmm-1p95b.mjs +127 -0
- package/scripts/verify-clmm-control.mjs +84 -0
- package/scripts/verify-impersonators.mjs +138 -0
- package/scripts/verify-raw.mjs +110 -0
- package/scripts/verify-raw2.mjs +99 -0
- package/server.json +34 -0
- package/src/base58.ts +68 -0
- package/src/canonical.ts +447 -0
- package/src/cli.ts +941 -0
- package/src/curve.ts +349 -0
- package/src/dashboard.ts +504 -0
- package/src/keccak.ts +228 -0
- package/src/mcp.ts +735 -0
- package/src/operator.ts +219 -0
- package/src/receipt.ts +1219 -0
- package/src/render.ts +396 -0
- package/src/rpc.ts +435 -0
- package/src/sources.ts +714 -0
- package/src/store.ts +428 -0
- package/src/tokenmeta.ts +460 -0
- package/src/util.ts +276 -0
- package/src/vaults.ts +574 -0
- package/src/wallet.ts +459 -0
- package/src/warnings.ts +40 -0
- package/src/worker.ts +1086 -0
- package/src/x402.ts +717 -0
package/src/render.ts
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* render.ts — turn a receipt into human-readable proof.
|
|
3
|
+
* - `renderTerminal` : ANSI terminal output
|
|
4
|
+
* - `renderMarkdown` : the shareable artifact (used for GitHub Pages)
|
|
5
|
+
* - `renderSvgCard` : the social card (the "trend" engine)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Receipt } from './receipt.js';
|
|
9
|
+
import { c, num, usd, ratio } from './util.js';
|
|
10
|
+
|
|
11
|
+
const VERDICT_COLOR: Record<string, (s: string) => string> = {
|
|
12
|
+
FAKE_LIQUIDITY: c.red,
|
|
13
|
+
NO_DEPTH: c.red,
|
|
14
|
+
DRAINED: c.red,
|
|
15
|
+
UNBACKED_LIQUIDITY: c.yellow,
|
|
16
|
+
THIN: c.yellow,
|
|
17
|
+
CONSISTENT: c.green,
|
|
18
|
+
NO_ROUTE: c.blue,
|
|
19
|
+
UNKNOWN: c.gray,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Verdicts that accuse a token of being fake. */
|
|
23
|
+
export const ACCUSATORY_VERDICTS = ['FAKE_LIQUIDITY', 'NO_DEPTH', 'DRAINED'];
|
|
24
|
+
|
|
25
|
+
export function renderTerminal(r: Receipt): string {
|
|
26
|
+
const paint = VERDICT_COLOR[r.verdict] ?? c.gray;
|
|
27
|
+
const L: string[] = [];
|
|
28
|
+
|
|
29
|
+
L.push('');
|
|
30
|
+
L.push(c.bold(' LIQPROOF') + c.gray(' · on-chain liquidity receipt'));
|
|
31
|
+
L.push(c.gray(' ' + '─'.repeat(64)));
|
|
32
|
+
L.push('');
|
|
33
|
+
L.push(` ${c.bold(r.mint)}`);
|
|
34
|
+
if (r.symbol) L.push(` ${c.gray('symbol')} ${r.symbol}`);
|
|
35
|
+
L.push('');
|
|
36
|
+
L.push(` ${c.bold('VERDICT')} ${paint(c.bold(r.verdict))}`);
|
|
37
|
+
L.push('');
|
|
38
|
+
L.push(` ${c.bold(r.headline)}`);
|
|
39
|
+
L.push(` ${c.gray(r.summary)}`);
|
|
40
|
+
L.push('');
|
|
41
|
+
L.push(c.gray(' ' + '─'.repeat(64)));
|
|
42
|
+
|
|
43
|
+
L.push('');
|
|
44
|
+
L.push(` ${c.bold('CLAIMED')} (aggregators)`);
|
|
45
|
+
L.push(` liquidity ${usd(r.claimed.liquidityUsd)}`);
|
|
46
|
+
L.push(` price $${num(r.claimed.priceUsd, 8)}`);
|
|
47
|
+
for (const s of r.claimed.sources.slice(0, 3)) {
|
|
48
|
+
L.push(
|
|
49
|
+
` ${c.gray(s.source.padEnd(15))} ${usd(s.liquidityUsd).padStart(12)} ${c.gray(s.pool.slice(0, 12) + '…')}`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
// ── the aggregators disagree ──────────────────────────────────────────────
|
|
53
|
+
//
|
|
54
|
+
// This is the line that turns a measurement into a bug report. On
|
|
55
|
+
// 2026-12-04 GeckoTerminal still listed a Raydium CLMM pool at
|
|
56
|
+
// $1,919,430,000 while DexScreener listed the same pool at $0.19 — for a
|
|
57
|
+
// pool whose entire reserve had been drained in a single transaction
|
|
58
|
+
// eleven hours earlier. Two aggregators, one pool, four orders of
|
|
59
|
+
// magnitude between them. The chain settles it.
|
|
60
|
+
const srcs = r.claimed.sources.filter((s) => s.liquidityUsd > 0);
|
|
61
|
+
if (srcs.length > 1) {
|
|
62
|
+
const hi = [...srcs].sort((a, b) => b.liquidityUsd - a.liquidityUsd)[0];
|
|
63
|
+
const lo = [...srcs].sort((a, b) => a.liquidityUsd - b.liquidityUsd)[0];
|
|
64
|
+
if (hi.liquidityUsd / Math.max(lo.liquidityUsd, 0.01) > 100) {
|
|
65
|
+
L.push('');
|
|
66
|
+
L.push(
|
|
67
|
+
` ${c.red(c.bold('aggregators disagree'))} ${c.gray('on the same pool:')}`,
|
|
68
|
+
);
|
|
69
|
+
L.push(
|
|
70
|
+
` ${c.bold(hi.source.padEnd(15))} ${usd(hi.liquidityUsd).padStart(12)} ${c.gray('← the number people see')}`,
|
|
71
|
+
);
|
|
72
|
+
L.push(
|
|
73
|
+
` ${c.gray(lo.source.padEnd(15))} ${usd(lo.liquidityUsd).padStart(12)} ${c.gray('← the number the chain supports')}`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ── which pool, and whose liquidity is it ─────────────────────────────────
|
|
79
|
+
if (r.audited?.pool) {
|
|
80
|
+
L.push('');
|
|
81
|
+
L.push(
|
|
82
|
+
` ${c.bold('AUDITED POOL')} ${c.gray(r.audited.pool)} ${c.gray(r.audited.dexId ? `(${r.audited.dexId})` : '')}`,
|
|
83
|
+
);
|
|
84
|
+
if (r.audited.counterpartyOnly) {
|
|
85
|
+
L.push(
|
|
86
|
+
` ${c.yellow('counterparty pool')} ${c.gray('the audited mint is only the QUOTE token here —')} ${c.gray('this finding is about that pool, not about the mint')}`,
|
|
87
|
+
);
|
|
88
|
+
} else if (r.audited.orientation === 'base') {
|
|
89
|
+
L.push(
|
|
90
|
+
` ${c.gray(`base-side pool (${r.audited.baseSidePools}/${r.audited.candidatePools} candidate pools) — the mint IS this pool's base token`)}`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
L.push('');
|
|
96
|
+
L.push(` ${c.bold('REAL')} (read from the chain)`);
|
|
97
|
+
L.push(` deposited ${usd(r.real.depositedUsd)}`);
|
|
98
|
+
L.push(` tokens held ${num(r.real.heldTokens, 2)}`);
|
|
99
|
+
L.push(
|
|
100
|
+
` coverage ${c.bold(pct(r.real.coverage))} ${c.gray('(deposited / claimed)')}`,
|
|
101
|
+
);
|
|
102
|
+
if (r.real.selfDenominatedPct > 0.5) {
|
|
103
|
+
L.push(
|
|
104
|
+
` ${c.red('self-denominated')} ${c.bold(pct(r.real.selfDenominatedPct))} ${c.gray('of the claim is the token itself')}`,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
if (Number.isFinite(r.real.divergenceRatio) && r.real.divergenceRatio > 1.5) {
|
|
108
|
+
L.push(
|
|
109
|
+
` divergence ${c.red(c.bold(`${ratio(r.real.divergenceRatio)} overstated`))}`,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
if (r.real.peakDepositedUsd !== undefined) {
|
|
113
|
+
L.push(` peak ever ${usd(r.real.peakDepositedUsd)} ${c.gray(r.real.peakAt ?? '')}`);
|
|
114
|
+
}
|
|
115
|
+
if (r.real.drainAt) {
|
|
116
|
+
L.push(` ${c.red('drain')} ${c.gray(r.real.drainAt)}`);
|
|
117
|
+
L.push(` ${c.gray('tx')} ${r.real.drainSignature}`);
|
|
118
|
+
L.push(` ${c.gray('delta')} ${usd(r.real.drainDeltaUsd ?? 0)}`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
L.push('');
|
|
122
|
+
L.push(` ${c.bold('EXECUTION ORACLE')} (Jupiter live route)`);
|
|
123
|
+
const o = r.oracle;
|
|
124
|
+
if (o.buyQuote) {
|
|
125
|
+
if (o.buyQuote.error) {
|
|
126
|
+
L.push(` $1 buy ${c.red('FAILS — ' + o.buyQuote.error.slice(0, 60))}`);
|
|
127
|
+
} else {
|
|
128
|
+
L.push(
|
|
129
|
+
` $1 buy ${num(Number(o.buyQuote.outAmount) / 1e6, 4)} tokens ${c.gray('impact')} ${c.bold(pct(o.buyQuote.priceImpactPct))}`,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (o.executablePriceUsd) {
|
|
134
|
+
L.push(` executable price $${num(o.executablePriceUsd, 12)}`);
|
|
135
|
+
}
|
|
136
|
+
if (o.priceDivergence && o.priceDivergence > 10) {
|
|
137
|
+
L.push(
|
|
138
|
+
` ${c.red(c.bold('displayed price is ' + Math.round(o.priceDivergence).toLocaleString('en-US') + '× the executable price'))}`,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
L.push(` sol→token ${o.solToTokenRoutable ? c.green('routes') : c.red('no route')}`);
|
|
142
|
+
L.push(` token→sol ${o.tokenToSolRoutable ? c.green('routes') : c.red('no route')}`);
|
|
143
|
+
|
|
144
|
+
if (r.timeline.points.length) {
|
|
145
|
+
L.push('');
|
|
146
|
+
L.push(c.bold(` TIMELINE`) + c.gray(` (${r.timeline.points.length} points, ${r.timeline.scanned} txs scanned)`));
|
|
147
|
+
const pts = r.timeline.points;
|
|
148
|
+
const show = pts.length <= 12 ? pts : [...pts.slice(0, 6), ...pts.slice(-6)];
|
|
149
|
+
for (const p of show) {
|
|
150
|
+
if (show.indexOf(p) === 6) L.push(c.gray(' …'));
|
|
151
|
+
const mark = p.note ? c.red(' ▼') : ' ';
|
|
152
|
+
L.push(
|
|
153
|
+
` ${c.gray(p.at.replace('T', ' ').replace('Z', ''))} ${usd(p.depositedUsd).padStart(11)} ${c.gray(p.signature.slice(0, 10) + '…')}${mark}`,
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
L.push('');
|
|
159
|
+
L.push(c.gray(' ' + '─'.repeat(64)));
|
|
160
|
+
|
|
161
|
+
// ── identity ─────────────────────────────────────────────────────────────
|
|
162
|
+
// The receipt does not just say "this liquidity is fake". It says WHICH
|
|
163
|
+
// token it thinks this is, and — when the answer is "an impostor" — which
|
|
164
|
+
// real token it is standing in for, with a link the reader can open.
|
|
165
|
+
const id = r.identity;
|
|
166
|
+
L.push('');
|
|
167
|
+
L.push(c.bold(' IDENTITY') + c.gray(" (read from the mint's own metadata account)"));
|
|
168
|
+
if (id.onChainName) {
|
|
169
|
+
L.push(` on-chain name "${id.onChainName}" ${c.gray(id.onChainSymbol ?? '')}`);
|
|
170
|
+
}
|
|
171
|
+
if (id.metadataPda) {
|
|
172
|
+
L.push(` metadata PDA ${id.metadataPda}`);
|
|
173
|
+
}
|
|
174
|
+
const can = id.canonical;
|
|
175
|
+
if (can.status === 'canonical') {
|
|
176
|
+
L.push(` ${c.green('canonical')} this IS the registered token`);
|
|
177
|
+
L.push(` ${c.gray(can.method)}`);
|
|
178
|
+
} else if (can.status === 'impersonator' && can.impersonates) {
|
|
179
|
+
const tag = can.confidence === 'confirmed' ? c.red('IMPOSTOR') : c.yellow('TICKER CLASH');
|
|
180
|
+
L.push(` ${tag} claims to be ${c.bold(can.impersonates.name)} (${can.impersonates.symbol})`);
|
|
181
|
+
L.push(` ${c.gray('canonical mint')} ${can.impersonates.mint}`);
|
|
182
|
+
L.push(` ${c.gray('proof')} ${can.impersonates.proof}`);
|
|
183
|
+
L.push(` ${c.gray(can.method)}`);
|
|
184
|
+
} else {
|
|
185
|
+
L.push(` ${c.gray('unresolved')} ${c.gray(can.method)}`);
|
|
186
|
+
}
|
|
187
|
+
if (id.operator) {
|
|
188
|
+
L.push(
|
|
189
|
+
` ${c.gray('creator')} ${id.operator.creator} ${c.gray(`(shared with ${id.operator.clusterSize} other tokens — lineage, not evidence)`)}`,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
if (r.flags.length) {
|
|
193
|
+
L.push(` ${c.gray('flags')} ${r.flags.join(' ')}`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
L.push('');
|
|
197
|
+
L.push(c.gray(' ' + '─'.repeat(64)));
|
|
198
|
+
L.push(c.gray(` generated ${r.generatedAt}`));
|
|
199
|
+
L.push(c.gray(` ${r.disclaimer}`));
|
|
200
|
+
L.push('');
|
|
201
|
+
return L.join('\n');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function pct(n: number): string {
|
|
205
|
+
if (!Number.isFinite(n)) return 'n/a';
|
|
206
|
+
if (n === 0) return '0%';
|
|
207
|
+
if (n < 0.001) return `${(n * 100).toPrecision(3)}%`;
|
|
208
|
+
return `${(n * 100).toFixed(2)}%`;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function renderMarkdown(r: Receipt): string {
|
|
212
|
+
const L: string[] = [];
|
|
213
|
+
L.push(`# LIQPROOF receipt — \`${r.mint}\``);
|
|
214
|
+
L.push('');
|
|
215
|
+
L.push(`> **${r.headline}**`);
|
|
216
|
+
L.push('');
|
|
217
|
+
L.push(`\`${r.summary}\``);
|
|
218
|
+
L.push('');
|
|
219
|
+
L.push('| | |');
|
|
220
|
+
L.push('|---|---|');
|
|
221
|
+
L.push(`| **Verdict** | \`${r.verdict}\` |`);
|
|
222
|
+
L.push(`| **Claimed liquidity** | ${usd(r.claimed.liquidityUsd)} |`);
|
|
223
|
+
L.push(`| **Actually deposited** | ${usd(r.real.depositedUsd)} |`);
|
|
224
|
+
L.push(`| **Coverage** | ${pct(r.real.coverage)} |`);
|
|
225
|
+
if (r.real.selfDenominatedPct > 0.5) {
|
|
226
|
+
L.push(
|
|
227
|
+
`| **Self-denominated** | ${pct(r.real.selfDenominatedPct)} of the claim is the token itself |`,
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
if (Number.isFinite(r.real.divergenceRatio) && r.real.divergenceRatio > 1.5) {
|
|
231
|
+
L.push(`| **Overstatement** | ${ratio(r.real.divergenceRatio)} |`);
|
|
232
|
+
}
|
|
233
|
+
if (r.audited?.pool) {
|
|
234
|
+
L.push(
|
|
235
|
+
`| **Audited pool** | [\`${r.audited.pool}\`](https://solscan.io/account/${r.audited.pool})${r.audited.dexId ? ` — ${r.audited.dexId}` : ''} |`,
|
|
236
|
+
);
|
|
237
|
+
if (r.audited.counterpartyOnly) {
|
|
238
|
+
L.push(
|
|
239
|
+
`| **Pool orientation** | ⚠️ counterparty pool — the audited mint is only the QUOTE token, so this is a finding about the pool, not an accusation against the mint |`,
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (r.claimed.sources.length) {
|
|
244
|
+
L.push('');
|
|
245
|
+
L.push('| Claim source | Says |');
|
|
246
|
+
L.push('|---|---|');
|
|
247
|
+
for (const s of r.claimed.sources) {
|
|
248
|
+
L.push(`| ${s.source} | ${usd(s.liquidityUsd)} |`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (r.real.peakDepositedUsd !== undefined) {
|
|
252
|
+
L.push(`| **Peak ever deposited** | ${usd(r.real.peakDepositedUsd)} (${r.real.peakAt ?? 'n/a'}) |`);
|
|
253
|
+
}
|
|
254
|
+
if (r.real.drainAt) {
|
|
255
|
+
L.push(`| **Drain event** | ${r.real.drainAt} |`);
|
|
256
|
+
L.push(`| **Drain tx** | [\`${r.real.drainSignature}\`](https://solscan.io/tx/${r.real.drainSignature}) |`);
|
|
257
|
+
}
|
|
258
|
+
if (r.oracle.priceDivergence && r.oracle.priceDivergence > 10) {
|
|
259
|
+
L.push(
|
|
260
|
+
`| **Displayed vs executable price** | ${Math.round(r.oracle.priceDivergence).toLocaleString('en-US')}× |`,
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
L.push('');
|
|
264
|
+
|
|
265
|
+
// ── identity ─────────────────────────────────────────────────────────────
|
|
266
|
+
const id = r.identity;
|
|
267
|
+
L.push('## Identity');
|
|
268
|
+
L.push('');
|
|
269
|
+
L.push('| | |');
|
|
270
|
+
L.push('|---|---|');
|
|
271
|
+
if (id.onChainName) {
|
|
272
|
+
L.push(`| **On-chain name** | "${id.onChainName}" / ${id.onChainSymbol ?? '—'} |`);
|
|
273
|
+
}
|
|
274
|
+
if (id.metadataPda) {
|
|
275
|
+
L.push(
|
|
276
|
+
`| **Metadata account** | [\`${id.metadataPda}\`](https://solscan.io/account/${id.metadataPda}) |`,
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
L.push(`| **Canonical status** | \`${id.canonical.status}\` |`);
|
|
280
|
+
L.push(`| **How we resolved it** | ${id.canonical.method} |`);
|
|
281
|
+
if (id.canonical.impersonates) {
|
|
282
|
+
const im = id.canonical.impersonates;
|
|
283
|
+
L.push(
|
|
284
|
+
`| **Claims to be** | ${im.name} (${im.symbol}) — canonical mint [\`${im.mint}\`](https://solscan.io/account/${im.mint}) |`,
|
|
285
|
+
);
|
|
286
|
+
L.push(`| **Proof** | [${im.proofLabel}](${im.proof}) — source: \`${im.source}\` |`);
|
|
287
|
+
L.push(`| **Confidence** | \`${id.canonical.confidence}\` |`);
|
|
288
|
+
}
|
|
289
|
+
if (id.operator) {
|
|
290
|
+
L.push(
|
|
291
|
+
`| **Metadata creator** | [\`${id.operator.creator}\`](https://solscan.io/account/${id.operator.creator}) — shared with ${id.operator.clusterSize} other tokens (a lineage, not evidence of wrongdoing) |`,
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
if (r.flags.length) {
|
|
295
|
+
L.push(`| **Flags** | ${r.flags.map((f) => `\`${f}\``).join(' ')} |`);
|
|
296
|
+
}
|
|
297
|
+
L.push('');
|
|
298
|
+
|
|
299
|
+
L.push('## On-chain evidence');
|
|
300
|
+
L.push('');
|
|
301
|
+
L.push('| Pool | Vault | Side | Balance |');
|
|
302
|
+
L.push('|---|---|---|---|');
|
|
303
|
+
for (const p of r.pools) {
|
|
304
|
+
for (const v of p.vaults) {
|
|
305
|
+
L.push(
|
|
306
|
+
`| [\`${p.pool.slice(0, 10)}…\`](https://solscan.io/account/${p.pool}) | [\`${v.address.slice(0, 10)}…\`](https://solscan.io/account/${v.address}) | ${v.side} | ${num(v.uiAmount, 6)} |`,
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
L.push('');
|
|
311
|
+
|
|
312
|
+
if (r.timeline.points.length) {
|
|
313
|
+
L.push('## Liquidity timeline');
|
|
314
|
+
L.push('');
|
|
315
|
+
L.push('| When | Slot | Deposited | Δ | Transaction |');
|
|
316
|
+
L.push('|---|---|---|---|---|');
|
|
317
|
+
const pts = r.timeline.points;
|
|
318
|
+
const show = pts.length <= 30 ? pts : [...pts.slice(0, 15), ...pts.slice(-15)];
|
|
319
|
+
for (const p of show) {
|
|
320
|
+
L.push(
|
|
321
|
+
`| ${p.at} | ${p.slot} | ${usd(p.depositedUsd)} | ${usd(p.deltaUsd)} | [\`${p.signature.slice(0, 10)}…\`](https://solscan.io/tx/${p.signature}) |`,
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
L.push('');
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
L.push('## Methodology');
|
|
328
|
+
L.push('');
|
|
329
|
+
for (const m of r.methodology) L.push(`- ${m}`);
|
|
330
|
+
L.push('');
|
|
331
|
+
L.push('---');
|
|
332
|
+
L.push('');
|
|
333
|
+
L.push(`_${r.disclaimer}_`);
|
|
334
|
+
L.push('');
|
|
335
|
+
L.push('Generated by [LIQPROOF](https://github.com/aihbusiness77-pixel/liqproof) — read-only, $0 infrastructure.');
|
|
336
|
+
L.push('');
|
|
337
|
+
return L.join('\n');
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** Social card: the artifact that travels. */
|
|
341
|
+
export function renderSvgCard(r: Receipt): string {
|
|
342
|
+
const W = 1200;
|
|
343
|
+
const H = 630;
|
|
344
|
+
const bad = ACCUSATORY_VERDICTS.includes(r.verdict);
|
|
345
|
+
const accent = bad
|
|
346
|
+
? '#ff3b5c'
|
|
347
|
+
: r.verdict === 'THIN' || r.verdict === 'UNBACKED_LIQUIDITY'
|
|
348
|
+
? '#ffb020'
|
|
349
|
+
: r.verdict === 'NO_ROUTE'
|
|
350
|
+
? '#38bdf8'
|
|
351
|
+
: '#22c55e';
|
|
352
|
+
const bg = '#0a0a0f';
|
|
353
|
+
const fg = '#f4f4f6';
|
|
354
|
+
const dim = '#8b8b9a';
|
|
355
|
+
|
|
356
|
+
const esc = (s: string) =>
|
|
357
|
+
s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
358
|
+
|
|
359
|
+
const claimed = usd(r.claimed.liquidityUsd);
|
|
360
|
+
const deposited = usd(r.real.depositedUsd);
|
|
361
|
+
const div = Number.isFinite(r.real.divergenceRatio)
|
|
362
|
+
? ratio(r.real.divergenceRatio)
|
|
363
|
+
: 'n/a';
|
|
364
|
+
|
|
365
|
+
// the three big numbers share the width, so each one is sized to fit
|
|
366
|
+
const big = 48;
|
|
367
|
+
const small = 34;
|
|
368
|
+
const divSize = div.length > 9 ? small : big;
|
|
369
|
+
const divSuffix = div.length > 9 ? ' overstated' : ' overstated';
|
|
370
|
+
|
|
371
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
372
|
+
<rect width="${W}" height="${H}" fill="${bg}"/>
|
|
373
|
+
<rect x="0" y="0" width="${W}" height="8" fill="${accent}"/>
|
|
374
|
+
<text x="64" y="86" font-family="ui-monospace,Menlo,monospace" font-size="26" fill="${dim}" letter-spacing="4">LIQPROOF · ON-CHAIN RECEIPT</text>
|
|
375
|
+
<text x="64" y="150" font-family="ui-monospace,Menlo,monospace" font-size="42" font-weight="700" fill="${accent}">${esc(r.verdict)}</text>
|
|
376
|
+
<text x="64" y="222" font-family="system-ui,sans-serif" font-size="40" font-weight="700" fill="${fg}">${esc(r.symbol ?? r.mint.slice(0, 16))}</text>
|
|
377
|
+
<text x="64" y="264" font-family="ui-monospace,Menlo,monospace" font-size="20" fill="${dim}">${esc(r.mint)}</text>
|
|
378
|
+
|
|
379
|
+
<line x1="64" y1="300" x2="1136" y2="300" stroke="#22222c" stroke-width="2"/>
|
|
380
|
+
|
|
381
|
+
<text x="64" y="352" font-family="ui-monospace,Menlo,monospace" font-size="19" fill="${dim}">CLAIMED LIQUIDITY</text>
|
|
382
|
+
<text x="64" y="404" font-family="ui-monospace,Menlo,monospace" font-size="${big}" font-weight="700" fill="${fg}">${esc(claimed)}</text>
|
|
383
|
+
|
|
384
|
+
<text x="440" y="352" font-family="ui-monospace,Menlo,monospace" font-size="19" fill="${dim}">ACTUALLY DEPOSITED</text>
|
|
385
|
+
<text x="440" y="404" font-family="ui-monospace,Menlo,monospace" font-size="${big}" font-weight="700" fill="${accent}">${esc(deposited)}</text>
|
|
386
|
+
|
|
387
|
+
<text x="880" y="352" font-family="ui-monospace,Menlo,monospace" font-size="19" fill="${dim}">DIVERGENCE</text>
|
|
388
|
+
<text x="880" y="404" font-family="ui-monospace,Menlo,monospace" font-size="${divSize}" font-weight="700" fill="${accent}">${esc(div)}</text>
|
|
389
|
+
<text x="880" y="436" font-family="ui-monospace,Menlo,monospace" font-size="19" fill="${dim}">${esc(divSuffix)}</text>
|
|
390
|
+
|
|
391
|
+
<line x1="64" y1="468" x2="1136" y2="468" stroke="#22222c" stroke-width="2"/>
|
|
392
|
+
<text x="64" y="510" font-family="system-ui,sans-serif" font-size="24" fill="${fg}">${esc(r.headline.slice(0, 74))}</text>
|
|
393
|
+
<text x="64" y="546" font-family="system-ui,sans-serif" font-size="24" fill="${fg}">${esc(r.headline.slice(74, 148))}</text>
|
|
394
|
+
<text x="64" y="596" font-family="ui-monospace,Menlo,monospace" font-size="18" fill="${dim}">read-only · no paid API · reproducible on mainnet · ${esc(r.generatedAt.slice(0, 10))}</text>
|
|
395
|
+
</svg>`;
|
|
396
|
+
}
|