solana-risk-engine 0.5.6 → 0.7.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/README.es.md CHANGED
@@ -16,6 +16,26 @@ 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
+ ## Cinco niveles (0.6.0)
20
+
21
+ Además de `lvl`, cada token con mercado lleva `tier`: lo que **es** el token, de más fiable a menos. `lvl` no cambia.
22
+
23
+ - `DIAMOND` (diamante): está en la lista revisada a mano de SolFlag, grandes proyectos (`BIG_PROJECTS`: Jupiter, Jito, Pyth…) y emisores de confianza (Circle, Paxos…). Estar en la lista basta.
24
+ - `GREEN` (verde): ninguna alerta y 7 días o más de mercado. Un meme puede ser verde, nunca diamante.
25
+ - `YELLOW` (amarillo): una alerta leve, algo que no se pudo comprobar o **menos de 7 días**: un recién nacido aún no ha demostrado nada y el amarillo es lo máximo que puede sacar (`tierCap: true`; `tierCapUntil`, cuándo acaba el techo).
26
+ - `ORANGE` (naranja): peligro sin trampa. Una alerta grave que no es trampa (liquidez muy baja, pocas wallets con casi todo) o dos o más leves.
27
+ - `RED` (rojo): una trampa (`TRAPS`: el creador puede crear más o sacar la liquidez, lanza en serie, liquidez o volumen falsos, copia de otro token…) o dos alertas graves.
28
+
29
+ En los recién nacidos rojo y naranja fracasan casi siempre; la diferencia es el tipo de peligro, no cuánto duran.
30
+
31
+ Las alertas se cuentan una a una y «nuevo» (`MKT_NEW`) no cuenta: la edad va por el techo. Un emisor que cambia sus claves sin revisar pierde el diamante. `tierLabel(r, "es")` y `tierNote(r, "es")` dan el nombre y una línea de explicación.
32
+
33
+ ## Puntos por apartado (0.7.0)
34
+
35
+ Una meme, una acción tokenizada y un token DeFi no se miden igual. `scoreProfile(res, perfil)` (o `analyzeToken(client, mint, { perfil })`, que añade `res.perfil`) pone el token en uno de siete apartados — `meme`, `rwa`, `defi`, `juegos`, `ia`, `apps`, `otros` — y lo puntúa sobre una base de 50 con las reglas de su apartado: quién está detrás y sus reservas en los activos tokenizados; comisiones, ingresos, auditorías y hackeos en DeFi; actividad real en los juegos; código público en la IA; si el token gana con el negocio (recompras, quemas) en las apps. Es una función pura: lo que no está en la cadena llega en `perfil`, una entrada de un archivo diario (SolFlag lo hace con DefiLlama, Jupiter, GitHub y Streamflow). Sin él, un emisor conocido es `rwa` y lo demás se puntúa con las reglas de meme, que solo usan la cadena.
36
+
37
+ Devuelve `{ap, pts, tier, cap, floor, trap, checks}`: `pts` llena una barra hasta 110 y `checks` da el color de cada chequeo (`suma`, `resta`, `grave`, `neutro`, `falta` = aún no lo sabemos, nunca cuenta). Reglas fijas: una trampa es rojo; diamante solo para la lista revisada a mano con 90 puntos o más, y la lista es como mínimo verde; lo nacido en una lanzadera se puntúa como meme (como mucho verde) y con menos de 7 días como mucho amarillo. `lvl` y `tier` no cambian.
38
+
19
39
  ## Volumen inflado (0.5.5)
20
40
 
21
41
  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.
package/README.md CHANGED
@@ -88,11 +88,33 @@ Methods (all accept `{ onProgress(step, fraction) }`):
88
88
 
89
89
  Every lower-level function is exported too (`buildLights`, `levelFrom`, `realLiq`, `clusterByFunder`, `chgDiff`, `pnlFromTrades`...). Most are pure functions that are easy to reuse and test.
90
90
 
