solana-risk-engine 0.5.4 → 0.5.5
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/README.es.md +4 -0
- package/README.md +1 -0
- package/package.json +1 -1
- package/src/i18n/en.js +1 -0
- package/src/i18n/es.js +1 -0
- package/src/index.js +1 -1
- package/src/markets.js +40 -0
- package/src/risk.js +16 -3
- package/src/wallet.js +1 -1
package/README.es.md
CHANGED
|
@@ -16,6 +16,10 @@ console.log(levelLabel(r, "es")); // "Riesgo bajo"
|
|
|
16
16
|
for (const l of r.lights) console.log(lightLabel(l.k, "es"), explainLight(l, "es"));
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
## Volumen inflado (0.5.5)
|
|
20
|
+
|
|
21
|
+
Al analizar un token suelto con un mercado de menos de 90 días, el motor lee las últimas ~300 operaciones de su pool principal (GeckoTerminal, una petición). Si el 80 % o más del volumen es de wallets que compran y venden lo mismo, sale `MKT_FAKE_VOLUME` en ámbar; en rojo si lo hacen 25 wallets o menos y las 3 mayores mueven el 75 % o más. En tokens veteranos los bots de arbitraje son normales y no se mira; a un emisor verificado tampoco. `noGecko` lo desactiva.
|
|
22
|
+
|
|
19
23
|
## Línea de comandos
|
|
20
24
|
|
|
21
25
|
```sh
|
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ for (const l of r.lights) // the four traffic lights
|
|
|
27
27
|
| **Creator control** | Mint/freeze authority still active, and whether it sits in a person's wallet or a program (bridge, protocol, staking pool). A key off the ed25519 curve is always a program (PDA), even when the System Program owns its account. Risky Token-2022 extensions: permanent delegate, transfer hook, transfer fee, non-transferable, default-frozen accounts. |
|
|
28
28
|
| **Real concentration** | Largest accounts are traced to their owners. Pools and programs are separated from people, so `w1`/`w10` measure *people*, not AMM vaults. |
|
|
29
29
|
| **Inflated liquidity** | DexScreener values both sides of a pool at the pool's price. A pool with 4B of a token against 2 USDC shows "$4,000M liquidity". The engine recomputes it from the real side (USDC/USDT/SOL). It only flags extreme gaps (real side under 5%), because concentrated-liquidity pools are lopsided by nature. |
|
|
30
|
+
| **Inflated volume** | Volume says nothing about who makes it. For a single token on a market under 90 days, the engine reads the last ~300 trades of its main pool (GeckoTerminal, one request) and flags `MKT_FAKE_VOLUME` when 80% or more of the volume comes from wallets that buy and sell the same amount (amber), red when 25 wallets or fewer make it and the top 3 move 75% or more. Arbitrage bots on veteran tokens are normal and are not checked; a verified issuer is left alone. `noGecko` skips it. |
|
|
30
31
|
| **Unlocked LP** | % of LP locked/burned via RugCheck. It only counts for markets under 90 days old, so veteran tokens don't get false positives, and never while a token is on Pump.fun's bonding curve, where there is no LP to pull. |
|
|
31
32
|
| **Serial creators** | For markets under 7 days: how many other tokens the creator launched in the last 24 h (RugCheck). 2 or more is a warning, 5 or more a red flag. `recentLaunches(client, wallet)` counts the same on chain for the wallet that *paid* a launch, which catches farms that name a fresh creator each time. When RugCheck has no report yet (it often answers 400 for tokens a few minutes old) the analysis falls back to `chainLaunches(client, mint)`: that count for the first signer of the token's creation transaction, reported as its own signal `CTL_SERIAL_PAYER` ("the wallet that paid for this launch…", never as the creator) and skipped when the SolFlag wallet base knows that wallet as an exchange or platform. |
|
|
32
33
|
| **Impostors** | Tokens using the symbol or name of a famous token (USDC, JUP, BONK, WIF, BTC, ETH...) with a different address. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solana-risk-engine",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "Explainable risk analysis for Solana tokens and wallets: creator control, real holder concentration, inflated liquidity, impostor tokens, funder clusters and PnL. Zero dependencies, runs in Node and the browser.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/i18n/en.js
CHANGED
|
@@ -72,6 +72,7 @@ export default {
|
|
|
72
72
|
MKT_LIQ_INFLATED: (d) => "Inflated liquidity: DexScreener says " + usd(d.reported) + ", but the pool only has about " + usd(d.real) + " in real tokens (USDC, USDT or SOL). That is the most you could get out when selling" + (d.reported >= 100 * Math.max(d.real, 1) ? ". A gap like that is no accident: it is set up to make the token look established" : ""),
|
|
73
73
|
MKT_LIQ_VERY_LOW: (d) => "Very low liquidity (" + usd(d.liq) + ")",
|
|
74
74
|
MKT_LIQ_LOW: (d) => "Low liquidity (" + usd(d.liq) + ")",
|
|
75
|
+
MKT_FAKE_VOLUME: (d) => "Inflated volume: " + d.rt + "% of the volume in the last " + d.trades + " trades comes from wallets that buy and sell the same amount" + (d.few ? ", and only " + d.wallets + " wallets make almost all of it (the top 3, " + d.top3 + "%)" : "") + ". That volume is not new buyers: it makes the token look busier than it is",
|
|
75
76
|
MKT_VOLUME_LOW: (d) => "Almost no 24h volume (" + usd(d.vol) + ")",
|
|
76
77
|
MKT_NEW: (d) => "Very new market (" + (d.days < 1 ? "less than a day" : d.days + (d.days === 1 ? " day" : " days")) + ")",
|
|
77
78
|
MKT_POSITION_HEAVY: (d) => "This wallet's position equals " + pct(d.pct) + " of the liquidity: selling at once would move the price a lot",
|
package/src/i18n/es.js
CHANGED
|
@@ -76,6 +76,7 @@ export default {
|
|
|
76
76
|
MKT_LIQ_INFLATED: (d) => "Liquidez inflada: DexScreener dice " + usd(d.reported) + ", pero el pool solo tiene unos " + usd(d.real) + " en tokens de verdad (USDC, USDT o SOL). Es lo máximo que podrías sacar al vender" + (d.reported >= 100 * Math.max(d.real, 1) ? ". Una diferencia así no es casual: está montada para que el token parezca establecido" : ""),
|
|
77
77
|
MKT_LIQ_VERY_LOW: (d) => "Liquidez muy baja (" + usd(d.liq) + ")",
|
|
78
78
|
MKT_LIQ_LOW: (d) => "Liquidez baja (" + usd(d.liq) + ")",
|
|
79
|
+
MKT_FAKE_VOLUME: (d) => "Volumen inflado: el " + d.rt + " % del volumen de las últimas " + d.trades + " operaciones es de wallets que compran y venden lo mismo" + (d.few ? ", y solo " + d.wallets + " wallets lo mueven casi todo (las 3 mayores, el " + d.top3 + " %)" : "") + ". Ese volumen no son compradores nuevos: hace que el token parezca más activo de lo que es",
|
|
79
80
|
MKT_VOLUME_LOW: (d) => "Volumen de 24 h casi nulo (" + usd(d.vol) + ")",
|
|
80
81
|
MKT_NEW: (d) => "Mercado muy nuevo (" + (d.days < 1 ? "menos de un día" : d.days + (d.days === 1 ? " día" : " días")) + ")",
|
|
81
82
|
MKT_POSITION_HEAVY: (d) => "La posición de esta wallet equivale al " + pct(d.pct) + " de la liquidez: vender de golpe movería mucho el precio",
|
package/src/index.js
CHANGED
|
@@ -49,7 +49,7 @@ export * from "./constants.js";
|
|
|
49
49
|
export { isOnCurve, onCurve, b58bytes } from "./curve.js";
|
|
50
50
|
export { KNOWN_WALLETS, knownWallet } from "./known.js";
|
|
51
51
|
export { getTokens, getMint, getConc, getAuthKinds, isMint, accountKinds, kindOf } from "./tokens.js";
|
|
52
|
-
export { getMarkets, realLiq, impostorOf, INFLATED_RATIO, geckoLiquidity, geckoPair, brandOf, copiesOf, fakeLiquidity, FAKE_LIQ_RATIO } from "./markets.js";
|
|
52
|
+
export { getMarkets, realLiq, impostorOf, INFLATED_RATIO, geckoLiquidity, geckoPair, brandOf, copiesOf, fakeLiquidity, FAKE_LIQ_RATIO, washStats, washSignal, washTrades, WASH_MIN_TRADES, WASH_ROUND_TRIP, WASH_FEW_WALLETS, WASH_TOP3 } from "./markets.js";
|
|
53
53
|
export { rugcheckSummary, rugcheckReport, rugcheckGraph, netBalances, creatorLaunches, CREATOR_DEAD_MCAP } from "./rugcheck.js";
|
|
54
54
|
export { score, issuerOf, trustedIssuer, issuerKeysChanged, setIssuers, tokenType, buildLights, levelFrom, dataOnly, reasonsFrom, assess, SERIAL_WARN, SERIAL_BAD, HISTORY_MIN, HISTORY_WARN, HISTORY_BAD_MIN, HISTORY_BAD } from "./risk.js";
|
|
55
55
|
export { recentLaunches, chainLaunches } from "./launch.js";
|
package/src/markets.js
CHANGED
|
@@ -111,6 +111,46 @@ export async function getMarkets(client, mints, onStep) {
|
|
|
111
111
|
return { data: best, failed: failed };
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/* ---------- Fake volume: who is actually trading ---------- */
|
|
115
|
+
// Volume says nothing about who makes it. Wash trading inflates it with wallets that buy and sell the same
|
|
116
|
+
// amount again and again, so the token looks busy and attracts buyers. Measured on the last ~300 trades of
|
|
117
|
+
// the main pool (GeckoTerminal, one request): the share of volume from wallets whose buys and sells match
|
|
118
|
+
// (within 20%) and how much the 3 biggest wallets move. Calibrated on 14/11/2026: 14 trending tokens 0–47%
|
|
119
|
+
// round-trip; a 6-minute-old pool 96%. Arbitrage bots on veteran tokens (JUP: 3 wallets, 84% of volume) are
|
|
120
|
+
// normal, so this is only applied to young markets (see risk.js).
|
|
121
|
+
export const WASH_MIN_TRADES = 100; // fewer trades are not enough to judge
|
|
122
|
+
export const WASH_ROUND_TRIP = 80; // % of volume from wallets that buy and sell the same
|
|
123
|
+
export const WASH_FEW_WALLETS = 25, WASH_TOP3 = 75; // also few wallets doing most of it: red
|
|
124
|
+
|
|
125
|
+
// trades: GeckoTerminal trade attributes. Returns {n, wallets, top3, rt, mins} (percentages 0–100) or null
|
|
126
|
+
export function washStats(trades) {
|
|
127
|
+
const t = (Array.isArray(trades) ? trades : []).filter(function (x) { return x && x.tx_from_address && Number(x.volume_in_usd) > 0; });
|
|
128
|
+
if (!t.length) return null;
|
|
129
|
+
const w = {};
|
|
130
|
+
t.forEach(function (x) { const o = w[x.tx_from_address] || (w[x.tx_from_address] = { b: 0, s: 0 }); o[x.kind === "buy" ? "b" : "s"] += Number(x.volume_in_usd); });
|
|
131
|
+
const ws = Object.keys(w).map(function (k) { return w[k]; });
|
|
132
|
+
const tot = ws.reduce(function (a, o) { return a + o.b + o.s; }, 0);
|
|
133
|
+
if (!tot) return null;
|
|
134
|
+
const sizes = ws.map(function (o) { return o.b + o.s; }).sort(function (a, b) { return b - a; });
|
|
135
|
+
const rt = ws.filter(function (o) { return o.b > 0 && o.s > 0 && Math.abs(o.b - o.s) <= 0.2 * (o.b + o.s); }).reduce(function (a, o) { return a + o.b + o.s; }, 0);
|
|
136
|
+
const times = t.map(function (x) { return Date.parse(x.block_timestamp); }).filter(function (v) { return v > 0; });
|
|
137
|
+
return { n: t.length, wallets: ws.length, top3: Math.round(100 * (sizes[0] + (sizes[1] || 0) + (sizes[2] || 0)) / tot), rt: Math.round(100 * rt / tot),
|
|
138
|
+
mins: times.length ? Math.round((Math.max.apply(null, times) - Math.min.apply(null, times)) / 60000) : null };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// The signal for those stats, or null: {code, s, data}
|
|
142
|
+
export function washSignal(st) {
|
|
143
|
+
if (!st || st.n < WASH_MIN_TRADES || st.rt < WASH_ROUND_TRIP) return null;
|
|
144
|
+
const few = st.wallets <= WASH_FEW_WALLETS && st.top3 >= WASH_TOP3;
|
|
145
|
+
return { code: "MKT_FAKE_VOLUME", s: few ? "bad" : "warn", data: { rt: st.rt, wallets: st.wallets, trades: st.n, top3: st.top3, few: few } };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export async function washTrades(client, pair) {
|
|
149
|
+
if (!pair || !pair.pairAddress) return null;
|
|
150
|
+
const j = await client.softJson(GECKO + "pools/" + pair.pairAddress + "/trades", 6000);
|
|
151
|
+
return washStats(((j && j.data) || []).map(function (x) { return x && x.attributes; }));
|
|
152
|
+
}
|
|
153
|
+
|
|
114
154
|
/* ---------- GeckoTerminal: fills two DexScreener gaps on Pump.fun ---------- */
|
|
115
155
|
// Both are optional extras: on any failure the market stays exactly as DexScreener gave it.
|
|
116
156
|
|
package/src/risk.js
CHANGED
|
@@ -2,7 +2,7 @@ import { EXT_POINTS, RANKS, PUMP_CURVE_DEXES, CL_POOL_LABELS, ISSUERS, OFFICIAL_
|
|
|
2
2
|
import { isCancel } from "./errors.js";
|
|
3
3
|
import { short, sleep } from "./util.js";
|
|
4
4
|
import { getMint, getAuthKinds, getConc } from "./tokens.js";
|
|
5
|
-
import { impostorOf, brandOf, copiesOf, fakeLiquidity } from "./markets.js";
|
|
5
|
+
import { impostorOf, brandOf, copiesOf, fakeLiquidity, washTrades, washSignal } from "./markets.js";
|
|
6
6
|
import { rugcheckSummary, creatorLaunches } from "./rugcheck.js";
|
|
7
7
|
import { chainLaunches } from "./launch.js";
|
|
8
8
|
|
|
@@ -296,6 +296,7 @@ export function reasonsFrom(lights) {
|
|
|
296
296
|
* @param [opts.marketUnknown] the DexScreener batch for this mint failed: no data, not "no market"
|
|
297
297
|
* @param [opts.skipConcentration]
|
|
298
298
|
* @param [opts.skipCreator] do not ask RugCheck what else the creator launched (markets under 7 days only)
|
|
299
|
+
* @param [opts.noGecko] do not ask GeckoTerminal who trades it (fake volume)
|
|
299
300
|
* @returns null for NFTs, otherwise {mint, sym, name, lvl, sev, pts, type, lights, reasons, impostor, value, pair, img}
|
|
300
301
|
*/
|
|
301
302
|
export async function assess(client, mint, pair, opts) {
|
|
@@ -316,6 +317,9 @@ export async function assess(client, mint, pair, opts) {
|
|
|
316
317
|
}) : Promise.resolve(null);
|
|
317
318
|
// Copies of the same name and ticker: one search per token, so only when asked (a single token, not a wallet)
|
|
318
319
|
const copiesPromise = pair && opts.copies && !OFFICIAL_TOKENS[mint] ? copiesOf(client, mint, pair).catch(function (e) { if (isCancel(e)) throw e; return null; }) : Promise.resolve(null);
|
|
320
|
+
// Who trades it (fake volume): one GeckoTerminal request, only for a single token and a market under 90 days
|
|
321
|
+
const youngMkt = pair && pair.pairCreatedAt && Date.now() - pair.pairCreatedAt < 90 * DAY;
|
|
322
|
+
const washPromise = youngMkt && opts.copies && !opts.noGecko && !OFFICIAL_TOKENS[mint] ? washTrades(client, pair).catch(function (e) { if (isCancel(e)) throw e; return null; }) : Promise.resolve(null);
|
|
319
323
|
let info = null, conc = null;
|
|
320
324
|
try { info = await getMint(client, mint); } catch (e) { if (isCancel(e)) throw e; }
|
|
321
325
|
if (info && info.decimals === 0 && info.supply === 1) return null; // NFT
|
|
@@ -333,7 +337,7 @@ export async function assess(client, mint, pair, opts) {
|
|
|
333
337
|
catch (e) { if (isCancel(e)) throw e; conc = null; if (!tryC) await sleep(client.retryDelayMs === undefined ? 1500 : client.retryDelayMs); }
|
|
334
338
|
}
|
|
335
339
|
}
|
|
336
|
-
const rc = await rcPromise, launches = await launchPromise, copies = await copiesPromise;
|
|
340
|
+
const rc = await rcPromise, launches = await launchPromise, copies = await copiesPromise, wash = await washPromise;
|
|
337
341
|
const base = (pair && pair.baseToken) || {};
|
|
338
342
|
let lvl, sev = 0, reasons = [], lights = null, type = null, pts = 0, imp = null;
|
|
339
343
|
if (pair) {
|
|
@@ -357,6 +361,15 @@ export async function assess(client, mint, pair, opts) {
|
|
|
357
361
|
const prev = lights[0], st = front.some(function (x) { return x.s === "bad"; }) ? "bad" : (prev.s === "bad" ? "bad" : "warn");
|
|
358
362
|
lights[0] = { k: "control", s: st, items: front.concat(prev.s !== "ok" ? prev.items : []) };
|
|
359
363
|
}
|
|
364
|
+
// fake volume goes into "market and exit"; a verified issuer's market is left alone
|
|
365
|
+
const ws = anyIssuer(info, mint) ? null : washSignal(wash);
|
|
366
|
+
if (ws) {
|
|
367
|
+
const mk = lights.filter(function (l) { return l.k === "market"; })[0];
|
|
368
|
+
if (mk) {
|
|
369
|
+
const items = (mk.s === "ok" ? [] : mk.items).concat([sig(ws.code, ws.s, ws.data)]);
|
|
370
|
+
lights[lights.indexOf(mk)] = mkLight("market", items);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
360
373
|
const lf = levelFrom(lights); lvl = lf.lvl; sev = lf.sev; reasons = reasonsFrom(lights);
|
|
361
374
|
// a copy of a famous token or a real company, or liquidity faked 100 times over, is high risk even
|
|
362
375
|
// when everything else looks normal: it is built to look like something it is not
|
|
@@ -377,7 +390,7 @@ export async function assess(client, mint, pair, opts) {
|
|
|
377
390
|
mint: mint, sym: base.symbol || short(mint), name: base.name || "", pts: pts, sev: sev,
|
|
378
391
|
lvl: lvl, type: type, lights: lights, reasons: reasons, impostor: imp, copies: copies, value: value, pair: pair,
|
|
379
392
|
rugcheck: rc ? { lpLockedPct: rc.lpLockedPct, score: rc.score_normalised !== undefined ? rc.score_normalised : rc.score } : null,
|
|
380
|
-
creator: launches,
|
|
393
|
+
creator: launches, trades: wash,
|
|
381
394
|
img: (pair && pair.info && pair.info.imageUrl) || null
|
|
382
395
|
};
|
|
383
396
|
}
|
package/src/wallet.js
CHANGED
|
@@ -30,7 +30,7 @@ export async function analyzeToken(client, mint, opts) {
|
|
|
30
30
|
await geckoLiquidity(client, mkr.data[mint]);
|
|
31
31
|
}
|
|
32
32
|
progress(opts.onProgress, "token", 0.45);
|
|
33
|
-
const r = await assess(client, mint, mkr.data[mint] || null, { marketUnknown: mkr.failed.length > 0, skipConcentration: opts.skipConcentration, skipCreator: opts.skipCreator, copies: opts.copies !== false });
|
|
33
|
+
const r = await assess(client, mint, mkr.data[mint] || null, { marketUnknown: mkr.failed.length > 0, skipConcentration: opts.skipConcentration, skipCreator: opts.skipCreator, copies: opts.copies !== false, noGecko: opts.noGecko });
|
|
34
34
|
if (!r) throw new ScanError("IS_NFT", "that address is an NFT, not a token");
|
|
35
35
|
progress(opts.onProgress, "done", 1);
|
|
36
36
|
return r;
|