solana-risk-engine 0.4.13 → 0.5.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.md +2 -0
- package/package.json +1 -1
- package/src/holders.js +8 -3
- package/src/i18n/en.js +4 -0
- package/src/i18n/es.js +124 -120
- package/src/index.js +5 -1
- package/src/map.js +250 -0
- package/src/tokens.js +3 -2
package/README.md
CHANGED
|
@@ -77,6 +77,8 @@ Methods (all accept `{ onProgress(step, fraction) }`):
|
|
|
77
77
|
| `analyzeAddress(addr)` | `{ kind: "token" \| "wallet", ... }`, detected automatically |
|
|
78
78
|
| `analyzeHolders(mint)` | `{ rows, clusters, groups, hotGroups, creator, mode, ageDays, signals, ... }`. Young tokens (under 14 days) also trace busy wallets; a source over 100 tx/h counts as an exchange; a group over 10% (young) or 15% (mature) of the supply gives a `HOLD_GROUP` signal. With `{ base: true }` it also reads [SolFlag's wallet base](https://solflag.com/datos/base.json) (exchanges, launch farms, distributors and serial creators its collector has seen): known exchanges are recognised without measuring them, and rows and group sources get `known` / `knownSources`. Best with your own RPC. |
|
|
79
79
|
| `loadWalletBase([url])` | SolFlag's wallet base `{ wallets: { addr: { t, ph, n, roles } } }`, or `null` if it cannot be read. Kept 10 minutes. `knownType(base, addr)` gives a wallet's type. |
|
|
80
|
+
| `analyzeHolders(mint)` | `{ rows, clusters, groups, hotGroups, creator, mode, ageDays, signals, ... }`. Young tokens (under 14 days) also trace busy wallets; a source over 100 tx/h counts as an exchange; a group over 10% (young) or 15% (mature) of the supply gives a `HOLD_GROUP` signal. Best with your own RPC. |
|
|
81
|
+
| `connectionMap(mint, { createdAt })` | `{ mode, holders, sources, groups, nets, hub, creator, payer, signals }`: largest holders typed person / bot / exchange (over 100 tx/h) / pool, who gave each one its first SOL, groups sharing that source, RugCheck's token-transfer networks with their links. `young` (under 14 days) or `mature` decides what is traced and when it warns (`MAP_GROUP`, `MAP_SWARM` for 10+ holders from one source whatever they hold, `MAP_HUB`, `MAP_WHALE`). 20 holders, 75 with your own RPC. |
|
|
80
82
|
| `estimatePnl(wallets)` | `{ pnl: { [wallet]: { realized, unreal, total, ret, st, open } } }`. Needs Helius. |
|
|
81
83
|
| `takeSnapshots(wallets)` | Today's holdings. Store them yourself and pass them to `diffSnapshots(prev, next)`. |
|
|
82
84
|
| `confluence(wallets, { pct, withPnl, pnlFilter })` | Tokens held in common, with risk. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solana-risk-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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/holders.js
CHANGED
|
@@ -24,7 +24,7 @@ export async function holderBase(client, mint, onProgress) {
|
|
|
24
24
|
});
|
|
25
25
|
const owned = uniq(owners.filter(Boolean));
|
|
26
26
|
progress(onProgress, "kinds", 0.7);
|
|
27
|
-
const kind = await accountKinds(client, owned,
|
|
27
|
+
const kind = await accountKinds(client, owned, true); // on the curve with no account: a wallet emptied of SOL
|
|
28
28
|
return { mint: mint, info: info, pair: pair, largest: largest, owners: owners, uniq: owned, kind: kind };
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -134,9 +134,14 @@ export const YOUNG_DAYS = 14;
|
|
|
134
134
|
// A group (holders sharing the source of their first SOL) over this % of the supply warns
|
|
135
135
|
export const HOLD_GROUP_YOUNG = 10, HOLD_GROUP_MATURE = 15;
|
|
136
136
|
|
|
137
|
-
//
|
|
137
|
+
// Below this many signatures there is no rate to speak of: a fresh wallet funded and buying within the same
|
|
138
|
+
// minute (or a one-use bundler that funded ten wallets in five) would look like thousands an hour, i.e. an
|
|
139
|
+
// exchange, and drop out of the groups it belongs to. Exchanges and bots have far more than this.
|
|
140
|
+
export const RATE_MIN_SIGS = 50;
|
|
141
|
+
|
|
142
|
+
// Transactions per hour over a page of signatures (newest first); 0 under RATE_MIN_SIGS
|
|
138
143
|
export function perHour(sigs) {
|
|
139
|
-
if (!sigs || sigs.length <
|
|
144
|
+
if (!sigs || sigs.length < RATE_MIN_SIGS) return 0;
|
|
140
145
|
const span = ((sigs[0].blockTime || 0) - (sigs[sigs.length - 1].blockTime || 0)) / 3600;
|
|
141
146
|
return span > 0 ? sigs.length / span : sigs.length * 3600;
|
|
142
147
|
}
|
package/src/i18n/en.js
CHANGED
|
@@ -39,6 +39,10 @@ export default {
|
|
|
39
39
|
CTL_NONE: () => "No active authorities: nobody can mint more or freeze",
|
|
40
40
|
CTL_SERIAL_CREATOR: (d) => "The creator launched " + d.n + " other tokens in the last 24 h (per RugCheck): a serial launcher, who usually drops each token as soon as buyers arrive",
|
|
41
41
|
CTL_SERIAL_PAYER: (d) => "The wallet that paid for this launch launched " + d.n + " other tokens in the last 24 h (counted on chain): a serial launcher, who usually drops each token as soon as buyers arrive",
|
|
42
|
+
MAP_GROUP: (d) => d.n + " holders got their first SOL from the same wallet and together hold " + pct(d.pct) + " of the supply: most likely one person or team",
|
|
43
|
+
MAP_SWARM: (d) => d.n + " of the " + d.of + " largest holders got their first SOL from the same wallet (together " + pct(d.pct) + "): this many wallets from one source is usually the team splitting its supply",
|
|
44
|
+
MAP_HUB: (d) => "One wallet handed tokens to " + d.n + " wallets: teams often split the supply this way to look more spread out",
|
|
45
|
+
MAP_WHALE: (d) => "A single person (not an exchange or a pool) holds " + pct(d.pct) + " of the supply",
|
|
42
46
|
BRAND_COPY: (d) => "Uses the name of " + d.brand + ", a real company with no token on Solana: it is not official, almost certainly an imitation to draw buyers",
|
|
43
47
|
BRAND_NAME: (d) => "Uses the name of " + d.brand + ", a real company: it is not an official " + d.brand + " token",
|
|
44
48
|
COPYCAT: (d) => "There " + (d.n === 1 ? "is another token" : "are " + d.n + " more tokens") + " with the same name and ticker; the oldest one with a real market (" + short(d.original) + ", " + d.days + (d.days === 1 ? " day" : " days") + " old) is not this one: check you have the right address",
|
package/src/i18n/es.js
CHANGED
|
@@ -1,121 +1,125 @@
|
|
|
1
|
-
// Spanish texts: the same wording the original single-file scanner used
|
|
2
|
-
function usd(n) {
|
|
3
|
-
if (!n) return "0 $";
|
|
4
|
-
if (n < 0.01) return "<0,01 $";
|
|
5
|
-
// de-DE instead of es-ES: same format (dot thousands, comma decimals), but es-ES does not group
|
|
6
|
-
// 4-digit numbers and "6494 $" showed next to "22.505 $"
|
|
7
|
-
return n.toLocaleString("de-DE", { minimumFractionDigits: n < 1000 ? 2 : 0, maximumFractionDigits: n < 1000 ? 2 : 0 }) + " $";
|
|
8
|
-
}
|
|
9
|
-
function pct(n) { return Math.round(n) + "%"; }
|
|
10
|
-
function short(a) { return a.slice(0, 4) + "…" + a.slice(-4); }
|
|
11
|
-
function prog(d) { return d && d.prog >= 20 ? ". Los pools y programas guardan el " + pct(d.prog) : ""; }
|
|
12
|
-
|
|
13
|
-
const EXT = {
|
|
14
|
-
permanentDelegate: "El emisor puede mover o quemar tus tokens (delegado permanente). Es normal en acciones tokenizadas, pero hay que confiar en el emisor",
|
|
15
|
-
transferHook: "Tiene transfer hook: ejecuta código externo en cada transferencia",
|
|
16
|
-
transferFeeConfig: "Cobra una comisión en cada transferencia",
|
|
17
|
-
nonTransferable: "No se puede transferir",
|
|
18
|
-
defaultAccountState: "Las cuentas nuevas pueden crearse congeladas"
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default {
|
|
22
|
-
fmt: { usd: usd, pct: pct, short: short },
|
|
23
|
-
signals: {
|
|
24
|
-
NO_INFO: () => "No se pudo leer la información del token",
|
|
25
|
-
MINT_BY_PROGRAM: () => "El mint lo controla un programa (suele ser un puente o un protocolo): hay que confiar en ese código",
|
|
26
|
-
MINT_ACTIVE: (d) => "El creador todavía puede crear más tokens (mint activo" + (d && d.byWallet ? ", en manos de una wallet" : "") + ")",
|
|
27
|
-
FREEZE_BY_PROGRAM: () => "El freeze lo controla un programa: puede congelar cuentas según su código",
|
|
28
|
-
FREEZE_ACTIVE: (d) => "El creador puede congelar cuentas (freeze activo" + (d && d.byWallet ? ", en manos de una wallet" : "") + ")",
|
|
29
|
-
EXTENSION: (d) => EXT[d.ext] || ("Extensión " + d.ext),
|
|
30
|
-
NO_MARKET: () => "No hay mercado en DexScreener (sin precio ni liquidez)",
|
|
31
|
-
MARKET_UNCHECKED: () => "No se pudo consultar el mercado de este token (fallo de red al conectar con DexScreener): vuelve a analizarlo para comprobarlo",
|
|
32
|
-
KNOWN_TOKEN: () => "Token muy conocido",
|
|
33
|
-
|
|
34
|
-
CTL_MINT_ACTIVE: () => "El creador puede crear más tokens (mint activo)",
|
|
35
|
-
CTL_FREEZE_ACTIVE: () => "El creador puede congelar cuentas (freeze activo)",
|
|
36
|
-
CTL_TRANSFER_HOOK: () => "Ejecuta código externo en cada transferencia",
|
|
37
|
-
CTL_TRANSFER_FEE: () => "Cobra una comisión en cada transferencia",
|
|
38
|
-
CTL_NON_TRANSFERABLE: () => "No se puede transferir",
|
|
39
|
-
CTL_DEFAULT_FROZEN: () => "Las cuentas nuevas pueden crearse congeladas",
|
|
40
|
-
CTL_ONLY_PROGRAMS: () => "Solo hay autoridades controladas por un programa (ver dependencia)",
|
|
41
|
-
CTL_KNOWN_ISSUER: (d) => "Lo controla su emisor, " + d.issuer + " (ver dependencia)",
|
|
42
|
-
CTL_NONE: () => "Sin autoridades activas: nadie puede crear más ni congelar",
|
|
43
|
-
CTL_SERIAL_CREATOR: (d) => "El creador ha lanzado " + d.n + " tokens más en las últimas 24 h (según RugCheck): es un lanzador en serie, que suele abandonar cada token en cuanto llegan compradores",
|
|
1
|
+
// Spanish texts: the same wording the original single-file scanner used
|
|
2
|
+
function usd(n) {
|
|
3
|
+
if (!n) return "0 $";
|
|
4
|
+
if (n < 0.01) return "<0,01 $";
|
|
5
|
+
// de-DE instead of es-ES: same format (dot thousands, comma decimals), but es-ES does not group
|
|
6
|
+
// 4-digit numbers and "6494 $" showed next to "22.505 $"
|
|
7
|
+
return n.toLocaleString("de-DE", { minimumFractionDigits: n < 1000 ? 2 : 0, maximumFractionDigits: n < 1000 ? 2 : 0 }) + " $";
|
|
8
|
+
}
|
|
9
|
+
function pct(n) { return Math.round(n) + "%"; }
|
|
10
|
+
function short(a) { return a.slice(0, 4) + "…" + a.slice(-4); }
|
|
11
|
+
function prog(d) { return d && d.prog >= 20 ? ". Los pools y programas guardan el " + pct(d.prog) : ""; }
|
|
12
|
+
|
|
13
|
+
const EXT = {
|
|
14
|
+
permanentDelegate: "El emisor puede mover o quemar tus tokens (delegado permanente). Es normal en acciones tokenizadas, pero hay que confiar en el emisor",
|
|
15
|
+
transferHook: "Tiene transfer hook: ejecuta código externo en cada transferencia",
|
|
16
|
+
transferFeeConfig: "Cobra una comisión en cada transferencia",
|
|
17
|
+
nonTransferable: "No se puede transferir",
|
|
18
|
+
defaultAccountState: "Las cuentas nuevas pueden crearse congeladas"
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
fmt: { usd: usd, pct: pct, short: short },
|
|
23
|
+
signals: {
|
|
24
|
+
NO_INFO: () => "No se pudo leer la información del token",
|
|
25
|
+
MINT_BY_PROGRAM: () => "El mint lo controla un programa (suele ser un puente o un protocolo): hay que confiar en ese código",
|
|
26
|
+
MINT_ACTIVE: (d) => "El creador todavía puede crear más tokens (mint activo" + (d && d.byWallet ? ", en manos de una wallet" : "") + ")",
|
|
27
|
+
FREEZE_BY_PROGRAM: () => "El freeze lo controla un programa: puede congelar cuentas según su código",
|
|
28
|
+
FREEZE_ACTIVE: (d) => "El creador puede congelar cuentas (freeze activo" + (d && d.byWallet ? ", en manos de una wallet" : "") + ")",
|
|
29
|
+
EXTENSION: (d) => EXT[d.ext] || ("Extensión " + d.ext),
|
|
30
|
+
NO_MARKET: () => "No hay mercado en DexScreener (sin precio ni liquidez)",
|
|
31
|
+
MARKET_UNCHECKED: () => "No se pudo consultar el mercado de este token (fallo de red al conectar con DexScreener): vuelve a analizarlo para comprobarlo",
|
|
32
|
+
KNOWN_TOKEN: () => "Token muy conocido",
|
|
33
|
+
|
|
34
|
+
CTL_MINT_ACTIVE: () => "El creador puede crear más tokens (mint activo)",
|
|
35
|
+
CTL_FREEZE_ACTIVE: () => "El creador puede congelar cuentas (freeze activo)",
|
|
36
|
+
CTL_TRANSFER_HOOK: () => "Ejecuta código externo en cada transferencia",
|
|
37
|
+
CTL_TRANSFER_FEE: () => "Cobra una comisión en cada transferencia",
|
|
38
|
+
CTL_NON_TRANSFERABLE: () => "No se puede transferir",
|
|
39
|
+
CTL_DEFAULT_FROZEN: () => "Las cuentas nuevas pueden crearse congeladas",
|
|
40
|
+
CTL_ONLY_PROGRAMS: () => "Solo hay autoridades controladas por un programa (ver dependencia)",
|
|
41
|
+
CTL_KNOWN_ISSUER: (d) => "Lo controla su emisor, " + d.issuer + " (ver dependencia)",
|
|
42
|
+
CTL_NONE: () => "Sin autoridades activas: nadie puede crear más ni congelar",
|
|
43
|
+
CTL_SERIAL_CREATOR: (d) => "El creador ha lanzado " + d.n + " tokens más en las últimas 24 h (según RugCheck): es un lanzador en serie, que suele abandonar cada token en cuanto llegan compradores",
|
|
44
44
|
CTL_SERIAL_PAYER: (d) => "La wallet que pagó este lanzamiento ha lanzado " + d.n + " tokens más en las últimas 24 h (contado en la cadena): es un lanzador en serie, que suele abandonar cada token en cuanto llegan compradores",
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
45
|
+
MAP_GROUP: (d) => d.n + " holders recibieron su primer SOL de la misma wallet y juntos tienen el " + pct(d.pct) + " del suministro: probablemente son la misma persona o equipo",
|
|
46
|
+
MAP_SWARM: (d) => d.n + " de los " + d.of + " mayores holders recibieron su primer SOL de la misma wallet (juntos tienen el " + pct(d.pct) + "): tantas wallets con el mismo origen suelen ser un reparto del equipo",
|
|
47
|
+
MAP_HUB: (d) => "Una wallet ha repartido tokens a " + d.n + " wallets: el equipo suele dividir el suministro así para parecer más repartido",
|
|
48
|
+
MAP_WHALE: (d) => "Una sola persona (que no es un exchange ni un pool) tiene el " + pct(d.pct) + " del suministro",
|
|
49
|
+
BRAND_COPY: (d) => "Usa el nombre de " + d.brand + ", una empresa real que no tiene token en Solana: no es oficial, casi seguro una imitación para atraer compradores",
|
|
50
|
+
BRAND_NAME: (d) => "Usa el nombre de " + d.brand + ", una empresa real: no es un token oficial de " + d.brand,
|
|
51
|
+
COPYCAT: (d) => "Hay " + (d.n === 1 ? "otro token" : d.n + " tokens más") + " con el mismo nombre y ticker; el más antiguo con mercado real (" + short(d.original) + ", de hace " + d.days + (d.days === 1 ? " día" : " días") + ") no es este: comprueba que tienes la dirección correcta",
|
|
52
|
+
HOLD_GROUP: (d) => d.n + " holders recibieron su primer SOL de la misma wallet y juntos tienen el " + pct(d.pct) + " del suministro: probablemente son la misma persona o equipo",
|
|
53
|
+
CTL_CREATOR_HISTORY: (d) => "De los " + d.old + " tokens que el creador lanzó antes (hace más de 24 h), " + d.dead + " se quedaron por debajo de 10.000 $ de capitalización (según RugCheck): sus lanzamientos no suelen despegar",
|
|
54
|
+
IMPOSTOR: (d) => "No es el " + d.symbol + " original. Comprueba que es el token que buscas",
|
|
55
|
+
|
|
56
|
+
CON_SKIPPED: () => "Sin comprobar la concentración de holders",
|
|
57
|
+
CON_UNAVAILABLE: () => "No se pudo comprobar la concentración de holders (el servicio no respondió; prueba otra vez en un rato)",
|
|
58
|
+
CON_ALL_POOLS: (d) => "Casi todo el supply está en pools o programas" + prog(d),
|
|
59
|
+
CON_OK: (d) => "Sin concentración preocupante (mayor wallet individual: " + pct(d.w1) + ")" + prog(d),
|
|
60
|
+
CON_TRUSTED: (d) => "No cuenta: en un token de " + d.issuer + " los grandes holders son su tesorería, custodios, exchanges y protocolos",
|
|
61
|
+
CON_ISSUER: (d) => "La mayor wallet tiene el " + pct(d.w1) + " y las 10 mayores el " + pct(d.w10) + ": con un emisor verificado suelen ser su tesorería, custodios, exchanges o protocolos, no cuenta como riesgo" + prog(d),
|
|
62
|
+
CON_HIGH: (d) => "La mayor wallet individual tiene el " + pct(d.w1) + " y las 10 mayores el " + pct(d.w10) + " del supply" + prog(d),
|
|
63
|
+
CON_UNSPLIT: (d) => "No se pudo separar pools de personas. La mayor cuenta tiene el " + pct(d.top1) + " del supply",
|
|
64
|
+
|
|
65
|
+
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" : ""),
|
|
66
|
+
MKT_LIQ_VERY_LOW: (d) => "Liquidez muy baja (" + usd(d.liq) + ")",
|
|
67
|
+
MKT_LIQ_LOW: (d) => "Liquidez baja (" + usd(d.liq) + ")",
|
|
68
|
+
MKT_VOLUME_LOW: (d) => "Volumen de 24 h casi nulo (" + usd(d.vol) + ")",
|
|
69
|
+
MKT_NEW: (d) => "Mercado muy nuevo (" + (d.days < 1 ? "menos de un día" : d.days + (d.days === 1 ? " día" : " días")) + ")",
|
|
70
|
+
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",
|
|
71
|
+
MKT_LP_UNLOCKED: (d) => "Solo el " + pct(d.pct) + " de la liquidez está bloqueada o quemada (según RugCheck): el resto se puede retirar de golpe",
|
|
72
|
+
MKT_LP_PARTLY_LOCKED: (d) => "Solo el " + pct(d.pct) + " de la liquidez está bloqueada o quemada (según RugCheck)",
|
|
73
|
+
MKT_OK: (d) => "Liquidez " + usd(d.liq) + " · volumen 24 h " + usd(d.vol),
|
|
74
|
+
|
|
75
|
+
DEP_PROGRAM_AUTHORITY: () => "Un programa controla el mint o el freeze (puente o protocolo): hay que confiar en su código",
|
|
76
|
+
DEP_PERMANENT_DELEGATE: () => "El emisor puede mover o quemar tus tokens (delegado permanente): confías en el emisor",
|
|
77
|
+
DEP_STABLE_ISSUER: () => "Su valor depende de quien la emite y la respalda",
|
|
78
|
+
DEP_TRUSTED_ISSUER: (d) => "Lo emite " + d.issuer + ", un emisor regulado de los pocos que SolFlag considera de confianza. Como cualquier emisor, puede congelar o retirar tokens por orden legal",
|
|
79
|
+
DEP_KNOWN_ISSUER: (d) => "Lo emite " + d.issuer + ": puede crear, congelar o mover tokens, como cualquier emisor regulado. Confías en el emisor",
|
|
80
|
+
DEP_NONE: () => "No depende de un emisor ni de un puente"
|
|
81
|
+
},
|
|
82
|
+
offSolana: " y su mercado principal puede estar fuera de Solana",
|
|
83
|
+
levels: {
|
|
84
|
+
HIGH: "Riesgo alto", MEDIUM: "Riesgo medio", LOW: "Riesgo bajo", SPAM: "Probable spam",
|
|
85
|
+
NO_DATA: "Sin comprobar", NO_MARKET: "Sin mercado", MEDIUM_DATA_ONLY: "Medio por falta de datos"
|
|
86
|
+
},
|
|
87
|
+
types: {
|
|
88
|
+
STABLE: { label: "Stablecoin", note: "Se juzga por su liquidez y por la confianza en quien la emite; la concentración pesa menos." },
|
|
89
|
+
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." },
|
|
90
|
+
BRIDGED: { label: "Puenteado o de protocolo", note: "Lo normal es que un programa controle el mint. El riesgo real es confiar en ese puente y que su mercado en Solana sea pequeño, porque el principal puede estar en otra red." },
|
|
91
|
+
CREATOR: { label: "Con control del creador", note: "Una wallet puede crear más tokens o congelar cuentas: es el patrón típico de estafa, así que se juzga con más dureza." },
|
|
92
|
+
OPEN: { label: "Token abierto", note: "Sin autoridades del creador, típico de memecoins y proyectos nuevos. Pesan sobre todo la concentración en personas y la liquidez." }
|
|
93
|
+
},
|
|
94
|
+
lights: { control: "Control del creador", concentration: "Concentración", market: "Mercado y salida", dependency: "Dependencia" },
|
|
95
|
+
missing: { control: "quién controla el token", concentration: "la concentración de holders", market: "el mercado", dependency: "la dependencia de un emisor" },
|
|
96
|
+
steps: {
|
|
97
|
+
address: "Comprobando la dirección…", wallet: "Leyendo la wallet…", markets: "Consultando precios y liquidez…",
|
|
98
|
+
tokens: "Revisando tokens…", token: "Leyendo el token…", owners: "Buscando a quién pertenece cada cuenta…",
|
|
99
|
+
kinds: "Distinguiendo wallets de pools y programas…", bots: "Separando personas de bots y exchanges…",
|
|
100
|
+
funders: "Buscando wallets con el mismo origen de fondos…", exchangeSources: "Comprobando si el origen de cada grupo es un exchange…",
|
|
101
|
+
creator: "Mirando quién creó el token (RugCheck)…", creatorTokens: "Revisando otros tokens del creador…",
|
|
102
|
+
networks: "Comprobando cuánto tienen hoy las redes de wallets…", wallets: "Leyendo wallets…",
|
|
103
|
+
pnl: "Estimando el resultado de cada wallet…", done: "Listo"
|
|
104
|
+
},
|
|
105
|
+
notes: {
|
|
106
|
+
PNL_NO_HELIUS: "No se estimó el resultado de las wallets porque falta una clave de Helius.",
|
|
107
|
+
PNL_PARTIAL: "No se pudo leer el historial de algunas wallets.",
|
|
108
|
+
PNL_APPROX: "No se pudo obtener el histórico de precio de SOL: se usó el precio de hoy y los resultados pueden estar muy alejados de la realidad."
|
|
109
|
+
},
|
|
110
|
+
errors: {
|
|
111
|
+
CANCELLED: () => "Cancelado.",
|
|
112
|
+
INVALID_ADDRESS: () => "Esa dirección no parece de Solana. Son de 32 a 44 letras y números y no empiezan por 0x.",
|
|
113
|
+
NOT_A_TOKEN: () => "Esa dirección no es un token.",
|
|
114
|
+
IS_NFT: () => "Esa dirección es un NFT, no un token. El escáner no revisa NFTs.",
|
|
115
|
+
NO_HOLDERS: () => "El RPC no devolvió datos de holders.",
|
|
116
|
+
HELIUS_REQUIRED: () => "Para estimar el resultado hace falta una clave de Helius (o una URL de RPC de Helius con la clave).",
|
|
117
|
+
SOL_PRICE: () => "No se pudo obtener el precio de SOL para calcular el resultado. Prueba otra vez dentro de un rato.",
|
|
118
|
+
DEX_UNREACHABLE: () => "No se pudo conectar con DexScreener. Revisa tu conexión a internet y prueba otra vez.",
|
|
119
|
+
TOO_FEW_WALLETS: (d) => d && d.filter ? "Solo " + d.n + (d.n === 1 ? " wallet cumple" : " wallets cumplen") + " el filtro de resultado (de " + d.total + " leídas)." : "Hacen falta al menos 2 wallets que se puedan leer.",
|
|
120
|
+
TOO_FEW_TOKENS: () => "Pega al menos 2 direcciones de tokens de Solana.",
|
|
121
|
+
NETWORK_PUBLIC: () => "Los servicios gratuitos de Solana no han respondido (a veces se saturan). Espera un minuto y prueba otra vez, o usa tu propia URL de RPC (Helius tiene plan gratuito).",
|
|
122
|
+
NETWORK_OWN: () => "No se pudo conectar con tu URL de RPC. Revisa que esté bien copiada (con la clave al final).",
|
|
123
|
+
UNKNOWN: (d) => "Algo ha fallado: " + d.message + ". Prueba otra vez o usa otro RPC."
|
|
124
|
+
}
|
|
125
|
+
};
|
package/src/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { takeSnapshots } from "./changes.js";
|
|
|
6
6
|
import { confluence, commonHolders } from "./confluence.js";
|
|
7
7
|
import { getTokens } from "./tokens.js";
|
|
8
8
|
import { loadWalletBase } from "./base.js";
|
|
9
|
+
import { connectionMap } from "./map.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* The easy entry point: one object with every high-level analysis bound to one network client.
|
|
@@ -24,6 +25,7 @@ export function createScanner(opts) {
|
|
|
24
25
|
analyzeWallet: (wallet, o) => analyzeWallet(client, wallet, o),
|
|
25
26
|
analyzeAddress: (addr, o) => analyzeAddress(client, addr, o),
|
|
26
27
|
analyzeHolders: (mint, o) => analyzeHolders(client, mint, o),
|
|
28
|
+
connectionMap: (mint, o) => connectionMap(client, mint, o),
|
|
27
29
|
estimatePnl: async (wallets, o) => {
|
|
28
30
|
// Current balances trim tokens the wallet moved away; read them if the caller did not pass them
|
|
29
31
|
o = o || {};
|
|
@@ -52,7 +54,9 @@ export { score, issuerOf, trustedIssuer, tokenType, buildLights, levelFrom, data
|
|
|
52
54
|
export { recentLaunches, chainLaunches } from "./launch.js";
|
|
53
55
|
export { analyzeToken, analyzeWallet, analyzeAddress, sortResults } from "./wallet.js";
|
|
54
56
|
export { holderBase, markBusy, onlyReceives, PASSIVE_SAMPLE, findFunder, findFunders, clusterByFunder, holderRows, creatorInfo, analyzeHolders,
|
|
55
|
-
perHour, sourceRates, groupList, EXCHANGE_PER_HOUR, YOUNG_DAYS, HOLD_GROUP_YOUNG, HOLD_GROUP_MATURE } from "./holders.js";
|
|
57
|
+
perHour, sourceRates, groupList, EXCHANGE_PER_HOUR, RATE_MIN_SIGS, YOUNG_DAYS, HOLD_GROUP_YOUNG, HOLD_GROUP_MATURE } from "./holders.js";
|
|
58
|
+
export { connectionMap, allHolders, transferNetworks, topHub, mapGroups, mapSignals, walletType,
|
|
59
|
+
BOT_PER_HOUR, mapType, MAP_GROUP_YOUNG, MAP_GROUP_MATURE, MAP_HUB, MAP_WHALE, MAP_SWARM, MAP_MAX_FREE, MAP_MAX_OWN } from "./map.js";
|
|
56
60
|
export { fetchSwaps, solHistory, priceSeries, parseTrades, pnlFromTrades, pnlStatus, estimatePnl } from "./pnl.js";
|
|
57
61
|
export { capSnap, chgDiff, chgAgg, takeSnapshots, diffSnapshots } from "./changes.js";
|
|
58
62
|
export { confluence, commonHolders } from "./confluence.js";
|
package/src/map.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { ADDRESS_RE, TOKEN_PROGRAM, TOKEN_2022, RUGCHECK } from "./constants.js";
|
|
2
|
+
import { ScanError, isCancel } from "./errors.js";
|
|
3
|
+
import { pool, progress, uniq } from "./util.js";
|
|
4
|
+
import { holderBase, EXCHANGE_PER_HOUR, perHour, sourceRates, onlyReceives } from "./holders.js";
|
|
5
|
+
export { EXCHANGE_PER_HOUR, perHour, sourceRates };
|
|
6
|
+
import { accountKinds } from "./tokens.js";
|
|
7
|
+
import { rugcheckReport } from "./rugcheck.js";
|
|
8
|
+
|
|
9
|
+
/* ---------- connection map ----------
|
|
10
|
+
Everything around a token at once: its largest holders, what kind of wallet each one is, who gave each
|
|
11
|
+
one its first SOL (holders sharing that source are probably one owner), and the token-transfer networks
|
|
12
|
+
RugCheck keeps (one wallet handing tokens to many). Young tokens (under 14 days) are read for the team's
|
|
13
|
+
split; mature ones for what stayed hidden, with exchanges and pools set aside. */
|
|
14
|
+
|
|
15
|
+
// Same rule as markBusy: 200 transactions within 2 days is a bot or trader, not a holder sitting on tokens
|
|
16
|
+
export const BOT_PER_HOUR = 200 / 48;
|
|
17
|
+
export const YOUNG_DAYS = 14;
|
|
18
|
+
export const MAP_GROUP_YOUNG = 10, MAP_GROUP_MATURE = 15, MAP_HUB = 20, MAP_WHALE = 10;
|
|
19
|
+
// Many holders funded by one wallet warn whatever they hold together: with only the top 20 read the share
|
|
20
|
+
// is cut short (1/11, Leverhedge: 19 of the top 20 with 0.4% each from one source, 8.1% in view)
|
|
21
|
+
export const MAP_SWARM = 10;
|
|
22
|
+
export const MAP_MAX_FREE = 20, MAP_MAX_OWN = 75;
|
|
23
|
+
|
|
24
|
+
const B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
25
|
+
function b58encode(bytes) {
|
|
26
|
+
let n = 0n;
|
|
27
|
+
for (const b of bytes) n = n * 256n + BigInt(b);
|
|
28
|
+
let s = "";
|
|
29
|
+
while (n > 0n) { s = B58[Number(n % 58n)] + s; n /= 58n; }
|
|
30
|
+
for (const b of bytes) { if (b !== 0) break; s = "1" + s; }
|
|
31
|
+
return s;
|
|
32
|
+
}
|
|
33
|
+
function b64bytes(s) {
|
|
34
|
+
if (typeof atob === "function") { const t = atob(s), out = new Uint8Array(t.length); for (let i = 0; i < t.length; i++) out[i] = t.charCodeAt(i); return out; }
|
|
35
|
+
return Uint8Array.from(Buffer.from(s, "base64"));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
// person | bot | exchange | pool
|
|
40
|
+
export function walletType(kind, rate) {
|
|
41
|
+
if (kind === "program") return "pool";
|
|
42
|
+
if (rate > EXCHANGE_PER_HOUR) return "exchange";
|
|
43
|
+
if (rate > BOT_PER_HOUR || kind === "active") return "bot";
|
|
44
|
+
return "person";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// walletType, but a busy wallet that signed none of the sampled transactions only RECEIVES (fee shares,
|
|
48
|
+
// airdrops, dust): it is a person who gets paid, not a bot or an exchange (same rule as markBusy, 0.4.7).
|
|
49
|
+
// Returns { type, passive }.
|
|
50
|
+
export async function mapType(client, addr, kind, rate, sigs) {
|
|
51
|
+
const type = walletType(kind, rate);
|
|
52
|
+
if ((type === "bot" || type === "exchange") && kind !== "active" && sigs && sigs.length >= 2 &&
|
|
53
|
+
await onlyReceives(client, addr, sigs)) return { type: "person", passive: true };
|
|
54
|
+
return { type: type, passive: false };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Every token account of the mint (own RPC only), summed by owner, largest first. Reads just the owner
|
|
58
|
+
// and amount of each account. Returns null when the RPC refuses or the token is too big to list.
|
|
59
|
+
export async function allHolders(client, mint, program, max) {
|
|
60
|
+
const filters = [{ memcmp: { offset: 0, bytes: mint } }];
|
|
61
|
+
if (program === TOKEN_PROGRAM) filters.push({ dataSize: 165 });
|
|
62
|
+
let res;
|
|
63
|
+
try { res = await client.rpc("getProgramAccounts", [program, { encoding: "base64", dataSlice: { offset: 32, length: 40 }, filters: filters }]); }
|
|
64
|
+
catch (e) { if (isCancel(e)) throw e; return null; }
|
|
65
|
+
if (!Array.isArray(res)) return null;
|
|
66
|
+
const by = {};
|
|
67
|
+
res.forEach(function (a) {
|
|
68
|
+
const d = a && a.account && a.account.data;
|
|
69
|
+
const raw = d && b64bytes(Array.isArray(d) ? d[0] : d);
|
|
70
|
+
if (!raw || raw.length < 40) return;
|
|
71
|
+
const owner = b58encode(raw.slice(0, 32));
|
|
72
|
+
let amt = 0n;
|
|
73
|
+
for (let i = 39; i >= 32; i--) amt = amt * 256n + BigInt(raw[i]);
|
|
74
|
+
if (amt > 0n) by[owner] = (by[owner] || 0n) + amt;
|
|
75
|
+
});
|
|
76
|
+
return Object.keys(by).sort(function (a, b) { return by[b] > by[a] ? 1 : by[b] < by[a] ? -1 : 0; })
|
|
77
|
+
.slice(0, max).map(function (o) { return { owner: o, raw: Number(by[o]) }; });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Up to 3 pages of signatures: the oldest one and the newest page (for the rate). first = null when the
|
|
81
|
+
// wallet has more than 3000 (its first transaction is too far back to find cheaply).
|
|
82
|
+
async function history(client, addr, pages) {
|
|
83
|
+
let before = null, first = null, top = null;
|
|
84
|
+
for (let i = 0; i < pages; i++) {
|
|
85
|
+
const page = await client.rpc("getSignaturesForAddress", [addr, before ? { limit: 1000, before: before } : { limit: 1000 }]);
|
|
86
|
+
if (!page || !page.length) break;
|
|
87
|
+
if (!top) top = page;
|
|
88
|
+
if (page.length < 1000) { first = page[page.length - 1].signature; break; }
|
|
89
|
+
before = page[page.length - 1].signature;
|
|
90
|
+
}
|
|
91
|
+
return { rate: perHour(top), n: top ? top.length : 0, first: first, top: top };
|
|
92
|
+
}
|
|
93
|
+
// Fee payer (account 0) of a transaction
|
|
94
|
+
async function payerOf(client, sig) {
|
|
95
|
+
let tx;
|
|
96
|
+
try { tx = await client.rpc("getTransaction", [sig, { maxSupportedTransactionVersion: 1, encoding: "jsonParsed" }]); }
|
|
97
|
+
catch (e) {
|
|
98
|
+
if (isCancel(e) || !/version|invalid param/i.test(e.message || "")) throw e;
|
|
99
|
+
tx = await client.rpc("getTransaction", [sig, { maxSupportedTransactionVersion: 0, encoding: "jsonParsed" }]);
|
|
100
|
+
}
|
|
101
|
+
const keys = tx && tx.transaction && tx.transaction.message && tx.transaction.message.accountKeys;
|
|
102
|
+
const k = keys && keys[0];
|
|
103
|
+
return k ? (k.pubkey !== undefined ? k.pubkey : k) : null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
// RugCheck's token-transfer networks with their links (who handed tokens to whom)
|
|
108
|
+
export async function transferNetworks(client, mint, supply) {
|
|
109
|
+
const g = await client.softJson(RUGCHECK + mint + "/insiders/graph", 8000);
|
|
110
|
+
if (!Array.isArray(g)) return [];
|
|
111
|
+
return g.map(function (n) {
|
|
112
|
+
const nodes = (n.nodes || []).filter(function (x) { return x && ADDRESS_RE.test(x.id || ""); })
|
|
113
|
+
.map(function (x) { return { addr: x.id, pct: supply > 0 ? Number(x.holdings || 0) / supply * 100 : 0 }; });
|
|
114
|
+
const links = (n.links || []).filter(function (l) { return l && l.source && l.target; }).map(function (l) { return [l.source, l.target]; });
|
|
115
|
+
return { type: n.network_type || "transfer", nodes: nodes, links: links };
|
|
116
|
+
}).filter(function (n) { return n.nodes.length > 1; }).sort(function (a, b) { return b.nodes.length - a.nodes.length; });
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Wallet in the networks that handed tokens to the most others
|
|
120
|
+
export function topHub(nets) {
|
|
121
|
+
let best = null;
|
|
122
|
+
nets.forEach(function (n) {
|
|
123
|
+
const out = {};
|
|
124
|
+
n.links.forEach(function (l) { out[l[0]] = (out[l[0]] || 0) + 1; });
|
|
125
|
+
Object.keys(out).forEach(function (a) { if (!best || out[a] > best.out) best = { addr: a, out: out[a] }; });
|
|
126
|
+
});
|
|
127
|
+
return best;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Groups: sources that gave the first SOL to 2+ holders and are not exchanges. In mature tokens only
|
|
131
|
+
// people count (bots there are traders who came later, not the team's split).
|
|
132
|
+
export function mapGroups(holders, sources, mode) {
|
|
133
|
+
const by = {};
|
|
134
|
+
holders.forEach(function (h) {
|
|
135
|
+
if (!h.funder) return;
|
|
136
|
+
if (mode === "mature" && h.type !== "person") return;
|
|
137
|
+
const s = sources[h.funder];
|
|
138
|
+
if (!s || s.type === "exchange") return;
|
|
139
|
+
(by[h.funder] = by[h.funder] || []).push(h);
|
|
140
|
+
});
|
|
141
|
+
const LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
142
|
+
return Object.keys(by).filter(function (f) { return by[f].length >= 2; }).map(function (f) {
|
|
143
|
+
return { funder: f, members: by[f].map(function (h) { return h.addr; }), pct: by[f].reduce(function (s, h) { return s + h.pct; }, 0), rate: sources[f].rate };
|
|
144
|
+
}).sort(function (a, b) { return b.pct - a.pct; }).map(function (g, i) { g.id = LETTERS[i] || "G" + i; return g; });
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function mapSignals(m) {
|
|
148
|
+
const out = [], young = m.mode === "young", big = m.groups[0];
|
|
149
|
+
const gLimit = young ? MAP_GROUP_YOUNG : MAP_GROUP_MATURE;
|
|
150
|
+
const grouped = big && big.pct > gLimit;
|
|
151
|
+
if (grouped) out.push({ code: "MAP_GROUP", s: young ? "bad" : "warn", data: { n: big.members.length, pct: big.pct, funder: big.funder } });
|
|
152
|
+
// the group with most wallets, unless it is the one MAP_GROUP already named
|
|
153
|
+
const many = m.groups.slice().sort(function (a, b) { return b.members.length - a.members.length || b.pct - a.pct; })[0];
|
|
154
|
+
if (many && many.members.length >= MAP_SWARM && !(grouped && many === big))
|
|
155
|
+
out.push({ code: "MAP_SWARM", s: young ? "bad" : "warn", data: { n: many.members.length, of: (m.holders || []).length, pct: many.pct, funder: many.funder } });
|
|
156
|
+
if (young && m.hub && m.hub.out >= MAP_HUB) out.push({ code: "MAP_HUB", s: "bad", data: { n: m.hub.out, addr: m.hub.addr } });
|
|
157
|
+
if (!young) {
|
|
158
|
+
const w = m.holders.filter(function (h) { return h.type === "person" && h.pct > MAP_WHALE; }).sort(function (a, b) { return b.pct - a.pct; })[0];
|
|
159
|
+
if (w) out.push({ code: "MAP_WHALE", s: "warn", data: { pct: w.pct, addr: w.addr } });
|
|
160
|
+
}
|
|
161
|
+
return out;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Connection map of a token.
|
|
166
|
+
* @param [opts.createdAt] ms when its market started (DexScreener pairCreatedAt); without it RugCheck's detectedAt
|
|
167
|
+
* @param [opts.max] holders to read (default 20, or 75 with your own RPC)
|
|
168
|
+
* @param [opts.now]
|
|
169
|
+
* @returns {mint, mode, ageDays, supply, holders: [{addr, pct, type, rate, funder}], sources: {addr: {rate, type, n}},
|
|
170
|
+
* groups, nets, hub, creator, payer, signals}
|
|
171
|
+
*/
|
|
172
|
+
export async function connectionMap(client, mint, opts) {
|
|
173
|
+
opts = opts || {};
|
|
174
|
+
const onProgress = opts.onProgress, now = opts.now || Date.now();
|
|
175
|
+
if (!ADDRESS_RE.test(mint || "")) throw new ScanError("INVALID_ADDRESS", "not a Solana address");
|
|
176
|
+
const own = client.ownRpc(), max = opts.max || (own ? MAP_MAX_OWN : MAP_MAX_FREE);
|
|
177
|
+
|
|
178
|
+
// 1) holders: with your own RPC, every account of the token (up to max); otherwise the RPC's top 20
|
|
179
|
+
const b = await holderBase(client, mint, onProgress);
|
|
180
|
+
const supply = Number(b.info.supply) || 0;
|
|
181
|
+
let rows = null;
|
|
182
|
+
if (own && max > 20) {
|
|
183
|
+
const prog = b.info.program === TOKEN_2022 ? TOKEN_2022 : TOKEN_PROGRAM;
|
|
184
|
+
rows = await allHolders(client, mint, prog, max);
|
|
185
|
+
}
|
|
186
|
+
let kind = b.kind;
|
|
187
|
+
if (rows && rows.length) {
|
|
188
|
+
const missing = rows.map(function (r) { return r.owner; }).filter(function (o) { return !kind[o]; });
|
|
189
|
+
if (missing.length) kind = Object.assign({}, kind, await accountKinds(client, missing, true));
|
|
190
|
+
} else {
|
|
191
|
+
const agg = {};
|
|
192
|
+
b.largest.forEach(function (a, i) { const o = b.owners[i] || a.address; agg[o] = (agg[o] || 0) + Number(a.amount); });
|
|
193
|
+
rows = Object.keys(agg).map(function (o) { return { owner: o, raw: agg[o] }; }).sort(function (x, y) { return y.raw - x.raw; });
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 2) age and mode
|
|
197
|
+
const rc = await rugcheckReport(client, mint);
|
|
198
|
+
const created = opts.createdAt || (rc && rc.detectedAt ? Date.parse(rc.detectedAt) : null);
|
|
199
|
+
const ageDays = created ? (now - created) / 86400000 : null;
|
|
200
|
+
const mode = ageDays !== null && ageDays < YOUNG_DAYS ? "young" : "mature";
|
|
201
|
+
|
|
202
|
+
// 3) each holder: how busy it is and who paid its first transaction
|
|
203
|
+
const holders = rows.map(function (r) { return { addr: r.owner, pct: supply > 0 ? r.raw / supply * 100 : 0, kind: kind[r.owner] || "program" }; });
|
|
204
|
+
let done = 0;
|
|
205
|
+
await pool(holders, 3, async function (h) {
|
|
206
|
+
try {
|
|
207
|
+
if (h.kind !== "program") {
|
|
208
|
+
const hs = await history(client, h.addr, mode === "young" ? 3 : 1);
|
|
209
|
+
h.rate = hs.rate;
|
|
210
|
+
const t = await mapType(client, h.addr, h.kind, hs.rate, hs.top);
|
|
211
|
+
h.type = t.type; if (t.passive) h.passive = true;
|
|
212
|
+
// in mature tokens only people are traced; exchanges never (they would join strangers)
|
|
213
|
+
let first = hs.first;
|
|
214
|
+
if (!first && mode === "mature" && h.type === "person" && hs.n >= 1000) first = (await history(client, h.addr, 3)).first;
|
|
215
|
+
if (first && h.type !== "exchange" && (mode === "young" || h.type === "person")) {
|
|
216
|
+
const p = await payerOf(client, first);
|
|
217
|
+
if (p && p !== h.addr) h.funder = p;
|
|
218
|
+
}
|
|
219
|
+
} else { h.type = "pool"; h.rate = 0; }
|
|
220
|
+
} catch (e) { if (isCancel(e)) throw e; h.type = h.type || walletType(h.kind, 0); }
|
|
221
|
+
delete h.kind;
|
|
222
|
+
done++; progress(onProgress, "funders", 0.45 + 0.35 * done / holders.length, { done: done, total: holders.length });
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// 4) the sources: exchanges or not
|
|
226
|
+
const srcList = uniq(holders.map(function (h) { return h.funder; }).filter(Boolean));
|
|
227
|
+
const rates = await sourceRates(client, srcList, function (c, n) { progress(onProgress, "exchangeSources", 0.8 + 0.08 * c / Math.max(1, n), { done: c, total: n }); });
|
|
228
|
+
const sources = {};
|
|
229
|
+
srcList.forEach(function (s) {
|
|
230
|
+
sources[s] = { rate: rates[s] || 0, type: (rates[s] || 0) > EXCHANGE_PER_HOUR ? "exchange" : "person",
|
|
231
|
+
n: holders.filter(function (h) { return h.funder === s; }).length };
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// 5) transfer networks, creator and who paid the launch (young tokens)
|
|
235
|
+
progress(onProgress, "networks", 0.9);
|
|
236
|
+
const nets = await transferNetworks(client, mint, supply);
|
|
237
|
+
let payer = null;
|
|
238
|
+
if (mode === "young") {
|
|
239
|
+
try { const mh = await history(client, mint, 3); if (mh.first) payer = await payerOf(client, mh.first); }
|
|
240
|
+
catch (e) { if (isCancel(e)) throw e; }
|
|
241
|
+
}
|
|
242
|
+
const m = {
|
|
243
|
+
mint: mint, mode: mode, ageDays: ageDays, supply: supply, holders: holders, sources: sources,
|
|
244
|
+
groups: mapGroups(holders, sources, mode), nets: nets, hub: topHub(nets),
|
|
245
|
+
creator: (rc && rc.creator) || null, payer: payer
|
|
246
|
+
};
|
|
247
|
+
m.signals = mapSignals(m);
|
|
248
|
+
progress(onProgress, "done", 1);
|
|
249
|
+
return m;
|
|
250
|
+
}
|
package/src/tokens.js
CHANGED
|
@@ -48,7 +48,8 @@ export async function getMint(client, mint) {
|
|
|
48
48
|
// transfer fee in basis points (the higher of the current and the scheduled one); null when not set
|
|
49
49
|
feeBps: feeBps(state("transferFeeConfig")),
|
|
50
50
|
// every key that controls something in the extensions (delegate, hook, pause, metadata...)
|
|
51
|
-
extKeys: extKeys(exts)
|
|
51
|
+
extKeys: extKeys(exts),
|
|
52
|
+
program: r.value.owner || null
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -114,7 +115,7 @@ export async function getConc(client, mint, supply) {
|
|
|
114
115
|
return x && x.data && x.data.parsed && x.data.parsed.info && x.data.parsed.info.owner || null;
|
|
115
116
|
});
|
|
116
117
|
if (owners.some(function (o) { return !o; })) return out;
|
|
117
|
-
const kind = await accountKinds(client, uniq(owners),
|
|
118
|
+
const kind = await accountKinds(client, uniq(owners), true); // emptied wallets (0 SOL) still count
|
|
118
119
|
const agg = {};
|
|
119
120
|
owners.forEach(function (o, i) { agg[o] = (agg[o] || 0) + amts[i]; });
|
|
120
121
|
const ws = [];
|