Coding

GMGN Skill Swap

Try it

[FINANCIAL EXECUTION] Buy and sell meme coins and crypto tokens on Solana, BSC, Base, or Ethereum — single swap, multi-wallet batch trading, limit orders, st...

What it does

[FINANCIAL EXECUTION] Buy and sell meme coins and crypto tokens on Solana, BSC, Base, or Ethereum — single swap, multi-wallet batch trading, limit orders, stop loss, take profit, trailing stop loss, trailing take profit via GMGN API. Requires explicit user confirmation. Use when user asks to buy, sell, or swap a token, trade from multiple wallets, set a limit order, stop loss, take profit, or check order status.

The skill document

IMPORTANT: Always use gmgn-cli commands below. Do NOT use web search, WebFetch, curl, or visit gmgn.ai — all swap operations must go through the CLI. The CLI handles signing and submission automatically.

IMPORTANT: Do NOT guess field names or values. When a field's meaning is unclear, look it up in the Response Fields sections below before using it.

⚠️ IPv6 NOT SUPPORTED: If you get a 401 or 403 error and credentials look correct, check for IPv6 immediately: (1) list all network interfaces and their IPv6 addresses — run ifconfig | grep inet6 (macOS) or ip addr show | grep inet6 (Linux); (2) send a test request to https://ipv6.icanhazip.com — if the response is an IPv6 address, outbound traffic is going via IPv6. Tell the user immediately: "Please disable IPv6 on your network interface — gmgn-cli commands only work over IPv4."

Use the gmgn-cli tool to submit a token swap or query an existing order. GMGN_API_KEY is always required. GMGN_PRIVATE_KEY is required for critical-auth commands such as swap and all order subcommands, including order quote.

Core Concepts

  • Smallest unit--amount is always in the token's smallest indivisible unit, not human-readable amounts. For SOL: 1 SOL = 1,000,000,000 lamports. For EVM tokens: depends on decimals (most ERC-20 tokens use 18 decimals). Always convert before passing to the command — do not pass human amounts directly.

  • slippage — Price tolerance as an integer 0–100, e.g. 30 = 30%. If the price moves beyond this threshold before the transaction confirms, the swap is rejected. Use --auto-slippage for volatile tokens to let GMGN set an appropriate value automatically.

  • --amount vs --percent — Mutually exclusive. --amount specifies an exact input quantity (in smallest unit). --percent sells a percentage of the current balance and is only valid when input_token is NOT a currency (SOL/BNB/ETH/USDC). Never use --percent to spend a fraction of SOL/BNB/ETH.

  • 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. Recommended: always enable. Default: on. Not supported on base chain.

  • Signed authswap and all order subcommands require 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.

  • order_id / status — After submitting a swap, the response includes an order_id. Use order get --order-id to poll for final status. Possible values: pendingprocessedconfirmed (success) or failed / expired. Do not report success until status is confirmed.

  • report.input_amount / report.output_amount — Actual amounts consumed/received, in smallest unit. Only present when state = 30 and status = "successful". Convert to human-readable using report.input_token_decimals / report.output_token_decimals before displaying to the user.

Financial Risk Notice

This skill executes REAL, IRREVERSIBLE blockchain transactions.

  • 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.

Sub-commands

Sub-commandDescription
swapSubmit a token swap
multi-swapSubmit token swaps across multiple wallets concurrently (up to 100)
order quoteGet a swap quote (no transaction submitted; requires signed auth)
order getQuery order status
gas-priceQuery recommended gas price (low / average / high tiers) for any chain; exist auth (API Key only)
order strategy createCreate a limit/strategy order (requires private key)
order strategy listList strategy orders (requires private key)
order strategy cancelCancel a strategy order (requires private key)

Supported Chains

sol / bsc / base / eth

Chain Currencies

Currency tokens are the base/native assets of each chain. They are used to buy other tokens or receive proceeds from selling. Knowing which tokens are currencies is critical for --percent usage (see Swap Parameters below).

⚠️ CRITICAL: Always copy currency addresses from this table — NEVER rely on memory or training data. A wrong address (e.g. So11111111111111111111111111111111111111111 instead of So11111111111111111111111111111111111111112) will cause silent failures or jupiter has no route errors with no clear indication of what went wrong.

