Compare commits

..

17 Commits

Author SHA1 Message Date
yangzhenhui fc80bb5d7c 1.1.1 2026-03-26 17:38:21 +08:00
yangzhenhui c9ae346989 1.1.2 2026-03-26 17:38:12 +08:00
yangzhenhui 821be4d0db 1.1.1 2026-03-26 17:36:19 +08:00
yangzhenhui 30ce20ff01 Add GitHub Actions CI and release workflows 2026-03-26 16:44:44 +08:00
deepfeature 2b37e81d44 Merge pull request #39 from GMGNAI/copilot/add-auto-slippage-parameter
Add `swap --auto-slippage` support and preserve manual slippage docs
2026-03-26 16:18:04 +08:00
copilot-swe-agent[bot] c9b3034cf2 docs: restore manual slippage examples
Co-authored-by: deepfeature <1503768+deepfeature@users.noreply.github.com>
Agent-Logs-Url: https://github.com/GMGNAI/gmgn-skills/sessions/ae308c31-cf9d-4707-8848-a659112b33f4
2026-03-26 08:13:41 +00:00
copilot-swe-agent[bot] 2ca2c24f9e docs: clarify auto-slippage examples
Co-authored-by: deepfeature <1503768+deepfeature@users.noreply.github.com>
Agent-Logs-Url: https://github.com/GMGNAI/gmgn-skills/sessions/b2089672-9ca8-402c-be14-138b55c1bb98
2026-03-26 07:54:11 +00:00
copilot-swe-agent[bot] bd533cb85e feat: add swap auto-slippage option
Co-authored-by: deepfeature <1503768+deepfeature@users.noreply.github.com>
Agent-Logs-Url: https://github.com/GMGNAI/gmgn-skills/sessions/b2089672-9ca8-402c-be14-138b55c1bb98
2026-03-26 07:52:26 +00:00
copilot-swe-agent[bot] 247aaf96f9 Initial plan 2026-03-26 07:50:07 +00:00
dev 45fb37d51f support trenches & kol & smartmoney 2026-03-25 22:20:56 +08:00
dev 8301bf515f upgrade version to 1.0.2 2026-03-25 21:22:59 +08:00
gumponchain 702eac9686 feat(market): update trending --interval to support 1m/5m/1h/6h/24h
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 16:46:55 +08:00
dev 34456974f3 fix rank interval 2026-03-24 20:48:23 +08:00
gumponchain 017672f480 docs: update README structure, add demo cases and screenshots
- Restructure README (EN + ZH): reorder sections, unify sub-heading format
- Add Demo Cases section with two annotated examples and screenshots
- Add static/ folder with all screenshots and header image
- Add Quick Start anchor link from Skills section to installation
- Split Verify Connection into AI Agent and CLI options
- Rename Prerequisites → Get Started / 准备工作 → 开始安装 Skills
2026-03-24 18:44:32 +08:00
dev 9d871e9166 fix order status 2026-03-24 10:25:12 +08:00
JhiNResH d6b7247cc0 feat(swap): add pre-swap token safety check via Maiat API
Adds a recommended pre-swap safety check section to gmgn-swap SKILL.md.
Before swapping into unknown tokens, agents can verify honeypot/rug risk
with a single curl call to Maiat's free API (no API key required).

