@gangfun/cli 0.16.2 → 0.16.4

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 CHANGED
@@ -227,4 +227,4 @@ gang agents --window 30d --sort follow
227
227
 
228
228
  ## Version
229
229
 
230
- `0.16.2` · repo [gangfun/cli](https://github.com/gangfun/cli) · published to [npm](https://www.npmjs.com/package/@gangfun/cli) on push to `main`
230
+ `0.16.4` · 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
@@ -200,4 +200,4 @@ gang agents --window 30d --sort follow
200
200
 
201
201
  ## 版本
202
202
 
203
- `0.16.2` · [gangfun/cli](https://github.com/gangfun/cli) · push 到 `main` 自动发布到 [npm](https://www.npmjs.com/package/@gangfun/cli)
203
+ `0.16.4` · [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.16.2",
3
+ "version": "0.16.4",
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/bond.js CHANGED
@@ -415,13 +415,20 @@ export async function runBond(sub, { opt, flag, out, fail, summarize }) {
415
415
  // not ready: the call only records / waits. If a chunk has become buyable by the time it lands, the max minimum
416
416
  // makes it revert (Slippage) instead of buying unchecked: re-run for a priced preview
417
417
  const toDead = ready && !m.live
418
- const minOut = toDead ? 0n : ready ? (tokensOut * BigInt(Math.round((100 - slippage) * 100))) / BPS : MAX_UINT
418
+ // the minimum comes from the chunk simulated with no minimum: previewBurn prices the whole quoteIn, so a quote that
419
+ // taxes transfers into the pair (fewer tokens bought) would fail every minimum taken from it
420
+ let expect = tokensOut
421
+ if (ready && !toDead) {
422
+ const dry = await simulate(ctx, me(), 'burnChunk', [token, 0n])
423
+ if (dry.result) expect = dry.result[1]
424
+ }
425
+ const minOut = toDead ? 0n : ready ? (expect * BigInt(Math.round((100 - slippage) * 100))) / BPS : MAX_UINT
419
426
  const sim = await simulate(ctx, me(), 'burnChunk', [token, minOut])
420
427
  if (sim.failed) return out({ success: false, step: 'burn', ...sim.failed })
421
428
  return out(send('burnChunk', [token, minOut], {
422
429
  step: 'burn', burnLeft: view.burnLeft, quote: view.quote,
423
430
  ...(toDead ? { quoteToDead: qf(quoteIn), note: 'slashed before the pair and still no pair 30 days after the post: the rest goes to 0xdead as quote' }
424
- : ready ? { chunkQuoteIn: qf(quoteIn), expectBurnTokens: tokens(tokensOut), minBurnTokens: tokens(minOut), slippagePct: slippage }
431
+ : ready ? { chunkQuoteIn: qf(quoteIn), expectBurnTokens: tokens(expect), minBurnTokens: tokens(minOut), slippagePct: slippage }
425
432
  : { note: 'no chunk this time: the call records the price observation (first call after a slash) or waits for the 10-minute average / a price no more than 2% above it. It is cheap; the platform keeper also calls it every 5 minutes (one chunk per 4 minutes at most). If a chunk becomes buyable before it lands, it reverts (Slippage) rather than buy without a minimum: re-run then' }),
426
433
  }))
427
434
  }
package/src/index.js CHANGED
@@ -289,7 +289,8 @@ graduated tokens only).
289
289
  pool and burned (0xdead), the rest to you (or --buyback-to <addr>; changeable later
290
290
  with gang buyback set-payee). Steps: clone your buy-back splitter
291
291
  (GangBuybackSplitterFactory; listed as a recipient in the same tx) → create with it as
292
- the recipient → bind → the rest of the launch. Without --buyback the tax goes to you
292
+ the recipient → bind → the rest of the launch. Without --buyback the tax goes to you.
293
+ Quote: WBNB (default), GANG or one listed in the pad's QuoteRegistry only
293
294
  gang create --fair … [--shares <n>] --bond <quote> [--bond-hold …] --bond-days <7-90>
294
295
  打新: create (the dev's --shares are bought in it) → bond. Progress is read from the
295
296
  chain (a token this wallet created with this symbol since the plan); a run that finds
package/src/launch.js CHANGED
@@ -40,6 +40,33 @@ const PAD_ABI = parseAbi([
40
40
  ])
41
41
  const ERC20_ABI = parseAbi(['function balanceOf(address) view returns (uint256)', 'function symbol() view returns (string)'])
42
42
  /** Flags only the chain reads; everything else goes to the step's own command. */
43
+ /** GANG on BSC mainnet: a quote gang.fun trusts besides WBNB and the pad's QuoteRegistry. */
44
+ const MAINNET_GANG_TOKEN = '0x0c6302401aa5325c2e36f170f52c00b1d220b405'
45
+ const REGISTRY_ABI = parseAbi(['function quoteRegistry() view returns (address)', 'function isQuoted(address quote) view returns (bool)'])
46
+
47
+ /**
48
+ * --buyback only over a quote gang.fun trusts (WBNB, GANG, or listed in the pad's QuoteRegistry): a splitter prices each
49
+ * buy-back chunk on what it sends, so a quote that taxes transfers into pairs fails the pair's K check on every chunk
50
+ * and the buy-back part is stuck for good (GangBond re-review L-1, 2026-10-29; splitter v3 has the same pricing).
51
+ * null when trusted; otherwise the failure to report.
52
+ */
53
+ async function untrustedBuybackQuote(read, net, quote) {
54
+ if (!isAddress(quote ?? '')) return { error: '--quote must be a 0x address', got: quote ?? null }
55
+ const q = quote.toLowerCase()
56
+ if (q === String(net.wbnb).toLowerCase() || (String(net.chainId) === '56' && q === MAINNET_GANG_TOKEN)) return null
57
+ const registry = await read(net.pad, REGISTRY_ABI, 'quoteRegistry').catch(() => null)
58
+ const listed = registry === null ? null
59
+ : registry === zeroAddress ? false
60
+ : await read(registry, REGISTRY_ABI, 'isQuoted', [quote]).catch(() => null)
61
+ if (listed) return null
62
+ return {
63
+ error: listed === null
64
+ ? 'could not read the pad\'s QuoteRegistry to check the --buyback quote: try again'
65
+ : '--buyback needs WBNB, GANG or a quote listed in the pad\'s QuoteRegistry: the buy-back splitter cannot buy back with a quote that taxes transfers into the pair, and an unlisted quote may do that',
66
+ quote, hint: 'drop --quote (WBNB), use a listed quote, or launch without --buyback',
67
+ }
68
+ }
69
+
43
70
  export const LAUNCH_FLAGS = ['dev-buy', 'bond', 'bond-hold', 'bond-days', 'buyback', 'buyback-to', 'restart']
44
71
  const NOTE_FLAGS = ['note', 'conf', 'reveal-after']
45
72
  /** `gang fair create --dev-buy`, with or without --bond (index.js stops the lone flag, runLaunch the chained one). */
@@ -152,6 +179,11 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
152
179
  // ---- buy-back splitter: cloned for the dev before the create, at predict(dev, plan.salt)
153
180
  if (buyback && !created) {
154
181
  if (!plan?.salt) {
182
+ const refused = await untrustedBuybackQuote(read, net, flag('quote') ? opt('quote') : net.wbnb)
183
+ if (refused) {
184
+ const { error, ...extra } = refused
185
+ return fail(error, extra)
186
+ }
155
187
  const salt = `0x${randomBytes(32).toString('hex')}`
156
188
  const at = await read(buyback.factory, FACTORY_ABI, 'predict', [me, salt])
157
189
  const args = [buyback.bps, salt, buyback.payee ?? zeroAddress]