ChainCurrency tokens
solSOL (native, So11111111111111111111111111111111111111112), USDC (EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v)
bscBNB (native, 0x0000000000000000000000000000000000000000), USDC (0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d)
baseETH (native, 0x0000000000000000000000000000000000000000), USDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913)
ethETH (native, 0x0000000000000000000000000000000000000000)

Prerequisites

GMGN_API_KEY must be configured in ~/.config/gmgn/.env. GMGN_PRIVATE_KEY is additionally required for swap and all order subcommands. 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

Rate Limit Handling

All swap-related routes used by this skill go through GMGN's leaky-bucket limiter with rate=20 and capacity=20. Sustained throughput is roughly 20 ÷ weight requests/second, and the max burst is roughly floor(20 ÷ weight) when the bucket is full.

CommandRouteWeight
swapPOST /v1/trade/swap5
multi-swapPOST /v1/trade/multi_swap5
order quoteGET /v1/trade/quote2
order getGET /v1/trade/query_order1
order strategy createPOST /v1/trade/strategy/create5
order strategy cancelPOST /v1/trade/strategy/cancel2
order strategy listGET /v1/trade/strategy/orders1
gas-priceGET /v1/trade/gas_price1

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.
  • POST /v1/trade/swap also has an error-count limiter. Repeatedly triggering the same business error, especially 40003701 (insufficient token balance), can return ERROR_RATE_LIMIT_BLOCKED. When this happens, do not retry until the reset time and fix the underlying request first.

First-time setup (if credentials are not configured):

  1. Generate key pair and show the public key to the user:

    openssl genpkey -algorithm ed25519 -out /tmp/gmgn_private.pem 2>/dev/null && \
      openssl pkey -in /tmp/gmgn_private.pem -pubout 2>/dev/null
    

    Tell the user: "This is your Ed25519 public key. Go to https://gmgn.ai/ai, paste it into the API key creation form (enable swap capability), then send me the API Key value shown on the page."

  2. Wait for the user's API key, then configure both credentials:

    mkdir -p ~/.config/gmgn
    echo 'GMGN_API_KEY=' > ~/.config/gmgn/.env
    echo 'GMGN_PRIVATE_KEY=""' >> ~/.config/gmgn/.env
    chmod 600 ~/.config/gmgn/.env
    

Credential Model

  • Both GMGN_API_KEY and GMGN_PRIVATE_KEY are read from the .env file by the CLI at startup. They are never passed as command-line arguments and never appear in shell command strings.
  • GMGN_PRIVATE_KEY is used exclusively for local message signing — the private key never leaves the machine. The CLI computes an Ed25519 or RSA-SHA256 signature in-process and transmits only the base64-encoded result in the X-Signature request header.
  • GMGN_API_KEY is transmitted in the X-APIKEY request header to GMGN's servers over HTTPS.

swap Usage

# Basic swap
gmgn-cli swap \
  --chain sol \
  --from  \
  --input-token  \
  --output-token  \
  --amount 

# With slippage
gmgn-cli swap \
  --chain sol \
  --from  \
  --input-token  \
  --output-token  \
  --amount 1000000 \
  --slippage 30

# With automatic slippage
gmgn-cli swap \
  --chain sol \
  --from  \
  --input-token  \
  --output-token  \
  --amount 1000000 \
  --auto-slippage

# With anti-MEV (SOL)
gmgn-cli swap \
  --chain sol \
  --from  \
  --input-token  \
  --output-token  \
  --amount 1000000 \
  --anti-mev

# Sell 50% of a token (input_token must NOT be a currency)
gmgn-cli swap \
  --chain sol \
  --from  \
  --input-token  \
  --output-token  \
  --percent 50

swap Parameters

