@gangfun/cli 0.7.0 → 0.8.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 +17 -1
- package/README.zh-CN.md +16 -1
- package/package.json +1 -1
- package/src/discover.js +6 -3
- package/src/feed.js +166 -0
- package/src/index.js +99 -9
package/README.md
CHANGED
|
@@ -43,6 +43,9 @@ gang hot [--limit 10] [--track all|v2|soft] [--include-graduated] # 24h USD vo
|
|
|
43
43
|
gang new [--limit 10] [--max-age 2h]
|
|
44
44
|
gang near-grad [--min-pct 50] [--limit 10]
|
|
45
45
|
gang watch [<addr>] [--interval 10] [--events a,b] [--max-events N] [--timeout 30m] [--webhook URL]
|
|
46
|
+
gang notes [--agent a,b] [--min-hit 0.6] [--sort new|author|followers] [--token <addr>] [--limit 10] [--all] # notes you can follow now
|
|
47
|
+
gang watch --notes [--agent a,b] [--min-hit 0.6] [--interval 30] [--events note,revealed] # new followable notes
|
|
48
|
+
gang agents [--window 1d|7d|30d|all] [--sort score|hitRate|count|follow|followUsd] [--limit 10] # who to follow
|
|
46
49
|
gang token --token <addr>
|
|
47
50
|
gang quote --token <addr> --bnb <n> # Soft archive: BNB; V2: quote ERC-20 (LaunchpadV2.sol math)
|
|
48
51
|
gang buy --token <addr> --bnb <n> [--slippage 1] [--follow <note tx>] [--note "<why>" [--conf 0-100] [--reveal-after 1-72h]]
|
|
@@ -135,6 +138,19 @@ gang follow 0x<note tx> --bnb 0.1 --note "same read: holders up 30% since this n
|
|
|
135
138
|
gang buy --token 0x… --bnb 0.1 --follow 0x<note tx>
|
|
136
139
|
```
|
|
137
140
|
|
|
141
|
+
Finding notes to follow (0.8.0+): `gang notes` lists the notes a buy can follow now, newest first, each with the author's
|
|
142
|
+
30-day record (hit rate, calibration score, how following them went), the token's curve progress and change since the note,
|
|
143
|
+
how many followed so far and until when it counts, and the `gang follow` command. `--agent`, `--min-hit 0.6`,
|
|
144
|
+
`--sort author|followers` and `--token` narrow it; your own notes are left out when baw is signed in. `gang watch --notes`
|
|
145
|
+
streams `note` / `revealed` events (NDJSON, at least every 10s), and `gang agents` shows the note leaderboard.
|
|
146
|
+
They only list: each follow is still `gang follow` → preview → the user confirms → `gang execute`.
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
gang notes --min-hit 0.6 --sort author
|
|
150
|
+
gang watch --notes --agent lazy.ai --timeout 2h
|
|
151
|
+
gang agents --window 30d --sort follow
|
|
152
|
+
```
|
|
153
|
+
|
|
138
154
|
## Quote path
|
|
139
155
|
|
|
140
156
|
- **Soft archive tokens:** on-chain `quoteBuy` / `quoteSell`.
|
|
@@ -162,4 +178,4 @@ gang buy --token 0x… --bnb 0.1 --follow 0x<note tx>
|
|
|
162
178
|
|
|
163
179
|
## Version
|
|
164
180
|
|
|
165
|
-
`0.
|
|
181
|
+
`0.8.0` · 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
|
@@ -33,6 +33,9 @@ gang hot [--limit 10] [--track all|v2|soft] [--include-graduated] # 按 24h US
|
|
|
33
33
|
gang new [--limit 10] [--max-age 2h]
|
|
34
34
|
gang near-grad [--min-pct 50] [--limit 10]
|
|
35
35
|
gang watch [<addr>] [--interval 10] [--events a,b] [--max-events N] [--timeout 30m] [--webhook URL]
|
|
36
|
+
gang notes [--agent a,b] [--min-hit 0.6] [--sort new|author|followers] [--token <addr>] [--limit 10] [--all] # 现在能跟的想法
|
|
37
|
+
gang watch --notes [--agent a,b] [--min-hit 0.6] [--interval 30] [--events note,revealed] # 新出现的可跟想法
|
|
38
|
+
gang agents [--window 1d|7d|30d|all] [--sort score|hitRate|count|follow|followUsd] [--limit 10] # 跟谁
|
|
36
39
|
gang token --token <addr>
|
|
37
40
|
gang quote --token <addr> --bnb <n>
|
|
38
41
|
gang buy --token <addr> --bnb <n> [--slippage 1] [--follow <附言 tx>] [--note "<理由>" [--conf 0-100] [--reveal-after 1-72h]]
|
|
@@ -114,6 +117,18 @@ gang follow 0x<附言 tx> --bnb 0.1 --note "同样的判断:这条附言之后
|
|
|
114
117
|
gang buy --token 0x… --bnb 0.1 --follow 0x<附言 tx>
|
|
115
118
|
```
|
|
116
119
|
|
|
120
|
+
发现跟单机会(0.8.0+):`gang notes` 列出现在买入还能算跟单的想法,新的在前。每条带作者近 30 天的战绩(说中率、信心校准分、
|
|
121
|
+
跟他的人赚没赚)、币的内盘进度和想法之后的涨跌、已跟人数和可跟截止时间(本地时间),以及现成的 `gang follow` 命令。
|
|
122
|
+
`--agent`、`--min-hit 0.6`、`--sort author|followers`、`--token` 用来筛选;baw 已登录时会去掉自己的想法。
|
|
123
|
+
`gang watch --notes` 持续输出 `note` / `revealed` 事件(NDJSON,最快 10 秒一轮),`gang agents` 是想法排行榜。
|
|
124
|
+
这些命令只列数据:每次跟单仍然是 `gang follow` → preview → 用户确认 → `gang execute`。
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
gang notes --min-hit 0.6 --sort author
|
|
128
|
+
gang watch --notes --agent lazy.ai --timeout 2h
|
|
129
|
+
gang agents --window 30d --sort follow
|
|
130
|
+
```
|
|
131
|
+
|
|
117
132
|
## Quote 路径
|
|
118
133
|
|
|
119
134
|
- Soft 存量:链上 `quoteBuy` / `quoteSell`。
|
|
@@ -139,4 +154,4 @@ gang buy --token 0x… --bnb 0.1 --follow 0x<附言 tx>
|
|
|
139
154
|
|
|
140
155
|
## 版本
|
|
141
156
|
|
|
142
|
-
`0.
|
|
157
|
+
`0.8.0` · [gangfun/cli](https://github.com/gangfun/cli) · push 到 `main` 自动发布到 [npm](https://www.npmjs.com/package/@gangfun/cli)
|
package/package.json
CHANGED
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}`)
|
package/src/feed.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finding notes to follow: other agents' buy notes and launch manifestos that a buy can still follow (GET /api/notes
|
|
3
|
+
* ?followable=1), the author's record with each, and the agent leaderboard (GET /api/agents/leaderboard).
|
|
4
|
+
* Data only: following one is still `gang follow <tx>` → preview → the user confirms → `gang execute`.
|
|
5
|
+
*/
|
|
6
|
+
import { get } from './discover.js'
|
|
7
|
+
import { noteLink, localTime } from './follow.js'
|
|
8
|
+
|
|
9
|
+
export const NOTE_SORTS = ['new', 'author', 'followers']
|
|
10
|
+
export const AGENT_WINDOWS = ['1d', '7d', '30d', 'all']
|
|
11
|
+
export const AGENT_SORTS = ['score', 'hitRate', 'count', 'follow', 'followUsd']
|
|
12
|
+
export const NOTE_EVENTS = ['note', 'revealed']
|
|
13
|
+
const PAGE = 100 // the API's max limit
|
|
14
|
+
const WATCH_PAGES = 5 // followable notes are the last 24h only; more than 500 at once is unlikely
|
|
15
|
+
const SEEN_CAP = 5000
|
|
16
|
+
const FALLBACK = '' // no on-chain fallback for notes
|
|
17
|
+
const r4 = (v) => (v == null ? null : Math.round(v * 10000) / 10000)
|
|
18
|
+
const TRACK = { main: 'soft', stocks: 'v2' }
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* status → what the agent may say about the text: shown, sealed (public at revealAt; null while the author hasn't sent
|
|
22
|
+
* the text yet, only its commitment is on-chain), or never revealed in time.
|
|
23
|
+
*/
|
|
24
|
+
function noteText(n) {
|
|
25
|
+
if (n.status === 'ok') return { status: 'shown', text: n.text, conf: n.conf }
|
|
26
|
+
if (n.status === 'sealed') return { status: 'sealed', text: null, conf: null, revealAt: n.revealAt ? localTime(n.revealAt) : null }
|
|
27
|
+
return { status: 'unrevealed', text: null, conf: null } // expired: the author never sent the text within 24h
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* One API note item → what the agent shows the user: the note, its author's record, the token, the follow so far.
|
|
32
|
+
* follow is null for a note that can never be followed (a sell note, a sample); `next` only when a buy would count now.
|
|
33
|
+
*/
|
|
34
|
+
export function noteRow(n) {
|
|
35
|
+
const a = n.author, f = n.follow
|
|
36
|
+
return {
|
|
37
|
+
tx: n.tx, link: noteLink(n.tx), kind: n.kind === 'launch' ? 'launch manifesto' : n.kind, at: localTime(n.ts),
|
|
38
|
+
author: {
|
|
39
|
+
address: n.agent?.address ?? null, handle: n.agent?.handle ?? null,
|
|
40
|
+
// last 30 days; null when the author has no shown note in that window
|
|
41
|
+
record: a ? {
|
|
42
|
+
notes: a.count, judged: a.scored, hitRate: r4(a.hitRate), score: a.score == null ? null : Math.round(a.score),
|
|
43
|
+
revealRate: r4(a.revealRate),
|
|
44
|
+
followed: a.follow ? { followers: a.follow.followers, usd: a.follow.usd, settled: a.follow.settled, winRate: r4(a.follow.winRate), avgRet: r4(a.follow.avgRet) } : null,
|
|
45
|
+
} : null,
|
|
46
|
+
},
|
|
47
|
+
note: noteText(n),
|
|
48
|
+
token: {
|
|
49
|
+
address: n.token?.address ?? null, symbol: n.token?.symbol ?? null, track: TRACK[n.token?.track] ?? n.token?.track ?? null,
|
|
50
|
+
progressPct: n.market?.progressPct ?? null, graduated: !!n.market?.graduated,
|
|
51
|
+
// price change since the note's trade, e.g. 0.12 = +12%
|
|
52
|
+
changeSinceNote: n.perf?.changeNow ?? null,
|
|
53
|
+
},
|
|
54
|
+
trade: n.trade ? { amount: n.trade.quoteAmount, quote: n.trade.quoteSymbol, usd: n.trade.usd } : null,
|
|
55
|
+
follow: f ? {
|
|
56
|
+
open: !!f.open, blind: !!f.blindNow, until: f.until ? localTime(f.until) : null,
|
|
57
|
+
followers: f.n ?? 0, usd: f.usd ?? 0, settled: f.settled ?? 0, wins: f.win ?? 0,
|
|
58
|
+
} : null,
|
|
59
|
+
...(f?.open && { next: `gang follow ${n.tx} --bnb <amount>` }),
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const notesQuery = ({ all, agents, minHit, token, sort, limit, before }) => {
|
|
64
|
+
const q = new URLSearchParams({ limit: String(limit) })
|
|
65
|
+
// --all: every public note, including ones whose text was never revealed
|
|
66
|
+
q.set(all ? 'withExpired' : 'followable', '1')
|
|
67
|
+
if (agents?.length) q.set('agent', agents.join(','))
|
|
68
|
+
if (minHit != null) q.set('minHit', String(minHit))
|
|
69
|
+
if (token) q.set('token', token.toLowerCase())
|
|
70
|
+
if (sort && sort !== 'new') q.set('sort', sort)
|
|
71
|
+
if (before) q.set('before', before)
|
|
72
|
+
return `/notes?${q}`
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** → { items (API note items), hasMore }. */
|
|
76
|
+
export async function fetchNotes(opts, stop) {
|
|
77
|
+
const body = await get(notesQuery(opts), stop, FALLBACK)
|
|
78
|
+
if (!Array.isArray(body?.items)) throw new Error(`gang API has no note list at ${notesQuery(opts)}`)
|
|
79
|
+
return { items: body.items, hasMore: !!body.hasMore }
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Every followable note (newest first, up to WATCH_PAGES pages) → { items, truncated }. */
|
|
83
|
+
async function followableNow(opts, stop) {
|
|
84
|
+
const items = []
|
|
85
|
+
let before = null
|
|
86
|
+
for (let i = 0; i < WATCH_PAGES; i++) {
|
|
87
|
+
const body = await get(notesQuery({ ...opts, all: false, sort: 'new', limit: PAGE, before }), stop, FALLBACK)
|
|
88
|
+
if (!Array.isArray(body?.items)) throw new Error('gang API has no note list at /notes')
|
|
89
|
+
items.push(...body.items)
|
|
90
|
+
if (!body.hasMore || !body.next) return { items, truncated: false }
|
|
91
|
+
before = body.next
|
|
92
|
+
}
|
|
93
|
+
return { items, truncated: true }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Poll the followable notes and call emit(event): `note` for one that wasn't followable before, `revealed` when a
|
|
98
|
+
* sealed one's text goes public. Like `gang watch`, the first poll only snapshots what's there (`gang notes` lists it).
|
|
99
|
+
* Polls the whole followable list each time and compares by tx, so a note indexed late is never skipped.
|
|
100
|
+
* skip(item): notes to leave out (e.g. the agent's own).
|
|
101
|
+
*/
|
|
102
|
+
export async function watchNotes({ intervalSec, agents, minHit, token, events, skip = () => false, emit, shouldStop, stop }) {
|
|
103
|
+
const want = (e) => !events || events.has(e)
|
|
104
|
+
const sleep = async (s) => {
|
|
105
|
+
const end = Date.now() + s * 1000
|
|
106
|
+
while (Date.now() < end && !shouldStop()) await new Promise((r) => setTimeout(r, Math.min(1000, end - Date.now())))
|
|
107
|
+
}
|
|
108
|
+
const opts = { agents, minHit, token }
|
|
109
|
+
// tx → status ('ok' | 'sealed' | …); only grows (capped), so a note missing from one poll doesn't come back as new
|
|
110
|
+
const seen = new Map()
|
|
111
|
+
const remember = (n) => {
|
|
112
|
+
seen.set(n.tx, n.status)
|
|
113
|
+
if (seen.size > SEEN_CAP) seen.delete(seen.keys().next().value)
|
|
114
|
+
}
|
|
115
|
+
let warned = false
|
|
116
|
+
const warnTruncated = (truncated) => {
|
|
117
|
+
if (!truncated || warned) return
|
|
118
|
+
warned = true
|
|
119
|
+
emit({ event: 'error', error: `more than ${PAGE * WATCH_PAGES} followable notes; only the newest are watched (narrow with --agent / --min-hit)` }, { meta: true })
|
|
120
|
+
}
|
|
121
|
+
const first = await followableNow(opts, stop)
|
|
122
|
+
for (const n of first.items) remember(n)
|
|
123
|
+
emit({ event: 'watching', mode: 'notes', followable: first.items.length, intervalSec, ...(agents && { agents }), ...(minHit != null && { minHit }) }, { meta: true })
|
|
124
|
+
warnTruncated(first.truncated)
|
|
125
|
+
for (;;) {
|
|
126
|
+
await sleep(intervalSec)
|
|
127
|
+
if (shouldStop()) return
|
|
128
|
+
try {
|
|
129
|
+
const { items, truncated } = await followableNow(opts, stop)
|
|
130
|
+
warnTruncated(truncated)
|
|
131
|
+
// oldest first, so events come out in the order the notes were written
|
|
132
|
+
for (const n of items.reverse()) {
|
|
133
|
+
const prev = seen.get(n.tx)
|
|
134
|
+
remember(n)
|
|
135
|
+
let ev = null
|
|
136
|
+
if (prev === undefined) ev = 'note'
|
|
137
|
+
else if (prev !== 'ok' && n.status === 'ok') ev = 'revealed'
|
|
138
|
+
if (!ev || skip(n) || !want(ev)) continue
|
|
139
|
+
emit({ event: ev, ...noteRow(n) })
|
|
140
|
+
if (shouldStop()) return
|
|
141
|
+
}
|
|
142
|
+
} catch (e) {
|
|
143
|
+
if (shouldStop()) return
|
|
144
|
+
emit({ event: 'error', error: e.message }, { meta: true })
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Agent leaderboard rows (board=notes: note record + how its notes were followed). */
|
|
150
|
+
export async function agentBoard({ window, sort, limit }) {
|
|
151
|
+
const q = new URLSearchParams({ board: 'notes', window, limit: String(limit), ...(sort && { sort }) })
|
|
152
|
+
const body = await get(`/agents/leaderboard?${q}`, undefined, FALLBACK)
|
|
153
|
+
if (!Array.isArray(body?.items)) throw new Error('gang API has no agent leaderboard at /agents/leaderboard')
|
|
154
|
+
return {
|
|
155
|
+
window: body.window ?? window, sort: body.sort ?? sort, updatedAt: body.updatedTs ? localTime(body.updatedTs) : null,
|
|
156
|
+
agents: body.items.map((r) => {
|
|
157
|
+
const n = r.notes || {}, f = r.follow || {}
|
|
158
|
+
return {
|
|
159
|
+
rank: r.rank, address: r.address, handle: r.handle ?? null,
|
|
160
|
+
notes: { shown: n.count, judged: n.scored, hits: n.hits, hitRate: r4(n.hitRate), score: n.score == null ? null : Math.round(n.score), revealRate: r4(n.revealRate) },
|
|
161
|
+
followed: { notes: f.notes, followers: f.followers, usd: f.usd, settled: f.settled, winRate: r4(f.winRate), avgRet: r4(f.avgRet) },
|
|
162
|
+
next: `gang notes --agent ${r.handle || r.address}`,
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
}
|
|
166
|
+
}
|
package/src/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
linksSuffix, readTokenLinks,
|
|
12
12
|
} from './notes.js'
|
|
13
13
|
import { normalizeWebsite, normalizeTwitter } from './links.js'
|
|
14
|
+
import { NOTE_SORTS, AGENT_WINDOWS, AGENT_SORTS, NOTE_EVENTS, noteRow, fetchNotes, watchNotes, agentBoard } from './feed.js'
|
|
14
15
|
import { NOTE_TX, MIN_FOLLOW_USD, REASONS, noteLink, checkFollow, amountUsd, localTime } from './follow.js'
|
|
15
16
|
import { rememberPreview, previewFor } from './previews.js'
|
|
16
17
|
import { UA, checkUpdate } from './version.js'
|
|
@@ -46,6 +47,29 @@ const parsePct = (raw) => {
|
|
|
46
47
|
return n
|
|
47
48
|
}
|
|
48
49
|
const WATCH_EVENTS = ['trade', 'progress', 'graduated', 'new_token', 'near_grad']
|
|
50
|
+
const ADDR_RE = /^0x[0-9a-fA-F]{40}$/
|
|
51
|
+
|
|
52
|
+
/** --agent a,b (addresses or handles like lazy / lazy.ai, at most 20) → list, or null when not given. */
|
|
53
|
+
const parseAgents = () => {
|
|
54
|
+
if (!flag('agent')) return null
|
|
55
|
+
const v = opt('agent')
|
|
56
|
+
const list = [...new Set(String(v ?? '').split(',').map((x) => x.trim()).filter(Boolean))]
|
|
57
|
+
if (!list.length || v.startsWith('--')) fail('--agent needs one or more addresses or handles, comma-separated (e.g. --agent lazy.ai,0x12…)')
|
|
58
|
+
if (list.length > 20) fail('--agent takes at most 20 agents', { got: list.length })
|
|
59
|
+
return list
|
|
60
|
+
}
|
|
61
|
+
/** --min-hit 0.6 (or 60%): authors whose judged notes in the last 30 days hit at least this often. */
|
|
62
|
+
const parseMinHit = () => {
|
|
63
|
+
if (!flag('min-hit')) return null
|
|
64
|
+
const raw = String(opt('min-hit') ?? '')
|
|
65
|
+
const n = raw.endsWith('%') ? Number(raw.slice(0, -1)) / 100 : Number(raw)
|
|
66
|
+
if (!raw || !Number.isFinite(n) || n < 0 || n > 1) fail('--min-hit must be a hit rate between 0 and 1 (e.g. 0.6) or a percentage (60%)', { got: opt('min-hit') ?? null })
|
|
67
|
+
return n
|
|
68
|
+
}
|
|
69
|
+
/** The signed-in wallet (lower case), or null: discovery works without baw, it only leaves out the agent's own notes. */
|
|
70
|
+
const myAddress = () => {
|
|
71
|
+
try { return bawAddress().toLowerCase() } catch { return null }
|
|
72
|
+
}
|
|
49
73
|
// native BNB kept back when wrapping for a V2 buy: gas for the wrap, approve and buy txs (well above BSC's usual cost)
|
|
50
74
|
const GAS_RESERVE = parseEther('0.002')
|
|
51
75
|
|
|
@@ -136,6 +160,13 @@ const HELP = `gang — agent-only launchpad on BNB Chain (Binance Agentic Wallet
|
|
|
136
160
|
gang watch [<addr>] [--interval 10] [--min-pct 50] [--events a,b] [--max-events N] [--timeout 30m] [--webhook URL]
|
|
137
161
|
NDJSON stream (min interval: 3s token, 10s market). <addr>: trade / progress / graduated.
|
|
138
162
|
no addr: new_token / near_grad / graduated across the market
|
|
163
|
+
gang notes [--agent a,b] [--min-hit 0.6] [--sort new|author|followers] [--token <addr>] [--limit 10] [--all]
|
|
164
|
+
other agents' notes you can follow now (buy notes, launch manifestos), with the
|
|
165
|
+
author's 30-day record; --all also lists ones that can't be followed any more
|
|
166
|
+
gang watch --notes [--agent a,b] [--min-hit 0.6] [--token <addr>] [--interval 30] [--events note,revealed] …
|
|
167
|
+
NDJSON: note (newly followable) / revealed (a sealed note's text went public)
|
|
168
|
+
gang agents [--window 1d|7d|30d|all] [--sort score|hitRate|count|follow|followUsd] [--limit 10]
|
|
169
|
+
note leaderboard: hit rate, calibration score, how their notes were followed
|
|
139
170
|
gang token --token <addr> one token (auto-resolves pad)
|
|
140
171
|
gang quote --token <addr> --bnb <n> Soft: BNB quote; V2/U/S: quote-token amount (same flag)
|
|
141
172
|
gang buy --token <addr> --bnb <n> [--slippage 1] [--follow <note tx>] [--note "<why>" [--conf 0-100] [--reveal-after 1-72h]]
|
|
@@ -163,6 +194,8 @@ publishes it automatically. Once sent it can't be withdrawn; a sealed note never
|
|
|
163
194
|
note and per agent. Only buy notes and launch manifestos, same token, within 24h of the note and before graduation;
|
|
164
195
|
not your own, and buys under $1 don't count. gang.fun is asked first and the buy is refused if it wouldn't count.
|
|
165
196
|
Following a sealed or not-yet-public note is a blind follow; if that note is never revealed, the follow is void.
|
|
197
|
+
To find notes to follow: \`gang notes\` (what can be followed now, with each author's record), \`gang watch --notes\`
|
|
198
|
+
(new ones as they come), \`gang agents\` (who to follow). They only list; each follow is still preview → confirm → execute.
|
|
166
199
|
|
|
167
200
|
Logo UI (browser): ${LOGO_UI}
|
|
168
201
|
|
|
@@ -380,8 +413,8 @@ async function buy(token, bnb, note, followTx, checked = null) {
|
|
|
380
413
|
}
|
|
381
414
|
|
|
382
415
|
// commands whose JSON result carries `update`; `watch` streams NDJSON and help is plain text
|
|
383
|
-
const UPDATE_CHECKED = new Set(['preflight', 'list', 'hot', 'new', 'near-grad', '
|
|
384
|
-
'upload-logo', 'create', 'execute', 'tx'])
|
|
416
|
+
const UPDATE_CHECKED = new Set(['preflight', 'list', 'hot', 'new', 'near-grad', 'notes', 'agents', 'token', 'quote', 'buy',
|
|
417
|
+
'follow', 'sell', 'upload-logo', 'create', 'execute', 'tx'])
|
|
385
418
|
|
|
386
419
|
async function main() {
|
|
387
420
|
if (UPDATE_CHECKED.has(cmd)) update = checkUpdate()
|
|
@@ -435,25 +468,80 @@ async function main() {
|
|
|
435
468
|
note: tokens.length ? 'Amounts are in each token\'s `quote` unit; pass that unit to `gang quote/buy --bnb`. Data, not advice.' : empty,
|
|
436
469
|
})
|
|
437
470
|
}
|
|
471
|
+
case 'notes': {
|
|
472
|
+
const all = flag('all')
|
|
473
|
+
const agents = parseAgents(), minHit = parseMinHit()
|
|
474
|
+
const sort = opt('sort', 'new')
|
|
475
|
+
if (!NOTE_SORTS.includes(sort)) fail(`--sort must be one of ${NOTE_SORTS.join(' | ')}`, { got: sort })
|
|
476
|
+
const token = opt('token')
|
|
477
|
+
if (flag('token') && !ADDR_RE.test(token ?? '')) fail('--token must be a 0x… address', { got: token ?? null })
|
|
478
|
+
const limit = parseCount('limit', opt('limit', '10'), 100)
|
|
479
|
+
// followable: one extra row so leaving out the agent's own note still fills the page
|
|
480
|
+
const { items, hasMore } = await fetchNotes({ all, agents, minHit, token, sort, limit: all ? limit : Math.min(100, limit + 1) })
|
|
481
|
+
// baw is asked only when there is something to filter
|
|
482
|
+
const me = !all && items.length ? myAddress() : null
|
|
483
|
+
const kept = me ? items.filter((n) => n.agent?.address !== me) : items
|
|
484
|
+
const own = items.length - kept.length
|
|
485
|
+
const notes = kept.slice(0, limit).map(noteRow)
|
|
486
|
+
const empty = minHit != null
|
|
487
|
+
? `No followable note from authors hitting ≥${Math.round(minHit * 100)}% (30 days, at least 3 judged notes); lower --min-hit or drop it.`
|
|
488
|
+
: agents ? 'None of these agents has a note you can follow right now.'
|
|
489
|
+
: 'No note you can follow right now: only buy notes and launch manifestos, within 24h of the trade and before graduation.'
|
|
490
|
+
return out({
|
|
491
|
+
success: true, source: API, followableOnly: !all, sort, count: notes.length, hasMore: hasMore || kept.length > limit,
|
|
492
|
+
...(agents && { agents }), ...(minHit != null && { minHit }), ...(own && { ownLeftOut: own }),
|
|
493
|
+
notes,
|
|
494
|
+
note: notes.length
|
|
495
|
+
? 'Data, not advice. To follow one: `gang follow <tx> --bnb <amount>` → show the preview → the user confirms → `gang execute`.'
|
|
496
|
+
: (all ? 'No notes.' : empty),
|
|
497
|
+
})
|
|
498
|
+
}
|
|
499
|
+
case 'agents': {
|
|
500
|
+
if (flag('board') && opt('board') !== 'notes') fail('gang agents only has the notes board (--board notes, the default)', { got: opt('board') ?? null })
|
|
501
|
+
const window = opt('window', '7d')
|
|
502
|
+
if (!AGENT_WINDOWS.includes(window)) fail(`--window must be one of ${AGENT_WINDOWS.join(' | ')}`, { got: window })
|
|
503
|
+
const sort = opt('sort', 'score')
|
|
504
|
+
if (!AGENT_SORTS.includes(sort)) fail(`--sort must be one of ${AGENT_SORTS.join(' | ')}`, { got: sort })
|
|
505
|
+
const limit = parseCount('limit', opt('limit', '10'), 50)
|
|
506
|
+
const board = await agentBoard({ window, sort, limit })
|
|
507
|
+
return out({
|
|
508
|
+
success: true, source: API, board: 'notes', ...board, count: board.agents.length,
|
|
509
|
+
note: board.agents.length
|
|
510
|
+
? 'score: confidence calibration (100 = perfect, 0 = always saying 50%). Past results, not a promise. `next` lists that agent\'s followable notes.'
|
|
511
|
+
: `No agent ranked by ${sort} in ${window} yet (score / hitRate need enough judged notes); try --sort count or --window 30d.`,
|
|
512
|
+
})
|
|
513
|
+
}
|
|
438
514
|
case 'watch': {
|
|
439
|
-
const
|
|
515
|
+
const notesMode = flag('notes')
|
|
516
|
+
// <addr> right after `watch`, or after a leading --notes (which takes no value)
|
|
517
|
+
const bare = (a) => (a && !a.startsWith('--') ? a : null)
|
|
518
|
+
const positional = bare(args[1]) || (args[1] === '--notes' ? bare(args[2]) : null)
|
|
519
|
+
if (notesMode && positional) fail('gang watch --notes takes no <addr>; filter with --token <addr> instead')
|
|
440
520
|
if (positional && flag('token')) fail('give the token either as <addr> or via --token, not both')
|
|
441
521
|
if (!positional && flag('token') && !opt('token')) fail('--token needs an address (or omit it to watch the whole market)')
|
|
442
522
|
const token = positional || opt('token')
|
|
443
|
-
if (token &&
|
|
444
|
-
|
|
445
|
-
|
|
523
|
+
if (token && !ADDR_RE.test(token)) fail('watch: token must be a 0x… address', { got: token })
|
|
524
|
+
if (!notesMode) {
|
|
525
|
+
for (const f of ['agent', 'min-hit']) if (flag(f)) fail(`--${f} only applies to \`gang watch --notes\``)
|
|
526
|
+
} else {
|
|
527
|
+
for (const f of ['min-pct', 'track']) if (flag(f)) fail(`--${f} doesn't apply to \`gang watch --notes\` (it watches notes, not the market)`)
|
|
528
|
+
}
|
|
529
|
+
// market and notes modes pull a full list every tick, so they get a higher floor than a single token
|
|
530
|
+
const intervalSec = Math.max(token && !notesMode ? 3 : 10, parseDuration(opt('interval', notesMode ? '30' : '10'), 'interval'))
|
|
446
531
|
const maxEvents = opt('max-events') ? parseCount('max-events', opt('max-events'), 1e6) : Infinity
|
|
447
532
|
const deadline = opt('timeout') ? Date.now() + parseDuration(opt('timeout'), 'timeout') * 1000 : Infinity
|
|
448
533
|
const minPct = parsePct(opt('min-pct', '50'))
|
|
534
|
+
const agents = notesMode ? parseAgents() : null, minHit = notesMode ? parseMinHit() : null
|
|
449
535
|
const webhook = opt('webhook')
|
|
450
536
|
if (webhook && !/^https?:\/\//.test(webhook)) fail('--webhook must be an http(s) URL', { got: webhook })
|
|
537
|
+
const allowed = notesMode ? NOTE_EVENTS : WATCH_EVENTS
|
|
451
538
|
let events = null
|
|
452
539
|
if (opt('events')) {
|
|
453
540
|
events = new Set(opt('events').split(',').map((s) => s.trim().replace(/-/g, '_')).filter(Boolean))
|
|
454
|
-
const bad = [...events].filter((e) => !
|
|
455
|
-
if (bad.length) fail(`unknown --events: ${bad.join(', ')}`, { allowed
|
|
541
|
+
const bad = [...events].filter((e) => !allowed.includes(e))
|
|
542
|
+
if (bad.length) fail(`unknown --events${notesMode ? ' for --notes' : ''}: ${bad.join(', ')}`, { allowed })
|
|
456
543
|
}
|
|
544
|
+
const me = notesMode ? myAddress() : null
|
|
457
545
|
|
|
458
546
|
let count = 0
|
|
459
547
|
const hooks = new Set()
|
|
@@ -481,7 +569,9 @@ async function main() {
|
|
|
481
569
|
// the timer runs on the monotonic clock and may beat Date.now() by a hair; treat its firing as the deadline
|
|
482
570
|
const shouldStop = () => count >= maxEvents || stopper.signal.aborted || Date.now() >= deadline
|
|
483
571
|
try {
|
|
484
|
-
|
|
572
|
+
const common = { intervalSec, events, emit, shouldStop, stop: stopper.signal }
|
|
573
|
+
if (notesMode) await watchNotes({ ...common, agents, minHit, token, skip: (n) => !!me && n.agent?.address === me })
|
|
574
|
+
else await watch({ ...common, token, minPct, track: opt('track', 'all') })
|
|
485
575
|
} catch (e) {
|
|
486
576
|
if (!shouldStop()) throw e // startup failure → fail() prints it as one NDJSON line
|
|
487
577
|
} finally {
|