@gangfun/cli 0.17.6 → 0.17.7
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 +2 -2
- package/README.zh-CN.md +2 -2
- package/package.json +1 -1
- package/src/chain.js +18 -9
- package/src/index.js +9 -3
- package/src/limit.js +13 -0
- package/src/portfolio.js +2 -13
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ gang watch --notes [--agent a,b] [--min-hit 0.6] [--interval 30] [--events note,
|
|
|
52
52
|
gang agents [--window 1d|7d|30d|all] [--sort score|hitRate|count|follow|followUsd] [--limit 10] # who to follow
|
|
53
53
|
# One command per action, whatever pad the token is on (0.12.0+): the CLI reads GangLaunchpad's kindOf (V3 curve / 打新
|
|
54
54
|
# sale; otherwise the V2 / Soft / U / S pads) and runs that kind's trade. --testnet = BSC testnet set 10 (GangLaunchpad only)
|
|
55
|
-
gang list [--kind v3|fair [--status …]]
|
|
55
|
+
gang list [--limit 20] [--kind v3|fair [--status …]] # V2 / Soft / U / S on chain, newest 20 per pad; --kind: from gang.fun
|
|
56
56
|
gang info --token <addr> # one token, any pad (gang token is the older name)
|
|
57
57
|
gang status --token <addr> # my position: balance; V3 dividend / 打新 reward, sellable; poolSellAll
|
|
58
58
|
gang portfolio [--from <addr>] # every holding: balance, value, cost / unrealized, claimable, USD; bonds
|
|
@@ -267,4 +267,4 @@ timed-out `gang_execute`, check `gang_status` / the wallet history instead of ex
|
|
|
267
267
|
|
|
268
268
|
## Version
|
|
269
269
|
|
|
270
|
-
`0.17.
|
|
270
|
+
`0.17.7` · repo [gangfun/cli](https://github.com/gangfun/cli) · published to [npm](https://www.npmjs.com/package/@gangfun/cli) on push to `main`
|
package/README.zh-CN.md
CHANGED
|
@@ -42,7 +42,7 @@ gang watch --notes [--agent a,b] [--min-hit 0.6] [--interval 30] [--events note,
|
|
|
42
42
|
gang agents [--window 1d|7d|30d|all] [--sort score|hitRate|count|follow|followUsd] [--limit 10] # 跟谁
|
|
43
43
|
# 一个动作一条命令,不管币在哪个内盘(0.12.0+):CLI 读 GangLaunchpad 的 kindOf(V3 内盘 / 打新;都不是就走
|
|
44
44
|
# V2 / Soft / U / S),再执行对应的交易。--testnet 走 BSC 测试网第 10 套(只有 GangLaunchpad)
|
|
45
|
-
gang list [--kind v3|fair [--status …]]
|
|
45
|
+
gang list [--limit 20] [--kind v3|fair [--status …]] # 链上读 V2 / Soft / U / S,每个盘最新 20 个;--kind:从 gang.fun 列
|
|
46
46
|
gang info --token <addr> # 任意内盘的一个币(gang token 是旧名)
|
|
47
47
|
gang status --token <addr> # 我的持仓:余额;V3 分红 / 打新奖励、还能卖多少;poolSellAll
|
|
48
48
|
gang portfolio [--from <addr>] # 全部持仓:余额、价值、成本 / 浮盈、可领、美元;押金
|
|
@@ -231,4 +231,4 @@ Claude Code:`claude mcp add gang -- gang mcp`。同一台机器上 `baw` 要
|
|
|
231
231
|
|
|
232
232
|
## 版本
|
|
233
233
|
|
|
234
|
-
`0.17.
|
|
234
|
+
`0.17.7` · [gangfun/cli](https://github.com/gangfun/cli) · push 到 `main` 自动发布到 [npm](https://www.npmjs.com/package/@gangfun/cli)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gangfun/cli",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.7",
|
|
4
4
|
"description": "Gang launchpad CLI for Binance Agentic Wallet agents: create on GangLaunchpad (untaxed or tax tokens), 打新 fair mint, PancakeSwap pool trades, LaunchpadV2 and legacy Soft/U/S trade.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/chain.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createPublicClient, formatEther, parseEther, encodeFunctionData, decode
|
|
|
2
2
|
import { bsc } from 'viem/chains'
|
|
3
3
|
import { SOFT_ABI, V2_ABI, S_ABI, ERC20_ABI, WBNB_ABI } from './abi.js'
|
|
4
4
|
import { kindOf, padNets, rpcTransport } from './gangpad.js'
|
|
5
|
+
import { mapLimit } from './limit.js'
|
|
5
6
|
|
|
6
7
|
export const ADDR = {
|
|
7
8
|
v2: '0x1B8F3f69DFa0a7F63d308C7EB0Fd38D8b099966E',
|
|
@@ -124,18 +125,26 @@ export async function tokenInfo(token, me) {
|
|
|
124
125
|
return info
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
/**
|
|
129
|
+
* `gang list` without --kind: the newest `perPad` tokens of each V2 / Soft / U / S pad, read on chain (the fallback when
|
|
130
|
+
* gang.fun's API is down). Reading every token of every pad took minutes (LaunchpadV2 alone has hundreds), so the
|
|
131
|
+
* newest first, a few reads at a time. → { tokens, pads: [{ pad, total, listed }] }
|
|
132
|
+
*/
|
|
133
|
+
export async function listTokens(me, perPad = 20) {
|
|
134
|
+
const tokens = []
|
|
135
|
+
const pads = []
|
|
129
136
|
for (const pad of PADS) {
|
|
130
137
|
try {
|
|
131
|
-
const n = await read(pad.address, pad.abi, 'tokenCount')
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
const n = Number(await read(pad.address, pad.abi, 'tokenCount'))
|
|
139
|
+
const idx = Array.from({ length: Math.min(n, perPad) }, (_, i) => BigInt(n - 1 - i))
|
|
140
|
+
const addrs = await mapLimit(idx, 8, (i) => read(pad.address, pad.abi, 'allTokens', [i]))
|
|
141
|
+
const infos = await mapLimit(addrs, 8, (a) => tokenInfo(a, me).catch(() => null))
|
|
142
|
+
const listed = infos.filter(Boolean)
|
|
143
|
+
tokens.push(...listed)
|
|
144
|
+
pads.push({ pad: pad.id, total: n, listed: listed.length })
|
|
145
|
+
} catch { pads.push({ pad: pad.id, total: null, listed: 0, error: 'pad unreadable' }) }
|
|
137
146
|
}
|
|
138
|
-
return
|
|
147
|
+
return { tokens, pads }
|
|
139
148
|
}
|
|
140
149
|
|
|
141
150
|
/** LaunchpadV2 curve constants (LaunchpadV2.sol) — unique off-chain path = on-chain math. */
|
package/src/index.js
CHANGED
|
@@ -212,8 +212,9 @@ graduated tokens only).
|
|
|
212
212
|
gang_help (this text + the rules), reads, watch, buy / sell / follow previews,
|
|
213
213
|
execute, and gang_cli for every other command
|
|
214
214
|
gang preflight check sign-in, Developer Mode, tradeAllTokens, Agent ID
|
|
215
|
-
gang list [--kind v3|fair [--status …]]
|
|
216
|
-
V2 / Soft / U / S tokens
|
|
215
|
+
gang list [--limit 20] [--kind v3|fair [--status …]]
|
|
216
|
+
V2 / Soft / U / S tokens read on chain (works without gang.fun), the newest --limit
|
|
217
|
+
per pad; --kind v3 (--status curve|graduated|all) / --kind fair
|
|
217
218
|
(--status minting|launched|all): GangLaunchpad tokens from gang.fun
|
|
218
219
|
gang hot [--limit 10] [--track all|v3|fair|v2|soft] [--include-graduated]
|
|
219
220
|
tokens not yet graduated / launched, ranked by 24h USD volume
|
|
@@ -1037,7 +1038,12 @@ async function main() {
|
|
|
1037
1038
|
fail('--kind must be v3 or fair (leave it out for the V2 / Soft / U / S tokens)', { got: kind ?? null })
|
|
1038
1039
|
}
|
|
1039
1040
|
const me = bawStatus() === 'CONNECTED' ? bawAddress() : undefined
|
|
1040
|
-
|
|
1041
|
+
const perPad = parseCount('limit', opt('limit', '20'), 1000)
|
|
1042
|
+
const { tokens, pads } = await listTokens(me, perPad)
|
|
1043
|
+
return out({
|
|
1044
|
+
success: true, createPad: padNets('v3').mainnet.pad, perPad, pads, tokens,
|
|
1045
|
+
...(pads.some((p) => p.total > p.listed) && { note: `newest ${perPad} per pad; --limit <n> (up to 1000) lists more` }),
|
|
1046
|
+
})
|
|
1041
1047
|
}
|
|
1042
1048
|
case 'hot':
|
|
1043
1049
|
case 'new':
|
package/src/limit.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** fn over items, at most `limit` at a time, results in order. */
|
|
2
|
+
export async function mapLimit(items, limit, fn) {
|
|
3
|
+
const out = new Array(items.length)
|
|
4
|
+
let next = 0
|
|
5
|
+
const worker = async () => {
|
|
6
|
+
while (next < items.length) {
|
|
7
|
+
const i = next++
|
|
8
|
+
out[i] = await fn(items[i], i)
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker))
|
|
12
|
+
return out
|
|
13
|
+
}
|
package/src/portfolio.js
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* or only bought on PancakeSwap, is not in that index and so not listed. Mainnet only: gang.fun indexes no testnet.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { mapLimit } from './limit.js'
|
|
12
|
+
|
|
11
13
|
const MAX_LAUNCHES = 100 // bonds are looked up on the newest launches up to this many
|
|
12
14
|
|
|
13
15
|
const num = (v) => (v == null || v === '' ? null : Number(v))
|
|
@@ -16,19 +18,6 @@ const round = (x) => (x == null || !Number.isFinite(x) ? null : Number(x.toPreci
|
|
|
16
18
|
const usd = (x) => (x == null || !Number.isFinite(x) ? null : Math.round(x * 100) / 100)
|
|
17
19
|
const sameAmount = (a, b) => a != null && b != null && Math.abs(a - b) <= Math.max(Math.abs(a), Math.abs(b)) * 1e-9
|
|
18
20
|
|
|
19
|
-
/** fn over items, at most `limit` at a time, results in order. */
|
|
20
|
-
async function mapLimit(items, limit, fn) {
|
|
21
|
-
const out = new Array(items.length)
|
|
22
|
-
let next = 0
|
|
23
|
-
const worker = async () => {
|
|
24
|
-
while (next < items.length) {
|
|
25
|
-
const i = next++
|
|
26
|
-
out[i] = await fn(items[i], i)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker))
|
|
30
|
-
return out
|
|
31
|
-
}
|
|
32
21
|
|
|
33
22
|
const KIND = { v3: 'v3', fair: 'fair', main: 'legacy', stocks: 'legacy' }
|
|
34
23
|
|