@gangfun/cli 0.43.1 → 0.44.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/src/flags.js CHANGED
@@ -27,7 +27,7 @@ export const CREATE_ACCEPTS = new Set([
27
27
  // every flag a buy's code reads, whatever the token's kind: a buy refuses the rest, since a misspelled --promoter would fall
28
28
  // through to a plain first buy, which uses up the wallet's only chance to bind
29
29
  export const BUY_ACCEPTS = new Set([
30
- 'agent', 'all', 'amount', 'bnb', 'board', 'break-bond', 'break-call-bond', 'buy-tax', 'calldata', 'cap', 'conf', 'confirm-out',
30
+ 'agent', 'all', 'amount', 'bnb', 'board', 'break-bond', 'break-call-bond', 'buy-tax', 'calldata', 'cap', 'cd-uncounted', 'conf', 'confirm-out',
31
31
  'description', 'dev-buy', 'dev-cut', 'dev-shares', 'dividend', 'events', 'exit-fee', 'fair', 'file', 'file-logo',
32
32
  'fly', 'follow', 'from', 'grad', 'guard', 'hash', 'hold', 'hours', 'include-graduated', 'interval', 'json',
33
33
  'keep-logo-uri', 'kind', 'limit', 'logo', 'logo-file', 'logo-uri', 'max-age', 'max-events', 'min-hit', 'min-pct',
package/src/floor.js CHANGED
@@ -421,7 +421,8 @@ function revertedCall(e) {
421
421
  }
422
422
 
423
423
  /**
424
- * Is `recipient` — an address someone typed as the tax recipient of a token created on `pad` — a floor module?
424
+ * Is `recipient` — an address someone typed as the tax recipient of a token created on `pad` — a floor module (or, with
425
+ * `type` 'countdown-v1' and the countdown factory, a countdown reward module: the same one-token-address rule)?
425
426
  * → { floor: true, by } | { floor: false } | { unlisted: true } | { unread: <detail> }.
426
427
  * A token that names a floor module by hand lands at another address than the one the module was cloned for, and its
427
428
  * tax is stuck there for good. So "no" is said only on the chain's own evidence, and whatever a node leaves unanswered
@@ -443,7 +444,7 @@ function revertedCall(e) {
443
444
  * not a module. A contract is asked moduleType(): `floor-v1` → a floor module; any other word (or more than a
444
445
  * word), an empty return, or a revert (revertedCall) → not one; a piece of a word, or no answer → `unread`.
445
446
  */
446
- export async function typedFloorModule({ client, pad }, recipient, factory) {
447
+ export async function typedFloorModule({ client, pad }, recipient, factory, type = FLOOR_TYPE) {
447
448
  try {
448
449
  const blockNumber = await client.getBlockNumber()
449
450
  const block = numberToHex(blockNumber)
@@ -488,7 +489,7 @@ export async function typedFloorModule({ client, pad }, recipient, factory) {
488
489
  return { floor: false }
489
490
  }
490
491
  const kind = r.length === 66 ? hexToString(r, { size: 32 }).replace(/\0+$/, '') : null
491
- if (kind === FLOOR_TYPE) return { floor: true, by: 'moduleType()' }
492
+ if (kind === type) return { floor: true, by: 'moduleType()' }
492
493
  if (byFactory) {
493
494
  if (kind === null || !KIND_RE.test(kind)) throw new Error('a listed module did not name its kind')
494
495
  return { floor: false }
package/src/gangpad.js CHANGED
@@ -61,6 +61,11 @@ export const GANG_GENS = {
61
61
  // floor-v1, 2026-11-12, block 133121257; the Safe allowed it on GangHandlerAdmin at block 133123169
62
62
  // (docs/MAINNET-FLOOR-MODULE-2026-11-12.md)
63
63
  floorFactory: '0x057d2C1557a0E8298a1E00834D6064497f5DC2fC',
64
+ // countdown-v1 (倒计时奖励), 2026-11-17, block 134102359; the Safe allowed it on GangHandlerAdmin (isFactory)
65
+ countdownFactory: '0xa1e3117a59104de7D97667cF22f9AB886a5f2957',
66
+ // the 3.0 tax handler's GangHandlerAdmin: a countdown factory counts only when its admin() is this one (no env
67
+ // override, so an env naming a forged factory can't pass the provenance check)
68
+ handlerAdmin: '0xC833CEC2B283759003945C0Bf8C048aB1949Af76',
64
69
  // the pool side of the promoter share, 2026-11-07, block 132218466; the Safe allowed it on GangHandlerAdmin at block
65
70
  // 132219892 (docs/MAINNET-GANG-LAUNCHPAD-3-PROMOTE-2026-11-07.md)
66
71
  promotePoolFactory: '0xA633e499ADcD69A4F91dc83587096b2c1903167A',
@@ -115,6 +120,11 @@ export const GANG_GENS = {
115
120
  // floor-v1, 2026-11-11 (deployed at block 142099242, allowed on the GangHandlerAdmin at block 142099247;
116
121
  // docs/TESTNET-FLOOR-MODULE-2026-11-11.md)
117
122
  floorFactory: '0x0804C018201D8fFe378b873b41B67f136dbdc3F8',
123
+ // countdown-v1 (倒计时奖励), 2026-11-17, with maxRound (deployed at block 143183058, allowed on the GangHandlerAdmin at
124
+ // block 143183063; docs/TESTNET-COUNTDOWN-REWARD-2026-11-17.md). The earlier factory 0x2Be9…aCdE (no maxRound) is
125
+ // superseded
126
+ countdownFactory: '0x0f83ABC7d39C0d043d3f5612E304D9395B5fe582',
127
+ handlerAdmin: '0x0fb8280B88a4DF00e8654cfE9cBd544D104a9D23',
118
128
  // the pool side of the promoter share, 2026-11-05 (docs/TESTNET-GANG-LAUNCHPAD-3-2026-11-03.md)
119
129
  promotePoolFactory: '0x7a68A65d27591a21C44f91015F930422BA79F1c2',
120
130
  // GangCallBond, 2026-11-09, block 141708762 (docs/TESTNET-CALL-BOND-2026-11-09.md)
@@ -157,20 +167,21 @@ export const GANG_GENS = {
157
167
  ],
158
168
  }
159
169
  // what a generation brings to a ctx (gen: '1.0' | '2.0' | PAD3_GEN | VAULT_GEN, null for a pad named by the env that this CLI does not know)
160
- const GEN_FIELDS = ['gen', 'pad', 'router', 'bond', 'splitterFactory', 'splitFactory', 'lpFactory', 'comboFactory', 'cappedFactory', 'floorFactory', 'promotePoolFactory', 'callBond']
170
+ const GEN_FIELDS = ['gen', 'pad', 'router', 'bond', 'splitterFactory', 'splitFactory', 'lpFactory', 'comboFactory', 'cappedFactory', 'floorFactory', 'promotePoolFactory', 'callBond', 'countdownFactory', 'handlerAdmin']
161
171
  // the env names of each field, per network (new name first; the old per-command names still work as aliases)
162
172
  const GEN_ENV = {
163
173
  mainnet: {
164
174
  pad: ['GANG_PAD', 'GANG_V3_PAD', 'GANG_FAIR_PAD'], router: ['GANG_ROUTER'], bond: ['GANG_BOND'],
165
175
  splitterFactory: ['GANG_SPLITTER_FACTORY'], splitFactory: ['GANG_SPLIT_FACTORY'], lpFactory: ['GANG_LP_FACTORY'],
166
176
  comboFactory: ['GANG_COMBO_FACTORY'], cappedFactory: ['GANG_CAPPED_FACTORY'], floorFactory: ['GANG_FLOOR_FACTORY'], promotePoolFactory: ['GANG_PROMOTE_POOL_FACTORY'],
167
- callBond: ['GANG_CALL_BOND'],
177
+ callBond: ['GANG_CALL_BOND'], countdownFactory: ['GANG_COUNTDOWN_FACTORY'],
168
178
  },
169
179
  testnet: {
170
180
  pad: ['GANG_TESTNET_PAD', 'GANG_V3_TESTNET_PAD', 'GANG_FAIR_TESTNET_PAD'], router: ['GANG_TESTNET_ROUTER', 'GANG_ROUTER_TESTNET'],
171
181
  bond: ['GANG_TESTNET_BOND'], splitterFactory: ['GANG_TESTNET_SPLITTER_FACTORY'], splitFactory: ['GANG_TESTNET_SPLIT_FACTORY'],
172
182
  lpFactory: ['GANG_TESTNET_LP_FACTORY'], comboFactory: ['GANG_TESTNET_COMBO_FACTORY'], cappedFactory: ['GANG_TESTNET_CAPPED_FACTORY'], floorFactory: ['GANG_TESTNET_FLOOR_FACTORY'],
173
183
  promotePoolFactory: ['GANG_TESTNET_PROMOTE_POOL_FACTORY'], callBond: ['GANG_TESTNET_CALL_BOND'],
184
+ countdownFactory: ['GANG_TESTNET_COUNTDOWN_FACTORY'],
174
185
  },
175
186
  }
176
187
 
package/src/gradreward.js CHANGED
@@ -55,7 +55,7 @@ export const GRAD_EVENT_ABIS = [GRAD_PAD_ABI]
55
55
 
56
56
  export const HINTS = {
57
57
  GradNotOpen: 'the graduation reward is closed on this pad: drop --grad-reward',
58
- BadGradConfig: '--grad-reward out of bounds: a seed above 0, --gr-min-buy above 0, --gr-entries 1–20, --gr-last 0–50, --gr-refund-days 30–180',
58
+ BadGradConfig: '--grad-reward out of bounds: a seed above 0, --gr-min-buy above 0, --gr-entries 1–20, --gr-last 0–50, --gr-refund-days 30–180, --gr-carry 0–50',
59
59
  BadCountdown: 'the tax recipient is a countdown reward module made for another token or quote (or a carry was asked without one)',
60
60
  NotGradState: 'the reward is not in the state this needs (on the curve for a refund; graduated for a claim, a settle or a sweep)',
61
61
  RefundNotDue: 'a refund needs: --gr-refund-days passed since the create to ask; then a 7-day public notice; then 3 days to take it, after which the request lapses',
@@ -69,7 +69,7 @@ export const revertOf = (e) => revertIn(e, [GRAD_PAD_ABI], HINTS)
69
69
 
70
70
  export const STATES = ['none', 'on the curve', 'graduated: claims open', 'refunded to the creator', 'closed']
71
71
  export const MAX_ENTRIES = 20
72
- export const DEFAULTS = { entries: 10, lastPct: 30, refundDays: 90 }
72
+ export const DEFAULTS = { entries: 10, lastPct: 30, refundDays: 90, carryPct: 20 }
73
73
  // in BNB, converted into the quote at the pad's own rate (graduation amount ÷ target)
74
74
  export const DEFAULT_MIN_BUY_BNB = '0.01'
75
75
  export const MIN_SEED_BNB = '0.1'
@@ -77,9 +77,9 @@ export const NOTICE_DAYS = 7
77
77
  export const WINDOW_DAYS = 3
78
78
  export const CLAIM_DAYS = 180
79
79
 
80
- export const GRAD_FLAGS = ['grad-reward', 'gr-min-buy', 'gr-entries', 'gr-last', 'gr-refund-days']
81
- export const GRAD_USAGE = '--grad-reward <seed> [--gr-min-buy <amount>] [--gr-entries <1-20>] [--gr-last <0-50>] [--gr-refund-days <30-180>]: the reward pool you put in at create (in the token\'s quote), the least a buy must spend to count, how many of the last buys share it, the % the graduating buy gets on top, and the days before you may ask for the pool back'
82
- export const GRAD_ALONE = 'a --grad-reward create stands alone in this CLI: no chained dev buy, GangBond or buy-back / split / LP / combined / floor / capped recipient, no --base, no --vault. A dev buy is its own gang buy after the create lands'
80
+ export const GRAD_FLAGS = ['grad-reward', 'gr-min-buy', 'gr-entries', 'gr-last', 'gr-refund-days', 'gr-carry']
81
+ export const GRAD_USAGE = '--grad-reward <seed> [--gr-min-buy <amount>] [--gr-entries <1-20>] [--gr-last <0-50>] [--gr-refund-days <30-180>] [--gr-carry <0-50>, with --countdown-reward]: the reward pool you put in at create (in the token\'s quote), the least a buy must spend to count, how many of the last buys share it, the % the graduating buy gets on top, the days before you may ask for the pool back, and (with --countdown-reward) the % of the pool carried into the token\'s countdown reward at graduation (default 20)'
82
+ export const GRAD_ALONE = 'a --grad-reward create goes alone or with --countdown-reward only: no chained dev buy, GangBond or buy-back / split / LP / combined / floor / capped recipient, no --base, no --vault. A dev buy is its own gang buy after the create lands'
83
83
  export const RULE = 'the reward pool is the creator\'s own money, paid to the last buys before graduation by a fixed public rule (by what each spent); buyers pay only the usual curve price and 1% fee and get the tokens they buy'
84
84
 
85
85
  /** The --grad-reward / --gr-* flags, checked: { seed, minBuy, entries, lastBps, refundDays } (amounts as typed), or { error }. */
@@ -104,7 +104,9 @@ export function parseGradReward(opt, flag) {
104
104
  if (l.error) return l
105
105
  const r = int('gr-refund-days', DEFAULTS.refundDays, 30, 180, 'days after the create before you may ask for the pool back')
106
106
  if (r.error) return r
107
- return { seed: String(seed).trim(), minBuy: minBuy && String(minBuy).trim(), entries: e.v, lastBps: l.v * 100, refundDays: r.v }
107
+ const c = int('gr-carry', null, 0, 50, '% of the pool carried into the token\'s countdown reward at graduation')
108
+ if (c.error) return c
109
+ return { seed: String(seed).trim(), minBuy: minBuy && String(minBuy).trim(), entries: e.v, lastBps: l.v * 100, refundDays: r.v, carryBps: c.v == null ? null : c.v * 100 }
108
110
  }
109
111
 
110
112
  /** Whether `ctx.pad` takes a graduation reward now: { open: true } / { open: false, why } / { unread }. */
@@ -119,6 +121,27 @@ export async function gradSupport(ctx) {
119
121
  return { open: true, countdownFactory: deps[2] }
120
122
  }
121
123
 
124
+ /** Why a carry can't be asked of this pad (its countdown factory is not this CLI's), or null. */
125
+ export const carryClosed = (padFactory, cliFactory) => (cliFactory && String(padFactory ?? '').toLowerCase() === cliFactory.toLowerCase()
126
+ ? null
127
+ : `--gr-carry: the pad has not opened the graduation reward's carry into the countdown reward yet (its countdown factory is ${padFactory ?? 'unset'}, this CLI's is ${cliFactory ?? 'none'}): add --gr-carry 0 to launch both without a carry`)
128
+
129
+ /**
130
+ * Before a --countdown-reward launch clones its module (gas, and the metadata fixed for good): what the create would
131
+ * refuse later about its --grad-reward, as { error, ...details }, or null.
132
+ */
133
+ export async function gradLaunchCheck(read, pad, testnet, gr, cliFactory) {
134
+ let deps
135
+ try { deps = await read(pad, GRAD_PAD_ABI, 'gradRewardDeps') } catch (e) {
136
+ if (missingRead(e)) return { error: `GangLaunchpad 3.0 on ${testnet ? 'the BSC testnet' : 'BSC mainnet'} has no graduation reward yet (the pad is not upgraded for it): drop --grad-reward`, pad }
137
+ return { error: 'could not check the pad for the graduation reward (RPC error)', pad, detail: e.shortMessage || e.message.split('\n')[0], retry: 'same command again' }
138
+ }
139
+ if (!deps[0]) return { error: 'the graduation reward is closed on this pad: drop --grad-reward', pad }
140
+ const carryBps = gr.carryBps ?? DEFAULTS.carryPct * 100
141
+ const closed = carryBps > 0 ? carryClosed(deps[2], cliFactory) : null
142
+ return closed ? { error: closed, pad } : null
143
+ }
144
+
122
145
  /** `amountBnb` (a decimal string) in the quote, at the rate the curve's graduation amount fixes (gradAmt ÷ target BNB). */
123
146
  export const bnbInQuote = (amountBnb, gradAmt, targetBnb) =>
124
147
  (parseUnits(String(amountBnb), 18) * gradAmt) / parseUnits(String(targetBnb), 18)
@@ -127,22 +150,26 @@ const iso = (s) => (Number(s) > 0 ? new Date(Number(s) * 1000).toISOString() : n
127
150
  const pctOf = (bps) => Number(bps) / 100
128
151
 
129
152
  /** What the create preview says about the reward (pure; amounts as display strings). */
130
- export function gradCreateView({ seed, minBuy, sym, entries, lastBps, refundDays, targetBnb, seedFloorNote, gateOn }) {
153
+ export function gradCreateView({ seed, minBuy, sym, entries, lastBps, refundDays, targetBnb, seedFloorNote, gateOn, carryBps = 0, toModule = false }) {
131
154
  const last = pctOf(lastBps)
155
+ const carry = pctOf(carryBps)
156
+ const pool = carry > 0 ? `the payout (the pool less the ${carry}% carry)` : 'the pool'
157
+ const rest = toModule ? 'to the token\'s countdown reward module (its reward pool)' : 'back to you'
132
158
  return {
133
159
  pool: `${seed} ${sym}`, payWithThisTx: `${seed} ${sym}, pulled from this wallet in the create (approve the pad for it first)`,
134
160
  minBuy: `${minBuy} ${sym}`, entries, lastPct: last, refundDays,
135
161
  who: `the last ${entries} curve buys that each actually spend at least ${minBuy} ${sym} (after a wallet-cap or graduation cut); the buy that graduates the token at ${targetBnb} BNB counts whatever it spends. Only while the pad's Agent gate is on (${gateOn ? 'it is on now' : 'IT IS OFF NOW: no buy would count until gang turns it back on'}): with it off, no buy counts`,
162
+ ...(carry > 0 && { carryPct: carry, carry: `at graduation ${carry}% of the pool goes into this token's countdown reward module, as its reward pool (through the module's receiveCarry; the pad found the module from the token's tax recipient, nobody types its address). If the module takes less (it refuses, or the gas runs short), the rest is owed and anyone resends it with gang grad-reward retry-carry. The last buys share the rest` }),
136
163
  split: last > 0
137
- ? `at graduation the buy that graduates it gets ${last}% of the pool on top; then all ${entries} entries, it included, split the rest by what each spent (a wallet with several entries adds them up)`
138
- : `at graduation all ${entries} entries split the pool by what each spent (a wallet with several entries adds them up)`,
164
+ ? `at graduation the buy that graduates it gets ${last}% of ${pool} on top; then all ${entries} entries, it included, split the rest by what each spent (a wallet with several entries adds them up)`
165
+ : `at graduation all ${entries} entries split ${pool} by what each spent (a wallet with several entries adds them up)`,
139
166
  sells: 'a curve sell takes out every entry that wallet has so far; a later buy of the same wallet counts again',
140
- claims: `buyers claim with gang grad-reward claim for ${CLAIM_DAYS} days after graduation; then anyone sweeps the unclaimed rest (and the rounding dust) back to you (to the token's countdown reward module instead, if its tax recipient is one)`,
167
+ claims: `buyers claim with gang grad-reward claim for ${CLAIM_DAYS} days after graduation; then anyone sweeps the unclaimed rest (and the rounding dust) ${rest}`,
141
168
  refund: `if the token does not graduate: ${refundDays} days after the create you may ask for the pool back (gang grad-reward refund-request). The request is public for ${NOTICE_DAYS} days; a graduation in that time pays the buyers as usual. Then you have ${WINDOW_DAYS} days to take it (gang grad-reward refund), after which the request lapses and must be made again`,
142
169
  rule: RULE,
143
170
  risks: 'anyone watching the curve can time the last buys, and one person with several Agent IDs can fill several entries: weighting by spend means many small entries earn no more than one large one, but a push into a full list still crowds out the oldest entries. A higher --gr-min-buy and more --gr-entries make that harder',
144
171
  ...(seedFloorNote && { seedFloor: seedFloorNote }),
145
- warning: `PERMANENT: ${seed} ${sym} leaves this wallet in the create. You get it back only through the refund above (if the token does not graduate) or as the unclaimed rest 180 days after graduation. The size, the rules and the numbers never change`,
172
+ warning: `PERMANENT: ${seed} ${sym} leaves this wallet in the create. You get it back only through the refund above (if the token does not graduate)${toModule ? '' : ' or as the unclaimed rest 180 days after graduation'}. The size, the rules and the numbers never change`,
146
173
  }
147
174
  }
148
175
 
package/src/index.js CHANGED
@@ -30,12 +30,13 @@ import { runCombo, COMBO_EVENT_ABIS } from './combo.js'
30
30
  import { runCapped, CAPPED_EVENT_ABIS } from './capped.js'
31
31
  import { runFloor, FLOOR_ABI, FLOOR_EVENT_ABIS } from './floor.js'
32
32
  import { runBase, BASE_EVENT_ABIS } from './base.js'
33
+ import { CD_ALONE, CD_FLAGS, COUNTDOWN_EVENT_ABIS, runCountdown } from './countdown.js'
33
34
  import { GRAD_ALONE, GRAD_EVENT_ABIS, GRAD_FLAGS, runGradReward } from './gradreward.js'
34
35
  import { wantsPoolModule } from './promote.js'
35
36
  import { runWeekly } from './weekly.js'
36
37
  import { runFly, flyCtx, isFlyToken, FLY_EVENT_ABIS, FLY_CREATE_FLAGS } from './fly.js'
37
38
  import { FAIR_DEV_BUY, isLaunch, LAUNCH_FLAGS, REDEEM_FEE_ALONE, runLaunch, TAX_CAP_ALONE } from './launch.js'
38
- import { poolPayBnb, poolTrade } from './pool.js'
39
+ import { poolPayBnb, poolTrade, refShown } from './pool.js'
39
40
  import { parseAmount, ROUTER_ABI, ROUTER_HINTS, revertOf as revertIn, step as writeStep } from './steps.js'
40
41
  import { MERGED_ERRORS_ABI, genOf, padNets } from './gangpad.js'
41
42
  import { creatorFeeCtx, creatorFeeList, runCreatorFee } from './creatorfee.js'
@@ -64,7 +65,8 @@ const out = (o) => {
64
65
  if (!o.code) o = { ...o, code: codeOf(o) }
65
66
  if (o.code === 'NO_FUNDS' && !o.fund) o = { ...o, fund: /^not enough (BNB|WBNB)\b/.test(String(o.error ?? '')) ? FUND_HINT : FUND_TOKEN_HINT }
66
67
  }
67
- if (refInfo && o && typeof o === 'object' && !('ref' in o)) o = { ...o, ref: refInfo }
68
+ // a pool trade never carries the invite tag (pool.js refShown): its result says so instead of the resolved ref
69
+ if (refInfo && o && typeof o === 'object' && !('ref' in o)) o = { ...o, ref: refShown(o, refInfo) }
68
70
  // a failed result built no tx, so it claims no tag; a bad id is always said
69
71
  if (toolInfo() && o && typeof o === 'object' && !('tool' in o) && (o.success !== false || !toolInfo().attached)) o = { ...o, tool: toolInfo() }
70
72
  record(args, o)
@@ -543,6 +545,30 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
543
545
  with the pad before the tx) → bind → the rest of the launch. Not with --buyback /
544
546
  --lp / --after-cap / --recipient / --vault; with --promote the promoter share stays
545
547
  on the curve. Quote: WBNB (default), GANG or one listed in the pad's QuoteRegistry.
548
+ gang create … --buy-tax <1-5> --sell-tax <1-5> --countdown-reward --cd-max-payout <amount> [--cd-window 60m]
549
+ [--cd-max-round 6h] [--cd-idle 30d] [--cd-payout 30] [--cd-last 20] [--cd-dev 0]
550
+ [--cd-entries 10] [--cd-min-buy 0.05] [--cd-min-pot 0.1] [--cd-seed <amount>] [--dev-buy …]
551
+ V3, taxed, countdown reward (倒计时奖励, GangCountdownReward, countdown-v1; BSC mainnet
552
+ and testnet): your share of the pool tax becomes a reward for buyers.
553
+ After graduation each buy of at least --cd-min-buy through the module (gang buy)
554
+ puts the countdown --cd-window ahead, never past --cd-max-round from the round's
555
+ first counted buy. When it runs out, the round's last --cd-entries counted buys
556
+ share --cd-payout % of the pool (at most --cd-max-payout, required): equal shares,
557
+ the last buy --cd-last % of the payout on top (a round that ends at its cap: equal
558
+ shares only). No round starts under --cd-min-pot; after --cd-idle days with no
559
+ counted buy anyone may pay the last round again (finalize). --cd-dev % of the tax
560
+ stays yours (claim-dev). --cd-min-buy / --cd-min-pot default to 0.05 / 0.1 BNB on a
561
+ WBNB-quoted token and must be given for another quote. --cd-seed adds that much of
562
+ the quote to the pool after the bind (approve, fund). A fund that does not show in
563
+ the module's books is built again only with --cd-seed-again (the first may still
564
+ wait for approval in the Binance App: approve only one). The preview shows the % of
565
+ pool volume that reaches the pool, what a round pays at most and what taking every
566
+ slot costs. Anyone, you included, can take slots with several wallets; only buys
567
+ through the module count. PERMANENT: every setting. Steps: the token's address
568
+ first (as --floor), clone your module for it → create → bind → seed → the rest of
569
+ the launch. Not with --floor / --buyback / --lp / --split / --tax-cap / --recipient /
570
+ --vault; with --grad-reward too (0.44.0+), --gr-carry % of that pool (default 20) goes into the module at graduation; with --promote the promoter share stays on the curve. Quote: WBNB, GANG or
571
+ one listed in the pad's QuoteRegistry
546
572
  gang create --fair … [--shares <n>] --bond <quote> [--bond-hold …] --bond-days <7-90>
547
573
  打新: create (the dev's --shares are bought in it) → bond. Progress is read from the
548
574
  chain (a token this wallet created with this symbol since the plan); a run that finds
@@ -632,17 +658,21 @@ OPENING BASE (GangLaunchpad 3.0, base-v1, 0.40.0+; open on BSC mainnet and testn
632
658
 
633
659
  GRADUATION REWARD (冲毕业奖励, GangLaunchpad 3.0, 0.42.0+; open on BSC mainnet and testnet; the pad says whether it is open):
634
660
  gang create … --grad-reward <seed> [--gr-min-buy <amount>] [--gr-entries <1-20>] [--gr-last <0-50>] [--gr-refund-days <30-180>]
661
+ [--countdown-reward … --gr-carry <0-50>]
635
662
  you seed a reward pool in the token's quote (pulled in the create: approve first;
636
663
  at least 0.1 BNB worth) for the last --gr-entries curve buys (default 10) that each
637
664
  actually spend --gr-min-buy (default 0.01 BNB worth), while the pad's Agent gate is
638
- on; the buy that graduates the token counts whatever it spends and gets --gr-last % of the pool on top (default 30); all
665
+ on; the buy that graduates the token counts whatever it spends and gets --gr-last % of the payout (the pool less any --gr-carry) on top (default 30); all
639
666
  entries, it included, split the rest by what each spent. A curve sell takes that
640
667
  wallet's earlier entries out. Buyers claim for 180 days after graduation, then the
641
668
  rest goes back to you (to the token's countdown module if that is its tax recipient). Not graduating: --gr-refund-days (default 90) after the
642
669
  create you may ask for it back; the request is public for 7 days (a graduation in
643
670
  that time pays the buyers), then you have 3 days to take it, else it lapses. The
644
671
  buyers pay only the usual price and fee: it is your money, paid by a fixed public rule. With --promote
645
- on an untaxed token or with --recipient; not with --vault / --base / --fair / --fly
672
+ on an untaxed token or with --recipient; with --countdown-reward (a taxed launch whose
673
+ recipient is the token's countdown reward module) --gr-carry % of the pool (default
674
+ 20) goes into that module's reward pool at graduation, and the unclaimed rest goes
675
+ there too, not back to you; not with --vault / --base / --fair / --fly
646
676
  or a launch in one command (--dev-buy, --bond, --buyback, --split, --lp, --tax-cap,
647
677
  --floor). gang buy / gang sell previews say whether a buy counts (rewards.gradReward)
648
678
  and what a sell takes out
@@ -855,12 +885,35 @@ FLOOR (a V3 token whose recipient is a floor module, floor-v1; GANG_FLOOR_FACTOR
855
885
  gang floor bind --token <addr> anyone: bind the module to the token it was cloned for (the launch does it).
856
886
  --module <addr> instead of --token names a module directly (not for redeem).
857
887
  Gas, --testnet, --calldata, --from as gang capped
888
+ COUNTDOWN REWARD (倒计时奖励, a V3 token whose recipient is its countdown module, countdown-v1; GANG_COUNTDOWN_FACTORY /
889
+ GANG_TESTNET_COUNTDOWN_FACTORY; BSC mainnet and testnet):
890
+ gang buy --token <addr> --amount <n> [--cd-uncounted]
891
+ graduated: the buy goes through the token's countdown module (WBNB-quoted: BNB, or
892
+ the quote after an approve with --use-quote; another quote: approve, then
893
+ buyWithQuote; --pay-bnb is refused), on the token's own pair. It must count by
894
+ default (a buy that would not, reverts NotCounted and buys nothing; the preview
895
+ says so first); --cd-uncounted buys through it anyway. rewards.countdown: counted
896
+ or not and why, the round, its deadline and cap, the pool, your estimated share if
897
+ no other counted buy came. No --ref / --promoter / --follow; a note is not carried.
898
+ Curve buys never count; sells never take out slots (no holding check)
899
+ gang countdown status --token <addr> the rules, the pool, the running round (deadline, cap, its slots oldest first),
900
+ the round before, what is due (settle / finalize) and this wallet's (or --from's)
901
+ claimable — and whether GangCountdownRewardFactory made the module and cloned it
902
+ for this token: if not, a warning, and no other gang countdown command is built
903
+ gang countdown claim --token <addr> [--to <addr>]
904
+ a buyer: everything credited to this wallet, paid to --to (default this wallet)
905
+ gang countdown settle --token <addr> anyone, once a round passed its deadline: end it and credit its slots
906
+ gang countdown finalize --token <addr> anyone, after the idle days with no counted buy: pay the last round's slots once
907
+ more (at most the max payout)
908
+ gang countdown claim-dev --token <addr>
909
+ anyone: send the dev its --cd-dev % of the tax (always to the dev). --testnet,
910
+ --calldata, --from as elsewhere
858
911
  gang execute --request-id <id> broadcast a previewed call
859
912
  gang tx --pending a trade that waited for Binance App approval (execute: pendingConfirmation): find its tx
860
913
  in the wallet's history by the exact call previewed, then as gang tx --hash below
861
914
  gang tx --hash <0x..> [--testnet] wait for receipt and decode Gang events: V2 / Soft / U / S, GangLaunchpad (V3 /
862
915
  打新, 铸币飞轮, tax routers, vaults), GangFlywheelPad (铸币飞轮 pads), split modules,
863
- LP splitters, combined and capped recipients, floor modules (publishes a queued --note; mainnet). GangLaunchpad events
916
+ LP splitters, combined and capped recipients, floor and countdown modules (publishes a queued --note; mainnet). GangLaunchpad events
864
917
  carry units: "raw" (amounts in wei, 18 decimals; bps / shares as is)
865
918
 
866
919
  --note is PUBLIC: shown on gang.fun next to the trade. Its hash goes into the tx calldata, so it is provably written
@@ -1354,6 +1407,7 @@ async function routed(verb) {
1354
1407
  if (flag('promoter') && verb !== 'buy') fail('--promoter applies to gang buy only: a wallet binds by its first buy', { token })
1355
1408
  const kind = await padKind(token, verb)
1356
1409
  if (flag('promoter') && kind !== 'v3') fail('--promoter is for V3 curve tokens on GangLaunchpad 3.0', { token, kind })
1410
+ if (flag('cd-uncounted') && !(verb === 'buy' && kind === 'v3')) fail('--cd-uncounted applies to gang buy of a graduated V3 token with a countdown reward', { token, kind })
1357
1411
  // 铸币飞轮 mints name the inviter in the contract call (fly.js); every other buy / mint carries the invite tag
1358
1412
  if (flag('ref') && kind !== 'fly') await resolveRef(fromArg() || (bawStatus() === 'CONNECTED' ? bawAddress() : null))
1359
1413
  const io = { ...PAD_IO, out: tagKind(kind) }
@@ -1458,9 +1512,9 @@ const PREFLIGHT_NEXT = [
1458
1512
  // commands whose JSON result carries `update`; `watch` streams NDJSON and help is plain text
1459
1513
  const UPDATE_CHECKED = new Set(['version', '--version', '-v', 'preflight', 'list', 'trending', 'invite', 'weekly', 'hot', 'new', 'near-grad', 'notes', 'agents', 'token', 'info', 'status', 'portfolio', 'quote',
1460
1514
  'buy', 'follow', 'sell', 'claim', 'mint', 'withdraw', 'release', 'upload-logo', 'create', 'execute', 'tx', 'fair', 'v3', 'bond',
1461
- 'buyback', 'split', 'lp', 'combo', 'capped', 'floor', 'base', 'grad-reward', 'fly', 'creator-fee', 'promote', 'call-bond'])
1515
+ 'buyback', 'split', 'lp', 'combo', 'capped', 'floor', 'base', 'grad-reward', 'countdown', 'fly', 'creator-fee', 'promote', 'call-bond'])
1462
1516
  // gang tx decodes these beside the V2 / Soft / U / S pads' events (GangLaunchpad: both kinds; the tax router; the vaults)
1463
- const GANG_EVENT_ABIS = [...V3_EVENT_ABIS, ...FAIR_EVENT_ABIS, ...FLY_EVENT_ABIS, ...SPLIT_EVENT_ABIS, ...LP_EVENT_ABIS, ...COMBO_EVENT_ABIS, ...CAPPED_EVENT_ABIS, ...FLOOR_EVENT_ABIS, ...BASE_EVENT_ABIS, ...GRAD_EVENT_ABIS, ...PROMOTE_EVENT_ABIS, CALL_BOND_ABI]
1517
+ const GANG_EVENT_ABIS = [...V3_EVENT_ABIS, ...FAIR_EVENT_ABIS, ...FLY_EVENT_ABIS, ...SPLIT_EVENT_ABIS, ...LP_EVENT_ABIS, ...COMBO_EVENT_ABIS, ...CAPPED_EVENT_ABIS, ...FLOOR_EVENT_ABIS, ...COUNTDOWN_EVENT_ABIS, ...BASE_EVENT_ABIS, ...GRAD_EVENT_ABIS, ...PROMOTE_EVENT_ABIS, CALL_BOND_ABI]
1464
1518
  // Split with three amounts is the event of four module kinds, and the amounts mean different things in each (a buy-back
1465
1519
  // splitter's toBuyback / toDev, an LP splitter's toLp / toDev, a promoter pool's toEscrow / toDev, a floor module's
1466
1520
  // toTreasury / toPayees): gang tx asks the
@@ -1589,7 +1643,10 @@ async function main() {
1589
1643
  if (flyCreate || flag('fair') || cmd === 'fair') fail(`--grad-reward rewards the last buys of a V3 curve: leave --${flyCreate ? 'fly' : 'fair'} out`)
1590
1644
  if (flag('base') || flag('vault')) fail(`--grad-reward and --${flag('base') ? 'base' : 'vault'} can't go together`)
1591
1645
  if (wantsPoolModule('v3', flag, opt)) fail('--grad-reward with --promote on a taxed token: that --promote would start a promoter pool launch, which a --grad-reward create does not take. Add --recipient <your address> (the creator\'s own share stays in the create), or use an untaxed token')
1592
- const launch = LAUNCH_FLAGS.find((f) => flag(f))
1646
+ if (flag('gr-carry') && !flag('countdown-reward')) fail('--gr-carry carries part of the pool into the token\'s countdown reward: add --countdown-reward, or leave --gr-carry out')
1647
+ // the one launch it goes with: --countdown-reward (and its --cd-* settings, --restart)
1648
+ const cdOk = (f) => flag('countdown-reward') && (f === 'countdown-reward' || f === 'restart' || CD_FLAGS.includes(f))
1649
+ const launch = LAUNCH_FLAGS.find((f) => flag(f) && !cdOk(f))
1593
1650
  if (launch) fail(`--${launch}: ${GRAD_ALONE}`)
1594
1651
  }
1595
1652
  // gang weekly apply takes the same --description / --website / --twitter as a create (they describe the token to come)
@@ -1603,6 +1660,10 @@ async function main() {
1603
1660
  // --bond-hold / --bond-days / --restart only mean something in a chained launch (--dev-buy / --bond); never drop them silently
1604
1661
  // gang fair create and gang create --fair are 打新 creates; the rest V3
1605
1662
  const launchKind = cmd === 'fair' || (cmd === 'create' && flag('fair')) ? 'fair' : 'v3'
1663
+ const cdFlag = CD_FLAGS.find((f) => flag(f))
1664
+ if (cdFlag && !tokenCreate) fail(`--${cdFlag} only applies when creating a token (gang create --countdown-reward …)`)
1665
+ if (flag('countdown-reward') && !tokenCreate) fail('--countdown-reward only applies when creating a token: gang create … --countdown-reward --cd-max-payout <amount>')
1666
+ if (tokenCreate && cdFlag && !flag('countdown-reward')) fail(`--${cdFlag}: ${CD_ALONE}`)
1606
1667
  if (tokenCreate && !flyCreate && !isLaunch(launchKind, flag, opt)) {
1607
1668
  // a 打新 dev buys with --shares in the create itself: say so here, not "add --bond" (which would only lead to that)
1608
1669
  if (launchKind === 'fair' && flag('dev-buy')) fail(FAIR_DEV_BUY)
@@ -1612,6 +1673,7 @@ async function main() {
1612
1673
  const floorFlag = ['floor', 'redeem-fee'].find((f) => flag(f))
1613
1674
  if (floorFlag && launchKind === 'fair') fail(`--${floorFlag} is for V3 tokens: it makes the tax recipient a floor module, and a 打新 token has no recipient`)
1614
1675
  if (flag('redeem-fee')) fail(REDEEM_FEE_ALONE)
1676
+ if (flag('countdown-reward') && launchKind === 'fair') fail('--countdown-reward is for V3 tokens: it makes the tax recipient a countdown reward module, and a 打新 token has no recipient')
1615
1677
  const lone = LAUNCH_FLAGS.find((f) => flag(f))
1616
1678
  if (lone) fail(`--${lone} only applies to a launch in one command: add --bond <quote>${launchKind === 'fair' ? '' : ' (or --dev-buy <quote> / --buyback <pct> / --split <addr>:<pct>,… / --lp <pct> / --tax-cap <amount> / --floor)'}`)
1617
1679
  }
@@ -1666,6 +1728,8 @@ async function main() {
1666
1728
  return runBase(args[1], { opt, flag, out, fail, summarize: summarizePreview })
1667
1729
  case 'grad-reward':
1668
1730
  return runGradReward(args[1], { opt, flag, out, fail, summarize: summarizePreview })
1731
+ case 'countdown':
1732
+ return runCountdown(args[1], { opt, flag, out, fail, summarize: summarizePreview })
1669
1733
  case 'weekly':
1670
1734
  return runWeekly(args[1], { opt, flag, out, fail, resolveLogo: resolveLogoUri })
1671
1735
  case 'capabilities':
@@ -2032,7 +2096,9 @@ async function main() {
2032
2096
  return out(await txReport(hash))
2033
2097
  }
2034
2098
  default:
2035
- console.log(HELP); process.exit(!cmd || cmd === '--help' || cmd === '-h' || cmd === 'help' ? 0 : 1)
2099
+ // the help is longer than a pipe's buffer (64 KiB): exit only once it is all written, or a pipe gets it cut short
2100
+ process.stdout.write(`${HELP}\n`, () => process.exit(!cmd || cmd === '--help' || cmd === '-h' || cmd === 'help' ? 0 : 1))
2101
+ return
2036
2102
  }
2037
2103
  }
2038
2104