Compare commits

...

25 Commits

Author SHA1 Message Date
David Lau dbe3eec697 docs(swap): require group_tag in order strategy list; add list examples
- Mark --group-tag as required (LimitOrder or STMix)
- Add usage examples: STMix for condition orders, LimitOrder for limit orders

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 15:05:01 +08:00
gumponchain a9979f9dd3 1.2.2 2026-04-08 11:58:55 +08:00
GMGN.AI 83aee6e759 Merge pull request #79 from GumpOnchain/docs/swap-group-tag-order-type
docs(swap): clarify group-tag and order-type descriptions
2026-04-08 11:50:45 +08:00
gumponchain 567c5f92d1 docs(swap): clarify group-tag and order-type descriptions
- --group-tag: LimitOrder fetches limit orders only; STMix fetches mixed strategy orders (take-profit, stop-loss, trailing variants)
- order cancel --order-type: clarify limit_order vs smart_trade meanings

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 11:47:35 +08:00
GMGN.AI 25b9da3fdf Merge pull request #78 from GMGNAI/feat/condition-order-trace-types
feat(swap): support profit_stop_trace and loss_stop_trace in condition orders
2026-04-08 11:09:29 +08:00
David Lau 7445c970bc feat(swap): support profit_stop_trace and loss_stop_trace in condition orders
- Add drawdown_rate optional field to StrategyConditionOrder interface
- Make price_scale optional (required only for fixed-price types)
- Update --condition-orders help text with trace type example
- Document all 4 condition order types in SKILL.md with field requirements,
  drawdown_rate semantics, and usage examples
- Sync order strategy create params: replace --side / auto-inference with
  explicit --order-type and --sub-order-type required options
- Add --group-tag to order strategy list params
- Add --order-type to order strategy cancel params
- Fix --gas-price description: gwei (not wei); CLI converts internally

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 11:02:31 +08:00
GMGN.AI c525fba661 Merge pull request #77 from prodev-nova/feat/cooking
docs(cooking): improve guided launch flow and clarify env credential lookup
2026-04-07 15:46:15 +08:00
prodev-nova 0ce0051e60 docs(cooking): improve guided launch flow and clarify env credential lookup
- Rewrite Guided Launch Flow: required fields collected one at a time,
  optional fields grouped into a single question for faster UX
- Add env lookup warning: document that a local .env in the workspace
  overrides ~/.config/gmgn/.env, with a check command
