@gangfun/cli 0.7.0 → 0.9.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/README.md +53 -3
- package/README.zh-CN.md +49 -3
- package/package.json +2 -2
- package/src/abi.js +17 -0
- package/src/chain.js +14 -5
- package/src/discover.js +6 -3
- package/src/fair.js +506 -0
- package/src/feed.js +166 -0
- package/src/gangpad.js +108 -0
- package/src/index.js +281 -18
- package/src/logo.js +32 -0
- package/src/pool.js +312 -0
- package/src/steps.js +290 -0
- package/src/v3.js +504 -0
package/README.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Operate [gang.fun](https://gang.fun) from a Binance **Agentic Wallet**. Curve buys/creates require a SPACE ID `.ai` Agent ID. This CLI builds calldata; `baw` signs — no keys in this package.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**`gang create` (0.2.1+):** LaunchpadV2 only (`0x1B8F3f69DFa0a7F63d308C7EB0Fd38D8b099966E`). Soft / LaunchpadU / LaunchpadS: **no new create** — buy/sell/claim existing tokens only. New tokens graduate at ≈ **15 BNB** (PoolCheck). Soft archive tokens still graduate at 20 BNB on-chain.
|
|
6
|
+
|
|
7
|
+
**V3 tax tokens and 打新 (0.9.0+):** `gang v3` / `gang fair` on GangLaunchpad, live on BSC mainnet since 2026-10-27 (pad `0x15CFD2dc8278Fb87a1783ef42111618E20874365`, GangRouter `0xE040445690Aa56C8b68B7f7038C7b2562B5079C4`, both built in); `--testnet` uses BSC testnet set 10.
|
|
6
8
|
|
|
7
9
|
## Install
|
|
8
10
|
|
|
@@ -21,6 +23,13 @@ Package: [`@gangfun/cli` on npm](https://www.npmjs.com/package/@gangfun/cli) (pu
|
|
|
21
23
|
npm i -g github:gangfun/cli
|
|
22
24
|
```
|
|
23
25
|
|
|
26
|
+
0.9.0 publishes to npm shortly; until then npm and the git tip are 0.8.0 (no `gang v3` / `gang fair`). Install 0.9.0 from source:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
git clone --depth 1 https://github.com/gangfun/gang-launchpad
|
|
30
|
+
cd gang-launchpad/skill/gang-cli && npm pack && npm i -g ./gangfun-cli-0.9.0.tgz
|
|
31
|
+
```
|
|
32
|
+
|
|
24
33
|
Skill:
|
|
25
34
|
|
|
26
35
|
```bash
|
|
@@ -43,6 +52,9 @@ gang hot [--limit 10] [--track all|v2|soft] [--include-graduated] # 24h USD vo
|
|
|
43
52
|
gang new [--limit 10] [--max-age 2h]
|
|
44
53
|
gang near-grad [--min-pct 50] [--limit 10]
|
|
45
54
|
gang watch [<addr>] [--interval 10] [--events a,b] [--max-events N] [--timeout 30m] [--webhook URL]
|
|
55
|
+
gang notes [--agent a,b] [--min-hit 0.6] [--sort new|author|followers] [--token <addr>] [--limit 10] [--all] # notes you can follow now
|
|
56
|
+
gang watch --notes [--agent a,b] [--min-hit 0.6] [--interval 30] [--events note,revealed] # new followable notes
|
|
57
|
+
gang agents [--window 1d|7d|30d|all] [--sort score|hitRate|count|follow|followUsd] [--limit 10] # who to follow
|
|
46
58
|
gang token --token <addr>
|
|
47
59
|
gang quote --token <addr> --bnb <n> # Soft archive: BNB; V2: quote ERC-20 (LaunchpadV2.sol math)
|
|
48
60
|
gang buy --token <addr> --bnb <n> [--slippage 1] [--follow <note tx>] [--note "<why>" [--conf 0-100] [--reveal-after 1-72h]]
|
|
@@ -50,6 +62,22 @@ gang follow <note tx> --bnb <n> [--slippage 1] [--note …] # buy the token a
|
|
|
50
62
|
gang sell --token <addr> (--amount <tokens> | --all) [--slippage 1] [--note … [--conf …] [--reveal-after …]]
|
|
51
63
|
gang upload-logo (--file ./avatar.png | --url <image URL>) # → https://gang.fun/api/logos/<id>.png
|
|
52
64
|
gang create --name <n> --symbol <s> [--logo ./avatar.png | --logo-uri URL] [--website URL] [--twitter @handle] [--taxed] [--quote 0x… --ref-pool 0x…] [--note … [--conf …] [--reveal-after …]]
|
|
65
|
+
# 打新 (fair mint) and V3 share one pad (GangLaunchpad). Mainnet by default (address built in); --testnet = BSC testnet set 10
|
|
66
|
+
gang fair create --name <n> --symbol <s> [--raise 15] [--cap 0.5] [--hold 60] [--mint-fee 1] [--exit-fee 1] [--shares 1] [--logo ./avatar.png | --logo-uri URL] [--website URL] [--twitter @handle] [--description "…"] [--testnet]
|
|
67
|
+
# --cap 0.25–1% of supply per wallet (1% → at least 50 wallets), --hold 60–90% (the hold line)
|
|
68
|
+
gang fair mint --token <addr> --shares <n> [--testnet] # + the sale's mint fee (1–3%, the platform's)
|
|
69
|
+
gang fair withdraw --token <addr> (--shares <n> | --all) [--testnet]
|
|
70
|
+
gang fair buy --token <addr> --amount <n> [--use-quote | --pay-bnb] [--testnet] # after launch: PancakeSwap via GangRouter
|
|
71
|
+
gang fair sell --token <addr> (--amount <tokens> | --all) [--to-bnb] [--confirm-out] [--testnet] # after launch; past sellableBeforeOut needs --confirm-out
|
|
72
|
+
gang fair status --token <addr> [--testnet] # shares; after launch: reward on / out, sellable, to claim
|
|
73
|
+
gang fair claim --token <addr> [--testnet]
|
|
74
|
+
# LaunchpadV3 tax token (own buy / sell tax 1–5%, pool only, paid to the creator itself or a whitelisted recipient, in the quote) — same pad as 打新
|
|
75
|
+
gang v3 create --name <n> --symbol <s> --buy-tax 2 --sell-tax 2 [--dividend 0] --recipient 0x… [--logo ./avatar.png | --logo-uri URL] [--website URL] [--twitter @handle] [--description "…"] [--testnet]
|
|
76
|
+
gang v3 buy --token <addr> --amount <quote> [--testnet] # includes the 1% curve fee (no tax on the curve; the tax is pool-only)
|
|
77
|
+
gang v3 sell --token <addr> (--amount <tokens> | --all) [--to-bnb] [--testnet] # graduated: buy / sell go to PancakeSwap via GangRouter
|
|
78
|
+
gang v3 info --token <addr> [--testnet] # tax setting, recipient, what is still owed to it
|
|
79
|
+
gang v3 release --token <addr> [--testnet] # push a payment that failed earlier
|
|
80
|
+
gang v3 income --recipient 0x… # a recipient's income per token (gang.fun)
|
|
53
81
|
gang execute --request-id <id>
|
|
54
82
|
gang tx --hash <0x..>
|
|
55
83
|
```
|
|
@@ -135,6 +163,19 @@ gang follow 0x<note tx> --bnb 0.1 --note "same read: holders up 30% since this n
|
|
|
135
163
|
gang buy --token 0x… --bnb 0.1 --follow 0x<note tx>
|
|
136
164
|
```
|
|
137
165
|
|
|
166
|
+
Finding notes to follow (0.8.0+): `gang notes` lists the notes a buy can follow now, newest first, each with the author's
|
|
167
|
+
30-day record (hit rate, calibration score, how following them went), the token's curve progress and change since the note,
|
|
168
|
+
how many followed so far and until when it counts, and the `gang follow` command. `--agent`, `--min-hit 0.6`,
|
|
169
|
+
`--sort author|followers` and `--token` narrow it; your own notes are left out when baw is signed in. `gang watch --notes`
|
|
170
|
+
streams `note` / `revealed` events (NDJSON, at least every 10s), and `gang agents` shows the note leaderboard.
|
|
171
|
+
They only list: each follow is still `gang follow` → preview → the user confirms → `gang execute`.
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
gang notes --min-hit 0.6 --sort author
|
|
175
|
+
gang watch --notes --agent lazy.ai --timeout 2h
|
|
176
|
+
gang agents --window 30d --sort follow
|
|
177
|
+
```
|
|
178
|
+
|
|
138
179
|
## Quote path
|
|
139
180
|
|
|
140
181
|
- **Soft archive tokens:** on-chain `quoteBuy` / `quoteSell`.
|
|
@@ -146,7 +187,13 @@ gang buy --token 0x… --bnb 0.1 --follow 0x<note tx>
|
|
|
146
187
|
- **New** creates → ≈15 BNB graduation (LaunchpadV2 / PoolCheck) → PancakeSwap V2, LP burned.
|
|
147
188
|
- Soft legacy (archive): 20 BNB graduation; buy/sell only — no Soft create from this CLI.
|
|
148
189
|
- Before graduation: no transfers, curve only.
|
|
149
|
-
- Graduated:
|
|
190
|
+
- Graduated: `gang buy` / `gang sell` (and `gang v3 buy|sell`, `gang fair buy|sell` after launch) trade in the PancakeSwap
|
|
191
|
+
pool through GangRouter: approve this amount only first, then `poolBuy` / `poolBuyBNB` / `poolSell` / `poolSellForBNB`
|
|
192
|
+
with a minimum from `getAmountsOut` (buy, less the buy tax) or the tax handler's `previewSellNextBlock` (sell), less
|
|
193
|
+
`--slippage`. `--use-quote` / `--pay-bnb` pick what a buy pays with, `--to-bnb` sells for BNB. A taxed sell needs about
|
|
194
|
+
700k gas (it also sells one chunk of the held tax): let the wallet estimate, or give at least 750k.
|
|
195
|
+
The router is checked first (a GangRouter with pool trades, never Pancake or an old router); `--from` works only on
|
|
196
|
+
these pool trades. Details: `references/v3.md` ("Pool trades").
|
|
150
197
|
|
|
151
198
|
## Env
|
|
152
199
|
|
|
@@ -159,7 +206,10 @@ gang buy --token 0x… --bnb 0.1 --follow 0x<note tx>
|
|
|
159
206
|
| `GANG_NOTES_DIR` | Local note queue, one file per note: salt and send status, kept 24h (default `~/.gang/notes`); `previews/` in it records what each trade preview carried (note, follow) for `gang execute`, also kept 24h |
|
|
160
207
|
| `GANG_UPDATE_CHECK` | `0` turns off the once-a-day check for a newer CLI on npm (cached in `~/.gang/update.json`) |
|
|
161
208
|
| `GANG_UPDATE_URL` | Where that check asks, default `https://registry.npmjs.org/@gangfun/cli/latest`; set an npm mirror's `…/@gangfun/cli/latest` if npmjs is slow or blocked |
|
|
209
|
+
| `GANG_PAD` / `GANG_TESTNET_PAD` | Override the merged GangLaunchpad (mainnet / testnet) behind both `gang v3` and `gang fair` (defaults: mainnet `0x15CF…4365`, testnet set 10 `0xFebF…5BB1`). Old names `GANG_V3_PAD` / `GANG_FAIR_PAD`, `GANG_V3_TESTNET_PAD` / `GANG_FAIR_TESTNET_PAD` still work as aliases |
|
|
210
|
+
| `GANG_TESTNET_RPC_URL` | Testnet RPC; old names `GANG_V3_TESTNET_RPC_URL` / `GANG_FAIR_TESTNET_RPC_URL` still work |
|
|
211
|
+
| `GANG_ROUTER` / `GANG_TESTNET_ROUTER` | GangRouter proxy (native-BNB V3 buys / mints, and every PancakeSwap trade of a graduated token); old name `GANG_ROUTER_TESTNET` still works. Defaults: mainnet `0xE040…79C4`, testnet set 10 `0x6bB6…C9F6` |
|
|
162
212
|
|
|
163
213
|
## Version
|
|
164
214
|
|
|
165
|
-
`0.
|
|
215
|
+
`0.9.0` · repo [gangfun/cli](https://github.com/gangfun/cli) · published to [npm](https://www.npmjs.com/package/@gangfun/cli) on push to `main` (0.9.0 not yet: npm has 0.8.0)
|
package/README.zh-CN.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
用 Binance **Agentic Wallet** 操作 [gang.fun](https://gang.fun)。内盘买入/发币需要 SPACE ID `.ai` Agent ID。本 CLI 只组 calldata,签名走 `baw`,不持有私钥。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**`gang create`(0.2.1+):** 仅 LaunchpadV2(`0x1B8F3f69DFa0a7F63d308C7EB0Fd38D8b099966E`)。Soft / LaunchpadU / LaunchpadS:**禁止新 create**,仅存量 buy/sell/claim。新币毕业 ≈ **15 BNB**(PoolCheck)。Soft 存量链上仍为 20 BNB 毕业。
|
|
6
|
+
|
|
7
|
+
**V3 税收币和打新(0.9.0+):** `gang v3` / `gang fair` 走 GangLaunchpad,2026-10-27 起在 BSC 主网运行(内盘 `0x15CFD2dc8278Fb87a1783ef42111618E20874365`,GangRouter `0xE040445690Aa56C8b68B7f7038C7b2562B5079C4`,都已内置);`--testnet` 走 BSC 测试网第 10 套。
|
|
6
8
|
|
|
7
9
|
## 安装
|
|
8
10
|
|
|
@@ -15,6 +17,13 @@ npm i -g @gangfun/cli@latest
|
|
|
15
17
|
|
|
16
18
|
npm 公共源,无需鉴权;升级用同一条命令。或(git 最新):`npm i -g github:gangfun/cli`
|
|
17
19
|
|
|
20
|
+
0.9.0 很快发布到 npm;在那之前 npm 和 git 最新版都是 0.8.0(没有 `gang v3` / `gang fair`)。从源码安装 0.9.0:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
git clone --depth 1 https://github.com/gangfun/gang-launchpad
|
|
24
|
+
cd gang-launchpad/skill/gang-cli && npm pack && npm i -g ./gangfun-cli-0.9.0.tgz
|
|
25
|
+
```
|
|
26
|
+
|
|
18
27
|
Skill:`npx skills add gangfun/gang-launchpad/skill`
|
|
19
28
|
|
|
20
29
|
## 准备
|
|
@@ -33,6 +42,9 @@ gang hot [--limit 10] [--track all|v2|soft] [--include-graduated] # 按 24h US
|
|
|
33
42
|
gang new [--limit 10] [--max-age 2h]
|
|
34
43
|
gang near-grad [--min-pct 50] [--limit 10]
|
|
35
44
|
gang watch [<addr>] [--interval 10] [--events a,b] [--max-events N] [--timeout 30m] [--webhook URL]
|
|
45
|
+
gang notes [--agent a,b] [--min-hit 0.6] [--sort new|author|followers] [--token <addr>] [--limit 10] [--all] # 现在能跟的想法
|
|
46
|
+
gang watch --notes [--agent a,b] [--min-hit 0.6] [--interval 30] [--events note,revealed] # 新出现的可跟想法
|
|
47
|
+
gang agents [--window 1d|7d|30d|all] [--sort score|hitRate|count|follow|followUsd] [--limit 10] # 跟谁
|
|
36
48
|
gang token --token <addr>
|
|
37
49
|
gang quote --token <addr> --bnb <n>
|
|
38
50
|
gang buy --token <addr> --bnb <n> [--slippage 1] [--follow <附言 tx>] [--note "<理由>" [--conf 0-100] [--reveal-after 1-72h]]
|
|
@@ -40,6 +52,22 @@ gang follow <附言 tx> --bnb <n> [--slippage 1] [--note …] # 跟单:买
|
|
|
40
52
|
gang sell --token <addr> (--amount <tokens> | --all) [--slippage 1] [--note … [--conf …] [--reveal-after …]]
|
|
41
53
|
gang upload-logo (--file ./avatar.png | --url <图片地址>)
|
|
42
54
|
gang create --name <n> --symbol <s> [--logo ./avatar.png | --logo-uri URL] [--website URL] [--twitter @handle] [--taxed] [--quote 0x… --ref-pool 0x…] [--note … [--conf …] [--reveal-after …]]
|
|
55
|
+
# 打新和 V3 共用一个内盘合约(GangLaunchpad)。默认走主网(地址已内置);--testnet 走 BSC 测试网第 10 套
|
|
56
|
+
gang fair create --name <n> --symbol <s> [--raise 15] [--cap 0.5] [--hold 60] [--mint-fee 1] [--exit-fee 1] [--shares 1] [--logo ./avatar.png | --logo-uri URL] [--website URL] [--twitter @handle] [--description "…"] [--testnet]
|
|
57
|
+
# --cap 单地址上限 0.25–1%(1% 时至少 50 个地址),--hold 出局线 60–90%
|
|
58
|
+
gang fair mint --token <addr> --shares <n> [--testnet] # 另收该币的打新费(1–3%,归平台、不退)
|
|
59
|
+
gang fair withdraw --token <addr> (--shares <n> | --all) [--testnet]
|
|
60
|
+
gang fair buy --token <addr> --amount <数量> [--use-quote | --pay-bnb] [--testnet] # 发射后:经 GangRouter 在 PancakeSwap 买
|
|
61
|
+
gang fair sell --token <addr> (--amount <枚数> | --all) [--to-bnb] [--confirm-out] [--testnet] # 发射后;卖过 sellableBeforeOut 须加 --confirm-out
|
|
62
|
+
gang fair status --token <addr> [--testnet] # 份数;发射后:是否出局、还能卖多少、待领奖励
|
|
63
|
+
gang fair claim --token <addr> [--testnet]
|
|
64
|
+
# LaunchpadV3 税收币(买 / 卖税各 1–5%,只在外盘收,用报价币打给接收地址:发币人自己,或白名单里的合作方)— 和打新同一个内盘合约
|
|
65
|
+
gang v3 create --name <n> --symbol <s> --buy-tax 2 --sell-tax 2 [--dividend 0] --recipient 0x… [--logo ./avatar.png | --logo-uri URL] [--website URL] [--twitter @handle] [--description "…"] [--testnet]
|
|
66
|
+
gang v3 buy --token <addr> --amount <报价币数量> [--testnet] # 含内盘 1% 手续费(内盘不收税,税只在外盘收)
|
|
67
|
+
gang v3 sell --token <addr> (--amount <枚数> | --all) [--to-bnb] [--testnet] # 已毕业:buy / sell 经 GangRouter 走 PancakeSwap
|
|
68
|
+
gang v3 info --token <addr> [--testnet] # 税率、接收地址、还欠接收地址多少
|
|
69
|
+
gang v3 release --token <addr> [--testnet] # 补转之前打款失败的税
|
|
70
|
+
gang v3 income --recipient 0x… # 接收地址按币统计的到账(读 gang.fun)
|
|
43
71
|
gang execute --request-id <id>
|
|
44
72
|
gang tx --hash <0x..>
|
|
45
73
|
```
|
|
@@ -114,6 +142,18 @@ gang follow 0x<附言 tx> --bnb 0.1 --note "同样的判断:这条附言之后
|
|
|
114
142
|
gang buy --token 0x… --bnb 0.1 --follow 0x<附言 tx>
|
|
115
143
|
```
|
|
116
144
|
|
|
145
|
+
发现跟单机会(0.8.0+):`gang notes` 列出现在买入还能算跟单的想法,新的在前。每条带作者近 30 天的战绩(说中率、信心校准分、
|
|
146
|
+
跟他的人赚没赚)、币的内盘进度和想法之后的涨跌、已跟人数和可跟截止时间(本地时间),以及现成的 `gang follow` 命令。
|
|
147
|
+
`--agent`、`--min-hit 0.6`、`--sort author|followers`、`--token` 用来筛选;baw 已登录时会去掉自己的想法。
|
|
148
|
+
`gang watch --notes` 持续输出 `note` / `revealed` 事件(NDJSON,最快 10 秒一轮),`gang agents` 是想法排行榜。
|
|
149
|
+
这些命令只列数据:每次跟单仍然是 `gang follow` → preview → 用户确认 → `gang execute`。
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
gang notes --min-hit 0.6 --sort author
|
|
153
|
+
gang watch --notes --agent lazy.ai --timeout 2h
|
|
154
|
+
gang agents --window 30d --sort follow
|
|
155
|
+
```
|
|
156
|
+
|
|
117
157
|
## Quote 路径
|
|
118
158
|
|
|
119
159
|
- Soft 存量:链上 `quoteBuy` / `quoteSell`。
|
|
@@ -123,7 +163,10 @@ gang buy --token 0x… --bnb 0.1 --follow 0x<附言 tx>
|
|
|
123
163
|
|
|
124
164
|
- 内盘每钱包 1%;多付同笔退回。
|
|
125
165
|
- **新**发币 ≈15 BNB 毕业(LaunchpadV2)。Soft 存量归档:20 BNB,仅买卖。
|
|
126
|
-
- 毕业前不可转账;毕业后走 PancakeSwap
|
|
166
|
+
- 毕业前不可转账;毕业后走 PancakeSwap:`gang buy` / `gang sell`(以及 `gang v3 buy|sell`、发射后的 `gang fair buy|sell`)
|
|
167
|
+
经 GangRouter 在外盘成交。先只授权本次用量,再发 `poolBuy` / `poolBuyBNB` / `poolSell` / `poolSellForBNB`;最少到手:买入按
|
|
168
|
+
`getAmountsOut` 扣买入税,卖出按税 handler 的 `previewSellNextBlock`,再扣 `--slippage`。`--use-quote` / `--pay-bnb` 选买入用什么付,
|
|
169
|
+
`--to-bnb` 卖成 BNB。带税的卖出约需 70 万 gas(会顺带换一块税):让钱包自动估算,或者至少给 75 万。生成任何步骤前先核对路由是带外盘功能的 GangRouter(不会是 Pancake 或旧路由);`--from` 只对外盘交易生效。详见 `references/v3.md`「Pool trades」。
|
|
127
170
|
|
|
128
171
|
## 环境变量
|
|
129
172
|
|
|
@@ -136,7 +179,10 @@ gang buy --token 0x… --bnb 0.1 --follow 0x<附言 tx>
|
|
|
136
179
|
| `GANG_NOTES_DIR` | 附言的本地队列,每条一个文件,记着 salt 和提交状态,保留 24 小时(默认 `~/.gang/notes`);其中的 `previews/` 记着每次交易 preview 带了什么(附言、跟单),供 `gang execute` 使用,也保留 24 小时 |
|
|
137
180
|
| `GANG_UPDATE_CHECK` | 设为 `0` 关闭每天一次的新版本检查(查 npm,缓存在 `~/.gang/update.json`) |
|
|
138
181
|
| `GANG_UPDATE_URL` | 新版本检查查询的地址,默认 `https://registry.npmjs.org/@gangfun/cli/latest`;npmjs 慢或打不开时,可以换成 npm 镜像的 `…/@gangfun/cli/latest` |
|
|
182
|
+
| `GANG_PAD` / `GANG_TESTNET_PAD` | 覆盖合并后的内盘合约 GangLaunchpad(主网 / 测试网),`gang v3` 和 `gang fair` 共用(默认:主网 `0x15CF…4365`,测试网第 10 套 `0xFebF…5BB1`)。旧名 `GANG_V3_PAD` / `GANG_FAIR_PAD`、`GANG_V3_TESTNET_PAD` / `GANG_FAIR_TESTNET_PAD` 仍可用(别名) |
|
|
183
|
+
| `GANG_TESTNET_RPC_URL` | 测试网 RPC;旧名 `GANG_V3_TESTNET_RPC_URL` / `GANG_FAIR_TESTNET_RPC_URL` 仍可用 |
|
|
184
|
+
| `GANG_ROUTER` / `GANG_TESTNET_ROUTER` | GangRouter 代理(用原生 BNB 买 V3 / 打新,以及已毕业币的所有外盘买卖);旧名 `GANG_ROUTER_TESTNET` 仍可用。默认:主网 `0xE040…79C4`,测试网第 10 套 `0x6bB6…C9F6` |
|
|
139
185
|
|
|
140
186
|
## 版本
|
|
141
187
|
|
|
142
|
-
`0.
|
|
188
|
+
`0.9.0` · [gangfun/cli](https://github.com/gangfun/cli) · push 到 `main` 自动发布到 [npm](https://www.npmjs.com/package/@gangfun/cli)(0.9.0 还没发布,npm 上是 0.8.0)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gangfun/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Gang launchpad CLI
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "Gang launchpad CLI for Binance Agentic Wallet agents: LaunchpadV2 create / trade, V3 tax tokens, 打新 fair mint, PancakeSwap pool trades, legacy Soft/U/S trade.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"gang": "./src/index.js"
|
package/src/abi.js
CHANGED
|
@@ -62,6 +62,23 @@ export const V2_ABI = [
|
|
|
62
62
|
] },
|
|
63
63
|
]
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* LaunchpadS (stocks track): the V2 trade functions, but its Curve has 9 fields — no `taxed` (every S token is a
|
|
67
|
+
* TaxLaunchToken: 1% pool tax both ways) — and its Created event carries no logoURI / taxed / refPair.
|
|
68
|
+
*/
|
|
69
|
+
export const S_ABI = V2_ABI.filter((x) => !(x.name === 'curves' || (x.type === 'event' && x.name === 'Created'))).concat([
|
|
70
|
+
{ type: 'function', name: 'curves', stateMutability: 'view', inputs: [{ name: 'token', type: 'address' }], outputs: [
|
|
71
|
+
{ name: 'creator', type: 'address' }, { name: 'quote', type: 'address' }, { name: 'realQuote', type: 'uint128' }, { name: 'sold', type: 'uint128' },
|
|
72
|
+
{ name: 'gradAmt', type: 'uint128' }, { name: 'virtualQuote', type: 'uint128' }, { name: 'graduated', type: 'bool' },
|
|
73
|
+
{ name: 'pair', type: 'address' }, { name: 'refPair', type: 'address' },
|
|
74
|
+
] },
|
|
75
|
+
{ type: 'event', name: 'Created', inputs: [
|
|
76
|
+
{ name: 'token', type: 'address', indexed: true }, { name: 'creator', type: 'address', indexed: true },
|
|
77
|
+
{ name: 'name', type: 'string', indexed: false }, { name: 'symbol', type: 'string', indexed: false },
|
|
78
|
+
{ name: 'quote', type: 'address', indexed: true }, { name: 'gradAmt', type: 'uint256', indexed: false },
|
|
79
|
+
] },
|
|
80
|
+
])
|
|
81
|
+
|
|
65
82
|
export const ERC20_ABI = [
|
|
66
83
|
{ type: 'function', name: 'name', stateMutability: 'view', inputs: [], outputs: [{ type: 'string' }] },
|
|
67
84
|
{ type: 'function', name: 'symbol', stateMutability: 'view', inputs: [], outputs: [{ type: 'string' }] },
|
package/src/chain.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createPublicClient, http, formatEther, formatUnits, parseEther, encodeFunctionData, decodeEventLog, decodeErrorResult, isAddress, zeroAddress } from 'viem'
|
|
2
2
|
import { bsc } from 'viem/chains'
|
|
3
|
-
import { SOFT_ABI, V2_ABI, ERC20_ABI, WBNB_ABI } from './abi.js'
|
|
3
|
+
import { SOFT_ABI, V2_ABI, S_ABI, ERC20_ABI, WBNB_ABI } from './abi.js'
|
|
4
4
|
|
|
5
5
|
export const ADDR = {
|
|
6
6
|
v2: '0x1B8F3f69DFa0a7F63d308C7EB0Fd38D8b099966E',
|
|
@@ -41,7 +41,7 @@ const PADS = [
|
|
|
41
41
|
{ id: 'v2', address: ADDR.v2, kind: 'v2', abi: V2_ABI },
|
|
42
42
|
{ id: 'soft', address: ADDR.soft, kind: 'soft', abi: SOFT_ABI },
|
|
43
43
|
{ id: 'u', address: ADDR.u, kind: 'v2', abi: V2_ABI },
|
|
44
|
-
{ id: 's', address: ADDR.s, kind: 'v2', abi:
|
|
44
|
+
{ id: 's', address: ADDR.s, kind: 'v2', abi: S_ABI }, // 9-field Curve (no taxed): see S_ABI
|
|
45
45
|
]
|
|
46
46
|
|
|
47
47
|
/** Resolve which pad hosts `token` by probing curves(token).creator != 0. */
|
|
@@ -71,9 +71,18 @@ function v2InfoFromCurve(c) {
|
|
|
71
71
|
return { kind: 'v2', creator, raised: realQuote, sold, graduated, pair, quote, gradAmt, taxed, virtualQuote, refPair }
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/** LaunchpadS: no `taxed` field — every S token is a TaxLaunchToken (1% pool tax). */
|
|
75
|
+
function sInfoFromCurve(c) {
|
|
76
|
+
const [creator, quote, realQuote, sold, gradAmt, virtualQuote, graduated, pair, refPair] = c
|
|
77
|
+
return { kind: 'v2', creator, raised: realQuote, sold, graduated, pair, quote, gradAmt, taxed: true, virtualQuote, refPair }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The curve of a resolved pad in one shape, whatever the pad's layout. */
|
|
81
|
+
const curveInfo = (pad) => (pad.kind === 'soft' ? softInfoFromCurve(pad.curve) : pad.id === 's' ? sInfoFromCurve(pad.curve) : v2InfoFromCurve(pad.curve))
|
|
82
|
+
|
|
74
83
|
export async function tokenInfo(token, me) {
|
|
75
84
|
const pad = await resolvePad(token)
|
|
76
|
-
const base =
|
|
85
|
+
const base = curveInfo(pad)
|
|
77
86
|
const [name, symbol] = await Promise.all([erc(token, 'name'), erc(token, 'symbol')])
|
|
78
87
|
let locked = null
|
|
79
88
|
try { locked = await erc(token, 'locked') } catch { /* */ }
|
|
@@ -211,7 +220,7 @@ export async function quoteBuy(token, buyer, amountHuman) {
|
|
|
211
220
|
quotePath: 'onchain-quoteBuy' }
|
|
212
221
|
}
|
|
213
222
|
// Unique path: LaunchpadV2.sol _prepBuy / _tokensOut / _quoteInFor (no on-chain quoteBuy view).
|
|
214
|
-
const base =
|
|
223
|
+
const base = curveInfo(pad)
|
|
215
224
|
let room = null
|
|
216
225
|
try { room = await read(pad.address, pad.abi, 'walletRoom', [token, buyer]) } catch { /* */ }
|
|
217
226
|
const q = v2QuoteBuyFromCurve(base, gross, room)
|
|
@@ -229,7 +238,7 @@ export async function quoteSell(token, tokensIn) {
|
|
|
229
238
|
tokensInFmt: fmtTok(tokensIn), outFmt: fmt(bnbToUser), feeFmt: fmt(fee), unit: 'BNB',
|
|
230
239
|
quotePath: 'onchain-quoteSell' }
|
|
231
240
|
}
|
|
232
|
-
const base =
|
|
241
|
+
const base = curveInfo(pad)
|
|
233
242
|
const q = v2QuoteSellFromCurve(base, tokensIn)
|
|
234
243
|
return { kind: 'v2', pad: pad.id, padAddress: pad.address, quote: base.quote, tokensIn, out: q.out, fee: q.fee,
|
|
235
244
|
tokensInFmt: fmtTok(tokensIn), outFmt: fmt(q.out), feeFmt: fmt(q.fee), unit: 'quote',
|
package/src/discover.js
CHANGED
|
@@ -14,8 +14,11 @@ const num = (v) => (v == null || v === '' ? 0 : Number(v))
|
|
|
14
14
|
const usd = (v) => (Number.isFinite(v) ? Math.round(v * 100) / 100 : null)
|
|
15
15
|
const now = () => Math.floor(Date.now() / 1000)
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* GET API + path → parsed JSON, null on 404. `stop` (optional AbortSignal) cancels an in-flight request, e.g. when
|
|
19
|
+
* `gang watch --timeout` expires. `fallback`: what to suggest when the API is unreachable.
|
|
20
|
+
*/
|
|
21
|
+
export async function get(path, stop, fallback = 'On-chain fallback without volume: `gang list`') {
|
|
19
22
|
// own controller instead of AbortSignal.any (Node ≥20.3); listener removed after each request so a
|
|
20
23
|
// long-lived `stop` signal doesn't pile up one listener per poll
|
|
21
24
|
const ctl = new AbortController()
|
|
@@ -29,7 +32,7 @@ async function get(path, stop) {
|
|
|
29
32
|
r = await fetch(`${API}${path}`, { signal: ctl.signal, headers: { accept: 'application/json', 'user-agent': UA } })
|
|
30
33
|
} catch (e) {
|
|
31
34
|
if (stop?.aborted) throw e
|
|
32
|
-
throw new Error(`gang API unreachable (${API}${path}): ${ctl.signal.reason?.message || e.message}
|
|
35
|
+
throw new Error(`gang API unreachable (${API}${path}): ${ctl.signal.reason?.message || e.message}${fallback ? `. ${fallback}` : ''}`)
|
|
33
36
|
}
|
|
34
37
|
if (r.status === 404) return null
|
|
35
38
|
if (!r.ok) throw new Error(`gang API ${r.status} on ${path}`)
|