solana-risk-engine 0.7.0 → 0.7.2
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/package.json +1 -1
- package/src/constants.js +3 -0
- package/src/markets.js +46 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solana-risk-engine",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
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/constants.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
export const PUBLIC_RPC = "https://solana-rpc.publicnode.com";
|
|
6
6
|
export const VIBE_RPC = "https://public.rpc.solanavibestation.com";
|
|
7
7
|
export const DEX = "https://api.dexscreener.com/tokens/v1/solana/";
|
|
8
|
+
// All pools of ONE token (up to 30). tokens/v1 returns a single pool per token, not always the deepest
|
|
9
|
+
// (22/11/2026: WIF showed an $87k Orca pool while its Raydium pool had $3.6M)
|
|
10
|
+
export const DEX_PAIRS = "https://api.dexscreener.com/token-pairs/v1/solana/";
|
|
8
11
|
// SolFlag's wallet base (see base.js)
|
|
9
12
|
export const WALLET_BASE_URL = "https://solflag.com/datos/base.json";
|
|
10
13
|
export const DEX_SEARCH = "https://api.dexscreener.com/latest/dex/search?q=";
|
package/src/markets.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEX, DEX_SEARCH, GECKO, USDC, USDT, WSOL, FAMOUS, BRANDS, brandKey, BRAND_MATURE_DAYS, BRAND_MATURE_LIQ, COPY_MIN_LIQ } from "./constants.js";
|
|
1
|
+
import { DEX, DEX_PAIRS, DEX_SEARCH, GECKO, USDC, USDT, WSOL, FAMOUS, BRANDS, brandKey, BRAND_MATURE_DAYS, BRAND_MATURE_LIQ, COPY_MIN_LIQ } from "./constants.js";
|
|
2
2
|
import { ScanError, isCancel } from "./errors.js";
|
|
3
3
|
import { sleep } from "./util.js";
|
|
4
4
|
|
|
@@ -83,9 +83,53 @@ export async function copiesOf(client, mint, pair, now) {
|
|
|
83
83
|
return { n: others.length, original: oldest.addr, days: Math.floor(((now || Date.now()) - oldest.at) / 86400000), origLiq: oldest.liq, liq: mine.liq };
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
//
|
|
86
|
+
// Up to this many tokens, each one gets its own request for all its pools (token-pairs/v1, 4 at a time).
|
|
87
|
+
// The batch request (tokens/v1) returns a single pool per token, not always the deepest: measured
|
|
88
|
+
// 22/11/2026 on 99 tokens, 15 came out with a much smaller pool (RUSH $0.6M instead of $42M).
|
|
89
|
+
// Bigger lists (a wallet with hundreds of tokens) stay on the batch request to respect DexScreener's limits.
|
|
90
|
+
export const PAIRS_MAX = 30;
|
|
91
|
+
|
|
92
|
+
// Best (most liquid) DexScreener pair per mint.
|
|
87
93
|
// `failed` lists mints whose batch failed: unknown, which is not the same as "no market".
|
|
88
94
|
export async function getMarkets(client, mints, onStep) {
|
|
95
|
+
const best = {};
|
|
96
|
+
let failed = [];
|
|
97
|
+
const keep = function (m, p) {
|
|
98
|
+
realLiq(p);
|
|
99
|
+
const liq = (p.liquidity && p.liquidity.usd) || 0;
|
|
100
|
+
const cur = best[m] && best[m].liquidity && best[m].liquidity.usd || 0;
|
|
101
|
+
if (!best[m] || liq > cur) best[m] = p;
|
|
102
|
+
};
|
|
103
|
+
if (mints.length <= PAIRS_MAX) {
|
|
104
|
+
let next = 0, done = 0;
|
|
105
|
+
const worker = async function () {
|
|
106
|
+
while (next < mints.length) {
|
|
107
|
+
const m = mints[next++];
|
|
108
|
+
try {
|
|
109
|
+
const pares = await client.jfetch(DEX_PAIRS + m);
|
|
110
|
+
if (Array.isArray(pares)) pares.forEach(function (p) {
|
|
111
|
+
if (p && p.baseToken && p.baseToken.address === m && (!p.chainId || p.chainId === "solana")) keep(m, p);
|
|
112
|
+
});
|
|
113
|
+
} catch (e) { if (isCancel(e)) throw e; }
|
|
114
|
+
done++;
|
|
115
|
+
if (onStep && done < mints.length) onStep(done, mints.length);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
await Promise.all([worker(), worker(), worker(), worker()].slice(0, Math.min(4, mints.length)));
|
|
119
|
+
// what got no answer (or no market) goes once more through the batch request
|
|
120
|
+
const rest = mints.filter(function (m) { return !best[m]; });
|
|
121
|
+
if (!rest.length) { if (onStep && mints.length) onStep(mints.length, mints.length); return { data: best, failed: failed }; }
|
|
122
|
+
const again = await batchMarkets(client, rest);
|
|
123
|
+
Object.keys(again.data).forEach(function (m) { best[m] = again.data[m]; });
|
|
124
|
+
if (onStep) onStep(mints.length, mints.length);
|
|
125
|
+
return { data: best, failed: again.failed };
|
|
126
|
+
}
|
|
127
|
+
const r = await batchMarkets(client, mints, onStep);
|
|
128
|
+
return r;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// 30 mints per request (tokens/v1)
|
|
132
|
+
async function batchMarkets(client, mints, onStep) {
|
|
89
133
|
const best = {};
|
|
90
134
|
let failed = [];
|
|
91
135
|
for (let i = 0; i < mints.length; i += 30) {
|