2026-04-07 15:08:06 +08:00
GMGN.AI 49397c2b62 Merge pull request #75 from GumpOnchain/order-fix
docs(swap): fix price_scale definition and update all skills
2026-04-03 17:14:16 +08:00
gumponchain 8999d36d1d docs(swap): fix price_scale definition and update all skills
- Redefine price_scale: profit_stop uses gain % from entry (e.g. "100" = +100% / 2×), loss_stop uses drop % from entry (e.g. "65" = drops 65%)
- Update all condition-order examples in SKILL.md and both READMEs accordingly
- Add is_anti_mev recommended note and anti-mev flag to swap examples
- Add order strategy create to Financial Risk Notice
- Fix response section heading format (bold → ###) for order strategy create/list
- Add reset_at field extraction guidance to Rate Limit Handling in all 6 skills

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 17:11:16 +08:00
GMGN.AI 013a6c867c Merge pull request #74 from GumpOnchain/order-fix
docs(swap): add condition-orders, ConditionOrder fields, and sell-ratio-type descriptions
2026-04-03 16:03:43 +08:00
gumponchain 29eeb723e4 docs(swap): add swap with TP/SL examples to readmes and update SKILL.md
- Add "Swap with Take-Profit / Stop-Loss Orders" section to Readme.md and Readme.zh.md
  with hold_amount and buy_amount mode examples (TP at +100%/+300%, SL at -65%)
- Reorder CLI Reference section: basic Swap moved before TP/SL examples
- Update SKILL.md condition-orders examples: add stop-loss at -65%, bump slippage to 0.3,
  add note that hold_amount includes any added positions at trigger time

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 15:52:40 +08:00
gumponchain 60a199cb80 docs(swap): add condition-orders params, ConditionOrder fields, and sell-ratio-type descriptions
- Add --condition-orders parameter with max-10-sub-orders note and best-effort strategy behavior
- Add --sell-ratio-type with detailed explanation of buy_amount vs hold_amount semantics
- Add ConditionOrder sub-table (order_type, side, price_scale, sell_ratio) with supported types
- Add two full CLI examples: hold_amount (sell 50% at 2x, remaining 50% at 4x) and buy_amount (fixed ratio each trigger)
- Add strategy_order_id to swap response fields
- Update --sell-ratio-type description in order strategy create section

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 15:32:50 +08:00
deepfeature e4bc94c625 Merge pull request #73 from GMGNAI/codex-issue-72-strategy-list-auth
[codex] Fix strategy list signature auth
2026-04-03 14:23:58 +08:00
deepfeature ed27705826 fix strategy list signature auth 2026-04-03 14:21:59 +08:00
GMGNAI e9ff951083 1.2.1 2026-04-03 12:24:49 +08:00
GMGNAI f7a2d075e3 1.2.0 2026-04-03 12:22:45 +08:00
gumponchain 8e413cef25 1.1.10 2026-04-03 12:18:06 +08:00
GMGN.AI 7959eaaed3 Merge pull request #71 from GumpOnchain/order-fix
fix(swap): remove --open-price and update docs with limit order & cooking examples
2026-04-03 12:16:45 +08:00
gumponchain 8c27e42aff fix(swap): remove --open-price parameter and update docs with cooking/limit order examples
- Remove --open-price option from swap order strategy create command
- Remove open_price field from OpenApiClient StrategyCreateParams type
- Update skills/gmgn-swap/SKILL.md: drop open-price row and inference table, simplify examples to use --sub-order-type directly
- Update docs/cli-usage.md: remove --open-price from command signature and parameter table
- Add /gmgn-cooking skill to Skills tables in Readme.md and Readme.zh.md
- Add limit order and cooking CLI examples to section 8 of both readmes
- Update Cline install instructions to include /gmgn-cooking

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 12:14:52 +08:00
GMGN.AI ae7729f26c Merge pull request #70 from GMGNAI/feat/cooking
feat(cooking): add cooking command with condition orders support
2026-04-03 11:57:01 +08:00
David Lau 759ab74709 fix(strategy): add missing order_type/sub_order_type, condition_orders, and group_tag
- Add --order-type and --sub-order-type as required flags to order strategy create
  (server requires both; omitting them caused every create call to 400)
- Remove --side from strategy create (field no longer exists in the API)
- Make --open-price optional in strategy create (matches API spec)
- Fix --gas-price in strategy create to convert gwei→wei (consistent with swap)
- Add --condition-orders and --sell-ratio-type to swap command for
  take-profit/stop-loss conditions attached after a successful swap
- Add --group-tag (LimitOrder/STMix) to order strategy list
- Add --order-type to order strategy cancel
- Add StrategyConditionOrder interface; extend SwapParams with condition_orders
  and sell_ratio_type; add order_type/sub_order_type to StrategyCreateParams;
  remove side; add order_type to StrategyCancelParams
- Update docs/cli-usage.md: fix strategy create table, add chain fee requirement
  notes (SOL requires priority_fee+tip_fee; BSC requires gas_price), add
  condition_orders example and strategy_order_id response field, add
  TRADING_BOT_UNAVAILABLE error code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 21:57:45 +08:00
axel dd1cb9d2e5 docs(cooking): rewrite SKILL.md with full guided launch flow and safety infrastructure
- Align opening banners with other GMGN skills (IPv6, no-guess, no-websearch)
- Add Core Concepts section (bonding curve, --buy-amt human units, --dex identifiers, image input, status polling, slippage)
- Add Financial Risk Notice (irreversible transactions, explicit confirmation required)
- Add Guided Launch Flow (6-step wizard: chain/platform → identity → logo → social → buy-amt → confirm)
- Add Rate Limit Handling with leaky-bucket weights
- Add First-time setup and Credential Model sections
- Add Pre-create Confirmation and Post-create Receipt output templates
- Add Execution Guidelines (confirmation, dex validation, image handling, order polling)
- Add --description parameter for token project pitch
- Add References table linking to other GMGN skills (swap, token, market, track, portfolio)
- Remove cross-skill dependencies (standalone skill, no gmgn-swap references)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 21:57:45 +08:00
deepfeature b12a2294b7 feat: add cooking command and update swap/docs 2026-04-02 21:57:45 +08:00
deepfeature 56086fa692 Merge pull request #67 from GMGNAI/codex-issue-13-fix
[codex] fix rate limit handling for skills
2026-04-01 14:18:18 +08:00
13 changed files with 327 additions and 73 deletions
+91 -3
View File
@@ -10,7 +10,7 @@ English | [简体中文](Readme.zh.md)
## 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.
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, one-command cooking orders (buy + condition orders in a single flow), and wallet management — including real-time holdings, recent P&L, and transaction history — all through natural language.
---
@@ -89,7 +89,8 @@ No more scraping web pages or getting blocked by Cloudflare. Query all the profe
| [`/gmgn-market`](skills/gmgn-market/SKILL.md) | K-line market data, trending tokens | [SKILL.md](skills/gmgn-market/SKILL.md) |
| [`/gmgn-portfolio`](skills/gmgn-portfolio/SKILL.md) | Wallet holdings, activity, stats | [SKILL.md](skills/gmgn-portfolio/SKILL.md) |
| [`/gmgn-track`](skills/gmgn-track/SKILL.md) | Follow-wallet trades, KOL trades, Smart Money trades | [SKILL.md](skills/gmgn-track/SKILL.md) |
| [`/gmgn-swap`](skills/gmgn-swap/SKILL.md) | Swap submission + order query | [SKILL.md](skills/gmgn-swap/SKILL.md) |
| [`/gmgn-swap`](skills/gmgn-swap/SKILL.md) | Swap submission + limit orders + strategy orders + order query | [SKILL.md](skills/gmgn-swap/SKILL.md) |
| [`/gmgn-cooking`](skills/gmgn-cooking/SKILL.md) | One-command cooking orders (buy + take-profit/stop-loss in a single flow) | [SKILL.md](skills/gmgn-cooking/SKILL.md) |
> For detailed CLI commands, parameters, and recommended values, see the [Wiki documentation](https://github.com/GMGNAI/gmgn-skills/wiki).
@@ -341,7 +342,7 @@ Skills are automatically discovered via the `.cursor-plugin/` configuration.
```bash
echo "$(npm root -g)/gmgn-skills/skills"
```
3. Restart Cline — `/gmgn-token`, `/gmgn-market`, `/gmgn-portfolio`, `/gmgn-track`, `/gmgn-swap` will be available
3. Restart Cline — `/gmgn-token`, `/gmgn-market`, `/gmgn-portfolio`, `/gmgn-track`, `/gmgn-swap`, `/gmgn-cooking` will be available
#### Codex CLI
@@ -542,6 +543,93 @@ gmgn-cli order quote \
gmgn-cli order get --chain sol --order-id <order-id>
```
### Swap with Take-Profit / Stop-Loss Orders (requires private key)
**`hold_amount` mode** — each condition order fires based on current holdings at trigger time:
```bash
# Buy token A with 0.01 SOL; take-profit 50% at +100%, take-profit remaining 50% at +300%, stop-loss 100% at -65%
gmgn-cli swap \
--chain sol \
--from <wallet_address> \
--input-token So11111111111111111111111111111111111111112 \
--output-token <token_A_address> \
--amount 10000000 \
--slippage 0.3 \
--anti-mev \
--condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"100","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"300","sell_ratio":"100"},{"order_type":"loss_stop","side":"sell","price_scale":"65","sell_ratio":"100"}]' \
--sell-ratio-type hold_amount
```
> `price_scale` for `profit_stop`: gain % from entry (`"100"` = +100% / 2×, `"300"` = +300% / 4×). For `loss_stop`: drop % from entry (`"65"` = drops 65%, triggers at 35% of entry).
> `hold_amount`: the second take-profit fires on whatever is held at that point (the remaining 50%). If you added to your position in between, those additional tokens will be included as well.
**`buy_amount` mode** — each condition order fires based on the original bought amount:
```bash
# Same strategy using fixed percentages of the original bought amount
gmgn-cli swap \
--chain sol \
--from <wallet_address> \
--input-token So11111111111111111111111111111111111111112 \
--output-token <token_A_address> \
--amount 10000000 \
--slippage 0.3 \
--anti-mev \
--condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"100","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"300","sell_ratio":"50"},{"order_type":"loss_stop","side":"sell","price_scale":"65","sell_ratio":"100"}]' \
--sell-ratio-type buy_amount
```
> `buy_amount`: each take-profit sells 50% of the **original** bought amount. Stop-loss sells 100% of the original bought amount.
---
### Limit Orders (requires private key)
```bash
# Create a take-profit order
gmgn-cli order strategy create \
--chain sol \
--from <wallet_address> \
--base-token <token_address> \
--quote-token <sol_address> \
--sub-order-type take_profit \
--check-price 0.002 \
--amount-in-percent 100 \
--slippage 0.01
# Create a stop-loss order
gmgn-cli order strategy create \
--chain sol \
--from <wallet_address> \
--base-token <token_address> \
--quote-token <sol_address> \
--sub-order-type stop_loss \
--check-price 0.0005 \
--amount-in-percent 100 \
--slippage 0.01
# List open strategy orders (requires private key)
gmgn-cli order strategy list --chain sol
# Cancel a strategy order
gmgn-cli order strategy cancel --chain sol --from <wallet_address> --order-id <order_id>
```
### Cooking (requires private key)
```bash
# Buy token and automatically attach take-profit + stop-loss condition orders
gmgn-cli cooking \
--chain sol \
--from <wallet_address> \
--input-token So11111111111111111111111111111111111111112 \
--output-token <token_address> \
--amount 1000000000 \
--slippage 0.3 \
--condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"100","sell_ratio":"100"},{"order_type":"loss_stop","side":"sell","price_scale":"50","sell_ratio":"100"}]'
```
## 9. Supported Chains
| Commands | Chains | Chain Currencies |
+91 -3
View File
@@ -10,7 +10,7 @@
## GMGN Agent Skills
使用 GMGN Agent Skills,你可以通过 AI Agent 实时查询多个链上热门代币排行榜,代币基础信息,社交媒体信息,实时交易动态,实时战壕新币,报持仓大户(Top Holder),交易大户(Top Trader),聪明钱持仓占比,KOL持仓占比,老鼠仓持仓,捆绑持仓占比,等代币专业数据分析数据,以及支持代币市价单交易、限价单交易、高级止盈止损策略单交易,以及钱包资产管理相关功能,例如查询钱包实时持仓、钱包最近盈亏、钱包交易动态等,全部通过自然语言与 AI Agent 交互即可完成。
使用 GMGN Agent Skills,你可以通过 AI Agent 实时查询多个链上热门代币排行榜,代币基础信息,社交媒体信息,实时交易动态,实时战壕新币,报持仓大户(Top Holder),交易大户(Top Trader),聪明钱持仓占比,KOL持仓占比,老鼠仓持仓,捆绑持仓占比,等代币专业数据分析数据,以及支持代币市价单交易、限价单交易、高级止盈止损策略单交易、一键 Cooking 策略单(买入 + 条件单一体化),以及钱包资产管理相关功能,例如查询钱包实时持仓、钱包最近盈亏、钱包交易动态等,全部通过自然语言与 AI Agent 交互即可完成。
---
@@ -92,7 +92,8 @@ SOL / BSC / Base 多链数据每次查询均为实时,支持多参数个性化
| [`/gmgn-market`](skills/gmgn-market/SKILL.md) | K 线行情数据、热门代币 | [SKILL.md](skills/gmgn-market/SKILL.md) |
| [`/gmgn-portfolio`](skills/gmgn-portfolio/SKILL.md) | 钱包持仓、活动、统计 | [SKILL.md](skills/gmgn-portfolio/SKILL.md) |
| [`/gmgn-track`](skills/gmgn-track/SKILL.md) | 追踪关注钱包交易动态、KOL 交易动态、聪明钱交易动态 | [SKILL.md](skills/gmgn-track/SKILL.md) |
| [`/gmgn-swap`](skills/gmgn-swap/SKILL.md) | 兑换提交 + 订单查询 | [SKILL.md](skills/gmgn-swap/SKILL.md) |
| [`/gmgn-swap`](skills/gmgn-swap/SKILL.md) | 兑换提交 + 限价单 + 策略单 + 订单查询 | [SKILL.md](skills/gmgn-swap/SKILL.md) |
| [`/gmgn-cooking`](skills/gmgn-cooking/SKILL.md) | 一键 Cooking 策略单(买入 + 止盈止损条件单一体化) | [SKILL.md](skills/gmgn-cooking/SKILL.md) |
> 如需查看详细的 CLI 接口说明、传参格式和推荐值,请参阅 [Wiki 文档](https://github.com/GMGNAI/gmgn-skills/wiki/Home-Chinese)。
@@ -345,7 +346,7 @@ cp .env.example .env
```bash
echo "$(npm root -g)/gmgn-skills/skills"
```
3. 重启 Cline — `/gmgn-token`、`/gmgn-market`、`/gmgn-portfolio`、`/gmgn-track`、`/gmgn-swap` 即可使用
3. 重启 Cline — `/gmgn-token`、`/gmgn-market`、`/gmgn-portfolio`、`/gmgn-track`、`/gmgn-swap`、`/gmgn-cooking` 即可使用
#### Codex CLI
@@ -574,6 +575,93 @@ gmgn-cli order quote \
gmgn-cli order get --chain sol --order-id <order-id>
```
### 带止盈止损的 Swap(需要私钥)
**`hold_amount` 模式** — 按触发时的实际持仓比例卖出:
```bash
# 用 0.01 SOL 买入代币 A;涨 100% 卖 50%,涨 300% 卖剩余 50%,跌 65% 全卖
gmgn-cli swap \
--chain sol \
--from <wallet_address> \
--input-token So11111111111111111111111111111111111111112 \
--output-token <token_A_address> \
--amount 10000000 \
--slippage 0.3 \
--anti-mev \
--condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"100","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"300","sell_ratio":"100"},{"order_type":"loss_stop","side":"sell","price_scale":"65","sell_ratio":"100"}]' \
--sell-ratio-type hold_amount
```
> `price_scale` 止盈时为涨幅百分比(`"100"` = 涨 100% / 2×,`"300"` = 涨 300% / 4×);止损时为跌幅百分比(`"65"` = 跌 65%,触发价为入场价的 35%)。
> `hold_amount`:第二个止盈单触发时,按触发时持仓(剩余 50%)的 100% 卖出。如果中间有加仓,加仓的部分也会一同被卖掉。
**`buy_amount` 模式** — 按原始买入量的固定百分比卖出:
```bash
# 相同策略,使用原始买入量的固定百分比
gmgn-cli swap \
--chain sol \
--from <wallet_address> \
--input-token So11111111111111111111111111111111111111112 \
--output-token <token_A_address> \
--amount 10000000 \
--slippage 0.3 \
--anti-mev \
--condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"100","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"300","sell_ratio":"50"},{"order_type":"loss_stop","side":"sell","price_scale":"65","sell_ratio":"100"}]' \
--sell-ratio-type buy_amount
```
> `buy_amount`:每个止盈单各卖原始买入量的 50%,止损单卖原始买入量的 100%。
---
### 限价单(需要私钥)
```bash
# 创建止盈单
gmgn-cli order strategy create \
--chain sol \
--from <wallet_address> \
--base-token <token_address> \
--quote-token <sol_address> \
--sub-order-type take_profit \
--check-price 0.002 \
--amount-in-percent 100 \
--slippage 0.01
# 创建止损单
gmgn-cli order strategy create \
--chain sol \
--from <wallet_address> \
--base-token <token_address> \
--quote-token <sol_address> \
--sub-order-type stop_loss \
--check-price 0.0005 \
--amount-in-percent 100 \
--slippage 0.01
# 查看当前挂单(需要私钥)
gmgn-cli order strategy list --chain sol
# 撤销策略单
gmgn-cli order strategy cancel --chain sol --from <wallet_address> --order-id <order_id>
```
### Cooking 一键策略单(需要私钥)
```bash
# 买入代币,同时自动挂止盈 + 止损条件单
gmgn-cli cooking \
--chain sol \
--from <wallet_address> \
--input-token So11111111111111111111111111111111111111112 \
--output-token <token_address> \
--amount 1000000000 \
--slippage 0.3 \
--condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"100","sell_ratio":"100"},{"order_type":"loss_stop","side":"sell","price_scale":"50","sell_ratio":"100"}]'
```
## 9. 支持的链
| 接口类型 | 支持的链 | 链原生货币 |
+1 -3
View File
@@ -483,7 +483,6 @@ gmgn-cli order strategy create \
--order-type <limit_order> \
--sub-order-type <buy_low|buy_high|stop_loss|take_profit> \
--check-price <price> \
[--open-price <price>] \
[--amount-in <amount> | --amount-in-percent <pct>] \
[--slippage <n> | --auto-slippage] \
[--limit-price-mode <exact|slippage>] \
@@ -505,7 +504,6 @@ gmgn-cli order strategy create \
| `--order-type` | Yes | Order type: `limit_order` |
| `--sub-order-type` | Yes | Sub-order type: `buy_low` / `buy_high` / `stop_loss` / `take_profit` |
| `--check-price` | Yes | Trigger check price |
| `--open-price` | No | Open/entry price |
| `--amount-in` | No* | Input amount (smallest unit); required unless `--amount-in-percent` is used |
| `--amount-in-percent` | No* | Input as percentage (e.g. `50` = 50%); required unless `--amount-in` is used |
| `--limit-price-mode` | No | `exact` / `slippage` (default: `slippage`) |
@@ -534,7 +532,7 @@ gmgn-cli order strategy create \
## order strategy list
List strategy orders. Uses normal auth.
List strategy orders. **Requires `GMGN_PRIVATE_KEY` configured in `.env`.**
```bash
gmgn-cli order strategy list --chain <chain> [--type <open|history>] [--from <address>] [--group-tag <tag>] [--base-token <address>] [--page-token <token>] [--limit <n>] [--raw]
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "gmgn-cli",
"version": "1.1.9",
"version": "1.2.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "gmgn-cli",
"version": "1.1.9",
"version": "1.2.2",
"license": "MIT",
"dependencies": {
"commander": "^12.1.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "gmgn-cli",
"version": "1.1.9",
"version": "1.2.2",
"description": "GMGN OpenAPI CLI — call GMGN market, token, portfolio and swap APIs from the command line",
"type": "module",
"bin": {
+39 -22
View File
@@ -66,6 +66,12 @@ When the user names a platform colloquially (e.g. "pump.fun", "four.meme", "Panc
- `cooking create`: Both `GMGN_API_KEY` and `GMGN_PRIVATE_KEY` must be configured in `~/.config/gmgn/.env`. The private key must correspond to the wallet bound to the API Key.
- `gmgn-cli` installed globally — if missing, run: `npm install -g gmgn-cli`
**IMPORTANT — Credential lookup order:** `gmgn-cli` loads `~/.config/gmgn/.env` first, then overlays any `.env` found in the **current working directory** (project-level overrides global). If credentials appear missing or wrong, check whether a `.env` in the workspace directory is shadowing the global config:
```bash
ls -la .env 2>/dev/null && echo "WARNING: local .env is overriding ~/.config/gmgn/.env"
```
If a local `.env` exists but lacks `GMGN_API_KEY` / `GMGN_PRIVATE_KEY`, either add them to that file or remove it so the global config is used.
## Rate Limit Handling
All cooking routes go through GMGN's leaky-bucket limiter with `rate=10` and `capacity=10`. Sustained throughput is roughly `10 ÷ weight` requests/second.
@@ -78,6 +84,7 @@ All cooking routes go through GMGN's leaky-bucket limiter with `rate=10` and `ca
When a request returns `429`:
- Read `X-RateLimit-Reset` from the response headers — Unix timestamp for when the limit resets.
- If the response body contains `reset_at` (e.g., `{"code":429,"error":"RATE_LIMIT_BANNED","message":"...","reset_at":1775184222}`), extract `reset_at` — it is the Unix timestamp when the ban lifts (typically 5 minutes). Convert to local time and tell the user exactly when they can retry.
- `cooking create` is a real transaction: **never loop or auto-resubmit** after a `429`. Wait until the reset time, then ask for confirmation again before retrying.
- For `RATE_LIMIT_EXCEEDED` or `RATE_LIMIT_BANNED`, repeated requests during cooldown extend the ban by 5 seconds each time, up to 5 minutes.
@@ -270,13 +277,15 @@ Block explorer links:
## Guided Launch Flow
When a user says they want to launch / create / deploy a token but has not provided all required information, do NOT ask for everything at once. Collect information in this order, one step at a time:
When a user says they want to launch / create / deploy a token but has not provided all required information, collect information **one required field at a time** — never bundle multiple required fields into a single question. The user should be able to reply with a single value, not a labeled list.
Ask each required field as a short, direct question. Wait for the answer before moving to the next. Optional fields are grouped into one question after all required fields are collected.
### Step 1 — Chain & Platform
Ask: *"Which chain and platform do you want to launch on?"*
Ask: *"Which chain and platform?"*
Show the available options:
Show the options concisely:
| Chain | Platform | `--dex` |
|-------|----------|---------|
@@ -294,39 +303,47 @@ Show the available options:
| Base | Flaunch | `flaunch` |
| Base | Virtuals | `virtuals_v2` |
If the user is unsure, recommend: **Pump.fun (SOL)** or **FourMeme (BSC)** — the two most active launchpads.
If the user is unsure, recommend: **Pump.fun (SOL)** or **FourMeme (BSC)**.
### Step 2 — Token Identity
### Step 2 — Token Name
Ask for name, symbol, and description together:
Ask: *"Token name?"*
*"What is your token's name, ticker symbol, and a short description?"*
Wait for the user's reply (e.g. `Doge Killer`).
- Name: the full display name (e.g. `Doge Killer`)
- Symbol: short uppercase ticker, typically 38 characters (e.g. `DOGEK`)
- Description: optional but recommended — a one-line pitch shown on the launchpad
### Step 3 — Token Symbol
### Step 3 — Logo
Ask: *"Ticker symbol?"*
Ask: *"Do you have a logo image? You can share a file path (e.g. `/Users/you/logo.png`) or an image URL."*
Wait for the user's reply (e.g. `DOGEK`). Typically 38 uppercase characters.
- If the user provides a **file path**: silently run `base64 -i <path>` and pass the result to `--image`. Do not mention "base64" to the user.
- If the user provides a **URL**: use `--image-url` directly.
- If the user has no logo: note that most platforms accept a launch without one, but it significantly reduces visibility. Ask if they want to proceed without it.
### Step 4 — Logo
### Step 4 — Social Links (optional)
Ask: *"Logo image? (file path or URL — skip to launch without one)"*
Ask: *"Do you have a Twitter, Telegram, or website to attach to the token? You can skip this."*
Collect any combination of `--twitter`, `--telegram`, `--website`. If the user skips, proceed to the next step.
- **File path** → silently run `base64 -i <path>` and pass the result to `--image`. Do not mention "base64" to the user.
- **URL** → use `--image-url` directly.
- **Skip / none** → proceed without a logo. Note that most platforms accept this, but it reduces visibility.
### Step 5 — Initial Buy Amount
Ask: *"How much {SOL / BNB / ETH} do you want to spend on the initial buy?"*
Ask: *"How much {SOL / BNB / ETH} for the initial buy?"*
Pass the user's answer directly to `--buy-amt` — this is already in full token units (e.g. `0.01` = 0.01 SOL), do NOT convert to lamports or wei.
Pass the user's answer directly to `--buy-amt` — already in full token units (e.g. `0.01` = 0.01 SOL). Do NOT convert to lamports or wei.
### Step 6 — Confirmation & Execute
### Step 6 — Optional Details (single question)
Ask all optional fields together in one message:
*"Any optional extras? (skip any you don't need)"*
- *Description* — one-line pitch shown on the launchpad
- *Twitter* — Twitter / X URL
- *Telegram* — Telegram group URL
- *Website* — project website URL
The user can reply with just the ones they have, or say "skip" / "none" to proceed.
### Step 7 — Confirmation & Execute
Once all information is collected, present the pre-create confirmation summary (see Output Format section) and wait for the user to reply "confirm" before executing.
+1
View File
@@ -71,6 +71,7 @@ All market routes used by this skill go through GMGN's leaky-bucket limiter with
When a request returns `429`:
- Read `X-RateLimit-Reset` from the response headers. It is a Unix timestamp in seconds that marks when the limit is expected to reset.
- If the response body contains `reset_at` (e.g., `{"code":429,"error":"RATE_LIMIT_BANNED","message":"...","reset_at":1775184222}`), extract `reset_at` — it is the Unix timestamp when the ban lifts (typically 5 minutes). Convert to local time and tell the user exactly when they can retry.
- The CLI may wait and retry once automatically when the remaining cooldown is short. If it still fails, stop and tell the user the exact retry time instead of sending more requests.
- For `RATE_LIMIT_EXCEEDED` or `RATE_LIMIT_BANNED`, repeated requests during the cooldown can extend the ban by 5 seconds each time, up to 5 minutes. Do not spam retries.
+1
View File
@@ -64,6 +64,7 @@ All portfolio routes used by this skill go through GMGN's leaky-bucket limiter w
When a request returns `429`:
- Read `X-RateLimit-Reset` from the response headers. It is a Unix timestamp in seconds that marks when the limit is expected to reset.
- If the response body contains `reset_at` (e.g., `{"code":429,"error":"RATE_LIMIT_BANNED","message":"...","reset_at":1775184222}`), extract `reset_at` — it is the Unix timestamp when the ban lifts (typically 5 minutes). Convert to local time and tell the user exactly when they can retry.
- The CLI may wait and retry once automatically when the remaining cooldown is short. If it still fails, stop and tell the user the exact retry time instead of sending more requests.
- For `RATE_LIMIT_EXCEEDED` or `RATE_LIMIT_BANNED`, repeated requests during the cooldown can extend the ban by 5 seconds each time, up to 5 minutes. Do not spam retries.
+90 -30
View File
@@ -24,7 +24,7 @@ Use the `gmgn-cli` tool to submit a token swap or query an existing order. **Req
- **Currency tokens** — Each chain has designated currency tokens (SOL, BNB, ETH, USDC). These are the base assets used to buy other tokens or receive swap proceeds. Their contract addresses are fixed — look them up in the Chain Currencies table, never guess them.
- **Anti-MEV** — MEV (Miner/Maximal Extractable Value) refers to frontrunning and sandwich attacks where bots exploit pending transactions. `--anti-mev` routes the transaction through protected channels to reduce this risk. Enabled by default.
- **Anti-MEV** — MEV (Miner/Maximal Extractable Value) refers to frontrunning and sandwich attacks where bots exploit pending transactions. `--anti-mev` routes the transaction through protected channels to reduce this risk. **Recommended: always enable.** Default: on.
- **Critical auth**`swap` requires both `GMGN_API_KEY` and `GMGN_PRIVATE_KEY`. The private key never leaves the machine — the CLI uses it only for local signing and sends only the resulting signature. Normal commands (like `order quote`) use API Key alone.
@@ -36,7 +36,7 @@ Use the `gmgn-cli` tool to submit a token swap or query an existing order. **Req
**This skill executes REAL, IRREVERSIBLE blockchain transactions.**
- Every `swap` command submits an on-chain transaction that moves real funds.
- Every `swap` and `order strategy create` command submits an on-chain transaction that moves real funds.
- Transactions cannot be undone once confirmed on-chain.
- The AI agent must **never auto-execute a swap** — explicit user confirmation is required every time, without exception.
- Only use this skill with funds you are willing to trade. Start with small amounts when testing.
@@ -49,7 +49,7 @@ Use the `gmgn-cli` tool to submit a token swap or query an existing order. **Req
| `order quote` | Get a swap quote (no transaction submitted) |
| `order get` | Query order status |
| `order strategy create` | Create a limit/strategy order (requires private key) |
| `order strategy list` | List strategy orders (normal auth) |
| `order strategy list` | List strategy orders (requires private key) |
| `order strategy cancel` | Cancel a strategy order (requires private key) |
## Supported Chains
@@ -87,6 +87,7 @@ All swap-related routes used by this skill go through GMGN's leaky-bucket limite
When a request returns `429`:
- Read `X-RateLimit-Reset` from the response headers. It is a Unix timestamp in seconds that marks when the limit is expected to reset.
- If the response body contains `reset_at` (e.g., `{"code":429,"error":"RATE_LIMIT_BANNED","message":"...","reset_at":1775184222}`), extract `reset_at` — it is the Unix timestamp when the ban lifts (typically 5 minutes). Convert to local time and tell the user exactly when they can retry.
- `swap` is a real transaction: never loop or auto-submit repeated swap attempts after a `429`. Wait until the reset time, then ask for confirmation again before retrying.
- The CLI may wait and retry once automatically for short cooldowns on read-only commands such as `order quote` and `order get`. If it still fails, stop and tell the user the exact retry time instead of sending more requests.
- For `RATE_LIMIT_EXCEEDED` or `RATE_LIMIT_BANNED`, repeated requests during the cooldown can extend the ban by 5 seconds each time, up to 5 minutes.
@@ -206,13 +207,71 @@ gmgn-cli order get --chain sol --order-id <order_id>
| `--slippage <n>` | No | Slippage tolerance, e.g. `0.01` = 1%. **Mutually exclusive with `--auto-slippage`** — use one or the other. |
| `--auto-slippage` | No | Enable automatic slippage. **Mutually exclusive with `--slippage`.** |
| `--min-output <n>` | No | Minimum output amount |
| `--anti-mev` | No | Enable anti-MEV protection (default true) |
| `--anti-mev` | No | Enable anti-MEV protection **recommended**; protects against frontrunning and sandwich attacks. Default: on |
| `--priority-fee <sol>` | No | Priority fee in SOL (≥ 0.00001, SOL only) |
| `--tip-fee <n>` | No | Tip fee (SOL ≥ 0.00001 / BSC ≥ 0.000001 BNB) |
| `--max-auto-fee <n>` | No | Max automatic fee cap |
| `--gas-price <gwei>` | No | Gas price in gwei (BSC ≥ 0.05 / BASE/ETH ≥ 0.01) |
| `--max-fee-per-gas <n>` | No | EIP-1559 max fee per gas (Base only) |
| `--max-priority-fee-per-gas <n>` | No | EIP-1559 max priority fee per gas (Base only) |
| `--condition-orders <json>` | No | JSON array of condition sub-orders (take-profit / stop-loss) to attach after a successful swap. **Max 10 sub-orders.** Strategy creation is best-effort: if the swap succeeds but strategy creation fails, the swap result is still returned. See ConditionOrder fields below. |
| `--sell-ratio-type <type>` | No | Sell ratio basis for `--condition-orders`: `buy_amount` (default) — when triggered, sells a fixed token amount stored at strategy creation time; `hold_amount` — when triggered, sells a fixed percentage of the position held at trigger time |
### ConditionOrder Fields (for `--condition-orders`)
Each element in the `--condition-orders` JSON array supports:
| Field | Required | Type | Description |
|-------|----------|------|-------------|
| `order_type` | Yes | string | Sub-order type: `profit_stop` (fixed take-profit), `loss_stop` (fixed stop-loss), `profit_stop_trace` (trailing take-profit), `loss_stop_trace` (trailing stop-loss) |
| `side` | Yes | string | Always `"sell"` |
| `price_scale` | Conditional | string | Gain/drop % from entry. Required for `profit_stop` / `loss_stop` / `profit_stop_trace`; optional for `loss_stop_trace`. For `profit_stop` / `profit_stop_trace`: gain % (e.g. `"100"` = +100% / 2× entry). For `loss_stop` / `loss_stop_trace`: drop % (e.g. `"65"` = drops 65%, triggers at 35% of entry). |
| `sell_ratio` | Yes | string | Percentage of position to sell when triggered, e.g. `"100"` = 100% |
| `drawdown_rate` | Conditional | string | Required for `profit_stop_trace` and `loss_stop_trace`. Trailing callback %: after price peaks, how far it must fall before the order fires. E.g. `"50"` = 50% drawdown from peak. |
**Example — attach take-profit at 2× (+100%) and stop-loss at -60%:**
```json
[
{"order_type": "profit_stop", "side": "sell", "price_scale": "100", "sell_ratio": "100"},
{"order_type": "loss_stop", "side": "sell", "price_scale": "60", "sell_ratio": "100"}
]
```
**Example — buy token A with 0.01 SOL, take-profit 50% at +100%, take-profit remaining 50% at +300%, stop-loss 100% at -65% (trigger at 35% entry price) (`hold_amount` mode):**
```bash
gmgn-cli swap \
--chain sol \
--from <wallet_address> \
--input-token So11111111111111111111111111111111111111112 \
--output-token <token_A_address> \
--amount 10000000 \
--slippage 0.3 \
--anti-mev \
--condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"100","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"300","sell_ratio":"100"},{"order_type":"loss_stop","side":"sell","price_scale":"65","sell_ratio":"100"}]' \
--sell-ratio-type hold_amount
```
> `price_scale` for `profit_stop`: gain % from entry (`"100"` = +100% / 2×, `"300"` = +300% / 4×). For `loss_stop`: drop % from entry (`"65"` = drops 65%, triggers at 35% of entry).
> `hold_amount`: the second take-profit fires on whatever is held at trigger time (the remaining 50%). If you added to your position in between, those additional tokens will be included as well.
**Same strategy using `buy_amount` mode — fixed percentage of the original bought amount at each trigger:**
```bash
gmgn-cli swap \
--chain sol \
--from <wallet_address> \
--input-token So11111111111111111111111111111111111111112 \
--output-token <token_A_address> \
--amount 10000000 \
--slippage 0.3 \
--anti-mev \
--condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"100","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"300","sell_ratio":"50"},{"order_type":"loss_stop","side":"sell","price_scale":"65","sell_ratio":"100"}]' \
--sell-ratio-type buy_amount
```
> `buy_amount`: each take-profit sells 50% of the **original** bought amount. Stop-loss sells 100% of the original bought amount.
## `swap` Response Fields
@@ -227,6 +286,7 @@ gmgn-cli order get --chain sol --order-id <order_id>
| `output_token` | string | Output token contract address |
| `filled_input_amount` | string | Actual input consumed (smallest unit); empty if not filled |
| `filled_output_amount` | string | Actual output received (smallest unit); empty if not filled |
| `strategy_order_id` | string | Strategy order ID; only present when `--condition-orders` was passed and strategy creation succeeded (best-effort) |
## Output Format
@@ -290,31 +350,23 @@ Convert `filled_input_amount` and `filled_output_amount` from smallest unit usin
| `--from` | Yes | Wallet address (must match API Key binding) |
| `--base-token` | Yes | Base token contract address |
| `--quote-token` | Yes | Quote token contract address |
| `--side` | Yes | Direction: `buy` / `sell` |
| `--open-price` | Yes | Open price; compared with `--check-price` to infer order type |
| `--check-price` | Yes | Trigger check price; compared with `--open-price` to infer order type |
| `--order-type` | Yes | Order type: `limit_order` |
| `--sub-order-type` | Yes | Sub-order type: `buy_low` / `buy_high` / `stop_loss` / `take_profit` |
| `--check-price` | Yes | Trigger check price |
| `--amount-in` | No* | Input amount (smallest unit). Mutually exclusive with `--amount-in-percent` |
| `--amount-in-percent` | No* | Input as percentage (e.g. `50` = 50%). Mutually exclusive with `--amount-in` |
| `--limit-price-mode` | No | `exact` / `slippage` (default: `slippage`) |
| `--expire-in` | No | Order expiry in seconds |
| `--sell-ratio-type` | No | `buy_amount` (default) / `hold_amount` |
| `--sell-ratio-type` | No | `buy_amount` (default) — when triggered, sells a fixed token amount stored at strategy creation time; `hold_amount` — when triggered, sells a fixed percentage of the position held at trigger time |
| `--slippage` | No | Slippage tolerance, e.g. `0.01` = 1%. Mutually exclusive with `--auto-slippage` |
| `--auto-slippage` | No | Enable automatic slippage |
| `--priority-fee` | No | Priority fee in SOL (SOL only) |
| `--tip-fee` | No | Tip fee |
| `--gas-price` | No | Gas price in wei (EVM chains) |
| `--gas-price` | No | Gas price in gwei (BSC ≥ 0.05 gwei / BASE/ETH ≥ 0.01 gwei) |
| `--anti-mev` | No | Enable anti-MEV protection |
Order direction is inferred automatically from `--side` and the comparison between `--open-price` and `--check-price`:
| `--side` | open_price vs check_price | Inferred type |
|----------|--------------------------|---------------|
| `buy` | open_price > check_price | buy_low |
| `buy` | open_price < check_price | buy_high |
| `sell` | open_price > check_price | stop_loss |
| `sell` | open_price < check_price | take_profit |
**`order strategy create` Response Fields:**
### `order strategy create` Response Fields
| Field | Type | Description |
|-------|------|-------------|
@@ -328,11 +380,12 @@ Order direction is inferred automatically from `--side` and the comparison betwe
| `--chain` | Yes | `sol` / `bsc` / `base` |
| `--type` | No | `open` (default) / `history` |
| `--from` | No | Filter by wallet address |
| `--group-tag` | Yes | Filter by order group: `LimitOrder` (limit orders only) / `STMix` (mixed strategy orders: take-profit, stop-loss, trailing take-profit, trailing stop-loss) |
| `--base-token` | No | Filter by token address |
| `--page-token` | No | Pagination cursor from previous response |
| `--limit` | No | Results per page (default 10 for history) |
**`order strategy list` Response Fields:**
### `order strategy list` Response Fields
| Field | Type | Description |
|-------|------|-------------|
@@ -347,40 +400,47 @@ Order direction is inferred automatically from `--side` and the comparison betwe
| `--chain` | Yes | `sol` / `bsc` / `base` |
| `--from` | Yes | Wallet address (must match API Key binding) |
| `--order-id` | Yes | Order ID to cancel |
| `--order-type` | No | Order type: `limit_order` (limit order) / `smart_trade` (mixed strategy order: take-profit, stop-loss, trailing take-profit, trailing stop-loss) |
| `--close-sell-model` | No | Sell model when closing the order |
## `order strategy` Usage Examples
```bash
# Create a take-profit order: sell when price rises above open price
# Create a take-profit order: sell when price rises to target
gmgn-cli order strategy create \
--chain sol \
--from <wallet_address> \
--base-token <token_address> \
--quote-token <sol_address> \
--side sell \
--open-price 0.001 \
--order-type limit_order \
--sub-order-type take_profit \
--check-price 0.002 \
--amount-in 1000000 \
--slippage 0.01
# Create a stop-loss order: sell when price drops below open price
# Create a stop-loss order: sell when price drops to target
gmgn-cli order strategy create \
--chain sol \
--from <wallet_address> \
--base-token <token_address> \
--quote-token <sol_address> \
--side sell \
--open-price 0.001 \
--order-type limit_order \
--sub-order-type stop_loss \
--check-price 0.0005 \
--amount-in-percent 100 \
--slippage 0.01
# List open strategy orders
gmgn-cli order strategy list --chain sol
# List open condition orders (profit_stop / loss_stop / trace types) — use STMix
gmgn-cli order strategy list --chain sol --group-tag STMix
# List history orders with pagination
gmgn-cli order strategy list --chain sol --type history --limit 20
# List open limit orders (buy_low / buy_high / stop_loss / take_profit) — use LimitOrder
gmgn-cli order strategy list --chain sol --group-tag LimitOrder
# List condition order history with pagination
gmgn-cli order strategy list --chain sol --group-tag STMix --type history --limit 20
# Filter by token
gmgn-cli order strategy list --chain sol --group-tag STMix --base-token <token_address>
# Cancel a strategy order
gmgn-cli order strategy cancel \
@@ -394,7 +454,7 @@ gmgn-cli order strategy cancel \
- Swap uses **critical auth** (API Key + signature) — CLI handles signing automatically, no manual processing needed
- After submitting a swap, use `order get` to poll for confirmation
- `--amount` is in the **smallest unit** (e.g., lamports for SOL)
- `order strategy create` and `order strategy cancel` use critical auth (require `GMGN_PRIVATE_KEY`); `order strategy list` uses normal auth
- `order strategy create`, `order strategy list`, and `order strategy cancel` use critical auth (require `GMGN_PRIVATE_KEY`)
- Use `--raw` to get single-line JSON for further processing
## Input Validation
+1
View File
@@ -64,6 +64,7 @@ All token routes used by this skill go through GMGN's leaky-bucket limiter with
When a request returns `429`:
- Read `X-RateLimit-Reset` from the response headers. It is a Unix timestamp in seconds that marks when the limit is expected to reset.
- If the response body contains `reset_at` (e.g., `{"code":429,"error":"RATE_LIMIT_BANNED","message":"...","reset_at":1775184222}`), extract `reset_at` — it is the Unix timestamp when the ban lifts (typically 5 minutes). Convert to local time and tell the user exactly when they can retry.
- The CLI may wait and retry once automatically when the remaining cooldown is short. If it still fails, stop and tell the user the exact retry time instead of sending more requests.
- For `RATE_LIMIT_EXCEEDED` or `RATE_LIMIT_BANNED`, repeated requests during the cooldown can extend the ban by 5 seconds each time, up to 5 minutes. Do not spam retries.
+1
View File
@@ -76,6 +76,7 @@ All tracking routes used by this skill go through GMGN's leaky-bucket limiter wi
When a request returns `429`:
- Read `X-RateLimit-Reset` from the response headers. It is a Unix timestamp in seconds that marks when the limit is expected to reset.
- If the response body contains `reset_at` (e.g., `{"code":429,"error":"RATE_LIMIT_BANNED","message":"...","reset_at":1775184222}`), extract `reset_at` — it is the Unix timestamp when the ban lifts (typically 5 minutes). Convert to local time and tell the user exactly when they can retry.
- The CLI may wait and retry once automatically when the remaining cooldown is short. If it still fails, stop and tell the user the exact retry time instead of sending more requests.
- For `RATE_LIMIT_EXCEEDED` or `RATE_LIMIT_BANNED`, repeated requests during the cooldown can extend the ban by 5 seconds each time, up to 5 minutes. Do not spam retries.
+5 -4
View File
@@ -90,10 +90,11 @@ export interface SwapParams {
}
export interface StrategyConditionOrder {
order_type: string; // "profit_stop" | "loss_stop"
order_type: string; // "profit_stop" | "loss_stop" | "profit_stop_trace" | "loss_stop_trace"
side: string; // "sell"
price_scale: string;
price_scale?: string;
sell_ratio: string;
drawdown_rate?: string;
}
export interface StrategyCreateParams {
@@ -307,14 +308,14 @@ export class OpenApiClient {
return this.criticalRequest("GET", "/v1/trade/query_order", { order_id: orderId, chain }, null);
}
// ---- Strategy order endpoints ----
// ---- Strategy order endpoints (critical auth) ----
async createStrategyOrder(params: StrategyCreateParams): Promise<unknown> {
return this.criticalRequest("POST", "/v1/trade/strategy/create", {}, params);
}
async getStrategyOrders(chain: string, extra: Record<string, string | number> = {}): Promise<unknown> {
return this.normalRequest("GET", "/v1/trade/strategy/orders", { chain, ...extra });
return this.criticalRequest("GET", "/v1/trade/strategy/orders", { chain, ...extra }, null);
}
async cancelStrategyOrder(params: StrategyCancelParams): Promise<unknown> {
+3 -5
View File
@@ -24,7 +24,7 @@ export function registerSwapCommands(program: Command): void {
.option("--gas-price <gwei>", "Gas price in gwei (BSC ≥ 0.05 / BASE/ETH ≥ 0.01)")
.option("--max-fee-per-gas <amount>", "EIP-1559 max fee per gas (Base)")
.option("--max-priority-fee-per-gas <amount>", "EIP-1559 max priority fee per gas (Base)")
.option("--condition-orders <json>", 'JSON array of take-profit/stop-loss conditions, e.g. \'[{"order_type":"profit_stop","side":"sell","price_scale":"150","sell_ratio":"100"}]\'')
.option("--condition-orders <json>", 'JSON array of take-profit/stop-loss conditions, e.g. \'[{"order_type":"profit_stop","side":"sell","price_scale":"150","sell_ratio":"100"}]\'; trace types: \'[{"order_type":"profit_stop_trace","side":"sell","price_scale":"150","sell_ratio":"100","drawdown_rate":"50"}]\'')
.option("--sell-ratio-type <type>", "Sell ratio base: buy_amount (default) / hold_amount; only used with --condition-orders")
.option("--raw", "Output raw JSON")
.action(async (opts) => {
@@ -121,7 +121,6 @@ export function registerSwapCommands(program: Command): void {
.requiredOption("--order-type <type>", "Order type: limit_order")
.requiredOption("--sub-order-type <type>", "Sub-order type: buy_low / buy_high / stop_loss / take_profit")
.requiredOption("--check-price <price>", "Trigger check price")
.option("--open-price <price>", "Open/entry price")
.option("--amount-in <amount>", "Input amount (smallest unit)")
.option("--amount-in-percent <pct>", "Input amount as a percentage (e.g. 50 = 50%)")
.option("--limit-price-mode <mode>", "Price mode: exact / slippage (default: slippage)")
@@ -153,7 +152,6 @@ export function registerSwapCommands(program: Command): void {
sub_order_type: opts.subOrderType,
check_price: opts.checkPrice,
};
if (opts.openPrice) params.open_price = opts.openPrice;
if (opts.amountIn) params.amount_in = opts.amountIn;
if (opts.amountInPercent) params.amount_in_percent = opts.amountInPercent;
if (opts.limitPriceMode) params.limit_price_mode = opts.limitPriceMode;
@@ -172,7 +170,7 @@ export function registerSwapCommands(program: Command): void {
strategy
.command("list")
.description("List strategy orders (normal auth)")
.description("List strategy orders (requires private key)")
.requiredOption("--chain <chain>", "Chain: sol / bsc / base")
.option("--type <type>", "open (default) / history")
.option("--from <address>", "Filter by wallet address")
@@ -190,7 +188,7 @@ export function registerSwapCommands(program: Command): void {
if (opts.baseToken) extra["base_token"] = opts.baseToken;
if (opts.pageToken) extra["page_token"] = opts.pageToken;
if (opts.limit != null) extra["limit"] = opts.limit;
const client = new OpenApiClient(getConfig());
const client = new OpenApiClient(getConfig(true));
const data = await client.getStrategyOrders(opts.chain, extra).catch(exitOnError);
printResult(data, opts.raw);
});