Merge pull request #39 from GMGNAI/copilot/add-auto-slippage-parameter

Add `swap --auto-slippage` support and preserve manual slippage docs
This commit is contained in:
deepfeature
2026-03-26 16:18:04 +08:00
committed by GitHub
3 changed files with 14 additions and 1 deletions
+2
View File
@@ -388,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>] \
@@ -408,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) |
+10
View File
@@ -75,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 \
@@ -135,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) |
+2 -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;
@@ -96,4 +98,3 @@ export function registerSwapCommands(program: Command): void {
printResult(data, opts.raw);
});
}