91
+ ### Five tiers (0.6.0)
92
+
93
+ Besides `lvl`, every token with a market gets a `tier`: what the token **is**, from most to least trustworthy. `lvl` is unchanged, so older code and data keep working.
94
+
95
+ | `tier` | Meaning |
96
+ |---|---|
97
+ | `DIAMOND` | On SolFlag's hand-reviewed list: big projects (`BIG_PROJECTS`: Jupiter, Jito, Pyth…) and trusted issuers (Circle, Paxos…). Being on the list is enough. |
98
+ | `GREEN` | No warning at all, and 7 days or more on the market. A memecoin can be green; it is never diamond. |
99
+ | `YELLOW` | One mild warning, or a check that could not run, or **younger than 7 days**: a newborn token has proven nothing yet, so yellow is the best it can get (`tierCap: true`, `tierCapUntil`: when the cap ends). |
100
+ | `ORANGE` | Danger without a trap: one serious warning that is not a trap (very low liquidity, a few wallets holding most of it), or two or more mild warnings. |
101
+ | `RED` | A trap (`TRAPS`: the creator can mint more or pull the liquidity, launches in series, fake liquidity or volume, a copy of another token…), or two serious warnings. |
102
+
103
+ Red and orange both fail almost always at launch; the difference is the kind of danger, not how long it lasts. Warnings are counted one by one, and "new" (`MKT_NEW`) is not one of them: age is handled by the cap. An issuer whose keys changed without review loses its diamond. `tierLabel(r, lang)` and `tierNote(r, lang)` give the name and a one-line explanation.
104
+
105
+ ### Points by section (0.7.0)
106
+
107
+ A meme, a tokenized stock and a DeFi token are not judged the same way. `scoreProfile(res, perfil)` (or `analyzeToken(client, mint, { perfil })`, which adds `res.perfil`) puts the token in one of seven sections — `meme`, `rwa`, `defi`, `juegos` (games), `ia` (AI), `apps`, `otros` (other) — and scores it on a base of 50 with that section's rules: who is behind it and its reserves for tokenized assets, fees, revenue, audits and hacks for DeFi, real activity for games, public code for AI, whether the token earns from the business (buybacks, burns) for apps. It is a pure function: the data that is not on chain comes in `perfil`, one entry of a daily file (SolFlag builds it from DefiLlama, Jupiter, GitHub and Streamflow). Without it, a known issuer is `rwa` and anything else is scored with the meme rules, which only use the chain.
108
+
109
+ It returns `{ap, pts, tier, cap, floor, trap, checks}`: `pts` fills a bar up to 110, `checks` gives each check its colour (`suma`, `resta`, `grave`, `neutro`, `falta` = not known yet, never counted). Fixed rules: a trap is red; diamond only for the hand-reviewed list with 90 points or more, and the list is green at least; a token born in a launchpad is scored as a meme (green at best) and is yellow at best under 7 days. `lvl` and `tier` stay as they were.
110
+
91
111
  ### Results
92
112
 