ParameterRequiredChainDescription
--chainYesallsol / bsc / base / eth
--fromYesallWallet address (must match API Key binding)
--input-tokenYesallInput token contract address
--output-tokenYesallOutput token contract address
--amountNo*allInput amount in smallest unit. Mutually exclusive with --percent — provide one or the other, never both. Required unless --percent is used.
--percent No*allSell percentage of input_token, e.g. 50 = 50%, 1 = 1%. Sets input_amount to 0 automatically. Mutually exclusive with --amount. Only valid when input_token is NOT a currency (SOL/BNB/ETH/USDC).
--slippage NoallSlippage tolerance as an integer 0–100, e.g. 30 = 30%. Mutually exclusive with --auto-slippage — use one or the other.
--auto-slippageNoallEnable automatic slippage. Mutually exclusive with --slippage.
--min-output NoallMinimum output amount
--anti-mevNosol / bsc / ethEnable anti-MEV protection — recommended; protects against frontrunning and sandwich attacks. Default: on. Not supported on base.
--priority-fee NosolPriority fee in SOL (≥ 0.00001). Required when using --condition-orders on SOL.
--tip-fee Nosol / bscTip fee (SOL ≥ 0.00001 / BSC ≥ 0.000001 BNB). Required when using --condition-orders on SOL.
--gas-price Nobsc / base / ethGas price in gwei (BSC ≥ 0.05 / BASE/ETH ≥ 0.01). Required when using --condition-orders on BSC. Mutually exclusive with --gas-level.
--gas-level NoethGas price tier: low / average / high. Mutually exclusive with --gas-price.
--auto-feeNoethOnly with --condition-orders. GMGN automatically selects the optimal fee.
--max-fee-per-gas Nobsc / base / ethEIP-1559 max fee per gas. Clamped per chain minimums. Defaults to --gas-price if omitted (BASE/ETH).
--max-priority-fee-per-gas Nobsc / base / ethEIP-1559 max priority fee per gas. Clamped per chain minimums; capped to --max-fee-per-gas.
--condition-orders NoallJSON 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 NoallOnly with --condition-orders. Sell ratio basis: buy_amount (default) — sells a fixed token amount stored at strategy creation time; hold_amount — 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:

FieldRequiredTypeDescription
order_typeYesstringSub-order type: profit_stop (fixed take-profit), loss_stop (fixed stop-loss), profit_stop_trace (trailing take-profit), loss_stop_trace (trailing stop-loss)
sideYesstringAlways "sell"
price_scaleConditionalstringGain/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_ratioYesstringPercentage of position to sell when triggered, e.g. "100" = 100%
drawdown_rateConditionalstringRequired 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%:

