diff --git a/Readme.md b/Readme.md index 2407b60..2838b14 100644 --- a/Readme.md +++ b/Readme.md @@ -295,6 +295,7 @@ npx gmgn-cli swap \ --input-token \ --output-token \ --amount 1000000 \ + --auto-slippage \ --slippage 0.01 # Query order diff --git a/Readme.zh.md b/Readme.zh.md index 0138564..0cf2296 100644 --- a/Readme.zh.md +++ b/Readme.zh.md @@ -295,6 +295,7 @@ npx gmgn-cli swap \ --input-token \ --output-token \ --amount 1000000 \ + --auto-slippage \ --slippage 0.01 # 查询订单 diff --git a/docs/cli-usage.md b/docs/cli-usage.md index 87e8737..8f5f450 100644 --- a/docs/cli-usage.md +++ b/docs/cli-usage.md @@ -388,6 +388,7 @@ npx gmgn-cli swap \ --output-token \ [--amount | --percent ] \ [--slippage ] \ + [--auto-slippage] \ [--min-output ] \ [--anti-mev] \ [--priority-fee ] \ @@ -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) | diff --git a/skills/gmgn-swap/SKILL.md b/skills/gmgn-swap/SKILL.md index 695904b..6766887 100644 --- a/skills/gmgn-swap/SKILL.md +++ b/skills/gmgn-swap/SKILL.md @@ -73,6 +73,7 @@ gmgn-cli swap \ --input-token \ --output-token \ --amount 1000000 \ + --auto-slippage \ --slippage 0.01 # With anti-MEV (SOL) @@ -135,6 +136,7 @@ gmgn-cli order get --chain sol --order-id | `--amount` | No* | Input amount in smallest unit. Required unless `--percent` is used. | | `--percent ` | 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 ` | No | Slippage tolerance, e.g. `0.01` = 1% | +| `--auto-slippage` | No | Enable automatic slippage | | `--min-output ` | No | Minimum output amount | | `--anti-mev` | No | Enable anti-MEV protection (default true) | | `--priority-fee ` | No | Priority fee in SOL (≥ 0.00001, SOL only) | diff --git a/src/commands/swap.ts b/src/commands/swap.ts index 6ad2674..35cabb1 100644 --- a/src/commands/swap.ts +++ b/src/commands/swap.ts @@ -15,6 +15,7 @@ export function registerSwapCommands(program: Command): void { .option("--amount ", "Input raw amount (smallest unit)") .option("--percent ", "Input amount as a percentage, e.g. 50 = 50%, 1 = 1%; only valid when input_token is NOT a currency", parseFloat) .option("--slippage ", "Slippage tolerance (e.g. 0.01 = 1%)", parseFloat) + .option("--auto-slippage", "Enable automatic slippage") .option("--min-output ", "Minimum output amount") .option("--anti-mev", "Enable anti-MEV protection, default true") .option("--priority-fee ", "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); }); } -