93
113
  ```js
94
114
  {
95
115
  lvl: "HIGH" | "MEDIUM" | "LOW" | "SPAM" | "NO_DATA" | "NO_MARKET",
116
+ tier: "DIAMOND" | "GREEN" | "YELLOW" | "ORANGE" | "RED" | null, // null without a market (SPAM is RED)
117
+ tierCap: false, tierCapUntil: null, tierBig: "Jupiter" | null,
96
118
  type: "STABLE" | "TOKENIZED" | "BRIDGED" | "CREATOR" | "OPEN" | null,
97
119
  lights: [ // null for tokens without a market
98
120
  { k: "control" | "concentration" | "market" | "dependency",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solana-risk-engine",
3
- "version": "0.5.6",
3
+ "version": "0.7.0",
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
@@ -92,6 +92,18 @@ export default {
92
92
  HIGH: "High risk", MEDIUM: "Medium risk", LOW: "Low risk", SPAM: "Likely spam",
93
93
  NO_DATA: "Not checked", NO_MARKET: "No market", MEDIUM_DATA_ONLY: "Medium due to missing data"
94
94
  },
95
+ // the five tiers (0.6.0): what the token is
96
+ tiers: {
97
+ DIAMOND: "Diamond", GREEN: "Green", YELLOW: "Yellow", ORANGE: "Orange", RED: "Red",
98
+ notes: {
99
+ DIAMOND: "Big project: passes everything",
100
+ GREEN: "Passes everything",
101
+ YELLOW: "Watch it",
102
+ ORANGE: "Danger: something serious, though not a trap (hard to sell or in few hands)",
103
+ RED: "A trap: better not touch it",
104
+ CAP: "Newborn: under 7 days old, yellow is the best it can get"
105
+ }
106
+ },
95
107
  types: {
96
108
  STABLE: { label: "Stablecoin", note: "Judged by its liquidity and trust in the issuer; concentration matters less." },
97
109
  TOKENIZED: { label: "Tokenized or regulated", note: "The issuer normally keeps control (permanent delegate). The real risk is trusting the issuer and having liquidity to exit." },
package/src/i18n/es.js CHANGED
@@ -96,6 +96,18 @@ export default {
96
96
  HIGH: "Riesgo alto", MEDIUM: "Riesgo medio", LOW: "Riesgo bajo", SPAM: "Probable spam",
97
97
  NO_DATA: "Sin comprobar", NO_MARKET: "Sin mercado", MEDIUM_DATA_ONLY: "Medio por falta de datos"
98
98
  },
99
+ // los cinco niveles (0.6.0): lo que es el token
100
+ tiers: {
101
+ DIAMOND: "Diamante", GREEN: "Verde", YELLOW: "Amarillo", ORANGE: "Naranja", RED: "Rojo",
102
+ notes: {
103
+ DIAMOND: "Gran proyecto: cumple todo",
104
+ GREEN: "Cumple todo",
105
+ YELLOW: "Vigilar",
106
+ ORANGE: "Peligro: algo grave, aunque sin trampa (difícil de vender o en pocas manos)",
107
+ RED: "Trampa: mejor ni tocarlo",
108
+ CAP: "Recién nacido: con menos de 7 días, el amarillo es lo máximo que puede sacar"
109
+ }
110
+ },
99
111
  types: {
100
112
  STABLE: { label: "Stablecoin", note: "Se juzga por su liquidez y por la confianza en quien la emite; la concentración pesa menos." },
101
113
  TOKENIZED: { label: "Tokenizado o regulado", note: "Lo normal es que el emisor tenga control (delegado permanente). El riesgo real es confiar en el emisor y que haya liquidez para salir." },
package/src/i18n/index.js CHANGED
@@ -37,6 +37,19 @@ export function levelLabel(result, lang) {
37
37
  return dataOnly(result) ? L.levels.MEDIUM_DATA_ONLY : (L.levels[result.lvl] || result.lvl);
38
38
  }
39
39
 
40
+ /** Name of a tier (result or "DIAMOND"...): "Diamante", "Green"... */
41
+ export function tierLabel(result, lang) {
42
+ const t = typeof result === "string" ? result : result && result.tier;
43
+ return t ? (pack(lang).tiers[t] || t) : "";
44
+ }
45
+
46
+ /** One line on what the tier means; for a capped newborn token, why it is not green yet */
47
+ export function tierNote(result, lang) {
48
+ const L = pack(lang).tiers.notes, t = typeof result === "string" ? result : result && result.tier;
49
+ if (result && typeof result === "object" && result.tierCap) return L.CAP;
50
+ return t ? (L[t] || "") : "";
51
+ }
52
+
40
53
  /** What could not be checked, e.g. "la concentración de holders y el mercado" */
41
54
  export function missingText(result, lang) {
42
55
  const L = pack(lang), and = lang === "es" ? " y " : " and ";
package/src/index.js CHANGED
@@ -53,6 +53,8 @@ export { getMarkets, realLiq, impostorOf, INFLATED_RATIO, geckoLiquidity, geckoP
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";
56
+ export { TIERS, NEW_CAP_DAYS, TRAPS, BIG_PROJECTS, tierFrom } from "./tier.js";
57
+ export { PERFILES, BIG_EXTRA, scoreProfile, sectionOf, bornInLaunchpad } from "./perfil.js";
56
58
  export { analyzeToken, analyzeWallet, analyzeAddress, sortResults } from "./wallet.js";
57
59
  export { holderBase, markBusy, onlyReceives, PASSIVE_SAMPLE, findFunder, findFunders, clusterByFunder, holderRows, creatorInfo, analyzeHolders,
58
60
  perHour, sourceRates, groupList, EXCHANGE_PER_HOUR, RATE_MIN_SIGS, YOUNG_DAYS, HOLD_GROUP_YOUNG, HOLD_GROUP_MATURE } from "./holders.js";
@@ -62,4 +64,4 @@ export { fetchSwaps, solHistory, priceSeries, parseTrades, pnlFromTrades, pnlSta
62
64
  export { capSnap, chgDiff, chgAgg, takeSnapshots, diffSnapshots } from "./changes.js";
63
65
  export { confluence, commonHolders } from "./confluence.js";
64
66
  export { loadWalletBase, knownType, WALLET_TYPES } from "./base.js";
65
- export { describe, explainLight, lightLabel, levelLabel, missingText, typeInfo, describeStep, describeNote, describeError, format, addLanguage } from "./i18n/index.js";
67
+ export { describe, explainLight, lightLabel, levelLabel, missingText, tierLabel, tierNote, typeInfo, describeStep, describeNote, describeError, format, addLanguage } from "./i18n/index.js";
package/src/perfil.js ADDED
@@ -0,0 +1,175 @@
1
+ // Points by section (perfil), 21/11/2026 — agreed with the user section by section on real tokens (mockups in
2
+ // maquetas/web/escaner-*.html). Pure function: no network. It takes what assess() already found on chain (lights,
3
+ // pair, creator) plus the daily profile of the token (perfiles.json, built by the Ecosystem job: fees, revenue,
4
+ // what goes back to the token, activity, code, unlocks, hacks...) and returns its section, points (base 50, bar
5
+ // up to 110), the colour of each check and the tier. The old risk level (lvl) and tierFrom() are left untouched.
6
+ //
7
+ // Sections: meme · rwa (tokenized assets) · defi · juegos (games) · ia (AI) · apps (apps and bots) · otros (other).
8
+ // Fixed rules for all of them: a trap is RED; DIAMOND only for the hand-reviewed list (BIG_PROJECTS, trusted
9
+ // issuers) and then with 90 points or more, and the list is GREEN at least; a token born in a launchpad (Pump.fun…)
10
+ // is scored as a meme (plus code for AI and business for apps/other) and GREEN is its best; under 7 days, YELLOW.
11
+ // What we do not have yet ("falta") never adds or subtracts.
12
+
13
+ import { BIG_PROJECTS, TRAPS, NEW_CAP_DAYS } from "./tier.js";
14
+
15
+ export const PERFILES = ["meme", "rwa", "defi", "juegos", "ia", "apps", "otros"];
16
+ // Big projects added with the points by section (21/11): Pump.fun — one company (launchpad, PumpSwap, Terminal,
17
+ // mobile app, perps) that buys back its token with part of what it earns
18
+ export const BIG_EXTRA = { pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn: "Pump.fun" };
19
+ // In a project (not a meme) minting is a minus, not a trap: games and networks mint rewards on purpose
20
+ const TRAPS_PROY = ["MKT_LP_UNLOCKED", "MKT_FAKE_VOLUME", "IMPOSTOR", "BRAND_COPY", "COPYCAT", "MKT_LIQ_INFLATED"];
21
+ const DAY = 86400000, YEAR = 365 * DAY;
22
+
23
+ function itemsOf(res) {
24
+ const it = [];
25
+ (res.lights || []).forEach(function (l) { (l.items || []).forEach(function (x) { it.push(x); }); });
26
+ return it;
27
+ }
28
+ // launchpad: the address of Pump.fun / Bonk tokens ends in pump / bonk, or it is still on the launchpad's curve.
29
+ // Not PumpSwap: other tokens trade there too (PUMP itself). A token on the reviewed list is never "launchpad".
30
+ export function bornInLaunchpad(res) {
31
+ const p = res.pair || {};
32
+ if (BIG_PROJECTS[res.mint] || BIG_EXTRA[res.mint]) return false;
33
+ return /(pump|bonk)$/i.test(res.mint || "") || /^(pumpfun|launchlab)$/i.test(p.dexId || "");
34
+ }
35
+ function reviewed(res, it) {
36
+ return !!(res.tierBig || BIG_PROJECTS[res.mint] || BIG_EXTRA[res.mint]) ||
37
+ it.some(function (x) { return x.code === "DEP_TRUSTED_ISSUER" || x.code === "CTL_KNOWN_ISSUER"; });
38
+ }
39
+
40
+ /** Section of a token: the profile's (daily file) or, without one, from what is on chain. */
41
+ export function sectionOf(res, perfil) {
42
+ if (perfil && PERFILES.indexOf(perfil.ap) >= 0) return perfil.ap;
43
+ const it = itemsOf(res);
44
+ if (it.some(function (x) { return x.code === "DEP_TRUSTED_ISSUER" || x.code === "CTL_KNOWN_ISSUER" || x.code === "DEP_KNOWN_ISSUER" || x.code === "DEP_STABLE_ISSUER"; })) return "rwa";
45
+ return "meme"; // no data: only what is on chain, which is what the meme rules use
46
+ }
47
+
48
+ /**
49
+ * Points by section.
50
+ * @param res assess() result for a token with a market (lights, pair, mint, tierBig, creator)
51
+ * @param perfil its entry in perfiles.json, or null. Fields (all optional): ap, f30 (fees 30 d, $), c (fees change
52
+ * vs the 30 days before, 0.1 = +10 %), r30 (revenue), h30 (what goes back to the token: buybacks, burns
53
+ * or sharing), tvl, aud (audits), hk [{d: unix s, p: $ lost and not returned}], desde (listed, unix s),
54
+ * trad (traders 24 h), org (organic score 0-100), tit (holders), titC (holders change 24 h, 0.01 = 1 %),
55
+ * cod {dias} (days since the last change in its public code; null = no code linked), dl {lib, bloq}
56
+ * (% of supply unlocked in 30 days and still locked; null = no Streamflow contracts),
57
+ * desv (price vs the real asset, 0.01 = 1 %), res (reserves: "si" | "parcial"), uso (true: used a lot)
58
+ * @param [o.now] time (ms)
59
+ * @returns {ap, pts, tier, cap, floor, trap, checks:[{k, col, p, d}]} col: suma | resta | grave | neutro | falta
60
+ */
61
+ export function scoreProfile(res, perfil, o) {
62
+ o = o || {};
63
+ const now = o.now || Date.now();
64
+ const P = perfil || {};
65
+ const it = itemsOf(res);
66
+ const has = function (c) { return it.some(function (x) { return x.code === c; }); };
67
+ const pair = res.pair || {};
68
+ const liq = (pair.liquidity && pair.liquidity.usd) || 0, vol = (pair.volume && pair.volume.h24) || 0;
69
+ const dias = pair.pairCreatedAt ? (now - pair.pairCreatedAt) / DAY : null;
70
+ const conc = it.filter(function (x) { return x.data && x.data.w1 != null; })[0];
71
+ const w1 = conc ? conc.data.w1 : null, w10 = conc ? conc.data.w10 : null;
72
+ const ap = sectionOf(res, perfil), lanz = bornInLaunchpad(res), rev = reviewed(res, it);
73
+ const forced = !!(res.impostor || has("IMPOSTOR") || has("BRAND_COPY"));
74
+ let n = 50; const checks = [];
75
+ const add = function (k, p, d, col) {
76
+ n += p;
77
+ checks.push({ k: k, p: p, d: d === undefined ? null : d, col: col || (p > 0 ? "suma" : p <= -20 ? "grave" : p < 0 ? "resta" : "neutro") });
78
+ };
79
+ const falta = function (k) { checks.push({ k: k, p: 0, d: null, col: "falta" }); };
80
+ let trap = false, dead = false, memeRules = ap === "meme" || (lanz && ap !== "rwa" && ap !== "defi");
81
+
82
+ if (ap === "rwa") {
83
+ // tokenized assets: who is behind matters more than liquidity (the issuer can bring liquidity from elsewhere)
84
+ if (forced) { trap = true; add("copia", 0, null, "grave"); }
85
+ add("oficial", rev ? 25 : -10);
86
+ if (has("CTL_ISSUER_KEYS_CHANGED")) add("claves", -30); else if (rev) add("claves", 5);
87
+ if (P.desv == null) falta("precio");
88
+ else if (Math.abs(P.desv) > 0.2) add("precio", 0, P.desv, "falta"); // over 20 % is a data error to review
89
+ else add("precio", Math.abs(P.desv) < 0.005 ? 10 : Math.abs(P.desv) <= 0.02 ? 0 : -15, P.desv);
90
+ if (P.res === "si") add("reservas", 10); else if (P.res === "parcial") add("reservas", 5); else falta("reservas");
91
+ add("liquidez", liq >= 1e5 ? 5 : liq >= 2e4 ? 0 : -5, liq);
92
+ if (has("DEP_PERMANENT_DELEGATE")) add("mover", -5);
93
+ if (has("CTL_TRANSFER_FEE")) add("comision", rev ? -15 : -5);
94
+ if (P.uso) add("uso", 5);
95
+ } else if (memeRules) {
96
+ trap = forced || it.some(function (x) { return x.s === "bad" && TRAPS.indexOf(x.code) >= 0; });
97
+ if (has("CTL_FREEZE_ACTIVE")) add("control", -25);
98
+ else if (has("CTL_TRANSFER_FEE") || has("CTL_TRANSFER_HOOK")) add("control", -10);
99
+ else if (has("CTL_NONE") || has("CTL_ONLY_PROGRAMS")) add("control", 15);
100
+ if (w10 != null) add("reparto", w10 < 25 ? 10 : w10 > 60 ? -20 : w10 > 40 ? -10 : 0, w10);
101
+ if (w1 != null && w1 > 15) add("wallet", w1 > 50 ? -35 : w1 > 30 ? -15 : -5, w1);
102
+ add("liquidez", liq >= 1e5 ? 10 : liq >= 5e4 ? 5 : liq >= 2e4 ? -5 : liq >= 1e4 ? -10 : liq >= 1e3 ? -25 : -40, liq);
103
+ if (liq < 1e3) dead = true;
104
+ if (has("MKT_LP_PARTLY_LOCKED")) add("lp", -10);
105
+ add("volumen", vol >= 1e4 ? 5 : vol < 1e3 ? -5 : 0, vol);
106
+ if (dias != null) add("edad", dias >= 365 ? 10 : dias >= 30 ? 5 : dias >= 7 ? 0 : dias >= 1 ? -5 : -10, dias);
107
+ const cr = res.creator;
108
+ if (cr && cr.old > 0 && !cr.dead) add("creador", 5);
109
+ if (ap === "ia") codigo();
110
+ if (ap === "apps" || ap === "otros") negocio();
111
+ } else {
112
+ // a project (defi, games, AI, apps, other): what it earns and whether it is used matter, not only the market
113
+ trap = forced || it.some(function (x) { return x.s === "bad" && TRAPS_PROY.indexOf(x.code) >= 0; });
114
+ add("oficial", 15);
115
+ if (P.f30 == null) falta("comisiones");
116
+ else {
117
+ add("comisiones", P.f30 >= 1e6 ? 10 : P.f30 >= 1e5 ? 5 : P.f30 < 1e4 ? -5 : 0, P.f30);
118
+ if (P.c != null) add("tendencia", P.c > 0.1 ? 5 : P.c < -0.3 ? -5 : 0, P.c);
119
+ }
120
+ if (P.r30 != null && P.r30 >= 1e4) add("ingresos", 5, P.r30);
121
+ if (ap === "defi") {
122
+ if (P.tvl) add("depositos", P.tvl >= 1e8 ? 5 : P.tvl < 1e6 ? -5 : 0, P.tvl);
123
+ if (P.aud) add("auditorias", 10, P.aud); else falta("auditorias");
124
+ }
125
+ if (ap === "apps" || ap === "otros") negocio();
126
+ if (ap === "ia") codigo();
127
+ if (ap !== "defi") {
128
+ if (P.trad != null) add("traders", P.trad >= 1000 ? 10 : P.trad >= 100 ? 5 : P.trad < 20 ? -10 : 0, P.trad);
129
+ if (P.org != null) add("organico", P.org >= 50 ? 5 : P.org < 15 ? -10 : 0, P.org);
130
+ if (P.tit != null) add("titulares", P.tit >= 1e5 ? 10 : P.tit >= 1e4 ? 5 : P.tit < 1000 ? -5 : 0, P.tit);
131
+ if (ap === "juegos" && P.titC != null) add("titularesC", P.titC > 0.01 ? 5 : P.titC < -0.02 ? -5 : 0, P.titC);
132
+ }
133
+ if (has("CTL_MINT_ACTIVE")) add("crear", -10);
134
+ if (has("CTL_FREEZE_ACTIVE")) add("congelar", -10);
135
+ if (P.dl === undefined || P.dl === null) falta("desbloqueos");
136
+ else add("desbloqueos", P.dl.lib > 2 ? -15 : P.dl.lib > 0.5 ? -5 : 0, P.dl);
137
+ if (w1 != null && w1 > 30) add("wallet", w1 > 50 ? -15 : -5, w1);
138
+ add("liquidez", liq >= 1e5 ? 5 : liq < 2e4 ? -15 : 0, liq);
139
+ if (ap === "defi") { if (P.desde && now / 1000 - P.desde > 2 * 365 * 86400) add("edad", 5); }
140
+ else if (dias != null && dias > 365) add("edad", 5);
141
+ hackeos();
142
+ }
143
+
144
+ function codigo() { // AI: is there public code and is it moving? No code linked does not subtract
145
+ if (!P.cod || P.cod.dias == null) falta("codigo");
146
+ else add("codigo", P.cod.dias <= 30 ? 10 : P.cod.dias <= 90 ? 5 : P.cod.dias > 180 ? -5 : 0, P.cod.dias);
147
+ }
148
+ function negocio() { // apps and other: does the token earn from the business (buybacks, burns, sharing)?
149
+ if (P.h30 != null && P.h30 >= 1e4) add("negocio", P.h30 >= 1e5 ? 10 : 5, P.h30);
150
+ else checks.push({ k: "negocio", p: 0, d: P.h30 == null ? null : P.h30, col: P.h30 == null ? "falta" : "neutro" });
151
+ }
152
+ function hackeos() {
153
+ const hk = P.hk || [], year = now / 1000 - 365 * 86400;
154
+ const rec = hk.filter(function (h) { return h.d > year; }), lost = rec.reduce(function (a, h) { return a + (h.p || 0); }, 0);
155
+ if (ap === "defi") {
156
+ if (rec.length) add("hackeo", lost >= 1e8 ? -40 : lost >= 1e7 ? -25 : lost > 0 ? -15 : -5, lost);
157
+ else if (hk.length) add("hackeo", -5, 0);
158
+ } else if (rec.length) add("hackeo", -15, lost);
159
+ }
160
+
161
+ // tier
162
+ const listed = !!(res.tierBig || BIG_PROJECTS[res.mint] || BIG_EXTRA[res.mint]);
163
+ let tier = (trap || dead) ? "RED" : n >= 75 ? "GREEN" : n >= 50 ? "YELLOW" : n >= 25 ? "ORANGE" : "RED";
164
+ let cap = false, floor = false;
165
+ if (!trap && !dead) {
166
+ if (ap === "rwa") {
167
+ if (rev && !has("CTL_ISSUER_KEYS_CHANGED")) { if (n >= 90) tier = "DIAMOND"; else if (tier !== "GREEN") { tier = "GREEN"; floor = true; } }
168
+ else if (tier === "GREEN") tier = "YELLOW"; // an unreviewed issuer is YELLOW at best
169
+ } else if (listed && !memeRules) {
170
+ if (n >= 90) tier = "DIAMOND"; else if (tier !== "GREEN") { tier = "GREEN"; floor = true; }
171
+ }
172
+ if (memeRules && dias != null && dias < NEW_CAP_DAYS && tier === "GREEN") { tier = "YELLOW"; cap = true; }
173
+ }
174
+ return { ap: ap, lanz: lanz && memeRules && ap !== "meme", pts: n, tier: tier, cap: cap, floor: floor, trap: trap, dead: dead, checks: checks };
175
+ }
package/src/risk.js CHANGED
@@ -5,6 +5,8 @@ import { getMint, getAuthKinds, getConc, kindOf } from "./tokens.js";
5
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
+ import { tierFrom } from "./tier.js";
9
+ import { scoreProfile } from "./perfil.js";
8
10
 
9
11
  // Every finding is a "signal": {code, s, data}. `s` is ok | na | warn | bad, `data` holds the numbers
10
12
  // behind it. Turning signals into sentences is i18n's job (describe / explainLight), never the engine's.
@@ -297,7 +299,9 @@ export function reasonsFrom(lights) {
297
299
  * @param [opts.skipConcentration]
298
300
  * @param [opts.skipCreator] do not ask RugCheck what else the creator launched (markets under 7 days only)
299
301
  * @param [opts.noGecko] do not ask GeckoTerminal who trades it (fake volume)
300
- * @returns null for NFTs, otherwise {mint, sym, name, lvl, sev, pts, type, lights, reasons, impostor, value, pair, img}
302
+ * @param [opts.perfil] the token's entry in the daily perfiles.json (or null if it is not there): adds
303
+ * `perfil` = points by section (scoreProfile in perfil.js). Left out: no `perfil`
304
+ * @returns null for NFTs, otherwise {mint, sym, name, lvl, sev, pts, type, lights, reasons, impostor, value, pair, img, perfil?}
301
305
  */
302
306
  export async function assess(client, mint, pair, opts) {
303
307
  opts = opts || {};
@@ -339,7 +343,7 @@ export async function assess(client, mint, pair, opts) {
339
343
  }
340
344
  const rc = await rcPromise, launches = await launchPromise, copies = await copiesPromise, wash = await washPromise;
341
345
  const base = (pair && pair.baseToken) || {};
342
- let lvl, sev = 0, reasons = [], lights = null, type = null, pts = 0, imp = null;
346
+ let lvl, sev = 0, reasons = [], lights = null, type = null, pts = 0, imp = null, tier = null;
343
347
  if (pair) {
344
348
  type = tokenType(info, pair);
345
349
  lights = buildLights(info, conc, pair, value, type, rc, null, launches);
@@ -373,7 +377,10 @@ export async function assess(client, mint, pair, opts) {
373
377
  const lf = levelFrom(lights); lvl = lf.lvl; sev = lf.sev; reasons = reasonsFrom(lights);
374
378
  // a copy of a famous token or a real company, or liquidity faked 100 times over, is high risk even
375
379
  // when everything else looks normal: it is built to look like something it is not
376
- if (imp || (brand && brand.exact) || (fakeLiquidity(pair) && !anyIssuer(info, mint))) { if (lvl !== "HIGH") sev += 5; lvl = "HIGH"; }
380
+ const forced = !!(imp || (brand && brand.exact) || (fakeLiquidity(pair) && !anyIssuer(info, mint)));
381
+ if (forced) { if (lvl !== "HIGH") sev += 5; lvl = "HIGH"; }
382
+ // five tiers (tier.js): what the token is, with a 7-day cap for newborn tokens; lvl stays as it was
383
+ tier = tierFrom(lights, pair, mint, { red: forced, trusted: issuerKeysChanged(info, mint) ? null : trustedIssuer(info, mint) });
377
384
  } else if (mintFailed) {
378
385
  // the RPC did not answer: unknown, not spam (a network error showed "probable spam" and the bot sent "worse")
379
386
  lvl = "NO_DATA"; reasons = [sig("NO_INFO", "na")];
@@ -386,20 +393,26 @@ export async function assess(client, mint, pair, opts) {
386
393
  }
387
394
  const s = score(info);
388
395
  pts = s.pts; reasons = s.why; lvl = pts >= 25 ? "SPAM" : "NO_MARKET";
396
+ if (lvl === "SPAM") tier = { tier: "RED", cap: false, capUntil: null, big: null };
389
397
  // an official token with no Solana pool (bgSOL trades on Bitget) is not spam: its issuer mints it
390
398
  // nor is a known issuer's token sold only to approved investors (Ondo's OUSG and USDon showed "probable spam", 12/11)
391
399
  const noMktIssuer = OFFICIAL_TOKENS[mint] || anyIssuer(info, mint);
392
400
  if (noMktIssuer) {
393
- pts = 0; lvl = "NO_MARKET"; reasons = [sig("DEP_KNOWN_ISSUER", "warn", { issuer: noMktIssuer }), sig("NO_MARKET", "na")];
401
+ pts = 0; lvl = "NO_MARKET"; tier = null; reasons = [sig("DEP_KNOWN_ISSUER", "warn", { issuer: noMktIssuer }), sig("NO_MARKET", "na")];
394
402
  const rot = issuerKeysChanged(info, mint);
395
403
  if (rot) reasons.unshift(sig("CTL_ISSUER_KEYS_CHANGED", "warn", { issuer: rot.issuer, keys: rot.keys }));
396
404
  }
397
405
  }
398
- return {
406
+ const out = {
399
407
  mint: mint, sym: base.symbol || short(mint), name: base.name || "", pts: pts, sev: sev,
400
- lvl: lvl, type: type, lights: lights, reasons: reasons, impostor: imp, copies: copies, value: value, pair: pair,
408
+ lvl: lvl, tier: tier ? tier.tier : null, tierCap: tier ? tier.cap : false, tierCapUntil: tier ? tier.capUntil : null, tierBig: tier ? tier.big : null,
409
+ type: type, lights: lights, reasons: reasons, impostor: imp, copies: copies, value: value, pair: pair,
401
410
  rugcheck: rc ? { lpLockedPct: rc.lpLockedPct, score: rc.score_normalised !== undefined ? rc.score_normalised : rc.score } : null,
402
411
  creator: launches, trades: wash,
403
412
  img: (pair && pair.info && pair.info.imageUrl) || null
404
413
  };
414
+ // points by section (perfil.js, 21/11): only with a market and when the caller passes the daily profile
415
+ // (opts.perfil: the entry of perfiles.json, or null for a token not in it). lvl and tier stay as they were
416
+ if (pair && opts.perfil !== undefined) out.perfil = scoreProfile(out, opts.perfil);
417
+ return out;
405
418
  }
package/src/tier.js ADDED
@@ -0,0 +1,80 @@
1
+ // Five tiers (0.6.0, 14/11/2026): what a token IS, from most to least trustworthy, alongside the old risk level
2
+ // (lvl: HIGH/MEDIUM/LOW), which stays as it was so the registry's history is not broken.
3
+ // DIAMOND on SolFlag's hand-reviewed list: big projects (BIG_PROJECTS) and trusted issuers (Circle, Paxos...).
4
+ // Being on the list is enough: the work is in reviewing who gets in (decided with the user, 14/11)
5
+ // GREEN no warning at all and 7 days or more on the market
6
+ // YELLOW one mild warning, or something that could not be checked, or younger than 7 days (the CAP: a newborn
7
+ // token has proven nothing yet, so YELLOW is the best it can get unless a big project is behind it)
8
+ // ORANGE danger without a trap: one serious warning that is not a trap (very low liquidity, a few wallets
9
+ // holding most of it: hard to sell, but nobody is deceiving you), or two or more mild warnings
10
+ // RED a trap (someone can take your money or you are being deceived: TRAPS below), or two serious warnings
11
+ // Both fail almost always at launch (registry: 99.4 % red and 99.6 % orange dead in a day): the difference is the
12
+ // KIND of danger, not how long it lasts (decided with the user, 14/11: "there are things worse than others").
13
+ // Warnings are counted one by one (two mild ones in the same light are two). "New" (MKT_NEW) is not counted as a
14
+ // warning: age is handled by the cap. In the registry, one red flag on a new token already meant 99.5 % dead in a
15
+ // day, the same as three (tools/estudio/madurez.md in escaner-solana).
16
+
17
+ export const TIERS = ["DIAMOND", "GREEN", "YELLOW", "ORANGE", "RED"];
18
+ export const NEW_CAP_DAYS = 7;
19
+ // Serious warnings that are a trap: the creator can print more, pull the liquidity or is launching in series (or his
20
+ // earlier tokens died), the liquidity or volume is fake, or it pretends to be another token
21
+ export const TRAPS = ["CTL_MINT_ACTIVE", "MKT_LP_UNLOCKED", "MKT_LIQ_INFLATED", "MKT_FAKE_VOLUME", "IMPOSTOR", "BRAND_COPY",
22
+ "COPYCAT", "CTL_SERIAL_CREATOR", "CTL_SERIAL_PAYER", "CTL_CREATOR_HISTORY"];
23
+ const DAY = 86400000;
24
+
25
+ // Big projects with a public product and team, reviewed by hand (address checked on DexScreener on 14/11/2026).
26
+ // A memecoin is never here however big it is: it can be GREEN, not DIAMOND.
27
+ export const BIG_PROJECTS = {
28
+ So11111111111111111111111111111111111111112: "Solana (wrapped SOL)",
29
+ JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN: "Jupiter",
30
+ jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL: "Jito",
31
+ J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn: "Jito (JitoSOL)",
32
+ mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So: "Marinade (mSOL)",
33
+ HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3: "Pyth Network",
34
+ "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R": "Raydium",
35
+ orcaEKTdK7LKz57vaAYr9QeNsVEPfiu6QeMU1kektZE: "Orca",
36
+ "85VBFQZC9TZkfaptBWjvUw7YbZjy52A6mjtPGjstQAmQ": "Wormhole",
37
+ hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux: "Helium",
38
+ rndrizKT3MK1iimdxRdWabcF7Zg7AR5T4nud4EkHBof: "Render"
39
+ };
40
+
41
+ function ageDays(pair, now) {
42
+ return pair && pair.pairCreatedAt ? (now - pair.pairCreatedAt) / DAY : null;
43
+ }
44
+
45
+ /**
46
+ * Tier of a token with a market.
47
+ * @param lights the four lights (buildLights + front signals), as in assess()
48
+ * @param pair its main pair (DexScreener shape)
49
+ * @param mint its address
50
+ * @param [o.trusted] name of the trusted issuer behind it, if any (Circle, Paxos...; not after an unreviewed key change)
51
+ * @param [o.red] forced red (impostor, exact brand copy, fake liquidity), as assess() forces HIGH
52
+ * @param [o.now] time (ms)
53
+ * @returns {tier, cap, capUntil, big} cap: it would be GREEN but is younger than 7 days; capUntil: when the cap ends;
54
+ * big: the project or issuer on the list (then the lights are still shown, but the tier is DIAMOND)
55
+ */
56
+ export function tierFrom(lights, pair, mint, o) {
57
+ o = o || {};
58
+ const now = o.now || Date.now();
59
+ const big = BIG_PROJECTS[mint] || o.trusted || null;
60
+ const out = { tier: null, cap: false, capUntil: null, big: big };
61
+ if (big) { out.tier = "DIAMOND"; return out; }
62
+ const items = [];
63
+ (lights || []).forEach(function (l) { (l.items || []).forEach(function (x) { if (x.code !== "MKT_NEW") items.push(x); }); });
64
+ const badItems = items.filter(function (x) { return x.s === "bad"; }), bad = badItems.length;
65
+ const trap = badItems.some(function (x) { return TRAPS.indexOf(x.code) >= 0; });
66
+ const warn = items.filter(function (x) { return x.s === "warn"; }).length;
67
+ const na = items.some(function (x) { return x.s === "na"; });
68
+ if (o.red || trap || bad >= 2) { out.tier = "RED"; return out; }
69
+ if (bad === 1 || warn >= 2) { out.tier = "ORANGE"; return out; }
70
+ if (warn === 1 || na) { out.tier = "YELLOW"; return out; }
71
+ const age = ageDays(pair, now);
72
+ // a newborn token has proven nothing yet: YELLOW at best (a big project or trusted issuer is DIAMOND above)
73
+ if (age === null || age < NEW_CAP_DAYS) {
74
+ out.tier = "YELLOW"; out.cap = true;
75
+ if (pair && pair.pairCreatedAt) out.capUntil = pair.pairCreatedAt + NEW_CAP_DAYS * DAY;
76
+ return out;
77
+ }
78
+ out.tier = "GREEN";
79
+ return out;
80
+ }
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, noGecko: opts.noGecko });
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, perfil: opts.perfil });
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;