- Returns trustScore (0-100), verdict (proceed/caution/avoid), riskFlags
- Zero dependencies — pure curl + jq
- Works for any ERC-20 on Base
2026-03-18 16:10:45 +08:00
David Lau c9dbb6f58b fix: rename --orderby to --order-by, expand holders/traders options, update chain-specific platform/filter values 2026-03-18 16:07:10 +08:00
23 changed files with 827 additions and 175 deletions
+40
View File
@@ -0,0 +1,40 @@
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
jobs:
build:
name: Build (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version:
- 20
- 24
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Verify publish artifact
run: npm pack --dry-run
+47
View File
@@ -0,0 +1,47 @@
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: read
id-token: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
cache: npm
- name: Ensure tag matches package version
run: |
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
TAG_VERSION="${GITHUB_REF_NAME#v}"
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
echo "package.json version ($PACKAGE_VERSION) does not match tag ($TAG_VERSION)"
exit 1
fi
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Verify publish artifact
run: npm pack --dry-run
- name: Publish to npm
run: npm publish --access public
+1 -1
View File
@@ -53,7 +53,7 @@ EOF
When creating or updating any file in `skills/`:
- **Language**: English only — no bilingual content. SKILL.md files are read by AI, not humans.
- **Package runner**: Always use the pre-installed `gmgn-cli` binary (e.g. `gmgn-cli token info ...`). Never use `npx gmgn-cli` or `npx gmgn-cli@<version>` — npx downloads the package at runtime alongside live credentials. The package must be installed once with `npm install -g gmgn-cli@1.0.1`.
- **Package runner**: Always use the pre-installed `gmgn-cli` binary (e.g. `gmgn-cli token info ...`). Never use `npx gmgn-cli` or `npx gmgn-cli@<version>` — npx downloads the package at runtime alongside live credentials. The package must be installed once with `npm install -g gmgn-cli@1.1.0`.
- **Section order**: Sub-commands → Supported Chains → Prerequisites → Parameters/Options (if needed) → Usage Examples → Notes
- **`--raw` flag**: All commands support `--raw` for single-line JSON output. Always document it in the Notes section.
- **YAML frontmatter**: Quote `argument-hint` values that contain `|` characters to avoid YAML parsing errors.
+150 -70
View File
@@ -1,8 +1,16 @@
# gmgn-cli
<div align="center">
> 中文文档:[Readme.zh.md](Readme.zh.md)
<img src="static/gmgnagentskills.png" alt="GMGN Agent Skills" />
GMGN AI skills for on-chain operations — token research, market data, wallet analysis, and swap.
[![X](https://img.shields.io/badge/Follow-%40gmgnai-black?logo=x&logoColor=white)](https://x.com/gmgnai) [![Telegram](https://img.shields.io/badge/Telegram-gmgnagentapi-2CA5E0?logo=telegram&logoColor=white)](https://t.me/gmgnagentapi) [![Discord](https://img.shields.io/badge/Discord-gmgnai-5865F2?logo=discord&logoColor=white)](https://discord.gg/gmgnai)
English | [简体中文](Readme.zh.md)
</div>
## GMGN Agent Skills
With GMGN Agent Skills, you can use AI agents to query real-time trending token rankings across multiple chains, token fundamentals, social media signals, live trading activity, new tokens in Trenches, top holders, top traders, smart money positions, KOL holdings, insider wallets, bundled wallet exposure, and other professional on-chain analytics. It also supports market orders, limit orders, advanced take-profit/stop-loss strategy orders, and wallet management — including real-time holdings, recent P&L, and transaction history — all through natural language.
---
@@ -15,50 +23,127 @@ GMGN AI skills for on-chain operations — token research, market data, wallet a
| [`/gmgn-portfolio`](skills/gmgn-portfolio/SKILL.md) | Wallet holdings, activity, stats | [SKILL.md](skills/gmgn-portfolio/SKILL.md) |
| [`/gmgn-swap`](skills/gmgn-swap/SKILL.md) | Swap submission + order query | [SKILL.md](skills/gmgn-swap/SKILL.md) |
---
> For detailed CLI commands, parameters, and recommended values, see the [Wiki documentation](https://github.com/GMGNAI/gmgn-skills/wiki).
## Usage Examples
### Quick Start
Natural language prompts you can send to any AI assistant with gmgn-cli skills installed:
```
buy 0.1 SOL of <token_address>
sell 50% of <token_address> on BSC
check order status <order_id>
is <token_address> safe to buy on solana?
show top holders of <token_address>
show my wallet holdings on SOL
query token details for 0x1234...
show trading stats for wallet <wallet_address> on BSC
```
Ready to install skills? [Jump to Installation →](#get-started)
---
## Setup
## Demo Cases
### 0. Prepare
### Trending Token Rankings
Before applying for an API Key, get two things ready:
Send this prompt to your AI Agent:
**Generate an Ed25519 key pair**
```
Fetch Solana 1h trending, filter for pump.fun tokens created within 6h, sort by volume descending.
```
Download and run the [Binance Asymmetric Key Generator](https://github.com/binance/asymmetric-key-generator/releases). You will need the **public key** when filling out the API Key application, and the **private key** in your `.env` later (for swap / order).
![Trending Token Rankings](static/market-rank-1h-Pumpfun-en.png)
**Get your public egress IP** (for the IP whitelist)
### Real-Time Token Trading Analysis
Send this prompt to your AI Agent:
```
Check the first token's K-line, analyze entry timing, plot price + volume chart, and provide social media links and smart money/KOL trading analysis.
```
![Token Analysis 1](static/market-tokenanalysis-en01.png)
![Token Analysis 2](static/market-tokenanalysis-en02.png)
---
## Get Started
Before installing, create your API Key at **https://gmgn.ai/ai**. The API key is used for:
1. Read data: tokens, trending lists, K-line, and featured on-chain metrics
2. Submit trades: market orders, limit orders, strategy orders, and more
---
## 1. Installation
Choose one of the following methods:
### 1.1 Via Agent (recommended)
Send this to your AI agent:
```bash
npx skills add GMGNAI/gmgn-skills
```
### 1.2 npm Global Install
```bash
npm install -g gmgn-cli@1.1.0
```
### 1.3 Local Development
```bash
npm install
npm run build
node dist/index.js <command> [options]
```
## 2. Verify Connection
### Option 1: Via AI Agent
Send this prompt to your AI Agent:
```
Run this CLI command: GMGN_API_KEY=gmgn_solbscbaseethmonadtron npx gmgn-cli market trending --chain sol --interval 1h --limit 3
```
### Option 2: Via CLI
Test with the public API key — no registration required:
```bash
GMGN_API_KEY=gmgn_solbscbaseethmonadtron gmgn-cli market trending --chain sol --interval 1h --limit 3
```
If you see JSON output, the CLI is working. The public key supports all read-only commands (token / market / portfolio). The public key is for testing only — apply for your own API key to use any feature (see step 3).
## 3. Get Your Own API Key
The public key in step 2 is for testing only. Apply for your own API key at **https://gmgn.ai/ai** — required for all actual use (read-only and swap). You will need:
### 3.1 Generate an Ed25519 Key Pair
**Option 1 — Ask your AI agent (recommended)**
Send this prompt to your agent:
```
Generate an Ed25519 key pair for me using OpenSSL and show me:
1. The public key (I need to fill it in the GMGN API Key application form)
2. The private key in PEM format (I need to set it as GMGN_PRIVATE_KEY in my .env)
```
**Option 2 — Binance Key Generator**
Download and run the [Binance Asymmetric Key Generator](https://github.com/binance/asymmetric-key-generator/releases).
Enter the **public key** in the application form.
### 3.2 Get Your Public Egress IP
For the IP whitelist (required when enabling swap capability on your API key):
```bash
curl ip.me
```
Or visit **https://ip.me** in your browser.
## 4. Configure Your API Key
### 1. Get an API Key
Apply at **https://gmgn.ai/ai** — enter the public key and your IP address from the step above.
### 2. Configure
**Option A — Global config (recommended)**
### Option 1: Global config (recommended)
Create `~/.config/gmgn/.env` once — works from any directory:
@@ -67,12 +152,12 @@ mkdir -p ~/.config/gmgn
cat > ~/.config/gmgn/.env << 'EOF'
GMGN_API_KEY=your_api_key_here
# Required for swap / order (private key from step 0):
# Required for swap / order only:
GMGN_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n<base64>\n-----END PRIVATE KEY-----\n"
EOF
```
**Option B — Project `.env`**
### Option 2: Project `.env`
```bash
cp .env.example .env
@@ -81,24 +166,16 @@ cp .env.example .env
Config lookup order: `~/.config/gmgn/.env` → project `.env` (project takes precedence).
### 3. CLI Install
## 5. Try in AI Clients
Install a pinned version to avoid pulling untrusted updates at runtime:
#### OpenClaw
Send the following prompt directly to test the query capabilities:
```bash
npm install -g gmgn-cli@1.0.1
```
Local development:
```bash
npm install
npm run build
node dist/index.js <command> [options]
Show me the trending tokens on Solana in the last 1 hour.
```
### 4. Connect to Your AI Tool
#### Claude Code
Skills are automatically discovered when the package is installed as a plugin.
@@ -107,19 +184,17 @@ Skills are automatically discovered when the package is installed as a plugin.
Skills are automatically discovered via the `.cursor-plugin/` configuration.
1. Complete steps 13 above
2. Configure credentials in `~/.config/gmgn/.env`
3. Restart Cursor — skills will be available in Agent mode via `/gmgn-*` commands
1. Complete the installation and configuration steps above
2. Restart Cursor — skills will be available in Agent mode via `/gmgn-*` commands
#### Cline
1. Complete steps 13 above
1. Complete the installation and configuration steps above
2. In Cline settings → **Skills directory**: point to the installed package's `skills/` folder:
```bash
echo "$(npm root -g)/gmgn-skills/skills"
```
3. Configure credentials in `~/.config/gmgn/.env`
4. Restart Cline — `/gmgn-token`, `/gmgn-market`, `/gmgn-portfolio`, `/gmgn-swap` will be available
3. Restart Cline — `/gmgn-token`, `/gmgn-market`, `/gmgn-portfolio`, `/gmgn-swap` will be available
#### Codex CLI
@@ -143,7 +218,24 @@ See [.opencode/INSTALL.md](.opencode/INSTALL.md) for full instructions.
---
## Typical Workflows
## 6. Usage
### Examples
Natural language prompts you can send to any AI assistant with gmgn-cli skills installed:
```
buy 0.1 SOL of <token_address>
sell 50% of <token_address> on BSC
check order status <order_id>
is <token_address> safe to buy on solana?
show top holders of <token_address>
show my wallet holdings on SOL
query token details for 0x1234...
show trading stats for wallet <wallet_address> on BSC
```
### Typical Workflows
**Research a token:**
```
@@ -167,9 +259,9 @@ market trending (top 50) → AI selects top 5 by multi-factor analysis → u
---
## CLI Reference
## 7. CLI Reference
Full parameter reference: [docs/cli-usage.md](docs/cli-usage.md)
Full parameter reference: [docs/cli-usage.md](docs/cli-usage.md). All commands support `--raw` for single-line JSON output (pipe-friendly, e.g. `| jq '.price'`).
### Token
@@ -209,9 +301,7 @@ npx gmgn-cli swap \
npx gmgn-cli order get --chain sol --order-id <order-id>
```
---
## Supported Chains
## 8. Supported Chains
| Commands | Chains | Chain Currencies |
|----------|--------|-----------------|
@@ -220,17 +310,7 @@ npx gmgn-cli order get --chain sol --order-id <order-id>
---
## Output Format
Default: formatted JSON. Use `--raw` for single-line JSON (pipe-friendly):
```bash
npx gmgn-cli token info --chain sol --address <addr> --raw | jq '.price'
```
---
## Security & Disclaimer
## 9. Security & Disclaimer
**About `GMGN_PRIVATE_KEY`**
@@ -241,7 +321,7 @@ npx gmgn-cli token info --chain sol --address <addr> --raw | jq '.price'
- Restrict config file permissions: `chmod 600 ~/.config/gmgn/.env`
- Never commit your `.env` file to version control — add it to `.gitignore`
- Do not share `GMGN_API_KEY` or `GMGN_PRIVATE_KEY` in logs, screenshots, or chat messages
- Use a pinned install (`npm install -g gmgn-cli@1.0.1`) rather than `npx gmgn-cli` to avoid executing unintended package updates alongside your credentials
- Use a pinned install (`npm install -g gmgn-cli@1.1.0`) rather than `npx gmgn-cli` to avoid executing unintended package updates alongside your credentials
**Disclaimer**
+155 -75
View File
@@ -1,8 +1,16 @@
# gmgn-cli
<div align="center">
> English: [Readme.md](Readme.md)
<img src="static/gmgnagentskills.png" alt="GMGN Agent Skills" />
GMGN 链上操作 AI 技能套件 — Token 研究、行情数据、钱包分析和交易。
[![X](https://img.shields.io/badge/关注-%40gmgnai-black?logo=x&logoColor=white)](https://x.com/gmgnai) [![Telegram](https://img.shields.io/badge/Telegram-gmgnagentapi-2CA5E0?logo=telegram&logoColor=white)](https://t.me/gmgnagentapi) [![Discord](https://img.shields.io/badge/Discord-gmgnai-5865F2?logo=discord&logoColor=white)](https://discord.gg/gmgnai)
[English](Readme.md) | 简体中文
</div>
## GMGN Agent Skills
使用 GMGN Agent Skills,你可以通过 AI Agent 实时查询多个链上热门代币排行榜,代币基础信息,社交媒体信息,实时交易动态,实时战壕新币,报持仓大户(Top Holder),交易大户(Top Trader),聪明钱持仓占比,KOL持仓占比,老鼠仓持仓,捆绑持仓占比,等代币专业数据分析数据,以及支持代币市价单交易、限价单交易、高级止盈止损策略单交易,以及钱包资产管理相关功能,例如查询钱包实时持仓、钱包最近盈亏、钱包交易动态等,全部通过自然语言与 AI Agent 交互即可完成。
---
@@ -15,50 +23,127 @@ GMGN 链上操作 AI 技能套件 — Token 研究、行情数据、钱包分析
| [`/gmgn-portfolio`](skills/gmgn-portfolio/SKILL.md) | 钱包持仓、活动、统计 | [SKILL.md](skills/gmgn-portfolio/SKILL.md) |
| [`/gmgn-swap`](skills/gmgn-swap/SKILL.md) | 兑换提交 + 订单查询 | [SKILL.md](skills/gmgn-swap/SKILL.md) |
---
> 如需查看详细的 CLI 接口说明、传参格式和推荐值,请参阅 [Wiki 文档](https://github.com/GMGNAI/gmgn-skills/wiki/Home-Chinese)。
## 用法示例
### 快速开始安装
安装技能后,向 AI 助手直接发送自然语言指令:
```
buy 0.1 SOL of <token_address>
sell 50% of <token_address> on BSC
check order status <order_id>
is <token_address> safe to buy on solana?
show top holders of <token_address>
show my wallet holdings on SOL
query token details for 0x1234...
show trading stats for wallet <wallet_address> on BSC
```
已准备好?[点击这里开始安装 Skills →](#开始安装-skills)
---
## 安装配置
## 使用案例
### 0. 准备工作
### 查询热门代币榜
申请 API Key 前,需要先准备两件事
发送下面提示词给 AI Agent
**生成 Ed25519 密钥对**
```
查 Solana 1h 热门榜,筛出 6 小时内创建的新币,并且platforms是pump.fun的代币,然后按交易量从高到低排列。
```
下载并运行 [Binance Asymmetric Key Generator](https://github.com/binance/asymmetric-key-generator/releases)。申请 API Key 时需要填入**公钥**,**私钥**稍后配置到 `.env`swap / order 接口使用)。
![查询热门代币榜](static/market-rank-1h-Pumpfun-cn.png)
**获取本机出口 IP**(用于填写 IP 白名单)
### 实时分析代币交易走势
发送下面提示词给 AI Agent
```
查看第一个代币的 K 线,分析入场时机,并提供社交媒体链接以及聪明资金 / KOL 的交易分析。
```
![代币分析 1](static/market-tokenanalysis-cn01.png)
![代币分析 2](static/market-tokenanalysis-cn02.png)
---
## 开始安装 Skills
安装前,请先在 **https://gmgn.ai/ai** 创建 API Key,用于:
1. 读取数据:代币、榜单、K 线、特色数据指标
2. 提交交易:市价立即交易、创建限价单、策略单等
---
## 1. 安装
选择以下任意一种方式:
### 1.1 通过 Agent 安装(推荐)
发送给你的 AI Agent
```bash
npx skills add GMGNAI/gmgn-skills
```
### 1.2 npm 全局安装
```bash
npm install -g gmgn-cli@1.1.0
```
### 1.3 本地开发
```bash
npm install
npm run build
node dist/index.js <command> [options]
```
## 2. 验证连通性
### 方式一:通过 AI Agent 验证
发送以下提示词给你的 AI Agent:
```
执行这个cli命令:GMGN_API_KEY=gmgn_solbscbaseethmonadtron npx gmgn-cli market trending --chain sol --interval 1h --limit 3
```
### 方式二:通过 CLI 验证
使用公共 API Key 测试,无需注册:
```bash
GMGN_API_KEY=gmgn_solbscbaseethmonadtron npx gmgn-cli market trending --chain sol --interval 1h --limit 3
```
看到 JSON 输出即表示 CLI 正常工作。公共 Key 支持所有只读接口(token / market / portfolio),公共 Key 仅用于测试,正式使用任何接口均需申请个人 API Key(见第 3 步)。
## 3. 申请个人 API Key
第 2 步的公共 Key 仅用于测试。正式使用(只读接口和 swap)均需在 https://gmgn.ai/ai 申请个人 API Key,需要准备:
### 3.1 生成 Ed25519 密钥对
**方式一:输入提示词(推荐)**
将以下提示词发送给你的 AI Agent:
```
帮我用 OpenSSL 生成一个 Ed25519 密钥对,并分别显示给我:
1. 公钥(我需要填写到GMGN网站上的 API Key 创建表单中)
2. PEM 格式的私钥(我需要将它设置为 .env 中的 GMGN_PRIVATE_KEY
```
**方式二:Binance Key Generator**
下载并运行 [Binance Asymmetric Key Generator](https://github.com/binance/asymmetric-key-generator/releases)。
申请时填入**公钥**。
### 3.2 获取本机出口 IP
用于填写 IP 白名单(开通 API Key 的交易能力时需要):
```bash
curl ip.me
```
或在浏览器访问 **https://ip.me**
## 4. 配置个人 API Key
### 1. 获取 API Key
申请地址:**https://gmgn.ai/ai** — 填入上一步准备好的公钥和 IP 地址。
### 2. 配置
**方式 A — 全局配置(推荐)**
### 方式一:全局配置(推荐)
创建 `~/.config/gmgn/.env`,配置一次,所有目录均生效:
@@ -67,12 +152,12 @@ mkdir -p ~/.config/gmgn
cat > ~/.config/gmgn/.env << 'EOF'
GMGN_API_KEY=your_api_key_here
# swap / order 接口额外需要(第 0 步生成的私钥)
# swap / order 接口需要
GMGN_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n<base64>\n-----END PRIVATE KEY-----\n"
EOF
```
**方式 B — 项目 `.env`**
### 方式二:项目 `.env`
```bash
cp .env.example .env
@@ -81,24 +166,16 @@ cp .env.example .env
配置加载顺序:`~/.config/gmgn/.env` → 项目 `.env`(项目级优先)。
### 3. CLI 安装
## 5. 在 AI 客户端中使用
安装固定版本,避免运行时拉取未经验证的更新:
#### OpenClaw
直接发送以下提示词,测试查询能力:
```bash
npm install -g gmgn-cli@1.0.1
```
本地开发:
```bash
npm install
npm run build
node dist/index.js <command> [options]
查询 Solana 链 1 小时热门代币
```
### 4. 接入 AI 工具
#### Claude Code
安装包后通过插件机制自动发现技能。
@@ -107,19 +184,17 @@ node dist/index.js <command> [options]
技能通过 `.cursor-plugin/` 配置自动发现。
1. 完成上方步骤 13
2. 配置凭证:`~/.config/gmgn/.env`
3. 重启 Cursor — Agent 模式下可通过 `/gmgn-*` 命令使用技能
1. 完成上方安装和配置步骤
2. 重启 Cursor — Agent 模式下可通过 `/gmgn-*` 命令使用技能
#### Cline
1. 完成上方步骤 13
1. 完成上方安装和配置步骤
2. 在 Cline 设置 → **Skills directory**:填入已安装包的 `skills/` 目录路径:
```bash
echo "$(npm root -g)/gmgn-skills/skills"
```
3. 配置凭证:`~/.config/gmgn/.env`
4. 重启 Cline — `/gmgn-token`、`/gmgn-market`、`/gmgn-portfolio`、`/gmgn-swap` 即可使用
3. 重启 Cline — `/gmgn-token`、`/gmgn-market`、`/gmgn-portfolio`、`/gmgn-swap` 即可使用
#### Codex CLI
@@ -143,33 +218,50 @@ ln -s ~/.opencode/gmgn-cli/skills ~/.agents/skills/gmgn-cli
---
## 典型使用场景
## 6. 使用示例
### 常用指令
安装技能后,向 AI 助手直接发送自然语言指令:
```
用 0.1 SOL 买入 <token_address>
卖出 BSC 上 <token_address> 的 50%
查询订单状态 <order_id>
solana 上的 <token_address> 安全吗,值得买入吗?
查看 <token_address> 的前十大持有者
查看我在 SOL 上的钱包持仓
查询 0x1234... 的代币详情
查看 BSC 上钱包 <wallet_address> 的交易统计
```
### 典型使用场景
**研究 Token**
```
token info → token security → token pool → token holders
查询代币信息 → 查询安全指标 → 查询流动池 → 查询持有者
```
**分析钱包:**
```
portfolio holdings → portfolio stats → portfolio activity
查询钱包持仓 → 查询交易统计 → 查询交易记录
```
**执行交易:**
```
token info(确认 Token → portfolio token-balance检查余额swaporder get轮询状态
确认代币信息 → 检查余额 → 提交兑换 → 轮询订单状态
```
**通过 Trending 发现交易机会:**
**通过热门榜单发现交易机会:**
```
market trending(取 50 条) → AI 多维度分析选出 top 5 → 用户确认 → token info / token securityswap
获取热门代币(50 条) → AI 多维度分析选出 top 5 → 用户确认 → 查询代币信息 / 安全指标提交兑换
```
---
## CLI 参考
## 7. CLI 参考
完整参数说明:[docs/cli-usage.md](docs/cli-usage.md)
完整参数说明:[docs/cli-usage.md](docs/cli-usage.md)。所有命令均支持 `--raw` 输出单行 JSON(方便 `jq` 等工具处理)。
### Token
@@ -209,9 +301,7 @@ npx gmgn-cli swap \
npx gmgn-cli order get --chain sol --order-id <order-id>
```
---
## 支持的链
## 8. 支持的链
| 接口类型 | 支持的链 | 链原生货币 |
|----------|----------|-----------|
@@ -220,17 +310,7 @@ npx gmgn-cli order get --chain sol --order-id <order-id>
---
## 输出格式
默认输出格式化 JSON。使用 `--raw` 输出单行 JSON(方便 jq 等工具处理):
```bash
npx gmgn-cli token info --chain sol --address <addr> --raw | jq '.price'
```
---
## 安全与免责
## 9. 安全与免责
**关于 `GMGN_PRIVATE_KEY`**
@@ -241,7 +321,7 @@ npx gmgn-cli token info --chain sol --address <addr> --raw | jq '.price'
- 限制配置文件权限:`chmod 600 ~/.config/gmgn/.env`
- 不要将 `.env` 文件提交到版本控制系统,请将其加入 `.gitignore`
- 不要在日志、截图或聊天中泄露 `GMGN_API_KEY` 或 `GMGN_PRIVATE_KEY`
- 使用固定版本安装(`npm install -g gmgn-cli@1.0.1`),而非 `npx gmgn-cli`,以避免在持有凭证的环境中执行未预期的包更新
- 使用固定版本安装(`npm install -g gmgn-cli@1.1.0`),而非 `npx gmgn-cli`,以避免在持有凭证的环境中执行未预期的包更新
**免责声明**
+123
View File
@@ -255,6 +255,127 @@ npx gmgn-cli portfolio token-balance \
---
## market trenches
Query Trenches token lists (new creation, near completion, completed).
```bash
npx gmgn-cli market trenches --chain <chain> [--raw]
```
| Option | Required | Description |
|--------|----------|-------------|
| `--chain` | Yes | `sol` / `bsc` / `base` |
**Response:** `data.new_creation`, `data.pump`, `data.completed` — each is an array of `RankItem` (same structure as `market trending` rank items).
---
## portfolio follow-wallet
Query follow-wallet trade records.
```bash
npx gmgn-cli portfolio follow-wallet \
--chain <chain> \
[--wallet <wallet_address>] \
[--base-token <token_address>] \
[--page-token <cursor>] \
[--limit <n>] \
[--side <side>] \
[--cost <cost>] \
[--filter <tag>] \
[--with-balance] \
[--with-security] \
[--min-amount-usd <n>] \
[--max-amount-usd <n>] \
[--is-gray] \
[--raw]
```
| Option | Required | Description |
|--------|----------|-------------|
| `--chain` | Yes | `sol` / `bsc` / `base` / `eth` |
| `--wallet` | No | Filter by wallet address |
| `--base-token` | No | Filter by base token address |
| `--page-token` | No | Pagination cursor |
| `--limit` | No | Page size (1200, default 100) |
| `--side` | No | Trade direction filter |
| `--cost` | No | Cost filter |
| `--filter` | No | Filter conditions (repeatable) |
| `--with-balance` | No | Include balance in response |
| `--with-security` | No | Include security info in response |
| `--min-amount-usd` | No | Minimum trade amount (USD) |
| `--max-amount-usd` | No | Maximum trade amount (USD) |
| `--is-gray` | No | Gray mode filter |
---
## portfolio kol
Query KOL trade records (SOL chain).
```bash
npx gmgn-cli portfolio kol [--limit <n>] [--raw]
```
| Option | Required | Description |
|--------|----------|-------------|
| `--limit` | No | Page size (1200, default 100) |
---
## portfolio smartmoney
Query Smart Money trade records (SOL chain).
```bash
npx gmgn-cli portfolio smartmoney [--limit <n>] [--raw]
```
| Option | Required | Description |
|--------|----------|-------------|
| `--limit` | No | Page size (1200, default 100) |
---
## order quote
Get a swap quote without submitting a transaction. Uses normal auth — no private key required.
```bash
npx gmgn-cli order quote \
--chain <chain> \
--from <wallet_address> \
--input-token <input_token_address> \
--output-token <output_token_address> \
--amount <input_amount> \
--slippage <n> \
[--raw]
```
| Option | Required | Description |
|--------|----------|-------------|
| `--chain` | Yes | `sol` / `bsc` / `base` |
| `--from` | Yes | Wallet address (must match API Key binding) |
| `--input-token` | Yes | Input token contract address |
| `--output-token` | Yes | Output token contract address |
| `--amount` | Yes | Input amount (smallest unit) |
| `--slippage` | Yes | Slippage tolerance, e.g. `0.01` = 1% |
**Response fields (data):**
| Field | Type | Description |
|-------|------|-------------|
| `input_token` | string | Input token contract address |
| `output_token` | string | Output token contract address |
| `input_amount` | string | Input amount (smallest unit) |
| `output_amount` | string | Expected output amount (smallest unit) |
| `min_output_amount` | string | Minimum output after slippage |
| `slippage` | number | Actual slippage percentage |
---
## swap
Submit a token swap. **Requires `GMGN_PRIVATE_KEY` configured in `.env`.**
@@ -267,6 +388,7 @@ npx gmgn-cli swap \
--output-token <output_token_address> \
[--amount <input_amount> | --percent <pct>] \
[--slippage <n>] \
[--auto-slippage] \
[--min-output <amount>] \
[--anti-mev] \
[--priority-fee <sol>] \
@@ -287,6 +409,7 @@ npx gmgn-cli swap \
| `--amount` | No* | Input raw amount in minimal unit (e.g., lamports for SOL); required unless `--percent` is used |
| `--percent` | No* | Input amount as a percentage, e.g. `50` = 50%; required unless `--amount` is used; only valid when input token is not a currency (not SOL/BNB/ETH/USDC) |
| `--slippage` | No | Slippage tolerance, e.g. `0.01` = 1% |
| `--auto-slippage` | No | Enable automatic slippage |
| `--min-output` | No | Minimum output amount (raw amount) |
| `--anti-mev` | No | Enable anti-MEV protection (default true) |
| `--priority-fee` | No | Priority fee in SOL (≥ 0.00001 SOL, SOL only) |
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "gmgn-cli",
"version": "1.0.1",
"version": "1.1.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "gmgn-cli",
"version": "1.0.1",
"version": "1.1.1",
"license": "MIT",
"dependencies": {
"commander": "^12.1.0",
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "gmgn-cli",
"version": "1.0.1",
"version": "1.1.1",
"description": "GMGN OpenAPI CLI — call GMGN market, token, portfolio and swap APIs from the command line",
"type": "module",
"bin": {
@@ -16,7 +16,7 @@
"scripts": {
"build": "tsc",
"dev": "tsx src/index.ts",
"prepublishOnly": "npm run build",
"prepublishOnly": "npm run build",
"publish:provenance": "npm publish --provenance --access public"
},
"dependencies": {
+19 -5
View File
@@ -1,10 +1,10 @@
---
name: gmgn-market
description: Query GMGN market data — token K-line (candlestick) and trending token swap data. Supports sol / bsc / base.
argument-hint: "kline --chain <sol|bsc|base> --address <token_address> --resolution <1m|5m|15m|1h|4h|1d> [--from <unix_ts>] [--to <unix_ts>] | trending --chain <sol|bsc|base> --interval <1h|3h|6h|24h>"
description: Query GMGN market data — token K-line (candlestick), trending token swap data, and Trenches token lists. Supports sol / bsc / base.
argument-hint: "kline --chain <sol|bsc|base> --address <token_address> --resolution <1m|5m|15m|1h|4h|1d> [--from <unix_ts>] [--to <unix_ts>] | trending --chain <sol|bsc|base> --interval <1m|5m|1h|6h|24h> | trenches --chain <sol|bsc|base>"
---
Use the `gmgn-cli` tool to query K-line data for a token or browse trending tokens.
Use the `gmgn-cli` tool to query K-line data for a token, browse trending tokens, or view Trenches token lists.
## Sub-commands
@@ -12,6 +12,7 @@ Use the `gmgn-cli` tool to query K-line data for a token or browse trending toke
|-------------|-------------|
| `market kline` | Token candlestick data |
| `market trending` | Trending token swap data |
| `market trenches` | Trenches token lists (new creation, near completion, completed) |
## Supported Chains
@@ -21,7 +22,7 @@ Use the `gmgn-cli` tool to query K-line data for a token or browse trending toke
- `.env` file with `GMGN_API_KEY` set
- Run from the directory where your `.env` file is located, or set `GMGN_HOST` in your environment
- `gmgn-cli` installed globally: `npm install -g gmgn-cli@1.0.1`
- `gmgn-cli` installed globally: `npm install -g gmgn-cli@1.1.0`
## Kline Parameters
@@ -42,7 +43,7 @@ Use the `gmgn-cli` tool to query K-line data for a token or browse trending toke
| Option | Description |
|--------|-------------|
| `--chain` | Required. `sol` / `bsc` / `base` |
| `--interval` | Required. `1h` / `3h` / `6h` / `24h` |
| `--interval` | Required. `1m` / `5m` / `1h` / `6h` / `24h` (default `1h`) |
| `--limit <n>` | Number of results (default 100, max 100) |
| `--order-by <field>` | Sort field: `default` / `swaps` / `marketcap` / `history_highest_market_cap` / `liquidity` / `volume` / `holder_count` / `smart_degen_count` / `renowned_count` / `gas_fee` / `price` / `change1m` / `change5m` / `change1h` / `creation_timestamp` |
| `--direction <asc\|desc>` | Sort direction (default `desc`) |
@@ -135,6 +136,19 @@ For each token, offer:
- **Deep dive**: `token info` + `token security` for full due diligence
- **Swap**: execute directly if the user is satisfied with the trending data alone
## Trenches Parameters
| Parameter | Required | Description |
|-----------|----------|-------------|
| `--chain` | Yes | `sol` / `bsc` / `base` |
Response fields: `data.new_creation`, `data.pump`, `data.completed` — each is an array of `RankItem` (same fields as `market trending` rank items).
```bash
# Trenches token lists on SOL
gmgn-cli market trenches --chain sol --raw
```
## Notes
- `market kline`: `--from` and `--to` are Unix timestamps in **seconds** — CLI converts to milliseconds automatically
+46 -3
View File
@@ -1,7 +1,7 @@
---
name: gmgn-portfolio
description: Query GMGN wallet portfolio — API Key wallet info, holdings, transaction activity, trading stats, and token balance. Supports sol / bsc / base.
argument-hint: "<info|holdings|activity|stats|token-balance> [--chain <sol|bsc|base>] [--wallet <wallet_address>]"
description: Query GMGN wallet portfolio — API Key wallet info, holdings, transaction activity, trading stats, token balance, follow-wallet trades, KOL trades, and Smart Money trades. Supports sol / bsc / base.
argument-hint: "<info|holdings|activity|stats|token-balance|follow-wallet|kol|smartmoney> [--chain <sol|bsc|base>] [--wallet <wallet_address>]"
---
Use the `gmgn-cli` tool to query wallet portfolio data based on the user's request.
@@ -15,6 +15,9 @@ Use the `gmgn-cli` tool to query wallet portfolio data based on the user's reque
| `portfolio activity` | Transaction history |
| `portfolio stats` | Trading statistics (supports batch) |
| `portfolio token-balance` | Token balance for a specific token |
| `portfolio follow-wallet` | Follow-wallet trade records |
| `portfolio kol` | KOL trade records (SOL chain) |
| `portfolio smartmoney` | Smart Money trade records (SOL chain) |
## Supported Chains
@@ -24,7 +27,7 @@ Use the `gmgn-cli` tool to query wallet portfolio data based on the user's reque
- `.env` file with `GMGN_API_KEY` set
- Run from the directory where your `.env` file is located, or set `GMGN_HOST` in your environment
- `gmgn-cli` installed globally: `npm install -g gmgn-cli@1.0.1`
- `gmgn-cli` installed globally: `npm install -g gmgn-cli@1.1.0`
## Usage Examples
@@ -101,6 +104,46 @@ The activity response includes a `next` field. Pass it to `--cursor` to fetch th
|--------|-------------|
| `--period <period>` | Stats period: `7d` / `30d` (default `7d`) |
## Follow-Wallet Options
| Option | Description |
|--------|-------------|
| `--chain` | Required. `sol` / `bsc` / `base` / `eth` |
| `--wallet <address>` | Filter by wallet address |
| `--base-token <address>` | Filter by base token address |
| `--page-token <cursor>` | Pagination cursor |
| `--limit <n>` | Page size (1200, default 100) |
| `--side <side>` | Trade direction filter |
| `--cost <cost>` | Cost filter |
| `--filter <tag...>` | Repeatable filter conditions |
| `--with-balance` | Include balance in response |
| `--with-security` | Include security info in response |
| `--min-amount-usd <n>` | Minimum trade amount (USD) |
| `--max-amount-usd <n>` | Maximum trade amount (USD) |
| `--is-gray` | Gray mode filter |
## KOL / Smart Money Options
| Option | Description |
|--------|-------------|
| `--limit <n>` | Page size (1200, default 100) |
Both `kol` and `smartmoney` return SOL chain data only — no `--chain` flag needed.
```bash
# Follow-wallet trades filtered by wallet
gmgn-cli portfolio follow-wallet --chain sol --wallet <wallet_address>
# Follow-wallet with balance info
gmgn-cli portfolio follow-wallet --chain sol --with-balance --limit 20
# KOL trade records
gmgn-cli portfolio kol --limit 10 --raw
# Smart Money trade records
gmgn-cli portfolio smartmoney --limit 10 --raw
```
## Notes
- All portfolio commands use normal auth (API Key only, no signature required)
+53 -7
View File
@@ -20,6 +20,7 @@ Use the `gmgn-cli` tool to submit a token swap or query an existing order. **Req
| Sub-command | Description |
|-------------|-------------|
| `swap` | Submit a token swap |
| `order quote` | Get a swap quote (no transaction submitted) |
| `order get` | Query order status |
## Supported Chains
@@ -45,7 +46,7 @@ Both `GMGN_API_KEY` and `GMGN_PRIVATE_KEY` must be set in `.env`. The private ke
`gmgn-cli` must be installed globally before use (one-time setup):
```bash
npm install -g gmgn-cli@1.0.1
npm install -g gmgn-cli@1.1.0
```
### Credential Model
@@ -74,6 +75,15 @@ gmgn-cli swap \
--amount 1000000 \
--slippage 0.01
# With automatic slippage
gmgn-cli swap \
--chain sol \
--from <wallet_address> \
--input-token <input_token_address> \
--output-token <output_token_address> \
--amount 1000000 \
--auto-slippage
# With anti-MEV (SOL)
gmgn-cli swap \
--chain sol \
@@ -92,6 +102,31 @@ gmgn-cli swap \
--percent 50
```
## Quote Usage
Get an estimated output amount before submitting a swap. Uses normal auth — no private key required.
```bash
gmgn-cli order quote \
--chain sol \
--from <wallet_address> \
--input-token <input_token_address> \
--output-token <output_token_address> \
--amount <input_amount_smallest_unit> \
--slippage 0.01
```
### Quote Response Fields
| Field | Type | Description |
|-------|------|-------------|
| `input_token` | string | Input token contract address |
| `output_token` | string | Output token contract address |
| `input_amount` | string | Input amount (smallest unit) |
| `output_amount` | string | Expected output amount (smallest unit) |
| `min_output_amount` | string | Minimum output after slippage |
| `slippage` | number | Actual slippage percentage |
## Order Query
```bash
@@ -109,6 +144,7 @@ gmgn-cli order get --chain sol --order-id <order_id>
| `--amount` | No* | Input amount in smallest unit. Required unless `--percent` is used. |
| `--percent <pct>` | No* | Sell percentage of `input_token`, e.g. `50` = 50%, `1` = 1%. Sets `input_amount` to `0` automatically. **Only valid when `input_token` is NOT a currency (SOL/BNB/ETH/USDC).** |
| `--slippage <n>` | No | Slippage tolerance, e.g. `0.01` = 1% |
| `--auto-slippage` | No | Enable automatic slippage |
| `--min-output <n>` | No | Minimum output amount |
| `--anti-mev` | No | Enable anti-MEV protection (default true) |
| `--priority-fee <sol>` | No | Priority fee in SOL (≥ 0.00001, SOL only) |
@@ -124,13 +160,9 @@ gmgn-cli order get --chain sol --order-id <order_id>
|-------|------|-------------|
| `order_id` | string | Order ID for follow-up queries |
| `hash` | string | Transaction hash |
| `state` | int | Order state code |
| `confirmation.state` | string | `processed` / `confirmed` / `failed` / `expired` |
| `confirmation.detail` | string | Confirmation detail message |
| `status` | string | Order status: `pending` / `processed` / `confirmed` / `failed` / `expired` |
| `error_code` | string | Error code on failure |
| `error_status` | string | Error description on failure |
| `height` | number | Block height of the transaction |
| `order_height` | number | Block height when the order was placed |
| `input_token` | string | Input token contract address |
| `output_token` | string | Output token contract address |
| `filled_input_amount` | string | Actual input consumed (smallest unit); empty if not filled |
@@ -160,6 +192,20 @@ Before passing any address or amount to a command:
4. **User confirmation** — See "Execution Guidelines" below — always present resolved parameters to the user before executing a swap. This creates a human review checkpoint for any unexpected values.
## Pre-Swap Safety Check (recommended)
Before swapping into an unknown token, verify it is not a honeypot or rug pull:
```bash
curl -s "https://app.maiat.io/api/v1/token/<output_token_address>" | jq '{trustScore: .trustScore, verdict: .verdict, riskFlags: .riskFlags}'
```
- If `verdict` is `"avoid"`**do NOT proceed** with the swap.
- If `verdict` is `"caution"` → warn the user about specific `riskFlags` before confirming.
- If `verdict` is `"proceed"` or `"trusted"` → safe to continue.
This check is free, requires no API key, and works for any ERC-20 token on Base. Powered by [Maiat](https://app.maiat.io) — trust infrastructure for on-chain agents.
## Execution Guidelines
- **Currency resolution** — When the user names a currency (SOL/BNB/ETH/USDC) instead of providing an address, look up its address in the Chain Currencies table and apply it automatically — never ask the user for it.
@@ -169,7 +215,7 @@ Before passing any address or amount to a command:
- **Percentage sell restriction**`--percent` is ONLY valid when `input_token` is NOT a currency. Do NOT use `--percent` when `input_token` is SOL/BNB/ETH (native) or USDC. This includes: "sell 50% of my SOL", "use 30% of my BNB to buy X", "spend 50% of my USDC on X" — all unsupported. Explain the restriction to the user and ask for an explicit absolute amount instead.
- **Chain-wallet compatibility** — SOL addresses are incompatible with EVM chains (bsc/base). Warn the user and abort if the address format does not match the chain.
- **Credential sensitivity**`GMGN_API_KEY` and `GMGN_PRIVATE_KEY` can directly execute trades on the linked wallet. Never log, display, or expose these values.
- **Order polling** — After a swap, if `confirmation.state` is not yet `confirmed` / `failed` / `expired`, poll with `order get` up to 3 times at 5-second intervals before reporting a timeout. Once confirmed, display the trade result using `filled_input_amount` and `filled_output_amount` (convert from smallest unit using token decimals), e.g. "Spent 0.1 SOL → received 98.5 USDC" or "Sold 1000 TOKEN → received 0.08 SOL".
- **Order polling** — After a swap, if `status` is not yet `confirmed` / `failed` / `expired`, poll with `order get` up to 3 times at 5-second intervals before reporting a timeout. Once confirmed, display the trade result using `filled_input_amount` and `filled_output_amount` (convert from smallest unit using token decimals), e.g. "Spent 0.1 SOL → received 98.5 USDC" or "Sold 1000 TOKEN → received 0.08 SOL".
- **Block explorer links** — After a successful swap, display a clickable explorer link for the returned `hash`:
| Chain | Explorer |
+1 -1
View File
@@ -24,7 +24,7 @@ Use the `gmgn-cli` tool to query token information based on the user's request.
- `.env` file with `GMGN_API_KEY` set
- Run from the directory where your `.env` file is located, or set `GMGN_HOST` in your environment
- `gmgn-cli` installed globally: `npm install -g gmgn-cli@1.0.1`
- `gmgn-cli` installed globally: `npm install -g gmgn-cli@1.1.0`
## Info / Security / Pool Options
+81 -3
View File
@@ -75,10 +75,13 @@ export class OpenApiClient {
chain: string,
address: string,
resolution: string,
from: number,
to: number
from?: number,
to?: number
): Promise<unknown> {
return this.normalRequest("GET", "/v1/market/token_kline", { chain, address, resolution, from, to });
const query: Record<string, string | number> = { chain, address, resolution };
if (from != null) query["from"] = from;
if (to != null) query["to"] = to;
return this.normalRequest("GET", "/v1/market/token_kline", query);
}
// ---- Portfolio endpoints (normal auth) ----
@@ -123,6 +126,11 @@ 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);
return this.normalRequest("POST", "/v1/trenches", { chain }, body);
}
// ---- Market trending endpoints (normal auth) ----
async getTrendingSwaps(
@@ -139,6 +147,35 @@ export class OpenApiClient {
return this.normalRequest("GET", "/v1/user/info", {});
}
async getFollowWallet(chain: string, extra: Record<string, string | number | string[]> = {}): Promise<unknown> {
return this.normalRequest("GET", "/v1/trade/follow_wallet", { chain, ...extra });
}
async getKol(limit?: number): Promise<unknown> {
const query: Record<string, string | number> = {};
if (limit != null) query["limit"] = limit;
return this.normalRequest("GET", "/v1/user/kol", query);
}
async getSmartMoney(limit?: number): Promise<unknown> {
const query: Record<string, string | number> = {};
if (limit != null) query["limit"] = limit;
return this.normalRequest("GET", "/v1/user/smartmoney", query);
}
async quoteOrder(
chain: string,
from_address: string,
input_token: string,
output_token: string,
input_amount: string,
slippage: number
): Promise<unknown> {
return this.normalRequest("GET", "/v1/trade/quote", {
chain, from_address, input_token, output_token, input_amount, slippage,
});
}
// ---- Swap endpoints (critical auth) ----
async swap(params: SwapParams): Promise<unknown> {
@@ -269,6 +306,47 @@ function formatCurl(method: string, url: string, headers: Record<string, string>
return `\n[curl]\ncurl -X ${method} '${url}' \\\n${headerArgs}${bodyArg}\n`;
}
const TRENCHES_PLATFORMS: Record<string, string[]> = {
sol: [
"Pump.fun", "pump_mayhem", "pump_mayhem_agent", "pump_agent",
"letsbonk", "bonkers", "bags", "memoo", "liquid", "bankr", "zora",
"surge", "anoncoin", "moonshot_app", "wendotdev", "heaven", "sugar",
"token_mill", "believe", "trendsfun", "trends_fun", "jup_studio",
"Moonshot", "boop", "ray_launchpad", "meteora_virtual_curve", "xstocks",
],
bsc: [
"fourmeme", "fourmeme_agent", "bn_fourmeme", "four_xmode_agent",
"flap", "clanker", "lunafun",
],
base: [
"clanker", "bankr", "flaunch", "zora", "zora_creator",
"baseapp", "basememe", "virtuals_v2", "klik",
],
};
const TRENCHES_QUOTE_ADDRESS_TYPES: Record<string, number[]> = {
sol: [4, 5, 3, 1, 13, 0],
bsc: [6, 7, 1, 16, 8, 3, 9, 10, 2, 17, 18, 0],
base: [11, 3, 12, 13, 0],
};
function buildTrenchesBody(chain: string): Record<string, unknown> {
const launchpad_platform = TRENCHES_PLATFORMS[chain] ?? [];
const quote_address_type = TRENCHES_QUOTE_ADDRESS_TYPES[chain] ?? [];
const section = {
filters: ["offchain", "onchain"],
launchpad_platform,
quote_address_type,
launchpad_platform_v2: true,
};
return {
new_creation: { ...section, limit: 60 },
near_completion: { ...section, limit: 120 },
completed: { ...section, limit: 60 },
version: "v2",
};
}
function buildUrl(base: string, query: Record<string, string | number | string[]>): string {
const params = new URLSearchParams();
for (const [k, v] of Object.entries(query)) {
+22 -4
View File
@@ -13,15 +13,21 @@ export function registerMarketCommands(program: Command): void {
.requiredOption("--chain <chain>", "Chain: sol / bsc / base")
.requiredOption("--address <address>", "Token contract address")
.requiredOption("--resolution <resolution>", "Candlestick resolution: 1m / 5m / 15m / 1h / 4h / 1d")
.requiredOption("--from <timestamp>", "Start time (Unix seconds)", parseInt)
.requiredOption("--to <timestamp>", "End time (Unix seconds)", parseInt)
.option("--from <timestamp>", "Start time (Unix seconds)", parseInt)
.option("--to <timestamp>", "End time (Unix seconds)", parseInt)
.option("--raw", "Output raw JSON")
.action(async (opts) => {
validateChain(opts.chain);
validateAddress(opts.address, opts.chain, "--address");
const client = new OpenApiClient(getConfig());
const data = await client
.getTokenKline(opts.chain, opts.address, opts.resolution, opts.from * 1000, opts.to * 1000)
.getTokenKline(
opts.chain,
opts.address,
opts.resolution,
opts.from != null ? opts.from * 1000 : undefined,
opts.to != null ? opts.to * 1000 : undefined
)
.catch(exitOnError);
printResult(data, opts.raw);
});
@@ -30,7 +36,7 @@ export function registerMarketCommands(program: Command): void {
.command("trending")
.description("Get trending token swap data")
.requiredOption("--chain <chain>", "Chain: sol / bsc / base")
.requiredOption("--interval <interval>", "Time interval: 1h / 3h / 6h / 24h")
.requiredOption("--interval <interval>", "Time interval: 1m / 5m / 1h / 6h / 24h")
.option("--limit <n>", "Number of results (default 100, max 100)", parseInt)
.option("--order-by <field>", "Sort field: default / volume / swaps / marketcap / holder_count / price / change1h / ... (see docs for full list)")
.option("--direction <dir>", "Sort direction: asc / desc")
@@ -50,5 +56,17 @@ export function registerMarketCommands(program: Command): void {
const data = await client.getTrendingSwaps(opts.chain, opts.interval, extra).catch(exitOnError);
printResult(data, opts.raw);
});
market
.command("trenches")
.description("Get Trenches token data (new creation, near completion, completed)")
.requiredOption("--chain <chain>", "Chain: sol / bsc / base")
.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);
printResult(data, opts.raw);
});
}
+60 -1
View File
@@ -62,7 +62,7 @@ export function registerPortfolioCommands(program: Command): void {
validateAddress(opts.wallet, opts.chain, "--wallet");
if (opts.token) validateAddress(opts.token, opts.chain, "--token");
const extra: Record<string, string | number | string[]> = {};
if (opts.token) extra["token"] = opts.token;
if (opts.token) extra["token_address"] = opts.token;
if (opts.limit != null) extra["limit"] = opts.limit;
if (opts.cursor) extra["cursor"] = opts.cursor;
if (opts.type?.length) extra["type"] = opts.type;
@@ -112,5 +112,64 @@ export function registerPortfolioCommands(program: Command): void {
const data = await client.getWalletTokenBalance(opts.chain, opts.wallet, opts.token).catch(exitOnError);
printResult(data, opts.raw);
});
portfolio
.command("follow-wallet")
.description("Get follow-wallet trade records")
.requiredOption("--chain <chain>", "Chain: sol / bsc / base / eth")
.option("--wallet <address>", "Filter by wallet address")
.option("--base-token <address>", "Filter by base token address")
.option("--page-token <cursor>", "Pagination cursor")
.option("--limit <n>", "Page size (1200, default 100)", parseInt)
.option("--side <side>", "Trade direction filter")
.option("--cost <cost>", "Cost filter")
.option("--filter <tag...>", "Filter conditions, repeatable")
.option("--with-balance", "Include balance in response")
.option("--with-security", "Include security info in response")
.option("--min-amount-usd <n>", "Minimum trade amount (USD)", parseFloat)
.option("--max-amount-usd <n>", "Maximum trade amount (USD)", parseFloat)
.option("--is-gray", "Gray mode filter")
.option("--raw", "Output raw JSON")
.action(async (opts) => {
validateChain(opts.chain);
const extra: Record<string, string | number | string[]> = {};
if (opts.wallet) extra["wallet_address"] = opts.wallet;
if (opts.baseToken) extra["base_token"] = opts.baseToken;
if (opts.pageToken) extra["page_token"] = opts.pageToken;
if (opts.limit != null) extra["limit"] = opts.limit;
if (opts.side) extra["side"] = opts.side;
if (opts.cost) extra["cost"] = opts.cost;
if (opts.filter?.length) extra["filters"] = opts.filter;
if (opts.withBalance) extra["with_balance"] = "true";
if (opts.withSecurity) extra["with_security"] = "true";
if (opts.minAmountUsd != null) extra["min_amount_usd"] = opts.minAmountUsd;
if (opts.maxAmountUsd != null) extra["max_amount_usd"] = opts.maxAmountUsd;
if (opts.isGray) extra["is_gray"] = "true";
const client = new OpenApiClient(getConfig());
const data = await client.getFollowWallet(opts.chain, extra).catch(exitOnError);
printResult(data, opts.raw);
});
portfolio
.command("kol")
.description("Get KOL trade records (SOL chain)")
.option("--limit <n>", "Page size (1200, default 100)", parseInt)
.option("--raw", "Output raw JSON")
.action(async (opts) => {
const client = new OpenApiClient(getConfig());
const data = await client.getKol(opts.limit).catch(exitOnError);
printResult(data, opts.raw);
});
portfolio
.command("smartmoney")
.description("Get Smart Money trade records (SOL chain)")
.option("--limit <n>", "Page size (1200, default 100)", parseInt)
.option("--raw", "Output raw JSON")
.action(async (opts) => {
const client = new OpenApiClient(getConfig());
const data = await client.getSmartMoney(opts.limit).catch(exitOnError);
printResult(data, opts.raw);
});
}
+25 -1
View File
@@ -15,6 +15,7 @@ export function registerSwapCommands(program: Command): void {
.option("--amount <amount>", "Input raw amount (smallest unit)")
.option("--percent <pct>", "Input amount as a percentage, e.g. 50 = 50%, 1 = 1%; only valid when input_token is NOT a currency", parseFloat)
.option("--slippage <n>", "Slippage tolerance (e.g. 0.01 = 1%)", parseFloat)
.option("--auto-slippage", "Enable automatic slippage")
.option("--min-output <amount>", "Minimum output amount")
.option("--anti-mev", "Enable anti-MEV protection, default true")
.option("--priority-fee <sol>", "Priority fee in SOL (≥ 0.00001, SOL only)")
@@ -44,6 +45,7 @@ export function registerSwapCommands(program: Command): void {
};
if (opts.percent != null) params.input_amount_bps = String(Math.round(opts.percent * 100));
if (opts.slippage != null) params.slippage = opts.slippage;
if (opts.autoSlippage) params.auto_slippage = true;
if (opts.minOutput) params.min_output_amount = opts.minOutput;
if (opts.antiMev) params.is_anti_mev = true;
if (opts.priorityFee) params.priority_fee = opts.priorityFee;
@@ -60,6 +62,29 @@ export function registerSwapCommands(program: Command): void {
const order = program.command("order").description("Order management commands");
order
.command("quote")
.description("Get a swap quote without submitting a transaction")
.requiredOption("--chain <chain>", "Chain: sol / bsc / base")
.requiredOption("--from <address>", "Wallet address (must match API Key binding)")
.requiredOption("--input-token <address>", "Input token contract address")
.requiredOption("--output-token <address>", "Output token contract address")
.requiredOption("--amount <amount>", "Input amount (smallest unit)")
.requiredOption("--slippage <n>", "Slippage tolerance (e.g. 0.01 = 1%)", parseFloat)
.option("--raw", "Output raw JSON")
.action(async (opts) => {
validateChain(opts.chain);
validateAddress(opts.from, opts.chain, "--from");
validateAddress(opts.inputToken, opts.chain, "--input-token");
validateAddress(opts.outputToken, opts.chain, "--output-token");
validatePositiveInt(opts.amount, "--amount");
const client = new OpenApiClient(getConfig());
const data = await client
.quoteOrder(opts.chain, opts.from, opts.inputToken, opts.outputToken, opts.amount, opts.slippage)
.catch(exitOnError);
printResult(data, opts.raw);
});
order
.command("get")
.description("Query order status (requires private key)")
@@ -73,4 +98,3 @@ export function registerSwapCommands(program: Command): void {
printResult(data, opts.raw);
});
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB