feat(market): add structured --type/--launchpad-platform/--limit options for trenches command

Replace raw --body JSON parameter with structured CLI flags for better AI agent readability.
Add full response key reference and SOL/BSC/Base examples to SKILL.md and docs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
gumponchain
2026-03-26 17:02:24 +08:00
co-authored by Claude Sonnet 4.6
parent 5a8879c6d2
commit 08b48c8e24
6 changed files with 202 additions and 16 deletions
+12 -10
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): Promise<unknown> {
const body = buildTrenchesBody(chain);
async getTrenches(chain: string, types?: string[], platforms?: string[], limit?: number): Promise<unknown> {
const body = buildTrenchesBody(chain, types, platforms, limit);
return this.normalRequest("POST", "/v1/trenches", { chain }, body);
}
@@ -330,21 +330,23 @@ const TRENCHES_QUOTE_ADDRESS_TYPES: Record<string, number[]> = {
base: [11, 3, 12, 13, 0],
};
function buildTrenchesBody(chain: string): Record<string, unknown> {
const launchpad_platform = TRENCHES_PLATFORMS[chain] ?? [];
function buildTrenchesBody(chain: string, types?: string[], platforms?: string[], limit?: number): 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 = {
filters: ["offchain", "onchain"],
launchpad_platform,
quote_address_type,
launchpad_platform_v2: true,
limit: actualLimit,
};
return {
new_creation: { ...section, limit: 60 },
near_completion: { ...section, limit: 120 },
completed: { ...section, limit: 60 },
version: "v2",
};
const body: Record<string, unknown> = { version: "v2" };
for (const type of selectedTypes) {
body[type] = { ...section };
}
return body;
}
function buildUrl(base: string, query: Record<string, string | number | string[]>): string {
+4 -1
View File
@@ -61,11 +61,14 @@ export function registerMarketCommands(program: Command): void {
.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).catch(exitOnError);
const data = await client.getTrenches(opts.chain, opts.type, opts.launchpadPlatform, opts.limit).catch(exitOnError);
printResult(data, opts.raw);
});
}