Compare commits

...

6 Commits

Author SHA1 Message Date
GMGNAI 0a15c3f82b 1.1.9 2026-03-31 16:09:46 +08:00
gumponchain 00f45bf649 feat(trenches): add server-side filter support to API client and update docs
- OpenApiClient: extend getTrenches/buildTrenchesBody to accept and spread
  server-side filter fields into each category section of the request body
- SKILL.md: clarify entrapment_ratio description as Entrapment/Phishing
- workflow-early-project-screening: add filter-preset examples to Step 1

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 15:57:37 +08:00
gumponchain fbbb1c6c6a fix(trenches): restore min/max_x_follower — confirmed working by user test
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 15:57:37 +08:00
gumponchain e9d453ff36 fix(trenches): restore 5 incorrectly removed filter field pairs
Previous validation used millisecond timestamps causing 401 errors,
which jq parsed as 0 and were mistaken for "field ignored" results.
Re-validated with correct second-precision timestamps — all 30 pairs
confirmed working. Only min/max_x_follower remains removed (truly ignored).

Restored fields (10 flags, 5 pairs):
- min/max_volume_24h
- min/max_net_buy_24h
- min/max_swaps_24h
- min/max_buys_24h
- min/max_sells_24h

Also restored min_volume_24h=1000 in the strict filter preset.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 15:57:37 +08:00
gumponchain 8f190890bc feat(trenches): remove 6 unsupported server-side filter fields after API validation
Validated all 31 min/max field pairs against the live API using extreme values.
Fields returning baseline count (80) on both min and max tests are silently
ignored by the server — confirmed not supported.

Removed fields (12 flags, 6 pairs):
- min/max_volume_24h
- min/max_net_buy_24h
- min/max_swaps_24h
- min/max_buys_24h
- min/max_sells_24h
- min/max_x_follower

Also removed min_volume_24h from the `strict` filter preset.

Remaining 50 filter flags (25 pairs) are confirmed to work.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 15:57:37 +08:00
gumponchain c3c9db350e docs: improve Quick Start AI Agent flow to prevent early exit on demo key
Low-end models (e.g. Cursor default model) were stopping at Step 2
after seeing "the CLI is working", treating the demo key verification
as a success state and skipping the mandatory personal API key setup.

- Step 2: add explicit "Setup is NOT yet complete" warning after demo
  key verification, with "Do not stop here" directive
- Step 3: rename to "REQUIRED: Set up personal API key", add ⚠️ mandatory
  marker, change from passive "when the user asks" to imperative
  "immediately run without waiting for them to ask"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 15:57:37 +08:00
