From 29eeb723e4cd090045878b298dadd799c34960fe Mon Sep 17 00:00:00 2001 From: gumponchain Date: Fri, 3 Apr 2026 15:52:40 +0800 Subject: [PATCH] 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 --- Readme.md | 127 +++++++++++++++++++++++++------------- Readme.zh.md | 127 +++++++++++++++++++++++++------------- skills/gmgn-swap/SKILL.md | 18 +++--- 3 files changed, 175 insertions(+), 97 deletions(-) diff --git a/Readme.md b/Readme.md index bc73079..89edf42 100644 --- a/Readme.md +++ b/Readme.md @@ -500,6 +500,88 @@ gmgn-cli track smartmoney --limit 100 --raw gmgn-cli track smartmoney --chain sol --side sell --limit 50 --raw ``` +### Swap (requires private key) + +```bash +# Submit swap with fixed slippage +gmgn-cli swap \ + --chain sol \ + --from \ + --input-token \ + --output-token \ + --amount 1000000 \ + --slippage 0.01 + +# Submit swap with automatic slippage +gmgn-cli swap \ + --chain sol \ + --from \ + --input-token \ + --output-token \ + --amount 1000000 \ + --auto-slippage + +# Sell by position percentage (e.g. sell 50%) +gmgn-cli swap \ + --chain sol \ + --from \ + --input-token \ + --output-token \ + --percent 50 \ + --auto-slippage + +# Get quote (no transaction submitted) +gmgn-cli order quote \ + --chain sol \ + --from \ + --input-token \ + --output-token \ + --amount 1000000 \ + --slippage 0.01 + +# Query order +gmgn-cli order get --chain sol --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 \ + --input-token So11111111111111111111111111111111111111112 \ + --output-token \ + --amount 10000000 \ + --slippage 0.3 \ + --condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"200","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"400","sell_ratio":"100"},{"order_type":"loss_stop","side":"sell","price_scale":"35","sell_ratio":"100"}]' \ + --sell-ratio-type hold_amount +``` + +> `price_scale` is relative to entry: `"200"` = 2× (+100%), `"400"` = 4× (+300%), `"35"` = 35% of entry (-65%). +> `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 \ + --input-token So11111111111111111111111111111111111111112 \ + --output-token \ + --amount 10000000 \ + --slippage 0.3 \ + --condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"200","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"400","sell_ratio":"50"},{"order_type":"loss_stop","side":"sell","price_scale":"35","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 @@ -542,53 +624,10 @@ gmgn-cli cooking \ --input-token So11111111111111111111111111111111111111112 \ --output-token \ --amount 1000000000 \ - --slippage 0.1 \ + --slippage 0.3 \ --condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"200","sell_ratio":"100"},{"order_type":"loss_stop","side":"sell","price_scale":"50","sell_ratio":"100"}]' ``` -### Swap (requires private key) - -```bash -# Submit swap with fixed slippage -gmgn-cli swap \ - --chain sol \ - --from \ - --input-token \ - --output-token \ - --amount 1000000 \ - --slippage 0.01 - -# Submit swap with automatic slippage -gmgn-cli swap \ - --chain sol \ - --from \ - --input-token \ - --output-token \ - --amount 1000000 \ - --auto-slippage - -# Sell by position percentage (e.g. sell 50%) -gmgn-cli swap \ - --chain sol \ - --from \ - --input-token \ - --output-token \ - --percent 50 \ - --auto-slippage - -# Get quote (no transaction submitted) -gmgn-cli order quote \ - --chain sol \ - --from \ - --input-token \ - --output-token \ - --amount 1000000 \ - --slippage 0.01 - -# Query order -gmgn-cli order get --chain sol --order-id -``` - ## 9. Supported Chains | Commands | Chains | Chain Currencies | diff --git a/Readme.zh.md b/Readme.zh.md index d427178..b0a96a4 100644 --- a/Readme.zh.md +++ b/Readme.zh.md @@ -532,6 +532,88 @@ gmgn-cli track smartmoney --limit 100 --raw gmgn-cli track smartmoney --chain sol --side sell --limit 50 --raw ``` +### Swap(需要私钥) + +```bash +# 提交兑换(固定滑点) +gmgn-cli swap \ + --chain sol \ + --from \ + --input-token \ + --output-token \ + --amount 1000000 \ + --slippage 0.01 + +# 提交兑换(自动滑点) +gmgn-cli swap \ + --chain sol \ + --from \ + --input-token \ + --output-token \ + --amount 1000000 \ + --auto-slippage + +# 按持仓比例卖出(例:卖出 50%) +gmgn-cli swap \ + --chain sol \ + --from \ + --input-token \ + --output-token \ + --percent 50 \ + --auto-slippage + +# 获取报价(不提交交易) +gmgn-cli order quote \ + --chain sol \ + --from \ + --input-token \ + --output-token \ + --amount 1000000 \ + --slippage 0.01 + +# 查询订单状态 +gmgn-cli order get --chain sol --order-id +``` + +### 带止盈止损的 Swap(需要私钥) + +**`hold_amount` 模式** — 按触发时的实际持仓比例卖出: + +```bash +# 用 0.01 SOL 买入代币 A;涨 100% 卖 50%,涨 300% 卖剩余 50%,跌 65% 全卖 +gmgn-cli swap \ + --chain sol \ + --from \ + --input-token So11111111111111111111111111111111111111112 \ + --output-token \ + --amount 10000000 \ + --slippage 0.3 \ + --condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"200","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"400","sell_ratio":"100"},{"order_type":"loss_stop","side":"sell","price_scale":"35","sell_ratio":"100"}]' \ + --sell-ratio-type hold_amount +``` + +> `price_scale` 相对于入场价:`"200"` = 2×(涨 100%),`"400"` = 4×(涨 300%),`"35"` = 入场价的 35%(跌 65%)。 +> `hold_amount`:第二个止盈单触发时,按触发时持仓(剩余 50%)的 100% 卖出。如果中间有加仓,加仓的部分也会一同被卖掉。 + +**`buy_amount` 模式** — 按原始买入量的固定百分比卖出: + +```bash +# 相同策略,使用原始买入量的固定百分比 +gmgn-cli swap \ + --chain sol \ + --from \ + --input-token So11111111111111111111111111111111111111112 \ + --output-token \ + --amount 10000000 \ + --slippage 0.3 \ + --condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"200","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"400","sell_ratio":"50"},{"order_type":"loss_stop","side":"sell","price_scale":"35","sell_ratio":"100"}]' \ + --sell-ratio-type buy_amount +``` + +> `buy_amount`:每个止盈单各卖原始买入量的 50%,止损单卖原始买入量的 100%。 + +--- + ### 限价单(需要私钥) ```bash @@ -574,53 +656,10 @@ gmgn-cli cooking \ --input-token So11111111111111111111111111111111111111112 \ --output-token \ --amount 1000000000 \ - --slippage 0.1 \ + --slippage 0.3 \ --condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"200","sell_ratio":"100"},{"order_type":"loss_stop","side":"sell","price_scale":"50","sell_ratio":"100"}]' ``` -### Swap(需要私钥) - -```bash -# 提交兑换(固定滑点) -gmgn-cli swap \ - --chain sol \ - --from \ - --input-token \ - --output-token \ - --amount 1000000 \ - --slippage 0.01 - -# 提交兑换(自动滑点) -gmgn-cli swap \ - --chain sol \ - --from \ - --input-token \ - --output-token \ - --amount 1000000 \ - --auto-slippage - -# 按持仓比例卖出(例:卖出 50%) -gmgn-cli swap \ - --chain sol \ - --from \ - --input-token \ - --output-token \ - --percent 50 \ - --auto-slippage - -# 获取报价(不提交交易) -gmgn-cli order quote \ - --chain sol \ - --from \ - --input-token \ - --output-token \ - --amount 1000000 \ - --slippage 0.01 - -# 查询订单状态 -gmgn-cli order get --chain sol --order-id -``` - ## 9. 支持的链 | 接口类型 | 支持的链 | 链原生货币 | diff --git a/skills/gmgn-swap/SKILL.md b/skills/gmgn-swap/SKILL.md index f474f63..0370530 100644 --- a/skills/gmgn-swap/SKILL.md +++ b/skills/gmgn-swap/SKILL.md @@ -236,7 +236,7 @@ Each element in the `--condition-orders` JSON array supports: ] ``` -**Example — buy token A with 0.01 SOL, take-profit 50% at +100%, take-profit remaining 50% at +300%:** +**Example — buy token A with 0.01 SOL, take-profit 50% at +100%, take-profit remaining 50% at +300%, stop-loss 100% at -65% (`hold_amount` mode):** ```bash gmgn-cli swap \ @@ -245,15 +245,15 @@ gmgn-cli swap \ --input-token So11111111111111111111111111111111111111112 \ --output-token \ --amount 10000000 \ - --slippage 0.1 \ - --condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"200","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"400","sell_ratio":"100"}]' \ + --slippage 0.3 \ + --condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"200","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"400","sell_ratio":"100"},{"order_type":"loss_stop","side":"sell","price_scale":"35","sell_ratio":"100"}]' \ --sell-ratio-type hold_amount ``` -> `price_scale` is relative to entry price: `"200"` = 2× (+100%), `"400"` = 4× (+300%). -> `--sell-ratio-type hold_amount` ensures the second order sells 100% of whatever is held at trigger time (i.e. the remaining 50%). +> `price_scale` is relative to entry: `"200"` = 2× (+100%), `"400"` = 4× (+300%), `"35"` = 35% of entry (-65%). +> `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. -Or use `buy_amount` to sell a fixed percentage of the originally bought amount at each trigger: +**Same strategy using `buy_amount` mode — fixed percentage of the original bought amount at each trigger:** ```bash gmgn-cli swap \ @@ -262,12 +262,12 @@ gmgn-cli swap \ --input-token So11111111111111111111111111111111111111112 \ --output-token \ --amount 10000000 \ - --slippage 0.1 \ - --condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"200","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"400","sell_ratio":"50"}]' \ + --slippage 0.3 \ + --condition-orders '[{"order_type":"profit_stop","side":"sell","price_scale":"200","sell_ratio":"50"},{"order_type":"profit_stop","side":"sell","price_scale":"400","sell_ratio":"50"},{"order_type":"loss_stop","side":"sell","price_scale":"35","sell_ratio":"100"}]' \ --sell-ratio-type buy_amount ``` -> `--sell-ratio-type buy_amount`: both orders each sell 50% of the original bought amount — first at +100%, second at +300%. Total sold = 100% of original position. +> `buy_amount`: each take-profit sells 50% of the **original** bought amount. Stop-loss sells 100% of the original bought amount. ## `swap` Response Fields