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/dashboard.ts
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dashboard.ts — turn the local LIQPROOF store into two artefacts:
|
|
3
|
+
*
|
|
4
|
+
* 1. a CSV dataset (one row per audited token) for spreadsheets, papers and
|
|
5
|
+
* reproducible analysis;
|
|
6
|
+
* 2. a single self-contained HTML dashboard (no CDN, no external CSS/JS,
|
|
7
|
+
* no fonts) that works offline, from a file:// URL, on a phone.
|
|
8
|
+
*
|
|
9
|
+
* WHY a static dashboard: the audit trail is worthless if only one machine can
|
|
10
|
+
* read it. A static file can be committed to git, published to GitHub Pages,
|
|
11
|
+
* served from Cloudflare Workers, emailed, or opened from a USB stick — all
|
|
12
|
+
* for free, with no server to keep alive and no paid database.
|
|
13
|
+
*
|
|
14
|
+
* CSV column semantics:
|
|
15
|
+
* coverage fraction 0..1 (deposited USD / claimed USD)
|
|
16
|
+
* self_denominated_pct percentage 0..100 (share of the claim denominated
|
|
17
|
+
* in the token itself, from the stored receipt payload)
|
|
18
|
+
* price_impact fraction 0..1 (as reported by the Jupiter oracle)
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { Store, type TokenRow } from './store.js';
|
|
22
|
+
|
|
23
|
+
export interface DashboardResult {
|
|
24
|
+
html: string;
|
|
25
|
+
csv: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface DashboardRow {
|
|
29
|
+
mint: string;
|
|
30
|
+
symbol: string;
|
|
31
|
+
verdict: string;
|
|
32
|
+
claimedUsd: number | null;
|
|
33
|
+
depositedUsd: number | null;
|
|
34
|
+
coverage: number | null;
|
|
35
|
+
selfDenominatedPct: number | null;
|
|
36
|
+
priceImpact: number | null;
|
|
37
|
+
firstSeenIso: string;
|
|
38
|
+
lastSeenIso: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const TAGLINE = 'The chain doesn\'t lie. We keep receipts.';
|
|
42
|
+
const DISCLAIMER =
|
|
43
|
+
'LIQPROOF reports on-chain measurements only. It does not issue investment advice or legal conclusions.';
|
|
44
|
+
|
|
45
|
+
/** Escape every value that reaches the HTML document. */
|
|
46
|
+
export function escapeHtml(value: unknown): string {
|
|
47
|
+
const amp = String.fromCharCode(38);
|
|
48
|
+
const s = String(value ?? '');
|
|
49
|
+
return s
|
|
50
|
+
.replace(/&/g, amp + 'amp;')
|
|
51
|
+
.replace(/</g, amp + 'lt;')
|
|
52
|
+
.replace(/>/g, amp + 'gt;')
|
|
53
|
+
.replace(/"/g, amp + 'quot;')
|
|
54
|
+
.replace(/'/g, amp + '#39;');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Plain number formatting: no scientific notation, no thousands separators. */
|
|
58
|
+
export function plainNumber(n: number | null | undefined): string {
|
|
59
|
+
if (n === null || n === undefined || !Number.isFinite(n)) return '';
|
|
60
|
+
const s = String(n);
|
|
61
|
+
if (!/[eE]/.test(s)) return s;
|
|
62
|
+
|
|
63
|
+
// Expand exponential notation into plain decimal digits.
|
|
64
|
+
const m = /^(-?)(\d+)(?:\.(\d+))?[eE]([+-]?\d+)$/.exec(s);
|
|
65
|
+
if (!m) return s;
|
|
66
|
+
const sign = m[1]!;
|
|
67
|
+
const intPart = m[2]!;
|
|
68
|
+
const fracPart = m[3] ?? '';
|
|
69
|
+
const exp = Number(m[4]);
|
|
70
|
+
const digits = intPart + fracPart;
|
|
71
|
+
const point = intPart.length + exp;
|
|
72
|
+
let out: string;
|
|
73
|
+
if (point <= 0) out = '0.' + '0'.repeat(-point) + digits;
|
|
74
|
+
else if (point >= digits.length) out = digits + '0'.repeat(point - digits.length);
|
|
75
|
+
else out = digits.slice(0, point) + '.' + digits.slice(point);
|
|
76
|
+
if (out.includes('.')) out = out.replace(/0+$/, '').replace(/\.$/, '');
|
|
77
|
+
return sign + out;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** RFC 4180 CSV escaping: quote when needed, double the inner quotes. */
|
|
81
|
+
export function csvField(value: string | number | null | undefined): string {
|
|
82
|
+
if (value === null || value === undefined) return '';
|
|
83
|
+
const s = String(value);
|
|
84
|
+
if (/[",\n\r]/.test(s)) return `"${s.replace(/"/g, '""')}"`;
|
|
85
|
+
return s;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function isoFromEpoch(seconds: number | null | undefined): string {
|
|
89
|
+
if (!seconds || !Number.isFinite(seconds) || seconds <= 0) return '';
|
|
90
|
+
try {
|
|
91
|
+
return new Date(seconds * 1000).toISOString();
|
|
92
|
+
} catch {
|
|
93
|
+
return '';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function receiptSelfDenominatedPct(payload: string | undefined): number | null {
|
|
98
|
+
if (!payload) return null;
|
|
99
|
+
try {
|
|
100
|
+
const parsed = JSON.parse(payload) as any;
|
|
101
|
+
const v = Number(parsed?.real?.selfDenominatedPct);
|
|
102
|
+
if (Number.isFinite(v)) return v;
|
|
103
|
+
} catch {
|
|
104
|
+
/* a malformed receipt must never break the export */
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Read the store and shape it into dashboard rows. */
|
|
110
|
+
export function collectRows(store: Store): DashboardRow[] {
|
|
111
|
+
const tokens = store.allTokens();
|
|
112
|
+
const receipts = store.latestReceipts();
|
|
113
|
+
const byMint = new Map<string, number | null>();
|
|
114
|
+
for (const r of receipts) {
|
|
115
|
+
if (byMint.has(r.mint)) continue;
|
|
116
|
+
byMint.set(r.mint, receiptSelfDenominatedPct(r.payload));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return tokens.map((t: TokenRow) => ({
|
|
120
|
+
mint: t.mint,
|
|
121
|
+
symbol: t.symbol ?? '',
|
|
122
|
+
verdict: t.verdict ?? 'UNKNOWN',
|
|
123
|
+
claimedUsd: typeof t.claimed_usd === 'number' ? t.claimed_usd : null,
|
|
124
|
+
depositedUsd: typeof t.deposited_usd === 'number' ? t.deposited_usd : null,
|
|
125
|
+
coverage: typeof t.coverage === 'number' ? t.coverage : null,
|
|
126
|
+
selfDenominatedPct: byMint.get(t.mint) ?? null,
|
|
127
|
+
priceImpact: typeof t.price_impact === 'number' ? t.price_impact : null,
|
|
128
|
+
firstSeenIso: isoFromEpoch(t.first_seen),
|
|
129
|
+
lastSeenIso: isoFromEpoch(t.last_seen),
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const CSV_HEADER = [
|
|
134
|
+
'mint',
|
|
135
|
+
'symbol',
|
|
136
|
+
'verdict',
|
|
137
|
+
'claimed_usd',
|
|
138
|
+
'deposited_usd',
|
|
139
|
+
'coverage',
|
|
140
|
+
'self_denominated_pct',
|
|
141
|
+
'price_impact',
|
|
142
|
+
'first_seen_iso',
|
|
143
|
+
'last_seen_iso',
|
|
144
|
+
];
|
|
145
|
+
|
|
146
|
+
/** Build the LIQPROOF dataset as CSV text. */
|
|
147
|
+
export function buildCsv(rows: DashboardRow[]): string {
|
|
148
|
+
const lines: string[] = [CSV_HEADER.join(',')];
|
|
149
|
+
for (const r of rows) {
|
|
150
|
+
lines.push(
|
|
151
|
+
[
|
|
152
|
+
csvField(r.mint),
|
|
153
|
+
csvField(r.symbol),
|
|
154
|
+
csvField(r.verdict),
|
|
155
|
+
csvField(plainNumber(r.claimedUsd)),
|
|
156
|
+
csvField(plainNumber(r.depositedUsd)),
|
|
157
|
+
csvField(plainNumber(r.coverage)),
|
|
158
|
+
csvField(
|
|
159
|
+
r.selfDenominatedPct === null ? '' : plainNumber(r.selfDenominatedPct * 100),
|
|
160
|
+
),
|
|
161
|
+
csvField(plainNumber(r.priceImpact)),
|
|
162
|
+
csvField(r.firstSeenIso),
|
|
163
|
+
csvField(r.lastSeenIso),
|
|
164
|
+
].join(','),
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
return lines.join('\n') + '\n';
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function fmtUsd(n: number | null): string {
|
|
171
|
+
if (n === null || !Number.isFinite(n)) return '—';
|
|
172
|
+
const abs = Math.abs(n);
|
|
173
|
+
if (abs >= 1_000_000_000) return `$${(n / 1_000_000_000).toFixed(2)}B`;
|
|
174
|
+
if (abs >= 1_000_000) return `$${(n / 1_000_000).toFixed(2)}M`;
|
|
175
|
+
if (abs >= 1_000) return `$${(n / 1_000).toFixed(2)}K`;
|
|
176
|
+
if (abs >= 1) return `$${n.toFixed(2)}`;
|
|
177
|
+
return `$${n.toFixed(4)}`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function fmtPct(n: number | null, digits = 2): string {
|
|
181
|
+
if (n === null || !Number.isFinite(n)) return '—';
|
|
182
|
+
return `${(n * 100).toFixed(digits)}%`;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Coverage needs extra digits when it is tiny: 0.0000% is the difference
|
|
187
|
+
* between "empty" and "one part in a million", so we widen the precision
|
|
188
|
+
* until the value is actually legible.
|
|
189
|
+
*/
|
|
190
|
+
function fmtCoverage(n: number | null): string {
|
|
191
|
+
if (n === null || !Number.isFinite(n)) return '—';
|
|
192
|
+
const pctValue = n * 100;
|
|
193
|
+
if (pctValue === 0) return '0%';
|
|
194
|
+
if (pctValue < 0.0001) return `${pctValue.toExponential(3)}%`;
|
|
195
|
+
if (pctValue < 0.01) return `${pctValue.toFixed(6)}%`;
|
|
196
|
+
if (pctValue < 1) return `${pctValue.toFixed(4)}%`;
|
|
197
|
+
return `${pctValue.toFixed(2)}%`;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function fmtPctRaw(n: number | null, digits = 2): string {
|
|
201
|
+
if (n === null || !Number.isFinite(n)) return '—';
|
|
202
|
+
return `${n.toFixed(digits)}%`;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function shortTime(iso: string): string {
|
|
206
|
+
if (!iso) return '—';
|
|
207
|
+
return iso.replace('T', ' ').replace(/\.\d+Z$/, 'Z');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Build the offline, self-contained HTML dashboard. */
|
|
211
|
+
export function buildHtml(rows: DashboardRow[], store: Store): string {
|
|
212
|
+
const survival = store.survival();
|
|
213
|
+
const total = survival.total;
|
|
214
|
+
const fake = survival.fake;
|
|
215
|
+
const consistent = survival.consistent;
|
|
216
|
+
const coverageAvg = survival.coverageAvg;
|
|
217
|
+
|
|
218
|
+
const verdictEntries = Object.entries(survival.byVerdict).sort((a, b) => b[1] - a[1]);
|
|
219
|
+
const maxVerdict = verdictEntries.reduce((m, [, n]) => Math.max(m, n), 0) || 1;
|
|
220
|
+
|
|
221
|
+
const verdictBars = verdictEntries
|
|
222
|
+
.map(([verdict, n]) => {
|
|
223
|
+
const pctWidth = Math.round((n / maxVerdict) * 100);
|
|
224
|
+
const cls = verdictClass(verdict);
|
|
225
|
+
return `
|
|
226
|
+
<div class="bar-row">
|
|
227
|
+
<span class="bar-label ${cls}">${escapeHtml(verdict)}</span>
|
|
228
|
+
<span class="bar-track"><span class="bar-fill ${cls}" style="width:${pctWidth}%"></span></span>
|
|
229
|
+
<span class="bar-count">${escapeHtml(n)}</span>
|
|
230
|
+
</div>`;
|
|
231
|
+
})
|
|
232
|
+
.join('\n');
|
|
233
|
+
|
|
234
|
+
const tableRows = rows
|
|
235
|
+
.map((r) => {
|
|
236
|
+
const cls = verdictClass(r.verdict);
|
|
237
|
+
return `
|
|
238
|
+
<tr>
|
|
239
|
+
<td class="mono"><a href="https://solscan.io/token/${escapeHtml(r.mint)}" target="_blank" rel="noopener">${escapeHtml(r.mint)}</a>
|
|
240
|
+
<button class="copy" type="button" data-mint="${escapeHtml(r.mint)}" title="copy mint">copy</button></td>
|
|
241
|
+
<td>${escapeHtml(r.symbol || '—')}</td>
|
|
242
|
+
<td class="mono"><span class="tag ${cls}">${escapeHtml(r.verdict)}</span></td>
|
|
243
|
+
<td class="num" data-sort="${escapeHtml(plainNumber(r.claimedUsd))}">${escapeHtml(fmtUsd(r.claimedUsd))}</td>
|
|
244
|
+
<td class="num" data-sort="${escapeHtml(plainNumber(r.depositedUsd))}">${escapeHtml(fmtUsd(r.depositedUsd))}</td>
|
|
245
|
+
<td class="num" data-sort="${escapeHtml(plainNumber(r.coverage))}">${escapeHtml(fmtCoverage(r.coverage))}</td>
|
|
246
|
+
<td class="num" data-sort="${escapeHtml(plainNumber(r.selfDenominatedPct === null ? null : r.selfDenominatedPct * 100))}">${escapeHtml(r.selfDenominatedPct === null ? '—' : fmtPctRaw(r.selfDenominatedPct * 100))}</td>
|
|
247
|
+
<td class="num" data-sort="${escapeHtml(plainNumber(r.priceImpact))}">${escapeHtml(r.priceImpact === null ? '—' : fmtPct(r.priceImpact, 2))}</td>
|
|
248
|
+
<td class="mono dim">${escapeHtml(shortTime(r.firstSeenIso))}</td>
|
|
249
|
+
<td class="mono dim">${escapeHtml(shortTime(r.lastSeenIso))}</td>
|
|
250
|
+
</tr>`;
|
|
251
|
+
})
|
|
252
|
+
.join('\n');
|
|
253
|
+
|
|
254
|
+
return `<!doctype html>
|
|
255
|
+
<html lang="en">
|
|
256
|
+
<head>
|
|
257
|
+
<meta charset="utf-8">
|
|
258
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
259
|
+
<title>LIQPROOF — on-chain liquidity receipts</title>
|
|
260
|
+
<style>
|
|
261
|
+
:root {
|
|
262
|
+
--bg: #0a0a0f;
|
|
263
|
+
--panel: #11111a;
|
|
264
|
+
--panel-2: #161622;
|
|
265
|
+
--line: #262633;
|
|
266
|
+
--fg: #f2f2f6;
|
|
267
|
+
--dim: #8b8b9a;
|
|
268
|
+
--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
|
|
269
|
+
--red: #ff3b5c;
|
|
270
|
+
--green: #22c55e;
|
|
271
|
+
--amber: #ffb020;
|
|
272
|
+
--gray: #8b8b9a;
|
|
273
|
+
}
|
|
274
|
+
* { box-sizing: border-box; }
|
|
275
|
+
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
|
|
276
|
+
body {
|
|
277
|
+
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
278
|
+
line-height: 1.5;
|
|
279
|
+
padding: 0 0 48px;
|
|
280
|
+
}
|
|
281
|
+
.mono, code, th, .bar-label, .bar-count, .stat-value, .tag { font-family: var(--mono); }
|
|
282
|
+
header {
|
|
283
|
+
border-bottom: 1px solid var(--line);
|
|
284
|
+
background: linear-gradient(180deg, #0d0d15 0%, #0a0a0f 100%);
|
|
285
|
+
padding: 28px 20px 22px;
|
|
286
|
+
}
|
|
287
|
+
.wrap { max-width: 1180px; margin: 0 auto; }
|
|
288
|
+
h1 { font-family: var(--mono); font-size: 26px; letter-spacing: 6px; margin: 0 0 6px; }
|
|
289
|
+
.tagline { color: var(--dim); margin: 0 0 22px; font-size: 15px; }
|
|
290
|
+
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
|
|
291
|
+
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
|
|
292
|
+
.stat-label { color: var(--dim); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; font-family: var(--mono); }
|
|
293
|
+
.stat-value { font-size: 24px; margin-top: 4px; }
|
|
294
|
+
.stat.bad .stat-value { color: var(--red); }
|
|
295
|
+
.stat.good .stat-value { color: var(--green); }
|
|
296
|
+
main { max-width: 1180px; margin: 0 auto; padding: 24px 20px; }
|
|
297
|
+
section { margin-bottom: 34px; }
|
|
298
|
+
h2 { font-family: var(--mono); font-size: 14px; letter-spacing: 2px; text-transform: uppercase; color: var(--dim); margin: 0 0 12px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
|
|
299
|
+
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
|
|
300
|
+
.bar-row { display: grid; grid-template-columns: 150px 1fr 56px; gap: 12px; align-items: center; padding: 5px 0; }
|
|
301
|
+
.bar-label { font-size: 12px; letter-spacing: 1px; }
|
|
302
|
+
.bar-track { background: var(--panel-2); border-radius: 4px; height: 14px; overflow: hidden; border: 1px solid var(--line); }
|
|
303
|
+
.bar-fill { display: block; height: 100%; background: var(--gray); }
|
|
304
|
+
.bar-count { text-align: right; font-size: 13px; color: var(--fg); }
|
|
305
|
+
.bar-fill.FAKE_LIQUIDITY, .bar-label.FAKE_LIQUIDITY { color: var(--red); }
|
|
306
|
+
.bar-fill.FAKE_LIQUIDITY { background: var(--red); }
|
|
307
|
+
.bar-fill.NO_DEPTH, .bar-label.NO_DEPTH { color: var(--red); }
|
|
308
|
+
.bar-fill.NO_DEPTH { background: var(--red); }
|
|
309
|
+
.bar-fill.DRAINED, .bar-label.DRAINED { color: var(--red); }
|
|
310
|
+
.bar-fill.DRAINED { background: var(--red); }
|
|
311
|
+
.bar-fill.THIN, .bar-label.THIN { color: var(--amber); }
|
|
312
|
+
.bar-fill.THIN { background: var(--amber); }
|
|
313
|
+
.bar-fill.NO_ROUTE, .bar-label.NO_ROUTE { color: #38bdf8; }
|
|
314
|
+
.bar-fill.NO_ROUTE { background: #38bdf8; }
|
|
315
|
+
.bar-fill.CONSISTENT, .bar-label.CONSISTENT { color: var(--green); }
|
|
316
|
+
.bar-fill.CONSISTENT { background: var(--green); }
|
|
317
|
+
.bar-fill.UNKNOWN, .bar-label.UNKNOWN { color: var(--gray); }
|
|
318
|
+
.bar-fill.UNKNOWN { background: var(--gray); }
|
|
319
|
+
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
|
|
320
|
+
table { border-collapse: collapse; width: 100%; min-width: 900px; }
|
|
321
|
+
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
|
|
322
|
+
th { color: var(--dim); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; cursor: pointer; user-select: none; background: var(--panel-2); position: sticky; top: 0; }
|
|
323
|
+
th:hover { color: var(--fg); }
|
|
324
|
+
th::after { content: ""; display: inline-block; width: 10px; }
|
|
325
|
+
th.asc::after { content: " ▲"; color: var(--fg); }
|
|
326
|
+
th.desc::after { content: " ▼"; color: var(--fg); }
|
|
327
|
+
tbody tr:hover { background: #14141f; }
|
|
328
|
+
td.num { text-align: right; font-family: var(--mono); }
|
|
329
|
+
td.dim { color: var(--dim); }
|
|
330
|
+
a { color: #6ea8fe; text-decoration: none; }
|
|
331
|
+
a:hover { text-decoration: underline; }
|
|
332
|
+
.tag { font-size: 11px; letter-spacing: 1px; padding: 2px 7px; border-radius: 4px; border: 1px solid currentColor; }
|
|
333
|
+
.tag.FAKE_LIQUIDITY, .tag.NO_DEPTH, .tag.DRAINED { color: var(--red); }
|
|
334
|
+
.tag.THIN { color: var(--amber); }
|
|
335
|
+
.tag.NO_ROUTE { color: #38bdf8; }
|
|
336
|
+
.tag.CONSISTENT { color: var(--green); }
|
|
337
|
+
.tag.UNKNOWN { color: var(--gray); }
|
|
338
|
+
.copy { margin-left: 8px; background: var(--panel-2); color: var(--dim); border: 1px solid var(--line); border-radius: 4px; font-family: var(--mono); font-size: 10px; padding: 1px 6px; cursor: pointer; }
|
|
339
|
+
.copy:hover { color: var(--fg); border-color: var(--dim); }
|
|
340
|
+
.copy.ok { color: var(--green); border-color: var(--green); }
|
|
341
|
+
footer { max-width: 1180px; margin: 0 auto; padding: 0 20px; color: var(--dim); font-size: 12px; border-top: 1px solid var(--line); padding-top: 16px; }
|
|
342
|
+
.empty { color: var(--dim); font-family: var(--mono); padding: 18px; }
|
|
343
|
+
@media (max-width: 640px) {
|
|
344
|
+
h1 { font-size: 20px; letter-spacing: 4px; }
|
|
345
|
+
.bar-row { grid-template-columns: 110px 1fr 40px; }
|
|
346
|
+
}
|
|
347
|
+
</style>
|
|
348
|
+
</head>
|
|
349
|
+
<body>
|
|
350
|
+
<header>
|
|
351
|
+
<div class="wrap">
|
|
352
|
+
<h1>LIQPROOF</h1>
|
|
353
|
+
<p class="tagline">${escapeHtml(TAGLINE)}</p>
|
|
354
|
+
<div class="stats">
|
|
355
|
+
<div class="stat"><div class="stat-label">tokens audited</div><div class="stat-value">${escapeHtml(total)}</div></div>
|
|
356
|
+
<div class="stat bad"><div class="stat-label">fake / no depth</div><div class="stat-value">${escapeHtml(fake)}</div></div>
|
|
357
|
+
<div class="stat good"><div class="stat-label">consistent</div><div class="stat-value">${escapeHtml(consistent)}</div></div>
|
|
358
|
+
<div class="stat"><div class="stat-label">avg coverage</div><div class="stat-value">${escapeHtml(fmtPct(coverageAvg))}</div></div>
|
|
359
|
+
</div>
|
|
360
|
+
</div>
|
|
361
|
+
</header>
|
|
362
|
+
<main>
|
|
363
|
+
<section>
|
|
364
|
+
<h2>Verdict breakdown</h2>
|
|
365
|
+
<div class="panel">
|
|
366
|
+
${verdictBars || '<div class="empty">no verdicts recorded yet</div>'}
|
|
367
|
+
</div>
|
|
368
|
+
</section>
|
|
369
|
+
<section>
|
|
370
|
+
<h2>Audited tokens — click a column header to sort</h2>
|
|
371
|
+
<div class="table-wrap">
|
|
372
|
+
<table id="tokens">
|
|
373
|
+
<thead>
|
|
374
|
+
<tr>
|
|
375
|
+
<th data-type="text">mint</th>
|
|
376
|
+
<th data-type="text">symbol</th>
|
|
377
|
+
<th data-type="text">verdict</th>
|
|
378
|
+
<th data-type="num">claimed usd</th>
|
|
379
|
+
<th data-type="num">deposited usd</th>
|
|
380
|
+
<th data-type="num">coverage</th>
|
|
381
|
+
<th data-type="num">self-denominated %</th>
|
|
382
|
+
<th data-type="num">price impact</th>
|
|
383
|
+
<th data-type="text">first seen</th>
|
|
384
|
+
<th data-type="text">last seen</th>
|
|
385
|
+
</tr>
|
|
386
|
+
</thead>
|
|
387
|
+
<tbody>
|
|
388
|
+
${tableRows || '<tr><td colspan="10" class="empty">no tokens audited yet — run <code>liqproof scan</code></td></tr>'}
|
|
389
|
+
</tbody>
|
|
390
|
+
</table>
|
|
391
|
+
</div>
|
|
392
|
+
</section>
|
|
393
|
+
</main>
|
|
394
|
+
<footer>
|
|
395
|
+
<p>${escapeHtml(DISCLAIMER)}</p>
|
|
396
|
+
<p>Read-only on-chain measurements. No gas, no paid APIs, no chain mutation.</p>
|
|
397
|
+
<p>On-chain data powered by <a href="https://www.geckoterminal.com" target="_blank" rel="noopener">GeckoTerminal</a> · price data provided by <a href="https://www.coingecko.com" target="_blank" rel="noopener">CoinGecko</a> · powered by <a href="https://www.coingecko.com/en/api/" target="_blank" rel="noopener">CoinGecko API</a></p>
|
|
398
|
+
</footer>
|
|
399
|
+
<script>
|
|
400
|
+
(function () {
|
|
401
|
+
var table = document.getElementById('tokens');
|
|
402
|
+
if (!table) return;
|
|
403
|
+
var tbody = table.tBodies[0];
|
|
404
|
+
var headers = table.querySelectorAll('thead th');
|
|
405
|
+
var current = { index: -1, asc: true };
|
|
406
|
+
|
|
407
|
+
function cellValue(row, index) {
|
|
408
|
+
var cell = row.cells[index];
|
|
409
|
+
if (!cell) return '';
|
|
410
|
+
var sort = cell.getAttribute('data-sort');
|
|
411
|
+
if (sort !== null && sort !== '') return sort;
|
|
412
|
+
return (cell.textContent || '').trim();
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function compare(a, b, index, type) {
|
|
416
|
+
if (type === 'num') {
|
|
417
|
+
var x = parseFloat(cellValue(a, index));
|
|
418
|
+
var y = parseFloat(cellValue(b, index));
|
|
419
|
+
if (isNaN(x)) x = -Infinity;
|
|
420
|
+
if (isNaN(y)) y = -Infinity;
|
|
421
|
+
return x - y;
|
|
422
|
+
}
|
|
423
|
+
return cellValue(a, index).localeCompare(cellValue(b, index));
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
headers.forEach(function (th, index) {
|
|
427
|
+
th.addEventListener('click', function () {
|
|
428
|
+
var type = th.getAttribute('data-type') || 'text';
|
|
429
|
+
if (current.index === index) {
|
|
430
|
+
current.asc = !current.asc;
|
|
431
|
+
} else {
|
|
432
|
+
current.index = index;
|
|
433
|
+
current.asc = true;
|
|
434
|
+
}
|
|
435
|
+
headers.forEach(function (other) { other.classList.remove('asc', 'desc'); });
|
|
436
|
+
th.classList.add(current.asc ? 'asc' : 'desc');
|
|
437
|
+
|
|
438
|
+
var rows = Array.prototype.slice.call(tbody.rows);
|
|
439
|
+
rows.sort(function (a, b) {
|
|
440
|
+
var r = compare(a, b, index, type);
|
|
441
|
+
return current.asc ? r : -r;
|
|
442
|
+
});
|
|
443
|
+
rows.forEach(function (row) { tbody.appendChild(row); });
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
document.addEventListener('click', function (event) {
|
|
448
|
+
var target = event.target;
|
|
449
|
+
if (!target || !target.classList || !target.classList.contains('copy')) return;
|
|
450
|
+
var mint = target.getAttribute('data-mint');
|
|
451
|
+
if (!mint) return;
|
|
452
|
+
var done = function () {
|
|
453
|
+
target.textContent = 'copied';
|
|
454
|
+
target.classList.add('ok');
|
|
455
|
+
setTimeout(function () {
|
|
456
|
+
target.textContent = 'copy';
|
|
457
|
+
target.classList.remove('ok');
|
|
458
|
+
}, 1200);
|
|
459
|
+
};
|
|
460
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
461
|
+
navigator.clipboard.writeText(mint).then(done, function () {});
|
|
462
|
+
} else {
|
|
463
|
+
var area = document.createElement('textarea');
|
|
464
|
+
area.value = mint;
|
|
465
|
+
document.body.appendChild(area);
|
|
466
|
+
area.select();
|
|
467
|
+
try { document.execCommand('copy'); done(); } catch (e) {}
|
|
468
|
+
document.body.removeChild(area);
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
})();
|
|
472
|
+
</script>
|
|
473
|
+
</body>
|
|
474
|
+
</html>
|
|
475
|
+
`;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function verdictClass(verdict: string): string {
|
|
479
|
+
switch (verdict) {
|
|
480
|
+
case 'FAKE_LIQUIDITY':
|
|
481
|
+
case 'NO_DEPTH':
|
|
482
|
+
case 'DRAINED':
|
|
483
|
+
case 'UNBACKED_LIQUIDITY':
|
|
484
|
+
case 'THIN':
|
|
485
|
+
case 'NO_ROUTE':
|
|
486
|
+
case 'CONSISTENT':
|
|
487
|
+
case 'UNKNOWN':
|
|
488
|
+
return verdict;
|
|
489
|
+
default:
|
|
490
|
+
return 'UNKNOWN';
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Build both dashboard artefacts from the store.
|
|
496
|
+
* This is the entry point used by `liqproof export`.
|
|
497
|
+
*/
|
|
498
|
+
export function buildDashboard(store: Store): DashboardResult {
|
|
499
|
+
const rows = collectRows(store);
|
|
500
|
+
return {
|
|
501
|
+
html: buildHtml(rows, store),
|
|
502
|
+
csv: buildCsv(rows),
|
|
503
|
+
};
|
|
504
|
+
}
|