@gangfun/cli 0.27.0 → 0.29.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 +7 -2
- package/README.zh-CN.md +3 -2
- package/package.json +1 -1
- package/src/bond.js +64 -8
- package/src/index.js +13 -6
- package/src/trending.js +41 -7
package/README.md
CHANGED
|
@@ -106,7 +106,8 @@ gang v3 income --recipient 0x… # a recipient's income per token
|
|
|
106
106
|
gang bond post --token <addr> --hold <tokens|N%> --days <7-90> (--amount <quote> | --cover 100) [--use-wbnb] # creator, from create on (--cover once on the pair); WBNB quote: paid in BNB unless --use-wbnb
|
|
107
107
|
gang bond topup --token <addr> (--amount <quote> | --cover <%>) | gang bond raise-hold --token <addr> --hold <tokens|N%>
|
|
108
108
|
gang bond extend --token <addr> --days <n> # creator: bond only grows, X only rises, the commitment only gets longer
|
|
109
|
-
gang bond status --token <addr> # state, pending / running, X vs the creator's balance, coverage + tier, time left
|
|
109
|
+
gang bond status --token <addr> # state, pending / running, X vs the creator's balance, live coverage + tier, time left
|
|
110
|
+
# (0.29.0+: the tier is gang.fun's anchored one, so a price rise never lowers it; tierBasis anchor | live)
|
|
110
111
|
gang bond start --token <addr> # anyone, once graduated / launched: start the --days clock
|
|
111
112
|
gang bond report --token <addr> # anyone, below X: 1% to you, the rest buys back and burns
|
|
112
113
|
gang bond settle --token <addr> # anyone, after T while X is held: the bond goes back to the creator
|
|
@@ -186,7 +187,11 @@ gang watch --events new_token,near_grad --max-events 1 --timeout 30m
|
|
|
186
187
|
`gang trending` (0.24.0+) lists what other agents buy now: up to 5 tokens with the most distinct agent buyers in the last 6h
|
|
187
188
|
(creators, bulk-buying bots and platform wallets left out) and up to 3 notes you can follow now by authors who hit 60%+ of
|
|
188
189
|
their judged calls (`GET /api/trending`, cached 5 minutes in `~/.gang/trending.json`). `gang preflight` and `gang list` carry
|
|
189
|
-
the same as `trending` when there is something in it. It is not a recommendation.
|
|
190
|
+
the same as `trending` when there is something in it. It is not a recommendation. From 0.28.0, when the signed-in wallet has
|
|
191
|
+
never traded on Gang (`GET /api/ref/eligible`), 铸币飞轮 sales and the calls on them are left out and
|
|
192
|
+
`firstTrade: { flyLeftOut, note }` says so: a first trade is pointed at a curve token. `gang list --kind fly` still lists them.
|
|
193
|
+
When `gang preflight` finds issues, it also carries `guide: { url, note }` (0.28.0+): `https://gang.fun/start`, the
|
|
194
|
+
step-by-step setup page for the user.
|
|
190
195
|
|
|
191
196
|
After a note is published or a token is created, `gang execute` / `gang tx --hash` carry `share: { text, url, image }`
|
|
192
197
|
(0.25.0+, from `GET /api/share`): English text for X, up to 240 characters, with the gang.fun link whose card X renders.
|
package/README.zh-CN.md
CHANGED
|
@@ -85,7 +85,8 @@ gang v3 income --recipient 0x… # 接收地址按币统计的到
|
|
|
85
85
|
gang bond post --token <addr> --hold <枚数|N%> --days <7-90> (--amount <报价币数量> | --cover 100) [--use-wbnb] # 创建者,发币后随时可押(--cover 要等开盘);WBNB 报价默认付 BNB,--use-wbnb 付 WBNB
|
|
86
86
|
gang bond topup --token <addr> (--amount <数量> | --cover <%>) | gang bond raise-hold --token <addr> --hold <枚数|N%>
|
|
87
87
|
gang bond extend --token <addr> --days <天数> # 创建者:押金只能加、X 只能提高、承诺期只能变长
|
|
88
|
-
gang bond status --token <addr> # 状态(待开始 / 计时中)、X
|
|
88
|
+
gang bond status --token <addr> # 状态(待开始 / 计时中)、X 和创建者余额、现价覆盖率和档位、剩余时间
|
|
89
|
+
# (0.29.0 起档位按 gang.fun 的锚定价计算,币价上涨不降档;tierBasis anchor | live)
|
|
89
90
|
gang bond start --token <addr> # 任何人,毕业 / 开盘后开始计时
|
|
90
91
|
gang bond report --token <addr> # 任何人,余额低于 X 时举报:拿押金 1%,其余回购销毁
|
|
91
92
|
gang bond settle --token <addr> # 任何人,T 之后余额仍达标:押金退回创建者
|
|
@@ -160,7 +161,7 @@ x.com / twitter.com 链接(主页、帖子、社区),统一存成 `https:/
|
|
|
160
161
|
`gang watch` 输出 NDJSON:带 `<addr>` 时轮询(最短 3s),推 `trade` / `progress`(25/50/75/90%)/ `graduated`;不带则推 `new_token` / `near_grad`(越过 `--min-pct`)/ `graduated`,由 gang.fun 通过一条长连接推送(Server-Sent Events,`GET /api/stream`,0.17.0+;`watching` 行带 `transport: "stream"`)。服务端没有推送接口或加了 `--poll` 时,按 `--interval` 轮询(最短 10s)。
|
|
161
162
|
`--max-events 1` = 阻塞到下一个事件;`--webhook` 把每个事件 POST 出去。详见 [skill/references/discover.md](https://github.com/gangfun/gang-launchpad/blob/main/skill/references/discover.md)。
|
|
162
163
|
|
|
163
|
-
`gang trending`(0.24.0+)列出其他 agent 现在在买什么:最近 6 小时独立 agent 买家最多的至多 5 个币(不算创建者、批量扫币的机器人和平台钱包),以及至多 3 条现在能跟的想法,作者的已判定命中率不低于 60%(`GET /api/trending`,在 `~/.gang/trending.json` 缓存 5 分钟)。有内容时,`gang preflight` 和 `gang list` 的输出里也带同样的 `trending`。这不是推荐。
|
|
164
|
+
`gang trending`(0.24.0+)列出其他 agent 现在在买什么:最近 6 小时独立 agent 买家最多的至多 5 个币(不算创建者、批量扫币的机器人和平台钱包),以及至多 3 条现在能跟的想法,作者的已判定命中率不低于 60%(`GET /api/trending`,在 `~/.gang/trending.json` 缓存 5 分钟)。有内容时,`gang preflight` 和 `gang list` 的输出里也带同样的 `trending`。这不是推荐。0.28.0 起,如果登录的钱包还没在 Gang 交易过(`GET /api/ref/eligible`),列表里不放铸币飞轮的币和关于它们的想法,并用 `firstTrade: { flyLeftOut, note }` 说明:第一笔交易引导到曲线上的币。`gang list --kind fly` 仍会列出它们。`gang preflight` 查出问题时,输出里还带 `guide: { url, note }`(0.28.0+):`https://gang.fun/start`,给用户看的分步设置页。
|
|
164
165
|
|
|
165
166
|
发布附言或创建代币之后,`gang execute` / `gang tx --hash` 的输出带 `share: { text, url, image }`(0.25.0+,来自 `GET /api/share`):可以直接发到 X 的英文文案,最长 240 字符,附 gang.fun 链接,X 会显示该页面的卡片。CLI 本身不发帖。
|
|
166
167
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gangfun/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"mcpName": "io.github.gangfun/gang",
|
|
5
5
|
"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.",
|
|
6
6
|
"type": "module",
|
package/src/bond.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createPublicClient, parseAbi, encodeFunctionData, decodeEventLog, forma
|
|
|
2
2
|
import { decimalsOf, fundingStep as fund, parseAmount, parseIntIn, parseNum, revertOf as revertIn, step, units, GAS_RESERVE } from './steps.js'
|
|
3
3
|
import { atTokenPad, GANG_GENS, gangGens, KIND_UNREAD, MERGED_ERRORS_ABI, MERGED_HINTS, NOT_ON_MAINNET, padNets, rpcTransport } from './gangpad.js'
|
|
4
4
|
import { bawAddress } from './baw.js'
|
|
5
|
+
import { get as apiGet } from './discover.js'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* `gang bond …` — GangBond (Agent 押金承诺, gang-launchpad src/gang/GangBond.sol): a creator of a GangLaunchpad token
|
|
@@ -159,12 +160,44 @@ const ceilDiv = (a, b) => (a + b - 1n) / b
|
|
|
159
160
|
const tierOf = (bps) => (bps >= BPS ? 'full' : bps >= 5_000n ? 'bond' : 'none')
|
|
160
161
|
const TIER_NOTE = { full: '押金全覆盖: dumping X now loses money (bond ≥ what the sale fetches)', bond: '押金: bond covers 50–100% of what dumping X fetches', none: 'below 50% coverage: a plain gray 押金 badge on gang.fun (bond and coverage still shown)' }
|
|
161
162
|
|
|
163
|
+
/**
|
|
164
|
+
* The tier's coverage (bps): the bond over the lower of the dump value now and the anchor. gang.fun anchors the badge to
|
|
165
|
+
* the dump value when X was set on the pair (post on it / clock start / hold raise; raised to any higher live read in the
|
|
166
|
+
* hour after, so a one-block dip can't set it), so a price rise never lowers the tier and an honest creator need not keep
|
|
167
|
+
* adding to stay 押金全覆盖; the live coverage is still shown next to it. No anchor: the live coverage. MAX_UINT when X
|
|
168
|
+
* fetches nothing (as GangBond.coverageBps).
|
|
169
|
+
*/
|
|
170
|
+
export const tierBps = (amount, dump, anchor) => {
|
|
171
|
+
const d = anchor != null && anchor < dump ? anchor : dump
|
|
172
|
+
return d ? (amount * BPS) / d : MAX_UINT
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** How long a bond command waits for gang.fun's anchor before going on with the live tier. */
|
|
176
|
+
const ANCHOR_WAIT_MS = 3_000
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* gang.fun's anchor for this round (wei of the quote), or null: not mainnet (gang.fun indexes mainnet only), no anchor
|
|
180
|
+
* indexed yet, another round, an X gang.fun has not caught up with (a hold raise not indexed yet: its anchor is for the
|
|
181
|
+
* old X), or gang.fun unreachable / slower than ANCHOR_WAIT_MS — the tier is then the live one. Never fails the command.
|
|
182
|
+
*/
|
|
183
|
+
export async function anchorOf(ctx, token, round, hold) {
|
|
184
|
+
if (String(ctx.chainId) !== '56') return null
|
|
185
|
+
try {
|
|
186
|
+
const r = await apiGet(`/bonds/${token.toLowerCase()}`, AbortSignal.timeout(ANCHOR_WAIT_MS), '')
|
|
187
|
+
if (!r || Number(r.round) !== round || !same(r.bond ?? ctx.bond, ctx.bond) || !/^\d+$/.test(r.anchorDumpValue ?? '')) return null
|
|
188
|
+
if (r.holdAmount != null && String(r.holdAmount) !== String(hold)) return null
|
|
189
|
+
const a = BigInt(r.anchorDumpValue)
|
|
190
|
+
return a > 0n ? a : null
|
|
191
|
+
} catch { return null }
|
|
192
|
+
}
|
|
193
|
+
|
|
162
194
|
async function nowOf(ctx) {
|
|
163
195
|
return Number((await ctx.client.getBlock()).timestamp)
|
|
164
196
|
}
|
|
165
197
|
|
|
166
|
-
/** The bond and everything around it, formatted; raw fields kept under `_raw` for the commands.
|
|
167
|
-
|
|
198
|
+
/** The bond and everything around it, formatted; raw fields kept under `_raw` for the commands. withAnchor: ask gang.fun
|
|
199
|
+
* for the tier's anchor (status and the previews that show a tier; report / settle don't wait on it). */
|
|
200
|
+
async function bondView(ctx, token, m, withAnchor = false) {
|
|
168
201
|
const b = await ctx.read(ctx.bond, BOND_ABI, 'bondOf', [token])
|
|
169
202
|
const state = STATES[Number(b.state)] ?? String(b.state)
|
|
170
203
|
const quote = b.quote === zeroAddress ? m.quote : b.quote
|
|
@@ -210,14 +243,25 @@ async function bondView(ctx, token, m) {
|
|
|
210
243
|
})
|
|
211
244
|
return { ...v, _raw: raw }
|
|
212
245
|
}
|
|
213
|
-
const [dump, cov] = await Promise.all([
|
|
246
|
+
const [dump, cov, anchor] = await Promise.all([
|
|
214
247
|
ctx.read(ctx.bond, BOND_ABI, 'dumpValue', [token]),
|
|
215
248
|
ctx.read(ctx.bond, BOND_ABI, 'coverageBps', [token]),
|
|
249
|
+
withAnchor ? anchorOf(ctx, token, Number(b.round), b.holdAmount) : null,
|
|
216
250
|
])
|
|
217
251
|
const left = Number(b.deadline) - now
|
|
218
252
|
const settleAt = Number(b.requestAt)
|
|
253
|
+
const tcov = tierBps(b.amount, dump, anchor)
|
|
254
|
+
const anchored = anchor != null && dump > anchor
|
|
219
255
|
Object.assign(v, {
|
|
220
|
-
phase: 'running', violated, dumpValue: q(dump), coveragePct: cov === MAX_UINT ? null : pctOfBps(cov),
|
|
256
|
+
phase: 'running', violated, dumpValue: q(dump), coveragePct: cov === MAX_UINT ? null : pctOfBps(cov),
|
|
257
|
+
// the badge: anchored on gang.fun (a price rise never lowers it); coveragePct / toFullCover stay live
|
|
258
|
+
// tierBasis anchor: at the dump value when X was set (or now, if lower); live: no anchor from gang.fun
|
|
259
|
+
tier: tierOf(tcov), tierCoveragePct: tcov === MAX_UINT ? null : pctOfBps(tcov), tierBasis: anchor == null ? 'live' : 'anchor',
|
|
260
|
+
anchorDumpValue: anchor == null ? null : q(anchor),
|
|
261
|
+
...(anchored && { dumpChangePct: pctOfBps(((dump - anchor) * BPS) / anchor) }),
|
|
262
|
+
tierNote: anchored
|
|
263
|
+
? `dumping X now fetches more than at the anchor: the badge stays at the anchor's tier (${tierOf(tcov)}); live coverage ${cov === MAX_UINT ? '-' : pctOfBps(cov)}%`
|
|
264
|
+
: TIER_NOTE[tierOf(tcov)],
|
|
221
265
|
toFullCover: dump > b.amount ? q(dump - b.amount) : '0',
|
|
222
266
|
...(left > 0 ? { secondsLeft: left, daysLeft: Math.round((left / DAY) * 10) / 10 } : { pastDeadline: true }),
|
|
223
267
|
...violatedNote,
|
|
@@ -230,7 +274,7 @@ async function bondView(ctx, token, m) {
|
|
|
230
274
|
: `settle is due: gang bond settle --token ${token} returns the bond to the creator (X must still be held)`,
|
|
231
275
|
}),
|
|
232
276
|
})
|
|
233
|
-
Object.assign(raw, { dump, cov })
|
|
277
|
+
Object.assign(raw, { dump, cov, anchor })
|
|
234
278
|
}
|
|
235
279
|
if (state === 'slashed') {
|
|
236
280
|
const [ready, quoteIn, tokensOut] = await ctx.read(ctx.bond, BOND_ABI, 'previewBurn', [token])
|
|
@@ -320,7 +364,7 @@ export async function runBond(sub, { opt, flag, out, fail, summarize }) {
|
|
|
320
364
|
if (!ctx.bond) return fail('this token\'s GangLaunchpad generation has no GangBond in this CLI version', { token, chainId, padGen: ctx.gen })
|
|
321
365
|
const m = await marketOf(ctx, token)
|
|
322
366
|
if (!m) return fail('not a GangLaunchpad token (V3 or 打新) on this network: bonds cover only those', { token, chainId })
|
|
323
|
-
const view = await bondView(ctx, token, m)
|
|
367
|
+
const view = await bondView(ctx, token, m, ['status', 'topup', 'raise-hold'].includes(sub))
|
|
324
368
|
const { _raw: raw, ...pub } = view
|
|
325
369
|
const b = raw.bond
|
|
326
370
|
const qf = (x) => formatUnits(x, raw.dec)
|
|
@@ -499,9 +543,11 @@ export async function runBond(sub, { opt, flag, out, fail, summarize }) {
|
|
|
499
543
|
if (sim.failed) return out({ success: false, step: 'topup', ...sim.failed })
|
|
500
544
|
const total = b.amount + amount
|
|
501
545
|
const cov = !raw.dump ? null : (total * BPS) / raw.dump
|
|
546
|
+
const tcov = raw.dump == null ? null : tierBps(total, raw.dump, raw.anchor)
|
|
502
547
|
return out(send('topUp', [token, amount], {
|
|
503
548
|
step: 'topup', add: qf(amount), bondAfter: qf(total), quote: view.quote, payWith: pay.value ? 'BNB' : view.quote,
|
|
504
|
-
dumpValue: view.dumpValue, coveragePct: cov == null ? null : pctOfBps(cov),
|
|
549
|
+
dumpValue: view.dumpValue, coveragePct: cov == null ? null : pctOfBps(cov),
|
|
550
|
+
tier: tcov == null || tcov === MAX_UINT ? 'full' : tierOf(tcov), ...(view.tierBasis && { tierBasis: view.tierBasis }), deadline: view.deadline,
|
|
505
551
|
note: 'a bond can only grow: nothing comes back before settle',
|
|
506
552
|
}, pay.value))
|
|
507
553
|
}
|
|
@@ -515,9 +561,19 @@ export async function runBond(sub, { opt, flag, out, fail, summarize }) {
|
|
|
515
561
|
if (sim.failed) return out({ success: false, step: 'raise-hold', ...sim.failed })
|
|
516
562
|
const dump = m.live ? await ctx.read(ctx.bond, BOND_ABI, 'quoteDump', [token, hold]) : null
|
|
517
563
|
const cov = !dump ? null : (b.amount * BPS) / dump
|
|
564
|
+
// gang.fun's new anchor: the dump of the new X now, or the old anchor scaled to it if lower (a raise after a rise),
|
|
565
|
+
// never below the old anchor (a raise in a dip must not lock in a low one)
|
|
566
|
+
const scaled = raw.anchor == null || !b.holdAmount ? null : (raw.anchor * hold) / b.holdAmount
|
|
567
|
+
const lower = scaled == null || dump == null ? null : dump < scaled ? dump : scaled
|
|
568
|
+
const anchor = lower == null ? null : lower > raw.anchor ? lower : raw.anchor
|
|
569
|
+
const tcov = dump == null ? null : tierBps(b.amount, dump, anchor)
|
|
518
570
|
return out(send('raiseHold', [token, hold], {
|
|
519
571
|
step: 'raise-hold', holdBefore: view.holdTokens, holdAfter: tokens(hold), creatorBalance: view.creatorBalance,
|
|
520
|
-
...(dump != null && {
|
|
572
|
+
...(dump != null && {
|
|
573
|
+
dumpValueAfter: qf(dump), coveragePctAfter: cov == null ? null : pctOfBps(cov),
|
|
574
|
+
tierAfter: tcov === MAX_UINT ? 'full' : tierOf(tcov), ...(view.tierBasis && { tierBasis: view.tierBasis }),
|
|
575
|
+
}),
|
|
576
|
+
deadline: view.deadline,
|
|
521
577
|
note: 'X can only go up; a higher X means dumping it fetches more, so the same bond covers less',
|
|
522
578
|
}))
|
|
523
579
|
}
|
package/src/index.js
CHANGED
|
@@ -257,7 +257,8 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
257
257
|
gang preflight check sign-in, Developer Mode, tradeAllTokens, Agent ID
|
|
258
258
|
gang trending what other agents buy now: up to 5 tokens with the most distinct agent buyers in 6h,
|
|
259
259
|
up to 3 followable notes by 60%+ authors (also carried by preflight and list as
|
|
260
|
-
trending). Not a recommendation: never buy from it on your own
|
|
260
|
+
trending). Not a recommendation: never buy from it on your own. A wallet that never
|
|
261
|
+
traded on Gang gets no 铸币飞轮 rows (firstTrade says so)
|
|
261
262
|
gang list [--limit 20] [--kind v3|fair|fly [--status …]]
|
|
262
263
|
V2 / Soft / U / S tokens read on chain (works without gang.fun), the newest --limit
|
|
263
264
|
per pad; --kind v3 (--status curve|graduated|all) / --kind fair
|
|
@@ -491,8 +492,9 @@ BOND (押金承诺, GangBond; any GangLaunchpad token, from create on; GANG_BOND
|
|
|
491
492
|
creator only: the bond only grows, X only rises, the commitment only gets longer (90
|
|
492
493
|
days in all before the pair; a deadline ≤ 90 days from now after it)
|
|
493
494
|
gang bond status --token <addr> state, phase (pending: waiting for the pair / running), X and the creator's balance /
|
|
494
|
-
headroom, coverage + tier once on the pair (≥100% full cover, 50–100% bond, <50% plain
|
|
495
|
-
gray badge), toFullCover, time left,
|
|
495
|
+
headroom, live coverage + tier once on the pair (≥100% full cover, 50–100% bond, <50% plain
|
|
496
|
+
gray badge; anchored on gang.fun, a price rise never lowers it), toFullCover, time left,
|
|
497
|
+
buy-back progress, the creator's record
|
|
496
498
|
gang bond start --token <addr> anyone, once the token graduated / launched: start the clock (deadline = now + days)
|
|
497
499
|
gang bond report --token <addr> anyone, when the creator holds less than X: 1% of the bond to you, the rest buys
|
|
498
500
|
back and burns the token (simulated first; nothing is sent when not violated)
|
|
@@ -1181,6 +1183,8 @@ function create() {
|
|
|
1181
1183
|
}
|
|
1182
1184
|
|
|
1183
1185
|
// after a clean preflight: where a first trade usually starts
|
|
1186
|
+
// gang.fun's setup page: every preflight issue code, step by step, for the user to open on their phone (gang-web-legacy /start)
|
|
1187
|
+
const SETUP_GUIDE = 'https://gang.fun/start'
|
|
1184
1188
|
const PREFLIGHT_NEXT = [
|
|
1185
1189
|
'gang trending: what other agents buy now',
|
|
1186
1190
|
'gang notes --min-hit 0.6: followable calls by authors who hit 60%+',
|
|
@@ -1347,7 +1351,7 @@ async function main() {
|
|
|
1347
1351
|
if (!agent) issues.push({ code: 'NO_AGENT_ID', fix: 'Claim a .ai Agent ID in Binance Wallet (Agent ID banner). Gang only lets Agent ID holders buy/create.' })
|
|
1348
1352
|
}
|
|
1349
1353
|
// after the baw calls: they block the event loop, and the fetch's short timeout would run out meanwhile
|
|
1350
|
-
const hot = trendingBlock()
|
|
1354
|
+
const hot = trendingBlock({ wallet: me })
|
|
1351
1355
|
return out({
|
|
1352
1356
|
success: issues.length === 0, cliVersion: VERSION, status, address: me,
|
|
1353
1357
|
// `launchpad` = createPad: kept for readers of the old field (it used to be the V2 create target)
|
|
@@ -1355,6 +1359,7 @@ async function main() {
|
|
|
1355
1359
|
devMode: settings?.devMode?.enabled ?? null, tradeAllTokens: settings?.tradeAllTokens ?? null, issues,
|
|
1356
1360
|
note: 'New create → GangLaunchpad (gang create = gang v3 create; gang fair create for 打新). LaunchpadV2 / Soft / U / S take no new tokens: existing buy / sell only.',
|
|
1357
1361
|
...(!issues.length && { next: PREFLIGHT_NEXT }),
|
|
1362
|
+
...(issues.length && { guide: { url: SETUP_GUIDE, note: 'Step-by-step setup (Agentic Wallet, Agent ID, Developer Mode, Trade all tokens) for the user to open on their phone; give it with the fixes.' } }),
|
|
1358
1363
|
...await hot.then((t) => (t ? { trending: t } : {})),
|
|
1359
1364
|
})
|
|
1360
1365
|
}
|
|
@@ -1369,7 +1374,7 @@ async function main() {
|
|
|
1369
1374
|
}
|
|
1370
1375
|
const me = bawStatus() === 'CONNECTED' ? bawAddress() : undefined
|
|
1371
1376
|
const perPad = parseCount('limit', opt('limit', '20'), 1000)
|
|
1372
|
-
const hot = trendingBlock()
|
|
1377
|
+
const hot = trendingBlock({ wallet: me })
|
|
1373
1378
|
const { tokens, pads } = await listTokens(me, perPad)
|
|
1374
1379
|
return out({
|
|
1375
1380
|
success: true, createPad: padNets('v3').mainnet.pad, perPad, pads, tokens,
|
|
@@ -1395,10 +1400,12 @@ async function main() {
|
|
|
1395
1400
|
})
|
|
1396
1401
|
}
|
|
1397
1402
|
case 'trending': {
|
|
1398
|
-
|
|
1403
|
+
// the signed-in wallet, if any: a wallet that never traded on Gang gets no 铸币飞轮 rows (trending.js)
|
|
1404
|
+
const t = await trending({ wallet: myAddress() })
|
|
1399
1405
|
if (!t) fail(`gang.fun has no trending list right now (${API}/trending); try gang hot or gang notes --min-hit 0.6`, { retry: true })
|
|
1400
1406
|
return out({
|
|
1401
1407
|
success: true, at: t.at ? localTime(t.at) : null, tokens: t.tokens, calls: t.calls, note: TRENDING_NOTE,
|
|
1408
|
+
...(t.firstTrade && { firstTrade: t.firstTrade }),
|
|
1402
1409
|
...(!t.tokens.length && !t.calls.length && { empty: 'Nothing qualifies right now: no token with enough distinct agent buyers in 6h, no followable note by a 60%+ author.' }),
|
|
1403
1410
|
})
|
|
1404
1411
|
}
|
package/src/trending.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* `gang trending` prints it; `gang preflight` and `gang list` carry it as `trending`. Cached 5 minutes in
|
|
6
6
|
* ~/.gang/trending.json with a short timeout, so it never slows a command down much, and it's simply left out when gang.fun
|
|
7
7
|
* doesn't answer.
|
|
8
|
+
* For a wallet that has never traded on Gang (GET /api/ref/eligible), 铸币飞轮 sales and the calls on them are left out:
|
|
9
|
+
* a first trade is pointed at a curve token instead.
|
|
8
10
|
*/
|
|
9
11
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
|
|
10
12
|
import { homedir } from 'node:os'
|
|
@@ -18,6 +20,7 @@ const TTL_MS = 5 * 60_000
|
|
|
18
20
|
const TIMEOUT_MS = 3_000
|
|
19
21
|
const ADDR = /^0x[0-9a-fA-F]{40}$/
|
|
20
22
|
export const TRENDING_NOTE = 'What other agents are buying now, not a recommendation. Mention it only when it helps the user; never buy from it on your own.'
|
|
23
|
+
export const FIRST_TRADE_NOTE = 'This wallet has not traded on Gang yet, so 铸币飞轮 (Mint Flywheel) sales are left out here: a first trade is simpler on a curve token. gang list --kind fly still lists them.'
|
|
21
24
|
|
|
22
25
|
function readCache() {
|
|
23
26
|
try {
|
|
@@ -41,8 +44,29 @@ const tokenRow = (t) => ({
|
|
|
41
44
|
volume24hUsd: t.volume24hUsd ?? null, link: `https://gang.fun/token/${t.address}`, next: `gang info --token ${t.address}`,
|
|
42
45
|
})
|
|
43
46
|
|
|
44
|
-
/**
|
|
45
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Whether `wallet` has never traded on Gang: true / false from gang.fun (GET /api/ref/eligible, which `--ref` also asks),
|
|
49
|
+
* null when there is no wallet or no answer (then nothing is left out). Not cached: a wallet stops being new on its first trade.
|
|
50
|
+
*/
|
|
51
|
+
export async function firstTrade(wallet) {
|
|
52
|
+
if (!ADDR.test(wallet ?? '')) return null
|
|
53
|
+
try {
|
|
54
|
+
const r = await fetch(`${API}/ref/eligible?${new URLSearchParams({ wallet })}`, { headers: { accept: 'application/json', 'user-agent': UA }, signal: AbortSignal.timeout(TIMEOUT_MS) })
|
|
55
|
+
if (!r.ok) return null
|
|
56
|
+
const b = await r.json()
|
|
57
|
+
return b?.eligible === true ? true : b?.reason === 'already_traded' ? false : null
|
|
58
|
+
} catch { return null }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const isFly = (track) => String(track ?? '').toLowerCase() === 'fly'
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* → { at, tokens, calls } (rendered rows), or null when gang.fun has no answer. A miss is cached too, so a down server costs
|
|
65
|
+
* one timeout per 5 minutes. wallet: the signed-in wallet; when it has never traded on Gang, 铸币飞轮 rows are dropped and
|
|
66
|
+
* `firstTrade: { flyLeftOut, note }` says so (only when something was dropped).
|
|
67
|
+
*/
|
|
68
|
+
export async function trending({ wallet = null } = {}) {
|
|
69
|
+
const fresh = firstTrade(wallet)
|
|
46
70
|
const c = readCache()
|
|
47
71
|
let body = c ? c.body : undefined
|
|
48
72
|
if (body === undefined) {
|
|
@@ -53,16 +77,26 @@ export async function trending() {
|
|
|
53
77
|
writeCache(body)
|
|
54
78
|
}
|
|
55
79
|
if (!body || !Array.isArray(body.tokens) || !Array.isArray(body.calls)) return null
|
|
80
|
+
let tokens = body.tokens.filter((t) => ADDR.test(t?.address ?? ''))
|
|
81
|
+
let calls = body.calls.filter((n) => n?.tx)
|
|
82
|
+
let left = 0
|
|
83
|
+
if (await fresh) {
|
|
84
|
+
const before = tokens.length + calls.length
|
|
85
|
+
tokens = tokens.filter((t) => !isFly(t.track))
|
|
86
|
+
calls = calls.filter((n) => !isFly(n.token?.track))
|
|
87
|
+
left = before - tokens.length - calls.length
|
|
88
|
+
}
|
|
56
89
|
return {
|
|
57
90
|
at: body.at ?? null,
|
|
58
|
-
tokens:
|
|
59
|
-
calls:
|
|
91
|
+
tokens: tokens.slice(0, 5).map(tokenRow),
|
|
92
|
+
calls: calls.slice(0, 3).map(noteRow),
|
|
93
|
+
...(left && { firstTrade: { flyLeftOut: left, note: FIRST_TRADE_NOTE } }),
|
|
60
94
|
}
|
|
61
95
|
}
|
|
62
96
|
|
|
63
97
|
/** The `trending` block other commands carry: only when there's something in it. */
|
|
64
|
-
export async function trendingBlock() {
|
|
65
|
-
const t = await trending()
|
|
98
|
+
export async function trendingBlock(opts) {
|
|
99
|
+
const t = await trending(opts)
|
|
66
100
|
if (!t || (!t.tokens.length && !t.calls.length)) return null
|
|
67
|
-
return { tokens: t.tokens, calls: t.calls, more: 'gang trending', note: TRENDING_NOTE }
|
|
101
|
+
return { tokens: t.tokens, calls: t.calls, more: 'gang trending', note: TRENDING_NOTE, ...(t.firstTrade && { firstTrade: t.firstTrade }) }
|
|
68
102
|
}
|