gmgn-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +45 -0
- package/.claude-plugin/plugin.json +13 -0
- package/.cursor-plugin/plugin.json +23 -0
- package/LICENSE +21 -0
- package/Readme.md +236 -0
- package/Readme.zh.md +236 -0
- package/dist/client/OpenApiClient.d.ts +58 -0
- package/dist/client/OpenApiClient.d.ts.map +1 -0
- package/dist/client/OpenApiClient.js +174 -0
- package/dist/client/OpenApiClient.js.map +1 -0
- package/dist/client/signer.d.ts +32 -0
- package/dist/client/signer.d.ts.map +1 -0
- package/dist/client/signer.js +66 -0
- package/dist/client/signer.js.map +1 -0
- package/dist/commands/market.d.ts +3 -0
- package/dist/commands/market.d.ts.map +1 -0
- package/dist/commands/market.js +50 -0
- package/dist/commands/market.js.map +1 -0
- package/dist/commands/portfolio.d.ts +3 -0
- package/dist/commands/portfolio.d.ts.map +1 -0
- package/dist/commands/portfolio.js +112 -0
- package/dist/commands/portfolio.js.map +1 -0
- package/dist/commands/swap.d.ts +3 -0
- package/dist/commands/swap.d.ts.map +1 -0
- package/dist/commands/swap.js +73 -0
- package/dist/commands/swap.js.map +1 -0
- package/dist/commands/token.d.ts +3 -0
- package/dist/commands/token.d.ts.map +1 -0
- package/dist/commands/token.js +62 -0
- package/dist/commands/token.js.map +1 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +36 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/output.d.ts +3 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +22 -0
- package/dist/output.js.map +1 -0
- package/package.json +51 -0
- package/skills/gmgn-market/SKILL.md +144 -0
- package/skills/gmgn-portfolio/SKILL.md +105 -0
- package/skills/gmgn-swap/SKILL.md +142 -0
- package/skills/gmgn-token/SKILL.md +55 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gmgn-swap
|
|
3
|
+
description: Submit a GMGN token swap or query order status. Requires private key configured. Supports sol / bsc / base.
|
|
4
|
+
argument-hint: "[--chain <chain> --from <wallet> --input-token <addr> --output-token <addr> --amount <n>] | [order get --chain <chain> --order-id <id>]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Use the `gmgn-cli` tool to submit a token swap or query an existing order. **Requires private key** (`GMGN_PRIVATE_KEY` in `.env`).
|
|
8
|
+
|
|
9
|
+
## Sub-commands
|
|
10
|
+
|
|
11
|
+
| Sub-command | Description |
|
|
12
|
+
|-------------|-------------|
|
|
13
|
+
| `swap` | Submit a token swap |
|
|
14
|
+
| `order get` | Query order status |
|
|
15
|
+
|
|
16
|
+
## Supported Chains
|
|
17
|
+
|
|
18
|
+
`sol` / `bsc` / `base`
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Chain Currencies
|
|
22
|
+
|
|
23
|
+
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).
|
|
24
|
+
|
|
25
|
+
| Chain | Currency tokens |
|
|
26
|
+
|-------|----------------|
|
|
27
|
+
| `sol` | SOL (native, So11111111111111111111111111111111111111112), USDC (`EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`) |
|
|
28
|
+
| `bsc` | BNB (native, 0x0000000000000000000000000000000000000000), USDC (`0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d`) |
|
|
29
|
+
| `base` | ETH (native, 0x0000000000000000000000000000000000000000), USDC (`0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`) |
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Prerequisites
|
|
33
|
+
|
|
34
|
+
Both `GMGN_API_KEY` and `GMGN_PRIVATE_KEY` must be set in `.env`. The private key must correspond to the wallet bound to the API Key.
|
|
35
|
+
|
|
36
|
+
## Swap Usage
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Basic swap
|
|
40
|
+
npx gmgn-cli swap \
|
|
41
|
+
--chain sol \
|
|
42
|
+
--from <wallet_address> \
|
|
43
|
+
--input-token <input_token_address> \
|
|
44
|
+
--output-token <output_token_address> \
|
|
45
|
+
--amount <input_amount_smallest_unit>
|
|
46
|
+
|
|
47
|
+
# With slippage
|
|
48
|
+
npx gmgn-cli swap \
|
|
49
|
+
--chain sol \
|
|
50
|
+
--from <wallet_address> \
|
|
51
|
+
--input-token <input_token_address> \
|
|
52
|
+
--output-token <output_token_address> \
|
|
53
|
+
--amount 1000000 \
|
|
54
|
+
--slippage 0.01
|
|
55
|
+
|
|
56
|
+
# With anti-MEV (SOL)
|
|
57
|
+
npx gmgn-cli swap \
|
|
58
|
+
--chain sol \
|
|
59
|
+
--from <wallet_address> \
|
|
60
|
+
--input-token <input_token_address> \
|
|
61
|
+
--output-token <output_token_address> \
|
|
62
|
+
--amount 1000000 \
|
|
63
|
+
--anti-mev
|
|
64
|
+
|
|
65
|
+
# Sell 50% of a token (input_token must NOT be a currency)
|
|
66
|
+
npx gmgn-cli swap \
|
|
67
|
+
--chain sol \
|
|
68
|
+
--from <wallet_address> \
|
|
69
|
+
--input-token <token_address> \
|
|
70
|
+
--output-token <sol_or_usdc_address> \
|
|
71
|
+
--percent 50
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Order Query
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npx gmgn-cli order get --chain sol --order-id <order_id>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Swap Parameters
|
|
81
|
+
|
|
82
|
+
| Parameter | Required | Description |
|
|
83
|
+
|-----------|----------|-------------|
|
|
84
|
+
| `--chain` | Yes | `sol` / `bsc` / `base` |
|
|
85
|
+
| `--from` | Yes | Wallet address (must match API Key binding) |
|
|
86
|
+
| `--input-token` | Yes | Input token contract address |
|
|
87
|
+
| `--output-token` | Yes | Output token contract address |
|
|
88
|
+
| `--amount` | No* | Input amount in smallest unit. Required unless `--percent` is used. |
|
|
89
|
+
| `--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).** |
|
|
90
|
+
| `--slippage <n>` | No | Slippage tolerance, e.g. `0.01` = 1% |
|
|
91
|
+
| `--min-output <n>` | No | Minimum output amount |
|
|
92
|
+
| `--anti-mev` | No | Enable anti-MEV protection (default true) |
|
|
93
|
+
| `--priority-fee <sol>` | No | Priority fee in SOL (≥ 0.00001, SOL only) |
|
|
94
|
+
| `--tip-fee <n>` | No | Tip fee (SOL ≥ 0.00001 / BSC ≥ 0.000001 BNB) |
|
|
95
|
+
| `--max-auto-fee <n>` | No | Max automatic fee cap |
|
|
96
|
+
| `--gas-price <gwei>` | No | Gas price in gwei (BSC ≥ 0.05 / BASE/ETH ≥ 0.01) |
|
|
97
|
+
| `--max-fee-per-gas <n>` | No | EIP-1559 max fee per gas (Base only) |
|
|
98
|
+
| `--max-priority-fee-per-gas <n>` | No | EIP-1559 max priority fee per gas (Base only) |
|
|
99
|
+
|
|
100
|
+
## Swap Response Fields
|
|
101
|
+
|
|
102
|
+
| Field | Type | Description |
|
|
103
|
+
|-------|------|-------------|
|
|
104
|
+
| `order_id` | string | Order ID for follow-up queries |
|
|
105
|
+
| `hash` | string | Transaction hash |
|
|
106
|
+
| `state` | int | Order state code |
|
|
107
|
+
| `confirmation.state` | string | `processed` / `confirmed` / `failed` / `expired` |
|
|
108
|
+
| `confirmation.detail` | string | Confirmation detail message |
|
|
109
|
+
| `error_code` | string | Error code on failure |
|
|
110
|
+
| `error_status` | string | Error description on failure |
|
|
111
|
+
| `height` | number | Block height of the transaction |
|
|
112
|
+
| `order_height` | number | Block height when the order was placed |
|
|
113
|
+
| `input_token` | string | Input token contract address |
|
|
114
|
+
| `output_token` | string | Output token contract address |
|
|
115
|
+
| `filled_input_amount` | string | Actual input consumed (smallest unit); empty if not filled |
|
|
116
|
+
| `filled_output_amount` | string | Actual output received (smallest unit); empty if not filled |
|
|
117
|
+
|
|
118
|
+
## Notes
|
|
119
|
+
|
|
120
|
+
- Swap uses **critical auth** (API Key + signature) — CLI handles signing automatically, no manual processing needed
|
|
121
|
+
- After submitting a swap, use `order get` to poll for confirmation
|
|
122
|
+
- `--amount` is in the **smallest unit** (e.g., lamports for SOL)
|
|
123
|
+
- Use `--raw` to get single-line JSON for further processing
|
|
124
|
+
|
|
125
|
+
## Execution Guidelines
|
|
126
|
+
|
|
127
|
+
- **Currency resolution** — When the user names a currency (SOL/BNB/ETH/USDC) instead of providing an address, look up its address in the Chain Currencies table and apply it automatically — never ask the user for it.
|
|
128
|
+
- Buy ("buy X SOL of TOKEN", "spend 0.5 USDC on TOKEN") → resolve currency to `--input-token`
|
|
129
|
+
- Sell ("sell TOKEN for SOL", "sell 50% of TOKEN to USDC") → resolve currency to `--output-token`
|
|
130
|
+
- **Pre-trade confirmation** — Before executing `swap`, always present the key parameters (chain, from, input-token, output-token, amount or percent) to the user and ask for explicit confirmation.
|
|
131
|
+
- **Percentage sell restriction** — `--percent` is ONLY valid when `input_token` is NOT a currency. Do NOT use `--percent` when `input_token` is SOL/BNB/ETH (native) or USDC. This includes: "sell 50% of my SOL", "use 30% of my BNB to buy X", "spend 50% of my USDC on X" — all unsupported. Explain the restriction to the user and ask for an explicit absolute amount instead.
|
|
132
|
+
- **Chain-wallet compatibility** — SOL addresses are incompatible with EVM chains (bsc/base). Warn the user and abort if the address format does not match the chain.
|
|
133
|
+
- **Credential sensitivity** — `GMGN_API_KEY` and `GMGN_PRIVATE_KEY` can directly execute trades on the linked wallet. Never log, display, or expose these values.
|
|
134
|
+
- **Order polling** — After a swap, if `confirmation.state` is not yet `confirmed` / `failed` / `expired`, poll with `order get` up to 3 times at 5-second intervals before reporting a timeout. Once confirmed, display the trade result using `filled_input_amount` and `filled_output_amount` (convert from smallest unit using token decimals), e.g. "Spent 0.1 SOL → received 98.5 USDC" or "Sold 1000 TOKEN → received 0.08 SOL".
|
|
135
|
+
- **Block explorer links** — After a successful swap, display a clickable explorer link for the returned `hash`:
|
|
136
|
+
|
|
137
|
+
| Chain | Explorer |
|
|
138
|
+
|-------|----------|
|
|
139
|
+
| sol | `https://solscan.io/tx/<hash>` |
|
|
140
|
+
| bsc | `https://bscscan.com/tx/<hash>` |
|
|
141
|
+
| base | `https://basescan.org/tx/<hash>` |
|
|
142
|
+
| eth | `https://etherscan.io/tx/<hash>` |
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gmgn-token
|
|
3
|
+
description: Query GMGN token information — basic info, security, pool, top holders and top traders. Supports sol / bsc / base.
|
|
4
|
+
argument-hint: <sub-command> --chain <sol|bsc|base> --address <token_address>
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Use the `gmgn-cli` tool to query token information based on the user's request.
|
|
8
|
+
|
|
9
|
+
## Sub-commands
|
|
10
|
+
|
|
11
|
+
| Sub-command | Description |
|
|
12
|
+
|-------------|-------------|
|
|
13
|
+
| `token info` | Basic info + realtime price |
|
|
14
|
+
| `token security` | Security metrics (holder concentration, contract risks) |
|
|
15
|
+
| `token pool` | Liquidity pool info |
|
|
16
|
+
| `token holders` | Top token holders list |
|
|
17
|
+
| `token traders` | Top token traders list |
|
|
18
|
+
|
|
19
|
+
## Supported Chains
|
|
20
|
+
|
|
21
|
+
`sol` / `bsc` / `base`
|
|
22
|
+
|
|
23
|
+
## Prerequisites
|
|
24
|
+
|
|
25
|
+
- `.env` file with `GMGN_API_KEY` set
|
|
26
|
+
- Run from the directory where your `.env` file is located, or set `GMGN_HOST` in your environment
|
|
27
|
+
|
|
28
|
+
## Usage Examples
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Basic token info
|
|
32
|
+
npx gmgn-cli token info --chain sol --address <token_address>
|
|
33
|
+
|
|
34
|
+
# Security metrics
|
|
35
|
+
npx gmgn-cli token security --chain sol --address <token_address>
|
|
36
|
+
|
|
37
|
+
# Liquidity pool
|
|
38
|
+
npx gmgn-cli token pool --chain sol --address <token_address>
|
|
39
|
+
|
|
40
|
+
# Top holders
|
|
41
|
+
npx gmgn-cli token holders --chain sol --address <token_address>
|
|
42
|
+
npx gmgn-cli token holders --chain sol --address <token_address> --limit 50
|
|
43
|
+
|
|
44
|
+
# Top traders
|
|
45
|
+
npx gmgn-cli token traders --chain sol --address <token_address>
|
|
46
|
+
npx gmgn-cli token traders --chain sol --address <token_address> --limit 50
|
|
47
|
+
|
|
48
|
+
# Raw JSON output (for piping)
|
|
49
|
+
npx gmgn-cli token info --chain sol --address <token_address> --raw
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Notes
|
|
53
|
+
|
|
54
|
+
- All token commands use normal auth (API Key only, no signature required)
|
|
55
|
+
- Use `--raw` to get single-line JSON for further processing
|