[
  {"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):

gmgn-cli swap \
  --chain sol \
  --from  \
  --input-token So11111111111111111111111111111111111111112 \
  --output-token  \
  --amount 10000000 \
  --slippage 30 \
  --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:

gmgn-cli swap \
  --chain sol \
  --from  \
  --input-token So11111111111111111111111111111111111111112 \
  --output-token  \
  --amount 10000000 \
  --slippage 30 \
  --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 / order get Response Fields

FieldTypeDescription
order_idstringOrder ID for follow-up queries
hashstringTransaction hash
statusstringOrder status: pending / processed / confirmed / failed / expired
error_codestringError code on failure
error_statusstringError description on failure
strategy_order_idstringStrategy order ID; only present when --condition-orders was passed and strategy creation succeeded (best-effort)
reportobjectExecution report; only present when state = 30 and status = "successful". See Report Fields below.

Report Fields (present only when status = "successful")

FieldTypeDescription
input_tokenstringInput token contract address
input_token_decimalsintegerInput token decimal places
swap_modestringSwap mode: ExactIn / ExactOut
input_amountstringActual input consumed (smallest unit)
output_tokenstringOutput token contract address
output_token_decimalsintegerOutput token decimal places
output_amountstringActual output received (smallest unit)
quote_tokenstringQuote token contract address
quote_decimalsintegerQuote token decimal places
quote_amountstringQuote amount (smallest unit)
base_tokenstringBase token contract address
base_decimalsintegerBase token decimal places
base_amountstringBase token amount (smallest unit)
pricestringExecution price (quote/base token)
price_usdstringExecution price in USD
heightintegerBlock height of execution
order_heightintegerBlock height when order was placed
gas_nativestringGas fee in native token
gas_usdstringGas fee in USD

Output Format

Pre-swap Confirmation

Before displaying the confirmation, run order quote to get the estimated output (requires signed auth and GMGN_PRIVATE_KEY on every supported quote chain):

gmgn-cli order quote \
  --chain  \
  --from  \
  --input-token  \
  --output-token  \
  --amount  \
  --slippage 

Then display the confirmation summary using output_amount from the quote response:

⚠️ Swap Confirmation Required

Chain:        {chain}
Wallet:       {--from}
Sell:         {input amount in human units} {input token symbol}
Buy:          {output token symbol}
Slippage:     {slippage}% (or "auto")
Est. output:  ~{output_amount from quote} {output token symbol}
Risk Level:   🟢 Low / 🟡 Medium / 🔴 High  (based on rug_ratio from security check)

Reply "confirm" to proceed.

Note: Risk Level is derived from the required security check:

  • 🟢 Low: rug_ratio < 0.1
  • 🟡 Medium: rug_ratio 0.1–0.3
  • 🔴 High: rug_ratio > 0.3 (requires re-confirmation)

If the user explicitly skipped the security check, omit the Risk Level line and add a note: "(Security check skipped by user)"

Post-swap Receipt

After a confirmed swap, display:

✅ Swap Confirmed

Spent:    {report.input_amount in human units} {input symbol}
Received: {report.output_amount in human units} {output symbol}
Tx:       {explorer link for hash}
Order ID: {order_id}

Convert report.input_amount and report.output_amount from smallest unit using report.input_token_decimals and report.output_token_decimals before displaying.


multi-swap Usage

Submit a token swap across multiple wallets concurrently. Each wallet executes independently — one wallet's failure does not affect others. Up to 100 wallets per request. All wallets must be bound to the API Key. Requires GMGN_PRIVATE_KEY.

# Basic multi-wallet swap
gmgn-cli multi-swap \
  --chain sol \
  --accounts , \
  --input-token  \
  --output-token  \
  --input-amount '{"":"1000000","":"2000000"}' \
  --slippage 30

# Sell a percentage of each wallet's balance (use --input-amount-bps)
gmgn-cli multi-swap \
  --chain sol \
  --accounts , \
  --input-token  \
  --output-token  \
  --input-amount-bps '{"":"5000","":"10000"}' \
  --slippage 30

# With per-wallet take-profit / stop-loss (condition_orders)
gmgn-cli multi-swap \
  --chain sol \
  --accounts , \
  --input-token So11111111111111111111111111111111111111112 \
  --output-token  \
  --input-amount '{"":"1000000","":"2000000"}' \
  --slippage 30 \
  --priority-fee 0.00001 \
  --tip-fee 0.00001 \
  --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"}]'

# ETH multi-wallet swap (EIP-1559 gas)
gmgn-cli multi-swap \
  --chain eth \
  --accounts <0xaddr1>,<0xaddr2> \
  --input-token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 \
  --output-token  \
  --input-amount '{"<0xaddr1>":"1000000","<0xaddr2>":"2000000"}' \
  --slippage 30 \
  --gas-price 5

multi-swap Parameters

ParameterRequiredChainDescription
--chainYesallsol / bsc / base / eth
--accountsYesallComma-separated wallet addresses (1–100, all must be bound to the API Key)
--input-tokenYesallInput token contract address
--output-tokenYesallOutput token contract address
--input-amountNo*allJSON map of wallet_address → input amount (smallest unit). One of --input-amount, --input-amount-bps, or --output-amount is required.
--input-amount-bpsNo*allJSON map of wallet_address → percent in bps (1–10000; 5000 = 50%). Only valid when input_token is NOT a currency.
--output-amountNo*allJSON map of wallet_address → target output amount (smallest unit).
--slippage NoallSlippage tolerance as an integer 0–100, e.g. 30 = 30%. Mutually exclusive with --auto-slippage.
--auto-slippageNoallEnable automatic slippage.
--anti-mevNosol / bsc / ethEnable anti-MEV protection. Not supported on base.
--priority-fee NosolPriority fee in SOL (≥ 0.00001). Required when using --condition-orders on SOL.
--tip-fee Nosol / bscTip fee (SOL ≥ 0.00001 / BSC ≥ 0.000001 BNB). Required when using --condition-orders on SOL.
--gas-price Nobsc / base / ethGas price in gwei (BSC ≥ 0.05 / BASE/ETH ≥ 0.01). Required when using --condition-orders on BSC. Mutually exclusive with --gas-level.
--gas-level NoethGas price tier: low / average / high. Mutually exclusive with --gas-price.
--auto-feeNoethOnly with --condition-orders. GMGN automatically selects the optimal fee.
--max-fee-per-gas Nobsc / base / ethEIP-1559 max fee per gas. Clamped per chain minimums. Defaults to --gas-price if omitted (BASE/ETH).
--max-priority-fee-per-gas Nobsc / base / ethEIP-1559 max priority fee per gas. Clamped per chain minimums; capped to --max-fee-per-gas.
--condition-orders NoallJSON array of condition sub-orders (take-profit / stop-loss) attached to each successful wallet's swap. Same structure as swap --condition-orders. Strategy creation is best-effort per wallet.
--sell-ratio-type NoallOnly with --condition-orders. Sell ratio base: buy_amount (default) / hold_amount.

multi-swap Response Fields

The response data is an array — one element per wallet:

FieldTypeDescription
accountstringWallet address
successboolWhether this wallet's swap succeeded
errorstringError message on failure; absent on success
error_codestringError code on failure; absent on success
resultobjectOn success: OrderResponse (same fields as swap response). On failure: absent.
result.strategy_order_idstringStrategy order ID; only present when --condition-orders was passed and strategy creation succeeded (best-effort)

order quote Usage

Get an estimated output amount before submitting a swap. All supported quote chains use signed auth and require GMGN_PRIVATE_KEY.

gmgn-cli order quote \
  --chain sol \
  --from  \
  --input-token  \
  --output-token  \
  --amount  \
  --slippage 30

order quote Response Fields

FieldTypeDescription
input_tokenstringInput token contract address
output_tokenstringOutput token contract address
input_amountstringInput amount (smallest unit)
output_amountstringExpected output amount (smallest unit)
min_output_amountstringMinimum output after slippage
slippagenumberActual slippage percentage

order get Usage

gmgn-cli order get --chain sol --order-id 

Response fields are shared with swap — see swap / order get Response Fields above.


gas-price Usage

Query recommended gas price tiers for any chain. API Key only — no signature or private key required.

gmgn-cli gas-price --chain eth
gmgn-cli gas-price --chain bsc
gmgn-cli gas-price --chain base
gmgn-cli gas-price --chain sol

gas-price Response Fields

All fields are omitempty — fields unsupported by a chain are omitted. Units are chain-native (wei for EVM chains; lamports / chain-native for SOL).

FieldTypeDescription
chainstringChain identifier
autostringAutomatic gas price
auto_mevstringAnti-MEV automatic gas price
last_blockint64Latest block number
highstringHigh-priority gas price
averagestringAverage-priority gas price
lowstringLow-priority gas price
suggest_base_feestringSuggested base fee
high_prio_feestringHigh-priority fee
average_prio_feestringAverage-priority fee
low_prio_feestringLow-priority fee
high_prio_fee_mixedstringHigh mixed priority fee
average_prio_fee_mixedstringAverage mixed priority fee
low_prio_fee_mixedstringLow mixed priority fee
native_token_usd_pricefloat32Native token USD price
high_estimate_timeint64Estimated confirmation time for high tier (seconds)
average_estimate_timeint64Estimated confirmation time for average tier (seconds)
low_estimate_timeint64Estimated confirmation time for low tier (seconds)
high_orignstringHigh-priority raw origin value
average_orignstringAverage-priority raw origin value
low_orignstringLow-priority raw origin value

order strategy create Usage

# Create a take-profit order: sell when price rises to target (limit_order)
gmgn-cli order strategy create \
  --chain sol \
  --from  \
  --base-token  \
  --quote-token  \
  --order-type limit_order \
  --sub-order-type take_profit \
  --check-price 0.002 \
  --amount-in 1000000 \
  --slippage 30

# Create a stop-loss order: sell when price drops to target (limit_order)
gmgn-cli order strategy create \
  --chain sol \
  --from  \
  --base-token  \
  --quote-token  \
  --order-type limit_order \
  --sub-order-type stop_loss \
  --check-price 0.0005 \
  --amount-in-percent 100 \
  --slippage 30

# Create a smart_trade with buy_low entry + take-profit + stop-loss (smart_trade)
gmgn-cli order strategy create \
  --chain sol \
  --from  \
  --base-token  \
  --quote-token  \
  --order-type smart_trade \
  --sub-order-type mix_trade \
  --open-price 0.000082 \
  --amount-in 1000000 \
  --slippage 30 \
  --sell-param '{"slippage":30,"priority_fee":"0.00001","tip_fee":"0.00001"}' \
  --condition-orders '[{"order_type":"buy_low","side":"buy","check_price":"0.00008"},{"order_type":"profit_stop","side":"sell","price_scale":"100","sell_ratio":"50"},{"order_type":"loss_stop","side":"sell","price_scale":"50","sell_ratio":"100"}]'

order strategy create Parameters

ParameterRequiredChainDescription
--chainYesallsol / bsc / base / eth
--fromYesallWallet address (must match API Key binding)
--base-tokenYesallBase token contract address
--quote-tokenYesallQuote token contract address
--order-typeYesallOrder type: limit_order / smart_trade
--sub-order-typeYesalllimit_order: buy_low / buy_high / stop_loss / take_profit; smart_trade with condition_orders: mix_trade
--check-priceNo*allTrigger price — required for limit_order; omit for smart_trade (trigger is in the buy_low condition order)
--open-priceNoallOpen price of the position
--amount-inNo*allInput amount (smallest unit). Mutually exclusive with --amount-in-percent
--amount-in-percentNo*allInput as percentage (e.g. 50 = 50%). Mutually exclusive with --amount-in
--limit-price-modeNoallexact / slippage (default: slippage)
--expire-inNoallOrder expiry in seconds
--sell-ratio-typeNoallbuy_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
--quote-investmentNoallQuote token investment amount (smart_trade)
--sell-paramYes (smart_trade)allJSON object of sell-side trade params (slippage, fee, gas, etc.) used when a TP/SL condition fires. Required for smart_trade. Same fields as the root TradeParam; slippage is 0–100 integer.
--buy-paramNoallJSON object of buy-side trade params override for smart_trade. Same fields as root TradeParam; slippage is 0–100 integer.
--slippageNoallSlippage tolerance as an integer 0–100, e.g. 30 = 30%. Mutually exclusive with --auto-slippage. Defaults to auto-slippage if neither is set.
--auto-slippageNoallEnable automatic slippage
--priority-feeNosolPriority fee in SOL (≥ 0.00001). Required for SOL.
--tip-feeNosol / bscTip fee (SOL ≥ 0.00001 / BSC ≥ 0.000001 BNB). Required for SOL.
--auto-feeNoethAuto fee mode — GMGN automatically selects the optimal fee.
--gas-priceNobsc / base / ethGas price in gwei (BSC ≥ 0.05 / BASE/ETH ≥ 0.01). Required for BSC. Mutually exclusive with --gas-level.
--gas-levelNoethGas price tier: low / average / high. Mutually exclusive with --gas-price.
--max-fee-per-gasNobsc / base / ethEIP-1559 max fee per gas. Clamped per chain minimums.
--max-priority-fee-per-gasNobsc / base / ethEIP-1559 max priority fee per gas. Clamped per chain minimums; capped to --max-fee-per-gas.
--anti-mevNosol / bsc / ethEnable anti-MEV protection. Not supported on base.
--condition-ordersNoallJSON array of condition sub-orders for smart_trade. Must include one buy_low entry (with check_price lower than open_price) plus at least one TP/SL entry.

order strategy create Response Fields

FieldTypeDescription
order_idstringCreated strategy order ID
is_updatebooltrue if an existing order was updated, false if newly created

order strategy list Usage

# List open condition orders (profit_stop / loss_stop / trace types) — use STMix
gmgn-cli order strategy list --chain sol --group-tag STMix

# 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 

order strategy list Parameters

ParameterRequiredDescription
--chainYessol / bsc / base / eth
--typeNoopen (default) / history
--fromNoFilter by wallet address
--group-tagYesFilter by order group: LimitOrder (limit orders only) / STMix (mixed strategy orders: take-profit, stop-loss, trailing take-profit, trailing stop-loss)
--base-tokenNoFilter by token address
--page-tokenNoPagination cursor from previous response
--limitNoResults per page (default 10 for history)

order strategy list Response Fields

FieldTypeDescription
next_page_tokenstringCursor for next page; empty when no more data
totalintTotal count (only returned when --type open)
listarrayArray of strategy order objects; see fields below

list[] — Strategy Order Object

FieldTypeDescription
anti_mev_modestringAnti-MEV mode string; empty when not set
auto_slippageboolWhether auto slippage is enabled
base_decimalintBase token decimal places
base_tokenstringBase token contract address
chainstringChain: sol / bsc / base / eth
close_amountstringToken amount sold on close; empty when order is open
close_pricestringToken price at close; empty when order is open
close_sell_modelstringSell model used on close; empty when order is open
close_sign_hashstringClose transaction hash; empty when order is open
close_timeintClose timestamp (ms); 0 when order is open
condition_ordersarrayCondition sub-orders; each element is an object — see condition_orders[] below
create_timeintCreation timestamp (ms)
custom_rpcstringCustom RPC endpoint; empty string when not set
dev_sell_ratiostringDev sell trigger ratio; empty when not set
drawdown_ratestringTrailing drawdown rate for profit_stop_trace / loss_stop_trace; empty when not set
expire_timeintExpiration timestamp (ms)
feestringBase transaction fee
gas_pricestringGas price
is_anti_mevboolWhether anti-MEV protection is active
limit_price_modestringLimit price mode; empty when not set
loss_stopstringStop-loss trigger price; empty when not set
loss_stop_typestringStop-loss type; empty when not set
max_fee_per_gasstringEIP-1559 max fee per gas; EVM only; empty on SOL
max_priority_fee_per_gasstringEIP-1559 max priority fee per gas; EVM only; empty on SOL
open_amountstringToken amount at open (smallest unit)
open_pricestringToken price at open
open_sign_hashstringOpen transaction hash; empty before confirmed
order_idstringUnique order ID (UUID)
order_statisticobjectCumulative order statistics; see order_statistic Object below
order_typestringOrder type: smart_trade / limit_order
place_actionstringPlacement action; empty when not applicable
prepare_statusstringPreparation status; empty when not applicable
priority_feestringPriority fee; SOL / BSC only
profit_stopstringTake-profit trigger price; empty when not set
profit_stop_typestringTake-profit type; empty when not set
quote_decimalintQuote token decimal places
quote_investmentstringQuote token investment amount (smallest unit)
quote_tokenstringQuote token contract address
reason_bystringEntity that triggered the close; empty when open
reason_codestringReason code for the close action; empty when open
record_high_pricestringHighest recorded price since open; used for trailing stops
sell_paramobjectSell transaction parameters; see sell_param Object below
sell_ratiostringSell ratio; empty when not set
sell_ratio_typestringSell ratio base: buy_amount / others
slippageintSlippage tolerance (0 = auto)
statusstringOrder lifecycle status: open / closed
strategy_statusstringStrategy running status: running / stopped
sub_order_typestringSub-order type: mix_trade / others
tip_feestringTip fee; SOL only
token_balancestringRemaining token balance; empty when not available
token_logostringToken logo URL
token_namestringToken display name
token_pricestringCurrent token price; empty when not available
total_supplystringToken total supply
versionintOrder schema version
wallet_addressstringWallet address that placed the order

condition_orders[] — Condition Sub-Order Object

FieldTypeDescription
cidstringCondition sub-order ID (UUID)
order_typestringSub-order type: profit_stop / loss_stop / profit_stop_trace / loss_stop_trace
sidestringTrade side: sell
price_scalestringPrice ratio relative to open price (string); profit_stop / loss_stop required
sell_ratiostringSell ratio (string), e.g. "100"
check_pricestringComputed trigger price derived from price_scale and open price
statusstringSub-order status: cancel / success / failed

order_statistic Object

FieldTypeDescription
buy_amountstringBought token amount (smallest unit)
buy_quote_pricestringQuote token price at buy
buy_usdt_pricestringUSDT-denominated price at buy
quote_profitstringRealized profit in quote token
sell_amountstringTotal token amount sold
sell_numintTotal number of sell attempts
success_sell_amountstringSuccessfully sold token amount
success_sell_numintNumber of successful sells
usdt_profit

Related skills

Analyze any crypto wallet by address — holdings, realized/unrealized P&L, win rate, trading history, performance stats, specific token balance, and tokens cr...

26 installs1 stars

Get real-time crypto buy/sell activity from Smart Money wallets, KOL influencer wallets, and personally followed wallets via GMGN API — alpha signals, whale...

25 installs1 stars

Get crypto and meme token price charts (K-line, candlestick, OHLCV), trending meme coin rankings by volume, and newly launched tokens on launchpads (pump.fun...

25 installs1 stars

Execute DEX swaps on Solana or Base (including cross-chain bridges) and Hyperliquid perpetual trades. Use when buying or selling a token, getting a swap quote, executing a trade, or opening/closing/managing a perp position.

33 installs

Trade crypto, manage a multi-chain wallet, and query an AI analyst from one CLI.

162 installs109 stars

Use this skill when the user wants to analyze or roast a Solana wallet, score memecoin exposure, explain portfolio risks, generate rebalance ideas, draft a s...

26 installs