8 changed files with 380 additions and 27 deletions
+15 -6
View File
@@ -115,19 +115,23 @@ Already installed? [Upgrade Skills and CLI →](#9-upgrade-skills-and-cli)
npx skills add GMGNAI/gmgn-skills
```
**Step 2 — Verify with public key (no registration needed)**
**Step 2 — Verify CLI installation (demo key)**
```bash
GMGN_API_KEY=gmgn_solbscbaseethmonadtron gmgn-cli market trending --chain sol --interval 1h --limit 3
```
If JSON output appears, the CLI is working.
If JSON output appears, the CLI is installed correctly. **Setup is NOT yet complete — this is a public demo key for testing only. You must continue to Steps 34 to configure the user's personal API key. Do not stop here.**
**Step 3 — Guide user to get their own API key**
**Step 3 — REQUIRED: Set up personal API key**
Tell the user: "To use your own API key, go to **https://gmgn.ai/ai** and apply. You will need an Ed25519 public key. I can generate a key pair for you — just say the word."
⚠️ This step is mandatory. The demo key in Step 2 supports testing only and is not for actual use.
When the user asks, run:
Immediately tell the user the following, then run the key generation command **without waiting for them to ask**:
> "To use GMGN Skills, you need your own API key from **https://gmgn.ai/ai**. I'm generating an Ed25519 key pair for you now."
Run:
```bash
openssl genpkey -algorithm ed25519 -out /tmp/gmgn_private.pem 2>/dev/null && \
@@ -140,7 +144,7 @@ Show the **public key** to the user with the following instructions:
> 1. Go to **https://gmgn.ai/ai**, paste the public key above into the API Key creation form, and submit.
> 2. Once created, copy the **API Key** shown on the page and send it back to me — I'll handle Step 4 configuration for you.
Wait for the user to reply with their API Key before continuing to Step 4.
**Wait for the user to reply with their API Key before continuing to Step 4.**
**Step 4 — Configure credentials**
@@ -441,6 +445,11 @@ npx gmgn-cli market trenches \
--type new_creation --type near_completion --type completed \
--launchpad-platform Pump.fun --launchpad-platform pump_mayhem --launchpad-platform letsbonk \
--limit 80
# With server-side filters: safe preset + require smart money + sort by smart degen count
npx gmgn-cli market trenches \
--chain sol --type new_creation \
--filter-preset safe --min-smart-degen-count 1 --sort-by smart_degen_count
```
### Portfolio
+15 -6
View File
@@ -121,19 +121,23 @@ SOL / BSC / Base 多链数据每次查询均为实时,支持多参数个性化
npx skills add GMGNAI/gmgn-skills
```
**第 2 步 — 用公共 Key 验证(无需注册**
**第 2 步 — 验证 CLI 安装(演示 Key**
```bash
GMGN_API_KEY=gmgn_solbscbaseethmonadtron gmgn-cli market trending --chain sol --interval 1h --limit 3
```
看到 JSON 输出即表示 CLI 正常工作。
看到 JSON 输出说明 CLI 已安装成功。**但配置尚未完成 —— 此公共演示 Key 仅用于测试,不可用于实际使用。必须继续完成第 3~4 步,为用户配置个人 API Key。请勿在此停止。**
**第 3 步 — 引导用户申请个人 API Key**
**第 3 步 — 必须完成:配置个人 API Key**
告知用户:"需要个人 API Key,请前往 **https://gmgn.ai/ai** 申请。申请时需要一个 Ed25519 公钥,我可以帮你生成密钥对,告诉我一声就行。"
⚠️ 此步骤为必填项。第 2 步中的演示 Key 仅支持测试,无法用于正式使用。
用户确认后运行
请**立即**告知用户以下内容,并**无需等待用户主动询问**,直接运行密钥生成命令
> "使用 GMGN Skills 需要你自己的个人 API Key,申请地址:**https://gmgn.ai/ai**。我现在为你生成 Ed25519 密钥对。"
运行:
```bash
openssl genpkey -algorithm ed25519 -out /tmp/gmgn_private.pem 2>/dev/null && \
@@ -146,7 +150,7 @@ openssl genpkey -algorithm ed25519 -out /tmp/gmgn_private.pem 2>/dev/null && \
> 1. 打开 **https://gmgn.ai/ai**,将上方公钥填入 API Key 生成表单,完成创建。
> 2. 创建完成后,将页面上显示的 **API Key** 复制并发送给我,我来帮你完成第 4 步配置。
等用户回复 API Key 后,再继续第 4 步。
**等用户回复 API Key 后,再继续第 4 步。**
**第 4 步 — 配置凭证**
@@ -503,6 +507,11 @@ gmgn-cli market trenches \
--type new_creation --type near_completion --type completed \
--launchpad-platform Pump.fun --launchpad-platform pump_mayhem --launchpad-platform letsbonk \
--limit 80
# 服务端过滤:安全预设 + 要求有聪明钱 + 按聪明钱数量排序
gmgn-cli market trenches \
--chain sol --type new_creation \
--filter-preset safe --min-smart-degen-count 1 --sort-by smart_degen_count
```
### Portfolio
+24
View File
@@ -31,10 +31,34 @@ gmgn-cli market trenches --chain <chain> --type completed
From the results, note each token's `address`, `symbol`, `smart_degen_count`, `renowned_count`, `volume`, `swaps`, and `rug_ratio`.
**Tip — use filter flags to pre-screen at fetch time:**
```bash
# Fetch with safe baseline filter (server-side)
gmgn-cli market trenches --chain <chain> \
--type new_creation --type near_completion \
--filter-preset safe --sort-by smart_degen_count
# Strict: safe + require smart money + min 24h volume $1k
gmgn-cli market trenches --chain <chain> \
--type new_creation --type near_completion \
--filter-preset strict --sort-by smart_degen_count
# Custom: manual range filters (all sent server-side)
gmgn-cli market trenches --chain <chain> \
--type new_creation \
--max-rug-ratio 0.3 --max-bundler-rate 0.3 --max-insider-ratio 0.3 \
--min-smart-degen-count 1 --min-volume-24h 1000
```
Using `--filter-preset safe` (or `strict`) tells the server to pre-filter results before returning — equivalent to Steps 2's "Discard immediately" criteria, applied before the response is sent.
---
## Step 2 — First-Pass Filter (In-Response Scan)
> **If you used `--filter-preset safe` or `--filter-preset strict` in Step 1, the rug_ratio, bundler_rate, and insider_ratio checks below are already applied server-side.** Verify the remaining signals manually.
Before running any CLI commands per token, apply a quick in-response filter on the trenches results:
**Discard immediately if:**
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "gmgn-cli",
"version": "1.1.8",
"version": "1.1.9",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "gmgn-cli",
"version": "1.1.8",
"version": "1.1.9",
"license": "MIT",
"dependencies": {
"commander": "^12.1.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "gmgn-cli",
"version": "1.1.8",
"version": "1.1.9",
"description": "GMGN OpenAPI CLI — call GMGN market, token, portfolio and swap APIs from the command line",
"type": "module",
"bin": {
+124
View File
@@ -437,9 +437,95 @@ Use field combinations to determine what stage a token is in. This affects how s
| `--type` | No | Categories to query, repeatable: `new_creation` / `near_completion` / `completed` (default: all three) |
| `--launchpad-platform` | No | Launchpad platform filter, repeatable (default: all platforms for the chain) |
| `--limit` | No | Max results per category, max 80 (default: 80) |
| `--filter-preset` | No | Named server-side filter preset: `safe` / `smart-money` / `strict` |
| `--sort-by` | No | Client-side sort per category: `smart_degen_count` / `renowned_count` / `volume_24h` / `volume_1h` / `swaps_24h` / `swaps_1h` / `rug_ratio` / `holder_count` / `usd_market_cap` / `created_timestamp` |
| `--direction` | No | Sort direction: `asc` / `desc` (default: `desc`; `asc` for `rug_ratio`) |
| `--min-*` / `--max-*` | No | Server-side filter range flags — see Filter Fields Reference below |
### Filter Presets
Presets are applied server-side: the API filters tokens before returning results.
| Preset | Server-side filters applied |
|--------|----------------------------|
| `safe` | `max_rug_ratio=0.3` + `max_bundler_rate=0.3` + `max_insider_ratio=0.3` |
| `smart-money` | `min_smart_degen_count=1` |
| `strict` | `max_rug_ratio=0.3` + `max_bundler_rate=0.3` + `max_insider_ratio=0.3` + `min_smart_degen_count=1` + `min_volume_24h=1000` |
**Preset + explicit flag interaction:** Explicit filter flags always override preset values. For example, `--filter-preset safe --max-rug-ratio 0.1` applies the `safe` preset but overrides rug_ratio threshold to `0.1`.
**All filter flags are sent as part of the API request body (server-side)** — the server filters tokens before returning results. Use `--limit 80` (the default maximum) to maximise the pool.
Response fields: `data.new_creation`, `data.pump`, `data.completed` — each is an array of `RankItem` (same fields as `market trending` rank items). **Important: `data.pump` in the response corresponds to `--type near_completion` in the request. The API always returns this category under the key `pump`, not `near_completion`.**
### Server-Side Filter Fields
All filter flags are sent as part of the API request body — the server filters tokens before returning results. Flags follow the naming convention `--min-{field}` / `--max-{field}`.
| Flag pair | Type | Description |
|-----------|------|-------------|
| `--min-volume-24h` / `--max-volume-24h` | float | 24h trading volume (USD) |
| `--min-net-buy-24h` / `--max-net-buy-24h` | float | 24h net buy volume (USD) |
| `--min-swaps-24h` / `--max-swaps-24h` | int | 24h total swap count |
| `--min-buys-24h` / `--max-buys-24h` | int | 24h buy count |
| `--min-sells-24h` / `--max-sells-24h` | int | 24h sell count |
| `--min-visiting-count` / `--max-visiting-count` | int | Visitor count |
| `--min-progress` / `--max-progress` | float | Bonding curve progress (01) |
| `--min-marketcap` / `--max-marketcap` | float | Market cap (USD) |
| `--min-liquidity` / `--max-liquidity` | float | Liquidity (USD) |
| `--min-created` / `--max-created` | string | Token age (e.g. `1m` / `5m` / `1h` / `24h`) |
| `--min-holder-count` / `--max-holder-count` | int | Holder count |
| `--min-top-holder-rate` / `--max-top-holder-rate` | float | Top-10 holder concentration (01) |
| `--min-rug-ratio` / `--max-rug-ratio` | float | Rug pull risk score (01) |
| `--min-bundler-rate` / `--max-bundler-rate` | float | Bundle-bot trading ratio (01) |
| `--min-insider-ratio` / `--max-insider-ratio` | float | Insider trading ratio (01) |
| `--min-entrapment-ratio` / `--max-entrapment-ratio` | float | Entrapment/Phishing trading ratio (01) |
| `--min-private-vault-hold-rate` / `--max-private-vault-hold-rate` | float | Private vault holding ratio (01) |
| `--min-top70-sniper-hold-rate` / `--max-top70-sniper-hold-rate` | float | Top-70 sniper holding ratio (01) |
| `--min-bot-count` / `--max-bot-count` | int | Bot wallet count |
| `--min-bot-degen-rate` / `--max-bot-degen-rate` | float | Bot-degen wallet ratio (01) |
| `--min-fresh-wallet-rate` / `--max-fresh-wallet-rate` | float | Fresh wallet ratio (01) |
| `--min-total-fee` / `--max-total-fee` | float | Total fee |
| `--min-smart-degen-count` / `--max-smart-degen-count` | int | Smart-money holder count |
| `--min-renowned-count` / `--max-renowned-count` | int | KOL / renowned wallet count |
| `--min-creator-balance-rate` / `--max-creator-balance-rate` | float | Creator holding ratio (01) |
| `--min-creator-created-count` / `--max-creator-created-count` | int | Creator's total token creation count |
| `--min-creator-created-open-count` / `--max-creator-created-open-count` | int | Creator's graduated token count |
| `--min-creator-created-open-ratio` / `--max-creator-created-open-ratio` | float | Creator's graduation ratio (01) |
| `--min-x-follower` / `--max-x-follower` | int | Twitter / X follower count |
| `--min-twitter-rename-count` / `--max-twitter-rename-count` | int | Twitter rename count |
| `--min-tg-call-count` / `--max-tg-call-count` | int | Telegram call count |
### Trenches Filter Examples
```bash
# Apply the safe preset (server-side)
gmgn-cli market trenches --chain sol --type new_creation --filter-preset safe
# Require at least 1 smart money holder (server-side)
gmgn-cli market trenches --chain sol --type new_creation --min-smart-degen-count 1
# Safe preset + require smart money + sort by smart degen count (server-side filter, client-side sort)
gmgn-cli market trenches --chain sol --type new_creation \
--filter-preset safe --min-smart-degen-count 1 --sort-by smart_degen_count
# Strict preset — safe + smart money + min $1k volume (server-side)
gmgn-cli market trenches --chain sol --type new_creation --type near_completion \
--filter-preset strict --sort-by smart_degen_count
# Manual range filters (all sent server-side)
gmgn-cli market trenches --chain sol --type new_creation \
--max-rug-ratio 0.3 --max-bundler-rate 0.3 --max-insider-ratio 0.3 \
--min-smart-degen-count 1 --min-volume-24h 1000
# Filter by token age: only tokens created within the last 30 minutes
gmgn-cli market trenches --chain sol --type new_creation --max-created 30m
# Filter by market cap range
gmgn-cli market trenches --chain sol --type new_creation \
--min-marketcap 10000 --max-marketcap 500000
```
## `market trenches` Response Fields
**Basic Info**
@@ -526,6 +612,44 @@ Response fields: `data.new_creation`, `data.pump`, `data.completed` — each is
**After fetching trenches results, apply the Token Quality Filter Criteria section before presenting tokens to the user.** Do not dump raw results — filter first, then surface the strongest candidates.
### Trenches Filter Examples
```bash
# Quick safe screen — exclude rugs, wash trading, and bundlers
gmgn-cli market trenches --chain sol --type new_creation \
--filter-preset safe --raw
# Smart money screen — only tokens with smart money or KOL presence
gmgn-cli market trenches --chain sol \
--type new_creation --type near_completion \
--filter-preset smart-money \
--sort-by smart_degen_count --raw
# Strict screen — safe + smart money + minimum volume, sorted by smart degens
gmgn-cli market trenches --chain sol --type completed \
--filter-preset strict --sort-by smart_degen_count --raw
# Custom filter — no wash trading, rug_ratio <= 0.2, at least 1 smart degen
gmgn-cli market trenches --chain sol \
--type new_creation --type near_completion \
--exclude-wash-trading --max-rug-ratio 0.2 --min-smart-degen 1 \
--sort-by smart_degen_count --raw
# BSC — safe screen on new tokens from fourmeme
gmgn-cli market trenches --chain bsc --type new_creation \
--launchpad-platform fourmeme --launchpad-platform fourmeme_agent \
--filter-preset safe --sort-by volume_1h --raw
# Sort by rug_ratio ascending (safest first), no other filters
gmgn-cli market trenches --chain sol --type completed \
--sort-by rug_ratio --raw
# Find tokens with many holders and strong 1h swap activity
gmgn-cli market trenches --chain sol --type completed \
--min-holders 100 --min-swaps 50 \
--sort-by swaps_1h --raw
```
### Solana Trenches Examples
```bash
+5 -4
View File
@@ -126,8 +126,8 @@ export class OpenApiClient {
return this.normalRequest("GET", "/v1/user/wallet_token_balance", { chain, wallet_address: walletAddress, token_address: tokenAddress });
}
async getTrenches(chain: string, types?: string[], platforms?: string[], limit?: number): Promise<unknown> {
const body = buildTrenchesBody(chain, types, platforms, limit);
async getTrenches(chain: string, types?: string[], platforms?: string[], limit?: number, filters?: Record<string, number | string>): Promise<unknown> {
const body = buildTrenchesBody(chain, types, platforms, limit, filters);
return this.normalRequest("POST", "/v1/trenches", { chain }, body);
}
@@ -342,17 +342,18 @@ const TRENCHES_QUOTE_ADDRESS_TYPES: Record<string, number[]> = {
base: [11, 3, 12, 13, 0],
};
function buildTrenchesBody(chain: string, types?: string[], platforms?: string[], limit?: number): Record<string, unknown> {
function buildTrenchesBody(chain: string, types?: string[], platforms?: string[], limit?: number, filters?: Record<string, number | string>): Record<string, unknown> {
const selectedTypes = types?.length ? types : ["new_creation", "near_completion", "completed"];
const launchpad_platform = platforms?.length ? platforms : (TRENCHES_PLATFORMS[chain] ?? []);
const quote_address_type = TRENCHES_QUOTE_ADDRESS_TYPES[chain] ?? [];
const actualLimit = limit ?? 80;
const section = {
const section: Record<string, unknown> = {
filters: ["offchain", "onchain"],
launchpad_platform,
quote_address_type,
launchpad_platform_v2: true,
limit: actualLimit,
...filters,
};
const body: Record<string, unknown> = { version: "v2" };
for (const type of selectedTypes) {
+194 -8
View File
@@ -57,19 +57,205 @@ export function registerMarketCommands(program: Command): void {
printResult(data, opts.raw);
});
market
const trenchesCmd = market
.command("trenches")
.description("Get Trenches token data (new creation, near completion, completed)")
.requiredOption("--chain <chain>", "Chain: sol / bsc / base")
.option("--type <type...>", "Categories to query, repeatable: new_creation / near_completion / completed (default: all three)")
.option("--launchpad-platform <platform...>", "Launchpad platform filter, repeatable (default: all platforms for the chain)")
.option("--limit <n>", "Max results per category, max 80 (default: 80)", parseInt)
.option("--raw", "Output raw JSON")
.action(async (opts) => {
validateChain(opts.chain);
const client = new OpenApiClient(getConfig());
const data = await client.getTrenches(opts.chain, opts.type, opts.launchpadPlatform, opts.limit).catch(exitOnError);
printResult(data, opts.raw);
});
.option("--filter-preset <preset>", "Apply a named filter preset: safe / smart-money / strict")
.option("--sort-by <field>", "Client-side sort per category: smart_degen_count / renowned_count / volume_24h / volume_1h / swaps_24h / swaps_1h / rug_ratio / holder_count / usd_market_cap / created_timestamp")
.option("--direction <dir>", "Sort direction: asc / desc (default: desc; asc for rug_ratio)")
.option("--raw", "Output raw JSON");
// Dynamically register all server-side filter flags
for (const def of TRENCHES_FILTER_FIELDS) {
const flag = def.api.replace(/_/g, '-');
if (def.type === "int") {
trenchesCmd.option(`--${flag} <${def.type}>`, def.desc, parseInt);
} else if (def.type === "float") {
trenchesCmd.option(`--${flag} <${def.type}>`, def.desc, parseFloat);
} else {
trenchesCmd.option(`--${flag} <value>`, def.desc);
}
}
trenchesCmd.action(async (opts) => {
validateChain(opts.chain);
const client = new OpenApiClient(getConfig());
// Build server-side filter object
const filters: Record<string, number | string> = {};
// Apply preset values first
if (opts.filterPreset != null) {
const preset = TRENCHES_FILTER_PRESETS[opts.filterPreset as string];
if (!preset) {
console.error(`Unknown --filter-preset "${opts.filterPreset}". Valid options: ${Object.keys(TRENCHES_FILTER_PRESETS).join(", ")}`);
process.exit(1);
}
Object.assign(filters, preset);
}
// Apply individual filter flags (override preset values)
const optsMap = opts as Record<string, unknown>;
for (const def of TRENCHES_FILTER_FIELDS) {
const key = apiFieldToCliKey(def.api);
const val = optsMap[key];
if (val != null) filters[def.api] = val as number | string;
}
const data = await client
.getTrenches(opts.chain, opts.type, opts.launchpadPlatform, opts.limit, Object.keys(filters).length ? filters : undefined)
.catch(exitOnError);
const result = opts.sortBy
? sortTrenchesResult(data as Record<string, unknown>, opts.sortBy as string, (opts.direction as string) ?? "")
: data;
printResult(result, opts.raw);
});
}
// ---- Trenches filter field definitions ----
type TrenchesFieldType = "int" | "float" | "string";
interface TrenchesFilterField {
api: string;
type: TrenchesFieldType;
desc: string;
}
// All server-side filter fields for market trenches
// API field names map to CLI flags by replacing _ with - (e.g. min_volume_24h → --min-volume-24h)
const TRENCHES_FILTER_FIELDS: TrenchesFilterField[] = [
// Trading activity (24h)
{ api: "min_volume_24h", type: "float", desc: "Min 24h trading volume (USD)" },
{ api: "max_volume_24h", type: "float", desc: "Max 24h trading volume (USD)" },
{ api: "min_net_buy_24h", type: "float", desc: "Min 24h net buy volume (USD)" },
{ api: "max_net_buy_24h", type: "float", desc: "Max 24h net buy volume (USD)" },
{ api: "min_swaps_24h", type: "int", desc: "Min 24h total swap count" },
{ api: "max_swaps_24h", type: "int", desc: "Max 24h total swap count" },
{ api: "min_buys_24h", type: "int", desc: "Min 24h buy count" },
{ api: "max_buys_24h", type: "int", desc: "Max 24h buy count" },
{ api: "min_sells_24h", type: "int", desc: "Min 24h sell count" },
{ api: "max_sells_24h", type: "int", desc: "Max 24h sell count" },
{ api: "min_visiting_count", type: "int", desc: "Min visitor count" },
{ api: "max_visiting_count", type: "int", desc: "Max visitor count" },
// Market & liquidity
{ api: "min_progress", type: "float", desc: "Min bonding curve progress (01)" },
{ api: "max_progress", type: "float", desc: "Max bonding curve progress (01, 1 = completed)" },
{ api: "min_marketcap", type: "float", desc: "Min market cap (USD)" },
{ api: "max_marketcap", type: "float", desc: "Max market cap (USD)" },
{ api: "min_liquidity", type: "float", desc: "Min liquidity (USD)" },
{ api: "max_liquidity", type: "float", desc: "Max liquidity (USD)" },
// Token age
{ api: "min_created", type: "string", desc: "Min token age (e.g. 1m / 5m / 30m / 1h / 6h / 24h)" },
{ api: "max_created", type: "string", desc: "Max token age (e.g. 1m / 5m / 30m / 1h / 6h / 24h)" },
// Holders
{ api: "min_holder_count", type: "int", desc: "Min holder count" },
{ api: "max_holder_count", type: "int", desc: "Max holder count" },
{ api: "min_top_holder_rate", type: "float", desc: "Min top-10 holder concentration (01)" },
{ api: "max_top_holder_rate", type: "float", desc: "Max top-10 holder concentration (01)" },
// Risk signals
{ api: "min_rug_ratio", type: "float", desc: "Min rug pull risk score (01)" },
{ api: "max_rug_ratio", type: "float", desc: "Max rug pull risk score (01, e.g. 0.3 to exclude rugs)" },
{ api: "min_bundler_rate", type: "float", desc: "Min bundle-bot trading ratio (01)" },
{ api: "max_bundler_rate", type: "float", desc: "Max bundle-bot trading ratio (01)" },
{ api: "min_insider_ratio", type: "float", desc: "Min insider trading ratio (01)" },
{ api: "max_insider_ratio", type: "float", desc: "Max insider trading ratio (01)" },
{ api: "min_entrapment_ratio", type: "float", desc: "Min entrapment trading ratio (01)" },
{ api: "max_entrapment_ratio", type: "float", desc: "Max entrapment trading ratio (01)" },
{ api: "min_private_vault_hold_rate", type: "float", desc: "Min private vault holding ratio (01)" },
{ api: "max_private_vault_hold_rate", type: "float", desc: "Max private vault holding ratio (01)" },
{ api: "min_top70_sniper_hold_rate", type: "float", desc: "Min top-70 sniper holding ratio (01)" },
{ api: "max_top70_sniper_hold_rate", type: "float", desc: "Max top-70 sniper holding ratio (01)" },
{ api: "min_bot_count", type: "int", desc: "Min bot wallet count" },
{ api: "max_bot_count", type: "int", desc: "Max bot wallet count" },
{ api: "min_bot_degen_rate", type: "float", desc: "Min bot-degen wallet ratio (01)" },
{ api: "max_bot_degen_rate", type: "float", desc: "Max bot-degen wallet ratio (01)" },
{ api: "min_fresh_wallet_rate", type: "float", desc: "Min fresh wallet ratio (01)" },
{ api: "max_fresh_wallet_rate", type: "float", desc: "Max fresh wallet ratio (01)" },
{ api: "min_total_fee", type: "float", desc: "Min total fee" },
{ api: "max_total_fee", type: "float", desc: "Max total fee" },
// Smart money
{ api: "min_smart_degen_count", type: "int", desc: "Min smart-money holder count" },
{ api: "max_smart_degen_count", type: "int", desc: "Max smart-money holder count" },
{ api: "min_renowned_count", type: "int", desc: "Min KOL / renowned wallet count" },
{ api: "max_renowned_count", type: "int", desc: "Max KOL / renowned wallet count" },
// Dev / creator
{ api: "min_creator_balance_rate", type: "float", desc: "Min creator holding ratio (01)" },
{ api: "max_creator_balance_rate", type: "float", desc: "Max creator holding ratio (01)" },
{ api: "min_creator_created_count", type: "int", desc: "Min creator total token creation count" },
{ api: "max_creator_created_count", type: "int", desc: "Max creator total token creation count" },
{ api: "min_creator_created_open_count", type: "int", desc: "Min creator graduated token count" },
{ api: "max_creator_created_open_count", type: "int", desc: "Max creator graduated token count" },
{ api: "min_creator_created_open_ratio", type: "float", desc: "Min creator graduation ratio (01)" },
{ api: "max_creator_created_open_ratio", type: "float", desc: "Max creator graduation ratio (01)" },
// Social
{ api: "min_x_follower", type: "int", desc: "Min Twitter / X follower count" },
{ api: "max_x_follower", type: "int", desc: "Max Twitter / X follower count" },
{ api: "min_twitter_rename_count", type: "int", desc: "Min Twitter rename count (high = suspicious)" },
{ api: "max_twitter_rename_count", type: "int", desc: "Max Twitter rename count" },
{ api: "min_tg_call_count", type: "int", desc: "Min Telegram call count" },
{ api: "max_tg_call_count", type: "int", desc: "Max Telegram call count" },
];
// Named filter presets using actual server-side API field names
const TRENCHES_FILTER_PRESETS: Record<string, Record<string, number | string>> = {
safe: {
max_rug_ratio: 0.3,
max_bundler_rate: 0.3,
max_insider_ratio: 0.3,
},
"smart-money": {
min_smart_degen_count: 1,
},
strict: {
max_rug_ratio: 0.3,
max_bundler_rate: 0.3,
max_insider_ratio: 0.3,
min_smart_degen_count: 1,
min_volume_24h: 1000,
},
};
// Convert API snake_case field to Commander.js opts key
// Commander.js camelCase: only converts -[a-z] patterns, digits stay as-is
// e.g. min_volume_24h → min-volume-24h → minVolume-24h (digit prefix -24 is NOT converted)
// e.g. min_smart_degen_count → min-smart-degen-count → minSmartDegenCount (all letters, converts fully)
function apiFieldToCliKey(apiField: string): string {
return apiField
.replace(/_/g, '-')
.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());
}
// Client-side sort helpers (API does not support server-side sort for trenches)
interface TrenchesCategory {
[key: string]: unknown;
}
const TRENCHES_SORT_ASC_DEFAULTS = new Set(["rug_ratio"]);
const TRENCHES_STRING_NUMERIC_FIELDS = new Set(["usd_market_cap", "liquidity", "volume_1h", "volume_24h"]);
function sortTrenchesCategory(items: TrenchesCategory[], sortBy: string, direction: string): TrenchesCategory[] {
const dir = direction || (TRENCHES_SORT_ASC_DEFAULTS.has(sortBy) ? "asc" : "desc");
return [...items].sort((a, b) => {
const aVal = TRENCHES_STRING_NUMERIC_FIELDS.has(sortBy)
? parseFloat(String(a[sortBy] ?? 0))
: Number(a[sortBy] ?? 0);
const bVal = TRENCHES_STRING_NUMERIC_FIELDS.has(sortBy)
? parseFloat(String(b[sortBy] ?? 0))
: Number(b[sortBy] ?? 0);
return dir === "asc" ? aVal - bVal : bVal - aVal;
});
}
function sortTrenchesResult(data: Record<string, unknown>, sortBy: string, direction: string): Record<string, unknown> {
const result: Record<string, unknown> = {};
for (const [key, val] of Object.entries(data)) {
result[key] = Array.isArray(val) ? sortTrenchesCategory(val as TrenchesCategory[], sortBy, direction) : val;
}
return result;
}