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/dist/receipt.js
ADDED
|
@@ -0,0 +1,897 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* receipt.ts — build the LIQPROOF artifact.
|
|
3
|
+
*
|
|
4
|
+
* The artifact is a RECEIPT, not a score. It answers four questions with
|
|
5
|
+
* on-chain evidence:
|
|
6
|
+
*
|
|
7
|
+
* 1. What did the market CLAIM? (aggregator-reported liquidity, USD)
|
|
8
|
+
* 2. What is ACTUALLY there? (pool vault balances, read from the chain)
|
|
9
|
+
* 3. When did it change? (timestamped liquidity curve from tx metadata)
|
|
10
|
+
* 4. Can you actually trade? (Jupiter execution oracle: price impact)
|
|
11
|
+
*
|
|
12
|
+
* THE HEADLINE METRIC — DEPOSIT COVERAGE:
|
|
13
|
+
*
|
|
14
|
+
* coverage = (USDC actually sitting in the pool) / (USD the market claims)
|
|
15
|
+
*
|
|
16
|
+
* For an honest pool this is ~50-100%. For a rug it is 0.00003%. That single
|
|
17
|
+
* number is falsifiable, timestampable, and impossible to fake without
|
|
18
|
+
* actually depositing the money.
|
|
19
|
+
*
|
|
20
|
+
* THE SECOND METRIC — PRICE DIVERGENCE:
|
|
21
|
+
*
|
|
22
|
+
* divergence = (displayed price) / (price a real $1 buy actually gets you)
|
|
23
|
+
*
|
|
24
|
+
* When a pool is full of its own token and the quote side is nearly empty,
|
|
25
|
+
* the "price" is a fiction: $1 buys you a rounding error of tokens.
|
|
26
|
+
*/
|
|
27
|
+
import { jupiterQuote, quoteTokenPriceUsd, solPriceUsd, tokenReport, } from './sources.js';
|
|
28
|
+
import { liquidityCurve } from './curve.js';
|
|
29
|
+
import { readPoolVaults, mintMeta } from './vaults.js';
|
|
30
|
+
import { MINT } from './sources.js';
|
|
31
|
+
import { tokenMetadata } from './tokenmeta.js';
|
|
32
|
+
import { loadCanonicalIndex, resolveCanonical } from './canonical.js';
|
|
33
|
+
import { loadOperatorRegistry, findOperatorLink } from './operator.js';
|
|
34
|
+
import { ratio } from './util.js';
|
|
35
|
+
const METHODOLOGY = [
|
|
36
|
+
"Deposited USD = SPL token-account balance of the pool's quote-side vault, read directly from Solana mainnet (no aggregator, no paid API).",
|
|
37
|
+
'Claimed USD = reserve_in_usd as reported by GeckoTerminal (CoinGecko) and DexScreener.',
|
|
38
|
+
'Historical liquidity curve reconstructed from preTokenBalances/postTokenBalances in transaction metadata — no archive node required.',
|
|
39
|
+
'Executable price derived from a live Jupiter swap quote (lite-api), which simulates the actual route and reports price impact.',
|
|
40
|
+
'Every number above is reproducible with the read-only public RPC; no private indexer, no paid API, no chain mutation.',
|
|
41
|
+
];
|
|
42
|
+
const DISCLAIMER = 'LIQPROOF reports on-chain measurements only. It does not issue investment advice or legal conclusions. ' +
|
|
43
|
+
'Values are derived from public chain state at the stated slot and may differ from the state at the time of reading.';
|
|
44
|
+
/** Merge aggregator rows that describe the same on-chain pool. */
|
|
45
|
+
function mergePools(pools) {
|
|
46
|
+
const byAddress = new Map();
|
|
47
|
+
for (const p of pools) {
|
|
48
|
+
if (!p.address)
|
|
49
|
+
continue;
|
|
50
|
+
const existing = byAddress.get(p.address);
|
|
51
|
+
if (!existing) {
|
|
52
|
+
byAddress.set(p.address, {
|
|
53
|
+
...p,
|
|
54
|
+
reportedLiquidityUsd: p.reportedLiquidityUsd,
|
|
55
|
+
entries: [p],
|
|
56
|
+
sources: [p.source],
|
|
57
|
+
});
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
existing.entries.push(p);
|
|
61
|
+
if (!existing.sources.includes(p.source))
|
|
62
|
+
existing.sources.push(p.source);
|
|
63
|
+
// Keep the largest claim (and the price that came with it).
|
|
64
|
+
if (p.reportedLiquidityUsd > existing.reportedLiquidityUsd) {
|
|
65
|
+
existing.reportedLiquidityUsd = p.reportedLiquidityUsd;
|
|
66
|
+
existing.basePriceUsd = p.basePriceUsd || existing.basePriceUsd;
|
|
67
|
+
existing.quotePriceUsd = p.quotePriceUsd || existing.quotePriceUsd;
|
|
68
|
+
}
|
|
69
|
+
// Fill in any field a previous source left empty.
|
|
70
|
+
existing.baseTokenAddress ||= p.baseTokenAddress;
|
|
71
|
+
existing.baseTokenSymbol ||= p.baseTokenSymbol;
|
|
72
|
+
existing.quoteTokenAddress ||= p.quoteTokenAddress;
|
|
73
|
+
existing.quoteTokenSymbol ||= p.quoteTokenSymbol;
|
|
74
|
+
existing.dexId ||= p.dexId;
|
|
75
|
+
existing.name ||= p.name;
|
|
76
|
+
existing.createdAt ||= p.createdAt;
|
|
77
|
+
}
|
|
78
|
+
const out = [...byAddress.values()];
|
|
79
|
+
out.sort((a, b) => b.reportedLiquidityUsd - a.reportedLiquidityUsd);
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Fraction of a pool's value that is denominated in the token itself.
|
|
84
|
+
*
|
|
85
|
+
* self% = base_value / (base_value + quote_value)
|
|
86
|
+
*
|
|
87
|
+
* `baseTokens` is the live base-side balance, `priceUsd` the market price of
|
|
88
|
+
* that token, `quoteUsd` the live quote-side value (real money). The result
|
|
89
|
+
* is always in [0, 1] and always consistent in time, because both legs come
|
|
90
|
+
* from the same on-chain snapshot.
|
|
91
|
+
*/
|
|
92
|
+
function computeSelfDenominated(baseTokens, priceUsd, quoteUsd) {
|
|
93
|
+
const baseValue = baseTokens * priceUsd;
|
|
94
|
+
const total = baseValue + quoteUsd;
|
|
95
|
+
if (!Number.isFinite(total) || total <= 0)
|
|
96
|
+
return 0;
|
|
97
|
+
return Math.max(0, Math.min(1, baseValue / total));
|
|
98
|
+
}
|
|
99
|
+
function pct(n) {
|
|
100
|
+
if (!Number.isFinite(n))
|
|
101
|
+
return 'n/a';
|
|
102
|
+
if (n === 0)
|
|
103
|
+
return '0%';
|
|
104
|
+
if (n < 0.001)
|
|
105
|
+
return `${(n * 100).toPrecision(3)}%`;
|
|
106
|
+
return `${(n * 100).toFixed(2)}%`;
|
|
107
|
+
}
|
|
108
|
+
function fmtUsd(n) {
|
|
109
|
+
if (!Number.isFinite(n))
|
|
110
|
+
return 'n/a';
|
|
111
|
+
const abs = Math.abs(n);
|
|
112
|
+
if (abs >= 1_000_000_000)
|
|
113
|
+
return `$${(n / 1_000_000_000).toFixed(2)}B`;
|
|
114
|
+
if (abs >= 1_000_000)
|
|
115
|
+
return `$${(n / 1_000_000).toFixed(2)}M`;
|
|
116
|
+
if (abs >= 1_000)
|
|
117
|
+
return `$${(n / 1_000).toFixed(2)}K`;
|
|
118
|
+
if (abs >= 1)
|
|
119
|
+
return `$${n.toFixed(2)}`;
|
|
120
|
+
return `$${n.toFixed(4)}`;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Format an overstatement ratio for prose.
|
|
124
|
+
*
|
|
125
|
+
* The drained "BCH" pool measures 1.93 × 10¹⁵. Writing that out in full
|
|
126
|
+
* ("1,928,462,445,799,058×") implies a precision the measurement does not
|
|
127
|
+
* have and makes the sentence unreadable, so we scale it instead.
|
|
128
|
+
*
|
|
129
|
+
* (One implementation, shared with the renderer — see `ratio` in util.ts.)
|
|
130
|
+
*/
|
|
131
|
+
const fmtRatio = ratio;
|
|
132
|
+
/** Build a receipt for a mint. */
|
|
133
|
+
export async function buildReceipt(rpc, mint, opts = {}) {
|
|
134
|
+
const includeCurve = opts.includeCurve ?? true;
|
|
135
|
+
const maxTransactions = opts.maxTransactions ?? 600;
|
|
136
|
+
// ── 1. what the market claims ────────────────────────────────────────────
|
|
137
|
+
const report = await tokenReport(mint);
|
|
138
|
+
const pools = report.pools;
|
|
139
|
+
// ── 1b. what the token says it IS ────────────────────────────────────────
|
|
140
|
+
//
|
|
141
|
+
// The aggregator's `name` is a third party's claim. The mint's own
|
|
142
|
+
// Metaplex metadata account is the token's statement, and it is the only
|
|
143
|
+
// statement that cannot be edited without touching the chain. We read it
|
|
144
|
+
// directly, from the account's own PDA, and we surface the PDA as
|
|
145
|
+
// evidence so the reader can open it and check us.
|
|
146
|
+
let meta = null;
|
|
147
|
+
try {
|
|
148
|
+
meta = await tokenMetadata(rpc, mint);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
meta = null;
|
|
152
|
+
}
|
|
153
|
+
const identityName = meta?.name || report.name || '';
|
|
154
|
+
const identitySymbol = meta?.symbol || report.symbol || '';
|
|
155
|
+
// Resolve the canonical token behind this name/ticker. This is the step
|
|
156
|
+
// that stops us from calling a real project a counterfeit: on 2026-12-04
|
|
157
|
+
// it is the difference between accusing Chiliz and accusing the wallet
|
|
158
|
+
// that copied Chiliz's name.
|
|
159
|
+
let canonicalIndex = null;
|
|
160
|
+
let canonical;
|
|
161
|
+
try {
|
|
162
|
+
canonicalIndex = await loadCanonicalIndex();
|
|
163
|
+
canonical = resolveCanonical(mint, { name: identityName, symbol: identitySymbol }, canonicalIndex);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
canonical = resolveCanonical(mint, null, {
|
|
167
|
+
entries: [],
|
|
168
|
+
byMint: new Map(),
|
|
169
|
+
bySymbol: new Map(),
|
|
170
|
+
byCoreName: new Map(),
|
|
171
|
+
loadedAt: '',
|
|
172
|
+
counts: {},
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
// If the canonical index could not be loaded at all we do not know what
|
|
176
|
+
// the genuine article is — and a tool that cannot tell a real project
|
|
177
|
+
// from a fake one must not issue accusations.
|
|
178
|
+
const canonicalIndexAvailable = (canonicalIndex?.entries.length ?? 0) > 0;
|
|
179
|
+
const tokenIsCanonical = canonical.isCanonical;
|
|
180
|
+
// Link this mint to the wallet that deployed it and its siblings.
|
|
181
|
+
let operator = null;
|
|
182
|
+
if (meta?.creators?.length) {
|
|
183
|
+
try {
|
|
184
|
+
operator = findOperatorLink(loadOperatorRegistry(), mint, meta.creators);
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
operator = null;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// Several aggregators report the SAME pool address. If we audited one row
|
|
191
|
+
// per source we would read the same vaults twice and DOUBLE the deposit —
|
|
192
|
+
// we measured exactly that ($42.91 instead of the real $21.45). So merge by
|
|
193
|
+
// address FIRST, then audit each unique pool once.
|
|
194
|
+
const views = mergePools(pools);
|
|
195
|
+
/**
|
|
196
|
+
* ORIENTATION — whose liquidity is this pool, really?
|
|
197
|
+
*
|
|
198
|
+
* A pool in which the audited mint is only the QUOTE token is not evidence
|
|
199
|
+
* about that mint's liquidity; it is evidence about the other token. We got
|
|
200
|
+
* this wrong once and it produced the single most misleading row in our own
|
|
201
|
+
* dataset: USDT was audited on "BCH / USDT" — a pool whose entire reserve
|
|
202
|
+
* had been drained — so USDT was published as holding $0.00 of liquidity.
|
|
203
|
+
* The pool was the problem. USDT was the innocent counterparty, and the
|
|
204
|
+
* honest $40-billion USDT market was made to look like a scam.
|
|
205
|
+
*
|
|
206
|
+
* So: audit a pool where the mint is the BASE token whenever one exists.
|
|
207
|
+
* Only when there is no base-side pool at all do we fall back to a
|
|
208
|
+
* quote-side pool, and then the receipt says so in plain words instead of
|
|
209
|
+
* quietly blaming the counterparty.
|
|
210
|
+
*/
|
|
211
|
+
const baseSidePools = views.filter((v) => v.baseTokenAddress === mint);
|
|
212
|
+
const quoteSidePools = views.filter((v) => v.baseTokenAddress !== mint && v.quoteTokenAddress === mint);
|
|
213
|
+
const preferredPools = baseSidePools.length
|
|
214
|
+
? baseSidePools
|
|
215
|
+
: quoteSidePools.length
|
|
216
|
+
? quoteSidePools
|
|
217
|
+
: views;
|
|
218
|
+
let focus = opts.focusPool ?? preferredPools[0]?.address ?? views[0]?.address;
|
|
219
|
+
let focusView = views.find((v) => v.address === focus);
|
|
220
|
+
// The mining feed may know a pool that the token's own pool list does not
|
|
221
|
+
// return. Fall back to the feed's row so the audit still happens.
|
|
222
|
+
if (!focusView && opts.focusPoolData) {
|
|
223
|
+
const extra = mergePools([opts.focusPoolData]);
|
|
224
|
+
focusView = extra[0];
|
|
225
|
+
focus = focusView?.address;
|
|
226
|
+
}
|
|
227
|
+
const claimedLiquidityUsd = focusView?.reportedLiquidityUsd ?? 0;
|
|
228
|
+
const displayedPriceUsd = report.priceUsd ?? focusView?.basePriceUsd ?? 0;
|
|
229
|
+
/**
|
|
230
|
+
* How the audited mint sits in the pool we audited.
|
|
231
|
+
*
|
|
232
|
+
* 'base' — the mint IS the pool's base token. The pool's liquidity is
|
|
233
|
+
* the mint's liquidity, and every number in this receipt is a
|
|
234
|
+
* statement about the mint.
|
|
235
|
+
* 'quote' — the mint is only the counterparty (e.g. USDC in a BCH/USDT
|
|
236
|
+
* pool). The pool's numbers describe the OTHER token; a
|
|
237
|
+
* shortfall here is a finding about that pool, never about the
|
|
238
|
+
* mint. We say so out loud rather than publishing a number
|
|
239
|
+
* that reads as an accusation.
|
|
240
|
+
* 'unknown' — the aggregator did not tell us the orientation.
|
|
241
|
+
*/
|
|
242
|
+
const orientation = focusView && focusView.baseTokenAddress === mint
|
|
243
|
+
? 'base'
|
|
244
|
+
: focusView && focusView.quoteTokenAddress === mint
|
|
245
|
+
? 'quote'
|
|
246
|
+
: 'unknown';
|
|
247
|
+
const claimSources = (focusView?.entries ?? []).slice(0, 4).map((p) => ({
|
|
248
|
+
source: p.source,
|
|
249
|
+
liquidityUsd: p.reportedLiquidityUsd,
|
|
250
|
+
priceUsd: p.basePriceUsd,
|
|
251
|
+
pool: p.address,
|
|
252
|
+
}));
|
|
253
|
+
const solUsd = await solPriceUsd();
|
|
254
|
+
// ── 2. pick the pool to audit ────────────────────────────────────────────
|
|
255
|
+
const auditList = focusView ? [focusView] : [];
|
|
256
|
+
const snapshots = [];
|
|
257
|
+
let curve;
|
|
258
|
+
let oracle = {};
|
|
259
|
+
let baseDecimals = 6;
|
|
260
|
+
let poolQuotePrice = 0;
|
|
261
|
+
for (const pool of auditList) {
|
|
262
|
+
const baseMint = pool.baseTokenAddress || mint;
|
|
263
|
+
const quoteMint = pool.quoteTokenAddress || MINT.USDC;
|
|
264
|
+
const vaults = await readPoolVaults(rpc, pool.address, baseMint, quoteMint);
|
|
265
|
+
const baseVault = vaults.base;
|
|
266
|
+
const quoteVault = vaults.quote;
|
|
267
|
+
const quotePrice = await quoteTokenPriceUsd(quoteMint, pool.quotePriceUsd, baseMint);
|
|
268
|
+
if (poolQuotePrice === 0 && quotePrice > 0)
|
|
269
|
+
poolQuotePrice = quotePrice;
|
|
270
|
+
const realQuoteUsd = quoteVault ? quoteVault.uiAmount * quotePrice : 0;
|
|
271
|
+
const realBaseTokens = baseVault?.uiAmount ?? 0;
|
|
272
|
+
const coverage = claimedLiquidityUsd > 0 ? realQuoteUsd / claimedLiquidityUsd : 0;
|
|
273
|
+
const divergenceRatio = realQuoteUsd > 0 ? claimedLiquidityUsd / realQuoteUsd : Infinity;
|
|
274
|
+
// How much of the claimed liquidity is the token itself valued at its own
|
|
275
|
+
// price? (aggregator formula: reserve_in_usd = base_tokens × price + quote_usd)
|
|
276
|
+
//
|
|
277
|
+
// Each source is evaluated with ITS OWN price and ITS OWN claim, then we
|
|
278
|
+
// keep the SMALLEST percentage. That is the reading least favourable to
|
|
279
|
+
// an accusation — we only call a pool circular when even the most
|
|
280
|
+
// generous reading of the data says so.
|
|
281
|
+
// How much of the pool's value is the token itself?
|
|
282
|
+
//
|
|
283
|
+
// IMPORTANT — this is computed from the LIVE on-chain balances, NOT from
|
|
284
|
+
// the aggregator's claim. We originally derived it as
|
|
285
|
+
// (base_tokens × price) / claimed_liquidity, but that mixes a live
|
|
286
|
+
// balance with a claim that may be up to 15 minutes old, and the ratio
|
|
287
|
+
// could then exceed 100% and accuse an honest token (we caught exactly
|
|
288
|
+
// that: BONK, a bluechip, was briefly reported as FAKE_LIQUIDITY).
|
|
289
|
+
//
|
|
290
|
+
// The on-chain formulation cannot exceed 100% by construction and is
|
|
291
|
+
// time-consistent:
|
|
292
|
+
//
|
|
293
|
+
// self% = base_value / (base_value + quote_value)
|
|
294
|
+
//
|
|
295
|
+
// where base_value = live base balance × market price, and
|
|
296
|
+
// quote_value = live quote balance (real money, in USD).
|
|
297
|
+
//
|
|
298
|
+
// Honest pools land at 45-75% (the base token is the bigger leg).
|
|
299
|
+
// A pool whose "liquidity" is 99.99% its own token is circular.
|
|
300
|
+
const selfDenominatedPct = computeSelfDenominated(realBaseTokens, pool.basePriceUsd || displayedPriceUsd, realQuoteUsd);
|
|
301
|
+
// Per-source breakdown for auditability (each source contributes its own
|
|
302
|
+
// price for the base leg).
|
|
303
|
+
const selfBySource = [];
|
|
304
|
+
for (const e of pool.entries) {
|
|
305
|
+
const px = e.basePriceUsd || pool.basePriceUsd || displayedPriceUsd;
|
|
306
|
+
if (px <= 0)
|
|
307
|
+
continue;
|
|
308
|
+
selfBySource.push({
|
|
309
|
+
source: e.source,
|
|
310
|
+
claimUsd: e.reportedLiquidityUsd,
|
|
311
|
+
priceUsd: px,
|
|
312
|
+
selfDenominatedPct: computeSelfDenominated(realBaseTokens, px, realQuoteUsd),
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
if (baseMint === mint) {
|
|
316
|
+
const mm = await mintMeta(rpc, mint);
|
|
317
|
+
if (mm)
|
|
318
|
+
baseDecimals = mm.decimals;
|
|
319
|
+
}
|
|
320
|
+
snapshots.push({
|
|
321
|
+
pool: pool.address,
|
|
322
|
+
dexId: pool.dexId,
|
|
323
|
+
claimedLiquidityUsd: pool.reportedLiquidityUsd,
|
|
324
|
+
realQuoteUsd,
|
|
325
|
+
realBaseTokens,
|
|
326
|
+
selfDenominatedPct,
|
|
327
|
+
selfDenominatedBySource: selfBySource,
|
|
328
|
+
baseMint,
|
|
329
|
+
quoteMint,
|
|
330
|
+
quoteSymbol: pool.quoteTokenSymbol ||
|
|
331
|
+
(quoteMint === MINT.USDC ? 'USDC' : quoteMint === MINT.SOL ? 'SOL' : ''),
|
|
332
|
+
baseSymbol: pool.baseTokenSymbol || report.symbol || '',
|
|
333
|
+
coverage,
|
|
334
|
+
divergenceRatio,
|
|
335
|
+
vaults: vaults.all.map((v) => ({
|
|
336
|
+
address: v.address,
|
|
337
|
+
mint: v.mint,
|
|
338
|
+
side: v.side,
|
|
339
|
+
amount: v.amount,
|
|
340
|
+
uiAmount: v.uiAmount,
|
|
341
|
+
decimals: v.decimals,
|
|
342
|
+
})),
|
|
343
|
+
poolOwnerProgram: vaults.poolOwnerProgram,
|
|
344
|
+
poolLamports: vaults.poolLamports,
|
|
345
|
+
method: vaults.method,
|
|
346
|
+
note: vaults.note,
|
|
347
|
+
});
|
|
348
|
+
// ── 3. the curve ───────────────────────────────────────────────────────
|
|
349
|
+
if (includeCurve && !curve && vaults.all.length > 0) {
|
|
350
|
+
const vaultAddresses = vaults.all.map((v) => v.address);
|
|
351
|
+
const vaultMints = {};
|
|
352
|
+
for (const v of vaults.all)
|
|
353
|
+
vaultMints[v.address] = v.mint;
|
|
354
|
+
const prices = { [MINT.USDC]: 1, [MINT.SOL]: solUsd };
|
|
355
|
+
if (quotePrice > 0)
|
|
356
|
+
prices[quoteMint] = quotePrice;
|
|
357
|
+
curve = await liquidityCurve(rpc, pool.address, vaultAddresses, vaultMints, {
|
|
358
|
+
maxTransactions,
|
|
359
|
+
maxSignatures: Math.max(maxTransactions * 5, 3000),
|
|
360
|
+
prices,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
// ── 4. the execution oracle ──────────────────────────────────────────────
|
|
365
|
+
const BUY_AMOUNT = 1_000_000; // 1 USDC in base units
|
|
366
|
+
const buyQuote = await jupiterQuote(MINT.USDC, mint, String(BUY_AMOUNT));
|
|
367
|
+
const solToToken = await jupiterQuote(MINT.SOL, mint, '10000000'); // 0.01 SOL
|
|
368
|
+
const sellAmount = 10 ** baseDecimals; // 1 whole token
|
|
369
|
+
const sellQuote = await jupiterQuote(mint, MINT.USDC, String(sellAmount));
|
|
370
|
+
// tokens actually received for $1
|
|
371
|
+
const tokensPerDollar = buyQuote && !buyQuote.error && Number(buyQuote.outAmount) > 0
|
|
372
|
+
? Number(buyQuote.outAmount) / 10 ** baseDecimals
|
|
373
|
+
: undefined;
|
|
374
|
+
// executable unit price = what one token actually costs in a real trade
|
|
375
|
+
const executablePriceUsd = tokensPerDollar ? 1 / tokensPerDollar : undefined;
|
|
376
|
+
const priceDivergence = executablePriceUsd && executablePriceUsd > 0 && displayedPriceUsd > 0
|
|
377
|
+
? displayedPriceUsd / executablePriceUsd
|
|
378
|
+
: undefined;
|
|
379
|
+
oracle = {
|
|
380
|
+
buyQuote,
|
|
381
|
+
sellQuote,
|
|
382
|
+
executablePriceUsd,
|
|
383
|
+
displayedPriceUsd: displayedPriceUsd || undefined,
|
|
384
|
+
priceDivergence,
|
|
385
|
+
tokensPerDollar,
|
|
386
|
+
solToTokenRoutable: !!(solToToken && !solToToken.error),
|
|
387
|
+
tokenToSolRoutable: !!(sellQuote && !sellQuote.error),
|
|
388
|
+
};
|
|
389
|
+
// ── 5. assemble ──────────────────────────────────────────────────────────
|
|
390
|
+
const depositedUsd = snapshots.reduce((s, p) => s + p.realQuoteUsd, 0);
|
|
391
|
+
const heldTokens = snapshots.reduce((s, p) => s + p.realBaseTokens, 0);
|
|
392
|
+
const coverage = claimedLiquidityUsd > 0 ? depositedUsd / claimedLiquidityUsd : 0;
|
|
393
|
+
const divergenceRatio = depositedUsd > 0 ? claimedLiquidityUsd / depositedUsd : Infinity;
|
|
394
|
+
const selfDenominatedPct = snapshots.length
|
|
395
|
+
? snapshots.reduce((s, p) => s + p.selfDenominatedPct, 0) / snapshots.length
|
|
396
|
+
: 0;
|
|
397
|
+
// peak deposited USD across the whole reconstructed history.
|
|
398
|
+
// Use the "before" balance too — the peak may only appear as a pre-image.
|
|
399
|
+
const quoteMint = snapshots[0]?.quoteMint ?? MINT.USDC;
|
|
400
|
+
// Reuse the price we already resolved while auditing the pool. Recomputing
|
|
401
|
+
// here would issue a second round of network calls and could come back
|
|
402
|
+
// empty (which would wrongly gate the verdict to UNKNOWN).
|
|
403
|
+
const quotePriceUsd = poolQuotePrice > 0 ? poolQuotePrice : await quoteTokenPriceUsd(quoteMint, undefined, snapshots[0]?.baseMint);
|
|
404
|
+
const quoteDecimals = snapshots[0]?.vaults.find((v) => v.side === 'quote')?.decimals ?? 6;
|
|
405
|
+
let peakDepositedUsd;
|
|
406
|
+
let peakPoint;
|
|
407
|
+
for (const p of curve?.points ?? []) {
|
|
408
|
+
const post = p.balances[quoteMint];
|
|
409
|
+
const pre = p.before[quoteMint];
|
|
410
|
+
for (const raw of [post, pre]) {
|
|
411
|
+
if (raw === undefined)
|
|
412
|
+
continue;
|
|
413
|
+
const v = (Number(raw) / 10 ** quoteDecimals) * quotePriceUsd;
|
|
414
|
+
if (peakDepositedUsd === undefined || v > peakDepositedUsd) {
|
|
415
|
+
peakDepositedUsd = v;
|
|
416
|
+
peakPoint = p;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
// ── 6. verdict ───────────────────────────────────────────────────────────
|
|
421
|
+
//
|
|
422
|
+
// EVIDENCE GATING — the most important rule in this file.
|
|
423
|
+
// A receipt that accuses a token when it simply FAILED to read the vaults
|
|
424
|
+
// is worse than useless: it destroys the credibility of every other receipt
|
|
425
|
+
// we publish. Therefore:
|
|
426
|
+
//
|
|
427
|
+
// • no quote-side vault located → we have no deposit evidence → UNKNOWN
|
|
428
|
+
// • no quote price available → we cannot value the deposit → UNKNOWN
|
|
429
|
+
// • only then may we issue an adverse verdict
|
|
430
|
+
//
|
|
431
|
+
const impact = buyQuote && !buyQuote.error ? buyQuote.priceImpactPct : 1;
|
|
432
|
+
const quoteVaultFound = !!snapshots[0]?.vaults.some((v) => v.side === 'quote');
|
|
433
|
+
const quotePriced = quotePriceUsd > 0;
|
|
434
|
+
const hasDepositEvidence = quoteVaultFound && quotePriced;
|
|
435
|
+
// ── the tradeability oracle, and why it needs corroboration ──────────────
|
|
436
|
+
//
|
|
437
|
+
// A quote API's price-impact field is a RATIO where 1 means 100%. We
|
|
438
|
+
// verified this against four known pools: a dead BAT pool returns 1.0, a
|
|
439
|
+
// healthy bluechip returns 0.0007, a healthy but one-sided pool returns
|
|
440
|
+
// 0.00005.
|
|
441
|
+
//
|
|
442
|
+
// But the field is not self-describing. A price-impact number tells you
|
|
443
|
+
// how the ROUTER priced the route; it does not tell you whether the
|
|
444
|
+
// pool behind it holds anything. A consumer that thresholds on that one
|
|
445
|
+
// field will block healthy routes and wave through empty ones — we have
|
|
446
|
+
// seen both failure modes in our own tool, which is why the rule below
|
|
447
|
+
// exists.
|
|
448
|
+
//
|
|
449
|
+
// THE RULE: the oracle is a WITNESS, not a JUDGE. `impact === 1` is never
|
|
450
|
+
// a verdict on its own. It is only evidence when the on-chain depth
|
|
451
|
+
// independently agrees that there is almost nothing to trade against.
|
|
452
|
+
// Two channels must corroborate each other, or there is no verdict.
|
|
453
|
+
const quoteUsable = !!buyQuote && !buyQuote.error && Number(buyQuote.outAmount ?? 0) > 0;
|
|
454
|
+
const impactSevere = quoteUsable && impact >= 0.95;
|
|
455
|
+
/**
|
|
456
|
+
* NO_DEPTH — the pool advertises depth it does not have.
|
|
457
|
+
*
|
|
458
|
+
* Requires BOTH:
|
|
459
|
+
* • a real route exists (the quote succeeded) and a $1 trade costs
|
|
460
|
+
* ~the whole position (impact ≥ 95%), AND
|
|
461
|
+
* • the on-chain quote-side reserve is genuinely tiny.
|
|
462
|
+
*
|
|
463
|
+
* The second condition is what kills the OpenUSD false positive.
|
|
464
|
+
*/
|
|
465
|
+
const noDepth = hasDepositEvidence &&
|
|
466
|
+
impactSevere &&
|
|
467
|
+
depositedUsd < 10_000 &&
|
|
468
|
+
claimedLiquidityUsd > 100_000;
|
|
469
|
+
/**
|
|
470
|
+
* NO_ROUTE — the money IS there, but no router can reach it.
|
|
471
|
+
*
|
|
472
|
+
* This is NOT an accusation against the token: the pool is funded. It is a
|
|
473
|
+
* finding about the ROUTER, and it is exactly the kind of thing an
|
|
474
|
+
* aggregator's bug bounty pays for. We keep it separate from NO_DEPTH so we
|
|
475
|
+
* never call a well-funded pool "fake".
|
|
476
|
+
*/
|
|
477
|
+
const noRoute = hasDepositEvidence &&
|
|
478
|
+
!quoteUsable &&
|
|
479
|
+
buyQuote?.error != null &&
|
|
480
|
+
depositedUsd >= 10_000 &&
|
|
481
|
+
claimedLiquidityUsd > 100_000;
|
|
482
|
+
/**
|
|
483
|
+
* DRAINED — the money was there and is gone.
|
|
484
|
+
*
|
|
485
|
+
* Requires a positive signal that money left (a drain event we can point
|
|
486
|
+
* at), not merely a small balance. A pool that was born empty is
|
|
487
|
+
* FAKE_LIQUIDITY; a pool that was robbed is DRAINED, and the receipt
|
|
488
|
+
* should link the transaction that emptied it.
|
|
489
|
+
*/
|
|
490
|
+
const soldOut = hasDepositEvidence &&
|
|
491
|
+
depositedUsd < 100 &&
|
|
492
|
+
claimedLiquidityUsd > 100_000 &&
|
|
493
|
+
!!curve?.drain;
|
|
494
|
+
/**
|
|
495
|
+
* FAKE_LIQUIDITY — the advertised liquidity is essentially not there.
|
|
496
|
+
*
|
|
497
|
+
* The hard, on-chain-only test, and it needs BOTH halves:
|
|
498
|
+
*
|
|
499
|
+
* - coverage < 0.5% - less than half a percent of the advertised value
|
|
500
|
+
* is backed by real money in the quote-side vault, AND
|
|
501
|
+
* - deposited < $1,000 - there is not even a dollar's worth of depth, so
|
|
502
|
+
* the pool cannot absorb a single $1 trade.
|
|
503
|
+
*
|
|
504
|
+
* The absolute floor matters as much as the ratio: a ratio alone would
|
|
505
|
+
* equally accuse a $39,000 pool holding $124 (0.3% coverage) AND a
|
|
506
|
+
* $136,000,000 pool holding $23. Both are fake, and they are fake for the
|
|
507
|
+
* same reason, which is "there is no money", not "the ratio is small".
|
|
508
|
+
*
|
|
509
|
+
* Measured on live pools:
|
|
510
|
+
* BAT (native) $136,104,312 claim → $23.53 = 0.000017% → FAKE
|
|
511
|
+
* BAT trap #2 $1,099,765,355 claim → $22.06 = 0.0000020% → FAKE
|
|
512
|
+
* CHZ (fake A) $48,925,026 claim → $9.62 = 0.000019% → FAKE
|
|
513
|
+
* GRASS $242,698 claim → $15,600.34 = 6.43% → THIN
|
|
514
|
+
* YZY $37,992,428 claim → $1,535,634.52 = 4.04% → THIN
|
|
515
|
+
* OUSD $18,741,848 claim → $12,663,732.85 = 67.6% → CONSISTENT
|
|
516
|
+
* JUP $1,571,103 claim → $851,139.75 = 54.2% → CONSISTENT
|
|
517
|
+
*
|
|
518
|
+
* The gap between 0.32% and 4% is more than an order of magnitude wide.
|
|
519
|
+
* Any threshold in between separates the traps from every honest pool we
|
|
520
|
+
* have ever measured, and we chose 0.5% because it is the least
|
|
521
|
+
* aggressive value that still isolates the traps.
|
|
522
|
+
*/
|
|
523
|
+
const fake = hasDepositEvidence &&
|
|
524
|
+
coverage < 0.005 &&
|
|
525
|
+
depositedUsd < 1_000 &&
|
|
526
|
+
claimedLiquidityUsd > 10_000;
|
|
527
|
+
/**
|
|
528
|
+
* UNBACKED_LIQUIDITY — the money is not there, but we will not call the
|
|
529
|
+
* token fake.
|
|
530
|
+
*
|
|
531
|
+
* This is the verdict we issue when the liquidity gap is real but the
|
|
532
|
+
* token itself is NOT an impostor — either because we resolved it to the
|
|
533
|
+
* canonical mint, or because we could not resolve the canonical mint at
|
|
534
|
+
* all and therefore refuse to accuse.
|
|
535
|
+
*
|
|
536
|
+
* It is a DIFFERENT claim and it is deliberately weaker:
|
|
537
|
+
*
|
|
538
|
+
* FAKE_LIQUIDITY = "this pool's advertised number is not backed by
|
|
539
|
+
* deposits, and this mint is not the genuine token"
|
|
540
|
+
* UNBACKED_LIQUIDITY = "this pool's advertised number is not backed by
|
|
541
|
+
* deposits" — and nothing about the token's identity
|
|
542
|
+
*
|
|
543
|
+
* We hit exactly this case on the official Chiliz mint
|
|
544
|
+
* (6eftxVbSA…): its Meteora pool advertises $39,099 and holds $124.12 of
|
|
545
|
+
* USDC. The number is wrong, but Chiliz is Chiliz, and a receipt that
|
|
546
|
+
* said "FAKE_LIQUIDITY" there would be a lie about a real project.
|
|
547
|
+
*/
|
|
548
|
+
/**
|
|
549
|
+
* Can we issue an accusation against THIS mint?
|
|
550
|
+
*
|
|
551
|
+
* Three independent gates, all of which must open:
|
|
552
|
+
*
|
|
553
|
+
* 1. the canonical index loaded at all — if we do not know what the
|
|
554
|
+
* genuine article is, we do not accuse;
|
|
555
|
+
* 2. this mint is NOT the canonical token — a real project is never
|
|
556
|
+
* accused, its pool may still be reported (UNBACKED_LIQUIDITY);
|
|
557
|
+
* 3. the audited pool is one where the mint is the BASE token — a pool
|
|
558
|
+
* in which the mint is only the counterparty says nothing about the
|
|
559
|
+
* mint's own liquidity.
|
|
560
|
+
*/
|
|
561
|
+
const canAccuse = canonicalIndexAvailable && !tokenIsCanonical && orientation !== 'quote';
|
|
562
|
+
/**
|
|
563
|
+
* EVERY verdict that can read as an accusation goes through the SAME gate.
|
|
564
|
+
*
|
|
565
|
+
* This gate used to protect FAKE_LIQUIDITY only. DRAINED and NO_DEPTH were
|
|
566
|
+
* issued without it, which is how the canonical USDB mint
|
|
567
|
+
* (9GV3oZL4p5uGFhtSxS4JsyP64Dqvw4ZuvzgX7FzJ7eTD) ended up in the
|
|
568
|
+
* published dataset as NO_DEPTH on a $500M claim — one real project, one
|
|
569
|
+
* accusation we never meant to make, and exactly the class of mistake this
|
|
570
|
+
* product exists to avoid.
|
|
571
|
+
*
|
|
572
|
+
* The rule is now the rule it always should have been: a verdict that
|
|
573
|
+
* names the token as fake, drained or untradeable is only issued against a
|
|
574
|
+
* mint that is NOT the canonical token, AND only when the canonical index
|
|
575
|
+
* was available, AND only when the audited mint is the base side of the
|
|
576
|
+
* pool. Everything else is a finding about a POOL and is reported as
|
|
577
|
+
* UNBACKED_LIQUIDITY.
|
|
578
|
+
*/
|
|
579
|
+
const accusation = fake || soldOut || noDepth;
|
|
580
|
+
const unbacked = accusation && !canAccuse;
|
|
581
|
+
/**
|
|
582
|
+
* THIN — a fact, not an accusation.
|
|
583
|
+
*
|
|
584
|
+
* Less than 10% of the advertised value is real money. This is NOT proof
|
|
585
|
+
* of wrongdoing: a constant-product AMM naturally becomes one-sided when
|
|
586
|
+
* the price moves, and we measured a perfectly tradable pool at 4%.
|
|
587
|
+
* We publish it because a trader needs to know: "the headline number is
|
|
588
|
+
* mostly inventory, and here is how much is actually cash."
|
|
589
|
+
*/
|
|
590
|
+
const thin = hasDepositEvidence && coverage < 0.1 && claimedLiquidityUsd > 10_000;
|
|
591
|
+
let verdict = 'UNKNOWN';
|
|
592
|
+
if (!hasDepositEvidence) {
|
|
593
|
+
verdict = 'UNKNOWN';
|
|
594
|
+
}
|
|
595
|
+
else if (soldOut && canAccuse) {
|
|
596
|
+
verdict = 'DRAINED';
|
|
597
|
+
}
|
|
598
|
+
else if (fake && canAccuse) {
|
|
599
|
+
verdict = 'FAKE_LIQUIDITY';
|
|
600
|
+
}
|
|
601
|
+
else if (unbacked) {
|
|
602
|
+
verdict = 'UNBACKED_LIQUIDITY';
|
|
603
|
+
}
|
|
604
|
+
else if (noDepth && canAccuse) {
|
|
605
|
+
verdict = 'NO_DEPTH';
|
|
606
|
+
}
|
|
607
|
+
else if (noRoute) {
|
|
608
|
+
verdict = 'NO_ROUTE';
|
|
609
|
+
}
|
|
610
|
+
else if (thin) {
|
|
611
|
+
verdict = 'THIN';
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
verdict = 'CONSISTENT';
|
|
615
|
+
}
|
|
616
|
+
// ── flags: short machine-readable findings ───────────────────────────────
|
|
617
|
+
//
|
|
618
|
+
// A flag is a FACT, never an accusation. CREATOR_LINEAGE says "this mint
|
|
619
|
+
// was deployed by the same wallet as N other tokens" — which is true of
|
|
620
|
+
// every launchpad in the market and is therefore not, by itself, a
|
|
621
|
+
// finding. The accusation lives in the verdict, and it is earned by the
|
|
622
|
+
// on-chain money evidence plus a cited canonical mint.
|
|
623
|
+
const flags = [];
|
|
624
|
+
if (canonical.status === 'impersonator') {
|
|
625
|
+
// Two levels of impersonation evidence, and the receipt says which:
|
|
626
|
+
// IMPERSONATION — the NAME is already owned by a cited canonical mint
|
|
627
|
+
// TICKER_COLLISION — only the TICKER matched; real, but weaker
|
|
628
|
+
flags.push(canonical.confidence === 'confirmed' ? 'IMPERSONATION' : 'TICKER_COLLISION');
|
|
629
|
+
}
|
|
630
|
+
if (operator)
|
|
631
|
+
flags.push('CREATOR_LINEAGE');
|
|
632
|
+
if (selfDenominatedPct > 0.99)
|
|
633
|
+
flags.push('SELF_DENOMINATED');
|
|
634
|
+
if (canonical.status === 'canonical')
|
|
635
|
+
flags.push('CANONICAL');
|
|
636
|
+
/**
|
|
637
|
+
* STALE_CLAIM_AFTER_DRAIN — the aggregator is still advertising a pool we
|
|
638
|
+
* can prove was emptied.
|
|
639
|
+
*
|
|
640
|
+
* This is the strongest single signal LIQPROOF produces, because it needs
|
|
641
|
+
* no interpretation: we link the transaction that took the money, and the
|
|
642
|
+
* aggregator is still showing the number. Measured on 2026-12-04 on a
|
|
643
|
+
* Raydium CLMM pool that GeckoTerminal still listed at $1,924,538,558.67
|
|
644
|
+
* eleven hours after a single transaction moved the entire reserve to the
|
|
645
|
+
* pool creator.
|
|
646
|
+
*
|
|
647
|
+
* It is a FACT about the data, not a claim about the token — and it is
|
|
648
|
+
* exactly the shape of thing an aggregator's bug bounty pays for.
|
|
649
|
+
*/
|
|
650
|
+
if (curve?.drain && claimedLiquidityUsd > 100_000 && depositedUsd < 100) {
|
|
651
|
+
flags.push('STALE_CLAIM_AFTER_DRAIN');
|
|
652
|
+
}
|
|
653
|
+
if (orientation === 'quote')
|
|
654
|
+
flags.push('COUNTERPARTY_POOL');
|
|
655
|
+
const headline = buildHeadline({
|
|
656
|
+
verdict,
|
|
657
|
+
claimedLiquidityUsd,
|
|
658
|
+
depositedUsd,
|
|
659
|
+
coverage,
|
|
660
|
+
divergenceRatio,
|
|
661
|
+
impact,
|
|
662
|
+
executablePriceUsd,
|
|
663
|
+
displayedPriceUsd,
|
|
664
|
+
priceDivergence,
|
|
665
|
+
selfDenominatedPct,
|
|
666
|
+
identityName,
|
|
667
|
+
identitySymbol,
|
|
668
|
+
canonicalName: canonical.impersonates?.name,
|
|
669
|
+
canonicalConfirmed: canonical.confidence === 'confirmed',
|
|
670
|
+
tokenIsCanonical,
|
|
671
|
+
});
|
|
672
|
+
const summary = buildSummary({
|
|
673
|
+
verdict,
|
|
674
|
+
claimedLiquidityUsd,
|
|
675
|
+
depositedUsd,
|
|
676
|
+
coverage,
|
|
677
|
+
divergenceRatio,
|
|
678
|
+
impact,
|
|
679
|
+
priceDivergence,
|
|
680
|
+
peakDepositedUsd,
|
|
681
|
+
selfDenominatedPct,
|
|
682
|
+
flags,
|
|
683
|
+
tokenIsCanonical,
|
|
684
|
+
});
|
|
685
|
+
const timelinePoints = (curve?.points ?? []).map((p) => {
|
|
686
|
+
const raw = p.balances[quoteMint] ?? '0';
|
|
687
|
+
const deposited = (Number(raw) / 10 ** quoteDecimals) * quotePriceUsd;
|
|
688
|
+
return {
|
|
689
|
+
at: p.timestamp ? new Date(p.timestamp * 1000).toISOString() : `slot:${p.slot}`,
|
|
690
|
+
slot: p.slot,
|
|
691
|
+
signature: p.signature,
|
|
692
|
+
depositedUsd: deposited,
|
|
693
|
+
deltaUsd: p.deltaUsd,
|
|
694
|
+
note: p.deltaUsd < -100 ? 'LIQUIDITY_REMOVED' : undefined,
|
|
695
|
+
};
|
|
696
|
+
});
|
|
697
|
+
const evidence = [];
|
|
698
|
+
for (const s of snapshots) {
|
|
699
|
+
evidence.push({
|
|
700
|
+
kind: 'pool',
|
|
701
|
+
url: `https://solscan.io/account/${s.pool}`,
|
|
702
|
+
label: `pool ${s.pool}`,
|
|
703
|
+
});
|
|
704
|
+
for (const v of s.vaults) {
|
|
705
|
+
evidence.push({
|
|
706
|
+
kind: 'vault',
|
|
707
|
+
url: `https://solscan.io/account/${v.address}`,
|
|
708
|
+
label: `${v.side} vault ${v.address}`,
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
if (curve?.drain) {
|
|
713
|
+
evidence.push({
|
|
714
|
+
kind: 'tx',
|
|
715
|
+
url: `https://solscan.io/tx/${curve.drain.signature}`,
|
|
716
|
+
label: `drain tx ${curve.drain.signature.slice(0, 12)}…`,
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
evidence.push({
|
|
720
|
+
kind: 'source',
|
|
721
|
+
url: `https://dexscreener.com/solana/${mint}`,
|
|
722
|
+
label: 'aggregator claim',
|
|
723
|
+
});
|
|
724
|
+
// Identity evidence. The metadata account is the token's own statement;
|
|
725
|
+
// the canonical proof is the receipt for that statement being false.
|
|
726
|
+
if (meta?.metadataPda) {
|
|
727
|
+
evidence.push({
|
|
728
|
+
kind: 'metadata',
|
|
729
|
+
url: `https://solscan.io/account/${meta.metadataPda}`,
|
|
730
|
+
label: `on-chain metadata "${meta.name}" / "${meta.symbol}"`,
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
if (canonical.impersonates) {
|
|
734
|
+
evidence.push({
|
|
735
|
+
kind: 'canonical',
|
|
736
|
+
url: canonical.impersonates.proof,
|
|
737
|
+
label: `canonical ${canonical.impersonates.name} (${canonical.impersonates.source})`,
|
|
738
|
+
});
|
|
739
|
+
evidence.push({
|
|
740
|
+
kind: 'canonical-mint',
|
|
741
|
+
url: `https://solscan.io/account/${canonical.impersonates.mint}`,
|
|
742
|
+
label: `canonical mint ${canonical.impersonates.mint}`,
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
for (const c of meta?.creators ?? []) {
|
|
746
|
+
evidence.push({
|
|
747
|
+
kind: 'creator',
|
|
748
|
+
url: `https://solscan.io/account/${c.address}`,
|
|
749
|
+
label: `metadata creator ${c.address.slice(0, 12)}…`,
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
return {
|
|
753
|
+
version: '1.0',
|
|
754
|
+
generatedAt: new Date().toISOString(),
|
|
755
|
+
mint,
|
|
756
|
+
symbol: identitySymbol || report.symbol,
|
|
757
|
+
name: identityName || report.name,
|
|
758
|
+
verdict,
|
|
759
|
+
headline,
|
|
760
|
+
summary,
|
|
761
|
+
identity: {
|
|
762
|
+
onChainName: meta?.name,
|
|
763
|
+
onChainSymbol: meta?.symbol,
|
|
764
|
+
metadataPda: meta?.metadataPda,
|
|
765
|
+
creators: meta?.creators,
|
|
766
|
+
canonical: {
|
|
767
|
+
status: canonical.status,
|
|
768
|
+
isCanonical: canonical.isCanonical,
|
|
769
|
+
method: canonical.method,
|
|
770
|
+
confidence: canonical.confidence,
|
|
771
|
+
impersonates: canonical.impersonates
|
|
772
|
+
? {
|
|
773
|
+
mint: canonical.impersonates.mint,
|
|
774
|
+
name: canonical.impersonates.name,
|
|
775
|
+
symbol: canonical.impersonates.symbol,
|
|
776
|
+
source: canonical.impersonates.source,
|
|
777
|
+
proof: canonical.impersonates.proof,
|
|
778
|
+
proofLabel: canonical.impersonates.proofLabel,
|
|
779
|
+
}
|
|
780
|
+
: undefined,
|
|
781
|
+
},
|
|
782
|
+
operator: operator
|
|
783
|
+
? {
|
|
784
|
+
creator: operator.creator,
|
|
785
|
+
link: operator.link,
|
|
786
|
+
cluster: operator.cluster.id,
|
|
787
|
+
clusterSize: operator.cluster.members.length,
|
|
788
|
+
peers: operator.peers,
|
|
789
|
+
}
|
|
790
|
+
: undefined,
|
|
791
|
+
},
|
|
792
|
+
flags,
|
|
793
|
+
claimed: {
|
|
794
|
+
liquidityUsd: claimedLiquidityUsd,
|
|
795
|
+
priceUsd: displayedPriceUsd,
|
|
796
|
+
sources: claimSources,
|
|
797
|
+
},
|
|
798
|
+
real: {
|
|
799
|
+
depositedUsd,
|
|
800
|
+
heldTokens,
|
|
801
|
+
coverage,
|
|
802
|
+
divergenceRatio,
|
|
803
|
+
selfDenominatedPct,
|
|
804
|
+
peakDepositedUsd,
|
|
805
|
+
peakAt: peakPoint?.timestamp
|
|
806
|
+
? new Date(peakPoint.timestamp * 1000).toISOString()
|
|
807
|
+
: peakPoint
|
|
808
|
+
? `slot:${peakPoint.slot}`
|
|
809
|
+
: undefined,
|
|
810
|
+
drainAt: curve?.drain?.timestamp
|
|
811
|
+
? new Date(curve.drain.timestamp * 1000).toISOString()
|
|
812
|
+
: curve?.drain
|
|
813
|
+
? `slot:${curve.drain.slot}`
|
|
814
|
+
: undefined,
|
|
815
|
+
drainSlot: curve?.drain?.slot,
|
|
816
|
+
drainSignature: curve?.drain?.signature,
|
|
817
|
+
drainDeltaUsd: curve?.drain?.deltaUsd,
|
|
818
|
+
},
|
|
819
|
+
oracle,
|
|
820
|
+
timeline: {
|
|
821
|
+
points: timelinePoints,
|
|
822
|
+
scanned: curve?.scanned ?? 0,
|
|
823
|
+
unavailable: curve?.unavailable ?? 0,
|
|
824
|
+
truncated: curve?.truncated ?? false,
|
|
825
|
+
strategy: curve?.strategy ?? 'none',
|
|
826
|
+
totalSignatures: curve?.totalSignatures ?? 0,
|
|
827
|
+
},
|
|
828
|
+
pools: snapshots,
|
|
829
|
+
audited: {
|
|
830
|
+
pool: focusView?.address ?? '',
|
|
831
|
+
dexId: focusView?.dexId ?? '',
|
|
832
|
+
name: focusView?.name ?? '',
|
|
833
|
+
orientation,
|
|
834
|
+
counterpartyOnly: orientation === 'quote',
|
|
835
|
+
candidatePools: views.length,
|
|
836
|
+
baseSidePools: baseSidePools.length,
|
|
837
|
+
},
|
|
838
|
+
evidence,
|
|
839
|
+
methodology: METHODOLOGY,
|
|
840
|
+
disclaimer: DISCLAIMER,
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
function buildHeadline(x) {
|
|
844
|
+
switch (x.verdict) {
|
|
845
|
+
case 'FAKE_LIQUIDITY':
|
|
846
|
+
if (x.canonicalName && x.canonicalConfirmed) {
|
|
847
|
+
return `Market claims ${fmtUsd(x.claimedLiquidityUsd)} for "${x.identityName}". The pool holds ${fmtUsd(x.depositedUsd)}. This mint is not ${x.canonicalName}.`;
|
|
848
|
+
}
|
|
849
|
+
if (x.selfDenominatedPct > 0.9) {
|
|
850
|
+
return `${fmtUsd(x.claimedLiquidityUsd)} advertised — but ${pct(x.selfDenominatedPct)} of it is the token itself. Only ${fmtUsd(x.depositedUsd)} is real money.`;
|
|
851
|
+
}
|
|
852
|
+
return `Market claims ${fmtUsd(x.claimedLiquidityUsd)}. The pool actually holds ${fmtUsd(x.depositedUsd)}.`;
|
|
853
|
+
case 'UNBACKED_LIQUIDITY':
|
|
854
|
+
// A canonical mint gets the plainest possible sentence: the NUMBER is
|
|
855
|
+
// wrong, the TOKEN is not. The reader must never be able to quote this
|
|
856
|
+
// receipt as an accusation against a real project.
|
|
857
|
+
if (x.tokenIsCanonical) {
|
|
858
|
+
return `${fmtUsd(x.claimedLiquidityUsd)} advertised, ${fmtUsd(x.depositedUsd)} deposited — a finding about this pool, not about the token.`;
|
|
859
|
+
}
|
|
860
|
+
return `${fmtUsd(x.claimedLiquidityUsd)} advertised, ${fmtUsd(x.depositedUsd)} deposited — ${Number.isFinite(x.divergenceRatio) ? fmtRatio(x.divergenceRatio) + ' overstated' : 'unbacked'}.`;
|
|
861
|
+
case 'NO_DEPTH':
|
|
862
|
+
return `${fmtUsd(x.claimedLiquidityUsd)} claimed, but a $1 buy costs ${(x.impact * 100).toFixed(0)}% of the position.`;
|
|
863
|
+
case 'DRAINED':
|
|
864
|
+
return `Pool drained to ${fmtUsd(x.depositedUsd)} while still advertising ${fmtUsd(x.claimedLiquidityUsd)}.`;
|
|
865
|
+
case 'THIN':
|
|
866
|
+
return `Only ${pct(x.coverage)} of the claimed ${fmtUsd(x.claimedLiquidityUsd)} is actually deposited.`;
|
|
867
|
+
case 'CONSISTENT':
|
|
868
|
+
return `${fmtUsd(x.claimedLiquidityUsd)} claimed, ${fmtUsd(x.depositedUsd)} verified on-chain.`;
|
|
869
|
+
default:
|
|
870
|
+
return 'Insufficient on-chain data to form a verdict.';
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
function buildSummary(x) {
|
|
874
|
+
const parts = [];
|
|
875
|
+
parts.push(`claimed ${fmtUsd(x.claimedLiquidityUsd)} vs deposited ${fmtUsd(x.depositedUsd)}`);
|
|
876
|
+
parts.push(`coverage ${pct(x.coverage)}`);
|
|
877
|
+
if (x.tokenIsCanonical) {
|
|
878
|
+
parts.push('canonical token — pool finding only, never an accusation');
|
|
879
|
+
}
|
|
880
|
+
if (x.selfDenominatedPct > 0.5) {
|
|
881
|
+
parts.push(`${pct(x.selfDenominatedPct)} of the claim is the token itself`);
|
|
882
|
+
}
|
|
883
|
+
if (Number.isFinite(x.divergenceRatio) && x.divergenceRatio > 1.5) {
|
|
884
|
+
parts.push(`${fmtRatio(x.divergenceRatio)} overstated`);
|
|
885
|
+
}
|
|
886
|
+
if (x.peakDepositedUsd !== undefined && x.peakDepositedUsd > x.depositedUsd * 1.5) {
|
|
887
|
+
parts.push(`peak ever deposited ${fmtUsd(x.peakDepositedUsd)}`);
|
|
888
|
+
}
|
|
889
|
+
parts.push(`buy price impact ${(x.impact * 100).toFixed(0)}%`);
|
|
890
|
+
if (x.priceDivergence && x.priceDivergence > 10) {
|
|
891
|
+
parts.push(`displayed price ${Math.round(x.priceDivergence).toLocaleString('en-US')}× the executable price`);
|
|
892
|
+
}
|
|
893
|
+
if (x.flags.length)
|
|
894
|
+
parts.push(x.flags.join(' + '));
|
|
895
|
+
return parts.join(' · ');
|
|
896
|
+
}
|
|
897
|
+
//# sourceMappingURL=receipt.js.map
|