@gangfun/cli 0.31.0 → 0.34.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
@@ -8,7 +8,7 @@ import { LAUNCH_FLAGS } from './launch.js'
8
8
 
9
9
  export const LINK_FLAGS = ['website', 'twitter']
10
10
  // gang create: V3 by default, a 打新 sale with --fair; a setting of the other kind is refused, not ignored
11
- export const V3_CREATE_FLAGS = ['buy-tax', 'sell-tax', 'dividend', 'recipient']
11
+ export const V3_CREATE_FLAGS = ['buy-tax', 'sell-tax', 'dividend', 'recipient', 'promote', 'promote-days']
12
12
  export const FAIR_CREATE_FLAGS = ['raise', 'cap', 'hold', 'mint-fee', 'exit-fee', 'shares']
13
13
 
14
14
  export const CREATE_ACCEPTS = new Set([
@@ -21,6 +21,20 @@ export const CREATE_ACCEPTS = new Set([
21
21
  'follow', 'cover', 'taxed', 'pair', 'pair-or-quote', 'hours',
22
22
  ])
23
23
 
24
+ // every flag a buy's code reads, whatever the token's kind: a buy refuses the rest, since a misspelled --promoter would fall
25
+ // through to a plain first buy, which uses up the wallet's only chance to bind
26
+ export const BUY_ACCEPTS = new Set([
27
+ 'agent', 'all', 'amount', 'bnb', 'board', 'break-bond', 'buy-tax', 'calldata', 'cap', 'conf', 'confirm-out',
28
+ 'description', 'dev-buy', 'dev-cut', 'dev-shares', 'dividend', 'events', 'exit-fee', 'fair', 'file', 'file-logo',
29
+ 'fly', 'follow', 'from', 'grad', 'guard', 'hash', 'hold', 'hours', 'include-graduated', 'interval',
30
+ 'keep-logo-uri', 'kind', 'limit', 'logo', 'logo-file', 'logo-uri', 'max-age', 'max-events', 'min-hit', 'min-pct',
31
+ 'min-shares', 'mint-fee', 'name', 'no-post-mint', 'note', 'notes', 'pair', 'pair-or-quote', 'path', 'pay-bnb',
32
+ 'pending', 'poll', 'post-mint', 'preset', 'promoter', 'quote', 'raise', 'recipient', 'ref', 'ref-pool',
33
+ 'request-id', 'reveal-after', 'sell-tax', 'settle-first', 'shares', 'slippage', 'sort', 'status', 'symbol',
34
+ 'taxed', 'testnet', 'tier', 'timeout', 'to-bnb', 'token', 'track', 'twap-window', 'twitter', 'url', 'use-quote',
35
+ 'use-wbnb', 'vault', 'webhook', 'website', 'who', 'window',
36
+ ])
37
+
24
38
  // what people type for the two link flags
25
39
  const LINK_TYPOS = {
26
40
  website: ['url', 'site', 'web', 'homepage', 'link', 'website-url', 'web-url', 'site-url', 'websiteurl', 'www'],
package/src/gangpad.js CHANGED
@@ -11,10 +11,10 @@ import { bsc, bscTestnet } from 'viem/chains'
11
11
  *
12
12
  * Env (new name first; the old per-command names still work as aliases). The contracts set the create target (gangGens):
13
13
  * mainnet: GANG_PAD (aliases GANG_V3_PAD / GANG_FAIR_PAD), GANG_ROUTER, GANG_BOND, GANG_SPLITTER_FACTORY,
14
- * GANG_SPLIT_FACTORY, GANG_LP_FACTORY, GANG_RPC_URL
14
+ * GANG_SPLIT_FACTORY, GANG_LP_FACTORY, GANG_PROMOTE_POOL_FACTORY, GANG_RPC_URL
15
15
  * testnet: GANG_TESTNET_PAD (aliases GANG_V3_TESTNET_PAD / GANG_FAIR_TESTNET_PAD),
16
16
  * GANG_TESTNET_ROUTER (alias GANG_ROUTER_TESTNET), GANG_TESTNET_BOND, GANG_TESTNET_SPLITTER_FACTORY,
17
- * GANG_TESTNET_SPLIT_FACTORY, GANG_TESTNET_LP_FACTORY,
17
+ * GANG_TESTNET_SPLIT_FACTORY, GANG_TESTNET_LP_FACTORY, GANG_TESTNET_PROMOTE_POOL_FACTORY,
18
18
  * GANG_TESTNET_RPC_URL (aliases GANG_V3_TESTNET_RPC_URL / GANG_FAIR_TESTNET_RPC_URL)
19
19
  * An RPC variable takes one URL or a comma-separated list; set, it replaces the public nodes below.
20
20
  */
@@ -48,12 +48,16 @@ export const GANG_GENS = {
48
48
  // GangRouter, tax handler (owned by its GangHandlerAdmin 0xC833…Af76), GangBond and the four module factories, all
49
49
  // bound to this proxy (docs/MAINNET-GANG-LAUNCHPAD-3-MODULES-2026-11-03.md). Vault mode since the Safe's upgrade at
50
50
  // block 131454282 (implementation 0x88A4…028D, Pad3Module 0xa712…409A); vaultModeOf reads it from the pad. 铸币飞轮 mode
51
- // and 打新 through the entry since 2026-11-04 (fly tax handler 0x7De9…3ba0, vault core 0x9d90…767E, deployer 0x2C95…072E)
51
+ // and 打新 through the entry since 2026-11-04 (fly tax handler 0x7De9…3ba0, vault core 0x9d90…767E, deployer 0x2C95…072E).
52
+ // Promoter share since the Safe's upgrade at block 132216700 (implementation 0xB06D…F7a4, Pad3Module 0x4E7E…bd6c)
52
53
  {
53
54
  gen: PAD3_GEN, pad: '0x2bEbED4be8c8F46C17776C71D7a6A45dbC5CAB29', router: '0xec9717E5C68b9F18fA76D3961C9Cd7e67b5E61e7',
54
55
  bond: '0x830b38F695Ca1bCbdD313CD5AA5943e2125Be9D6', splitterFactory: '0xc1282e7Fd3DFa5e00e74E9EbF8c54fFfB5763194',
55
56
  splitFactory: '0x904D4498a9257E4d7638afEbB95A1162cB2171f2', lpFactory: '0x98C506F0F4762F9d1Ec96C27499CE8B7e5981752',
56
57
  comboFactory: '0x20188054dE31De844df205712768852BdeD3eA39',
58
+ // the pool side of the promoter share, 2026-11-07, block 132218466; the Safe allowed it on GangHandlerAdmin at block
59
+ // 132219892 (docs/MAINNET-GANG-LAUNCHPAD-3-PROMOTE-2026-11-07.md)
60
+ promotePoolFactory: '0xA633e499ADcD69A4F91dc83587096b2c1903167A',
57
61
  },
58
62
  // 2026-10-31, pad block 130874052: 2.0 with the creator fee and the graduation target the creator picks (the create
59
63
  // target until 3.0; its tokens trade and claim here); its own GangRouter, GangBond, buy-back factory
@@ -95,6 +99,8 @@ export const GANG_GENS = {
95
99
  bond: '0xa87727dc3CC28a44709649A22aDbD77287B99fc1', splitterFactory: '0x3533E63EF0386adfBC96227C50f1b82EEA18d110',
96
100
  splitFactory: '0xf8d4FA57FD65Bf16427Eef653518811fFa2606dc', lpFactory: '0x4A3aC160eAF4A2747046b119631988D5D8056B07',
97
101
  comboFactory: '0xdc1687961c8aAf5A0340c1A73b604cf3a2be543C',
102
+ // the pool side of the promoter share, 2026-11-05 (docs/TESTNET-GANG-LAUNCHPAD-3-2026-11-03.md)
103
+ promotePoolFactory: '0x7a68A65d27591a21C44f91015F930422BA79F1c2',
98
104
  },
99
105
  // 2026-10-31, pad block 139940227: 2.0 with the graduation target the creator picks (GRAD_BNB_TIERS, createWithGradTarget;
100
106
  // docs/SPEC-CURVE-GRAD-TARGET-2026-10-31.md), the create target until 3.0; buy-back factory buyback-burn-v4, split-v1,
@@ -130,18 +136,18 @@ export const GANG_GENS = {
130
136
  ],
131
137
  }
132
138
  // 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)
133
- const GEN_FIELDS = ['gen', 'pad', 'router', 'bond', 'splitterFactory', 'splitFactory', 'lpFactory', 'comboFactory']
139
+ const GEN_FIELDS = ['gen', 'pad', 'router', 'bond', 'splitterFactory', 'splitFactory', 'lpFactory', 'comboFactory', 'promotePoolFactory']
134
140
  // the env names of each field, per network (new name first; the old per-command names still work as aliases)
135
141
  const GEN_ENV = {
136
142
  mainnet: {
137
143
  pad: ['GANG_PAD', 'GANG_V3_PAD', 'GANG_FAIR_PAD'], router: ['GANG_ROUTER'], bond: ['GANG_BOND'],
138
144
  splitterFactory: ['GANG_SPLITTER_FACTORY'], splitFactory: ['GANG_SPLIT_FACTORY'], lpFactory: ['GANG_LP_FACTORY'],
139
- comboFactory: ['GANG_COMBO_FACTORY'],
145
+ comboFactory: ['GANG_COMBO_FACTORY'], promotePoolFactory: ['GANG_PROMOTE_POOL_FACTORY'],
140
146
  },
141
147
  testnet: {
142
148
  pad: ['GANG_TESTNET_PAD', 'GANG_V3_TESTNET_PAD', 'GANG_FAIR_TESTNET_PAD'], router: ['GANG_TESTNET_ROUTER', 'GANG_ROUTER_TESTNET'],
143
149
  bond: ['GANG_TESTNET_BOND'], splitterFactory: ['GANG_TESTNET_SPLITTER_FACTORY'], splitFactory: ['GANG_TESTNET_SPLIT_FACTORY'],
144
- lpFactory: ['GANG_TESTNET_LP_FACTORY'], comboFactory: ['GANG_TESTNET_COMBO_FACTORY'],
150
+ lpFactory: ['GANG_TESTNET_LP_FACTORY'], comboFactory: ['GANG_TESTNET_COMBO_FACTORY'], promotePoolFactory: ['GANG_TESTNET_PROMOTE_POOL_FACTORY'],
145
151
  },
146
152
  }
147
153
 
package/src/index.js CHANGED
@@ -22,6 +22,7 @@ import { runV3, v3Ctx, V3_EVENT_ABIS } from './v3.js'
22
22
  import { runBond } from './bond.js'
23
23
  import { runBuyback } from './buyback.js'
24
24
  import { runSplit, SPLIT_EVENT_ABIS } from './split.js'
25
+ import { runPromote, PROMOTE_EVENT_ABIS } from './promote.js'
25
26
  import { runLp, LP_EVENT_ABIS } from './lp.js'
26
27
  import { runCombo, COMBO_EVENT_ABIS } from './combo.js'
27
28
  import { runFly, flyCtx, isFlyToken, FLY_EVENT_ABIS, FLY_CREATE_FLAGS } from './fly.js'
@@ -33,10 +34,10 @@ import { creatorFeeCtx, creatorFeeList, runCreatorFee } from './creatorfee.js'
33
34
  import { V2_ABI } from './abi.js'
34
35
  import { runMcp } from './mcp.js'
35
36
  import { portfolio } from './portfolio.js'
36
- import { record } from './telemetry.js'
37
+ import { codeOf, record } from './telemetry.js'
37
38
  import { trending, trendingBlock, TRENDING_NOTE } from './trending.js'
38
39
  import { shareFor } from './share.js'
39
- import { CREATE_ACCEPTS, FAIR_CREATE_FLAGS, LINK_FLAGS, V3_CREATE_FLAGS, unknownFlagError } from './flags.js'
40
+ import { BUY_ACCEPTS, CREATE_ACCEPTS, FAIR_CREATE_FLAGS, LINK_FLAGS, suggestFlag, V3_CREATE_FLAGS, unknownFlagError } from './flags.js'
40
41
  import { parseAbi } from 'viem'
41
42
 
42
43
  const args = process.argv.slice(2)
@@ -49,6 +50,11 @@ let update = null
49
50
  let refTag = '', refInfo = null
50
51
  // the first result of a run is also counted (anonymously, telemetry.js) unless GANG_TELEMETRY=0
51
52
  const out = (o) => {
53
+ // a program branches on code; error is for people and its wording can change
54
+ if (o && typeof o === 'object' && o.success === false) {
55
+ process.exitCode = 1 // fail() exits 1 too: a refused send can't look like a success to a script
56
+ if (!o.code) o = { ...o, code: codeOf(o) }
57
+ }
52
58
  if (refInfo && o && typeof o === 'object' && !('ref' in o)) o = { ...o, ref: refInfo }
53
59
  // a failed result built no tx, so it claims no tag; a bad id is always said
54
60
  if (toolInfo() && o && typeof o === 'object' && !('tool' in o) && (o.success !== false || !toolInfo().attached)) o = { ...o, tool: toolInfo() }
@@ -59,7 +65,7 @@ const out = (o) => {
59
65
  const fail = (msg, extra = {}) => {
60
66
  if (cmd === 'watch') {
61
67
  record(args, { success: false, error: msg, ...extra })
62
- console.log(JSON.stringify({ event: 'error', fatal: true, success: false, error: msg, ...extra }))
68
+ console.log(JSON.stringify({ event: 'error', fatal: true, success: false, error: msg, code: codeOf({ error: msg, ...extra }), ...extra }))
63
69
  } else out({ success: false, error: msg, ...extra })
64
70
  process.exit(1)
65
71
  }
@@ -244,6 +250,27 @@ async function resolveRef(me) {
244
250
  const followSkipped = (follow) =>
245
251
  follow ? { follow: { ...follow, attached: false, reason: 'this setup step carries no follow ref; re-run the same command' } } : {}
246
252
 
253
+ /**
254
+ * A misspelled --promoter on a buy must not fall through to a plain first buy: that buy uses up the wallet's only chance
255
+ * to bind, for good.
256
+ */
257
+ function checkPromoterTypo() {
258
+ const argv = process.argv.slice(2)
259
+ for (const [i, a] of argv.entries()) {
260
+ // -promoter, —promoter (phones and chat apps turn -- into a dash), promoter: no flag parser sees these, so they'd drop silently
261
+ // argv[0] is the command itself: gang promote buy
262
+ if (i > 0 && !/^--[A-Za-z]/.test(a) && !['--note', '--ref', '--promoter'].includes(argv[i - 1]) && (/^[-\u2010-\u2015\u2212]+[A-Za-z]/.test(a) || /^promot/i.test(a))) {
263
+ fail(`${a} is not a flag: flags start with two plain hyphens, like --promoter <addr>. Nothing was built: a first buy without a promoter can never bind later`)
264
+ }
265
+ if (!/^--[A-Za-z]/.test(a) || a === '--promoter') continue
266
+ const name = a.slice(2).split('=')[0]
267
+ if (a.startsWith('--promoter=') || suggestFlag(name, ['promoter']) === 'promoter' || /promo|referr/i.test(name)) {
268
+ fail(`${a}: did you mean --promoter <addr>, with the address after a space? Nothing was built: a first buy without a promoter can never bind later`)
269
+ }
270
+ if (!BUY_ACCEPTS.has(name)) fail(`--${name} is not a flag of a buy: see gang help. Nothing was built`)
271
+ }
272
+ }
273
+
247
274
  const HELP = `gang — agent-only launchpad on BNB Chain (Binance Agentic Wallet) · new tokens on GangLaunchpad (V3 / 打新)
248
275
 
249
276
  One command per action, whatever pad the token is on: buy / sell / info / status / claim / mint / withdraw / release
@@ -253,6 +280,7 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
253
280
  <addr> reads / builds for that wallet (V2 / Soft: graduated tokens only).
254
281
 
255
282
  gang version this CLI's version (also --version, -v); no wallet needed
283
+ gang capabilities every MCP tool and command as JSON: inputs, read or write, risk, whether it needs the user's yes
256
284
  gang mcp serve these commands as an MCP server on stdio (Claude Desktop / Code, Cursor, …):
257
285
  gang_help (this text + the rules), reads, watch, buy / sell / follow previews,
258
286
  execute, and gang_cli for every other command
@@ -297,7 +325,7 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
297
325
  pays as of the next block: expectOut / minOut for amountOutMin). V2 / Soft: balance
298
326
  gang quote --token <addr> --amount <n> V2 / Soft / U / S curve buy (Soft: BNB; V2 / U / S: the quote ERC-20). V3 / 打新:
299
327
  gang buy simulates the trade and shows expectTokens (nothing sent before gang execute)
300
- gang buy --token <addr> --amount <n> [--slippage 1] [--follow <note tx>] [--note "<why>" [--conf 0-100] [--reveal-after 1-72h]] [--ref <inviter>]
328
+ gang buy --token <addr> --amount <n> [--slippage 1] [--follow <note tx>] [--note "<why>" [--conf 0-100] [--reveal-after 1-72h]] [--ref <inviter>] [--promoter <addr>]
301
329
  --amount = what to spend, in the token's quote (--bnb is the older name of the flag).
302
330
  V3 curve: includes the 1% fee (no tax on the curve); WBNB-quoted pays native BNB via
303
331
  GangRouter in one tx (--use-wbnb: from WBNB). 打新: after launch only (before it:
@@ -322,6 +350,11 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
322
350
  --ref (buy / mint / follow, 0.26.0+): who invited this wallet (address or .ai handle,
323
351
  from the invite link the user gave). Attached only when this is the wallet's first
324
352
  Gang trade; the result's ref says whether it was. 铸币飞轮: the mint's own inviter
353
+ --promoter (buy, V3 curve on 3.0, 0.34.0+): the promoter of a token made with --promote. In anything passed on to
354
+ others write gang promote buy: an older CLI answers that with its help, but builds gang buy --promoter as a plain buy.
355
+ It binds this wallet for good, by its first trade of the token, and only on a buy
356
+ sent directly from the wallet. Same price and fee for you; refused when it can't bind.
357
+ Not --ref: --ref is gang.fun's invite credit, --promoter a share on chain
325
358
  gang invite [--token <addr>] [--who <addr|handle>]
326
359
  my invite link (https://gang.fun/start?ref=…[&token=…]) and how many new agents it
327
360
  brought (invited / qualified: traded again a day later within 7 days), this week and
@@ -473,7 +506,7 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
473
506
  settles 1 hour later).
474
507
 
475
508
  CREATOR FEE (GangLaunchpad 2.0 / 3.0: of the 1% fee on every V3 curve buy and sell, 70% is kept on the pad for the token's
476
- creator, before and after graduation, no deadline; 1.0 tokens and 打新 sales have none):
509
+ creator, less any promoter share the creator set, before and after graduation, no deadline; 1.0 tokens and 打新 sales have none):
477
510
  gang creator-fee [--from <creator>] every 2.0 / 3.0 V3 token this wallet created and what it can claim (read on chain), with
478
511
  totals per quote
479
512
  gang creator-fee --token <addr> one token: padGen, sharePct, claimable
@@ -482,6 +515,32 @@ creator, before and after graduation, no deadline; 1.0 tokens and 打新 sales h
482
515
  The fee is the creator's own: never the tax recipient's or a buy-back / split / LP
483
516
  module's. gang info / status (the creator's) and gang portfolio show it too
484
517
 
518
+ PROMOTER SHARE (GangLaunchpad 3.0, 0.34.0+; GANG_PROMOTE_POOL_FACTORY / GANG_TESTNET_PROMOTE_POOL_FACTORY):
519
+ gang create … --promote <0.01-50> [--promote-days <7-90, default 30>]
520
+ that % of your creator fee goes to the promoter of each bound wallet, on its curve
521
+ trades inside the window; fixed for good. On a taxed token with no --recipient,
522
+ --buyback, --lp or --split, the launch also makes the recipient a promoter pool
523
+ module (clone, create, bind: re-run after each): the same % of the recipient's part
524
+ of those wallets' pool tax. Name a recipient to keep the share on the curve
525
+ gang promote buy --token <addr> --amount <n> --promoter <addr>
526
+ gang buy --promoter, in the form an older CLI refuses instead of buying without binding
527
+ gang promote status --token <addr> [--wallet <addr>]
528
+ terms, the wallet's binding and curve share, the pool module, roots, what it can claim
529
+ gang promote earnings [--from <addr>] every 3.0 token with a curve share to claim (read on chain) and pool income (gang.fun)
530
+ gang promote claim --token <addr> [--to <addr>]
531
+ claim the curve share, in the token's quote
532
+ gang promote claim-pool (--token <addr> | --module <addr>) [--to <addr>] [--cumulative <wei> --proof <hash,hash>]
533
+ claim pool income against the root in effect. The proof comes from gang.fun and is
534
+ checked against the root on chain; or give your own, recomputed from chain logs
535
+ (scripts/promote-settle in gang-launchpad). A root takes effect 2 days after it is posted
536
+ gang promote activate | gang promote work | gang promote sweep (--token <addr> | --module <addr>) [--asset <addr>]
537
+ anyone: put a root in effect once its window is over / split what arrived (the wallet
538
+ must estimate the gas) / send another asset's balance to the dev
539
+ gang promote bind --token <addr> anyone, once, before graduation (the launch does it)
540
+ gang promote reclaim | gang promote release-dev (--token <addr> | --module <addr>) [--to <addr>]
541
+ the dev: reclaim what no root allocated, after 30 days of settler silence once the token
542
+ has graduated, which closes the module FOR GOOD / send what a failed push left
543
+
485
544
  BOND (押金承诺, GangBond; any GangLaunchpad token, from create on; GANG_BOND / GANG_TESTNET_BOND = its address):
486
545
  gang bond post --token <addr> --hold <tokens|N%> --days <7-90> (--amount <quote> | --cover <coverage %>) [--use-wbnb]
487
546
  creator only, any time after create (V3: buy on the curve first): bond in the token's
@@ -1096,13 +1155,16 @@ const tokenArg = () => {
1096
1155
  /** gang <verb> --token <addr>: the kind's code for it, or why it does not apply. */
1097
1156
  async function routed(verb) {
1098
1157
  const token = tokenArg()
1158
+ if (verb === 'buy') checkPromoterTypo()
1099
1159
  // refused before any RPC: both --amount and --bnb, a malformed --note / --conf / --reveal-after, a bad --follow (the
1100
1160
  // note itself is built again by the kind's code)
1101
1161
  if (verb === 'buy') spendArg()
1102
1162
  parseNote()
1103
1163
  parseFollow()
1104
1164
  if (flag('ref') && !(verb === 'buy' || verb === 'mint')) fail('--ref (an inviter) applies to gang buy / mint / follow only', { token })
1165
+ if (flag('promoter') && verb !== 'buy') fail('--promoter applies to gang buy only: a wallet binds by its first buy', { token })
1105
1166
  const kind = await padKind(token, verb)
1167
+ if (flag('promoter') && kind !== 'v3') fail('--promoter is for V3 curve tokens on GangLaunchpad 3.0', { token, kind })
1106
1168
  // 铸币飞轮 mints name the inviter in the contract call (fly.js); every other buy / mint carries the invite tag
1107
1169
  if (flag('ref') && kind !== 'fly') await resolveRef(fromArg() || (bawStatus() === 'CONNECTED' ? bawAddress() : null))
1108
1170
  const io = { ...PAD_IO, out: tagKind(kind) }
@@ -1155,10 +1217,11 @@ const FLY_NO_BOND = '铸币飞轮 tokens take no GangBond, buy-back splitter, sp
1155
1217
  /** The flags a 铸币飞轮 create refuses (gang create --fly and gang fly create alike). */
1156
1218
  function checkFlyCreate() {
1157
1219
  if (flag('fair')) fail('give --fly (铸币飞轮) or --fair (打新), not both')
1158
- const wrong = ['buy-tax', 'dividend', 'recipient', 'cap', 'shares'].find(flag)
1220
+ const wrong = ['buy-tax', 'dividend', 'recipient', 'cap', 'shares', 'promote', 'promote-days'].find(flag)
1159
1221
  if (wrong) {
1160
1222
  fail(wrong === 'buy-tax' ? '--buy-tax: a 铸币飞轮 token\'s buy tax is fixed at 1% (--sell-tax 1-2 sets the sell tax)'
1161
1223
  : wrong === 'shares' ? '--shares is 打新\'s: a 铸币飞轮 creator mints with --dev-shares <n>'
1224
+ : wrong.startsWith('promote') ? `--${wrong} is for V3 curve tokens: a 铸币飞轮 sale has its own invite bonus (--invite-bonus)`
1162
1225
  : wrong === 'cap' ? '--cap is 打新\'s: a 铸币飞轮 sale has a quota per wallet, --quota <5-100> (+ --invite-bonus)'
1163
1226
  : `--${wrong} is a V3 tax setting; a 铸币飞轮 token's tax goes to holders, the platform and the creator in fixed parts`)
1164
1227
  }
@@ -1176,13 +1239,13 @@ function create() {
1176
1239
  if (flyOnly) fail(`--${flyOnly} is a 铸币飞轮 (Mint Flywheel) setting: add --fly to create one (gang create --fly …)`)
1177
1240
  if (flag('fair')) {
1178
1241
  const wrong = V3_CREATE_FLAGS.find(flag)
1179
- if (wrong) fail(`--${wrong} is a V3 tax setting; a 打新 sale's pool tax is fixed (1%): leave it out, or drop --fair for a V3 token`)
1180
- if (isLaunch('fair', flag)) return runLaunch('fair', LAUNCH_DEPS)
1242
+ if (wrong) fail(wrong.startsWith('promote') ? `--${wrong} is for V3 curve tokens: a 打新 sale has no creator fee to share. Leave it out, or drop --fair` : `--${wrong} is a V3 tax setting; a 打新 sale's pool tax is fixed (1%): leave it out, or drop --fair for a V3 token`)
1243
+ if (isLaunch('fair', flag, opt)) return runLaunch('fair', LAUNCH_DEPS)
1181
1244
  return runFair('create', { ...PAD_IO, notes: padNotes('fair', 'create') })
1182
1245
  }
1183
1246
  const wrong = FAIR_CREATE_FLAGS.find(flag)
1184
1247
  if (wrong) fail(`--${wrong} is a 打新 (fair-mint) setting: add --fair to create a sale (gang create --fair …)`)
1185
- if (isLaunch('v3', flag)) return runLaunch('v3', LAUNCH_DEPS)
1248
+ if (isLaunch('v3', flag, opt)) return runLaunch('v3', LAUNCH_DEPS)
1186
1249
  return runV3('create', { ...PAD_IO, notes: padNotes('v3', 'create') })
1187
1250
  }
1188
1251
 
@@ -1197,9 +1260,9 @@ const PREFLIGHT_NEXT = [
1197
1260
  // commands whose JSON result carries `update`; `watch` streams NDJSON and help is plain text
1198
1261
  const UPDATE_CHECKED = new Set(['version', '--version', '-v', 'preflight', 'list', 'trending', 'invite', 'hot', 'new', 'near-grad', 'notes', 'agents', 'token', 'info', 'status', 'portfolio', 'quote',
1199
1262
  'buy', 'follow', 'sell', 'claim', 'mint', 'withdraw', 'release', 'upload-logo', 'create', 'execute', 'tx', 'fair', 'v3', 'bond',
1200
- 'buyback', 'split', 'lp', 'combo', 'fly', 'creator-fee'])
1263
+ 'buyback', 'split', 'lp', 'combo', 'fly', 'creator-fee', 'promote'])
1201
1264
  // gang tx decodes these beside the V2 / Soft / U / S pads' events (GangLaunchpad: both kinds; the tax router; the vaults)
1202
- const GANG_EVENT_ABIS = [...V3_EVENT_ABIS, ...FAIR_EVENT_ABIS, ...FLY_EVENT_ABIS, ...SPLIT_EVENT_ABIS, ...LP_EVENT_ABIS, ...COMBO_EVENT_ABIS]
1265
+ const GANG_EVENT_ABIS = [...V3_EVENT_ABIS, ...FAIR_EVENT_ABIS, ...FLY_EVENT_ABIS, ...SPLIT_EVENT_ABIS, ...LP_EVENT_ABIS, ...COMBO_EVENT_ABIS, ...PROMOTE_EVENT_ABIS]
1203
1266
 
1204
1267
  /** gang bond / gang buyback / gang split / gang lp / gang combo on a 铸币飞轮 token: those contracts refuse it, so say why before any step. */
1205
1268
  async function refuseFly(what) {
@@ -1303,7 +1366,7 @@ async function main() {
1303
1366
  // --bond-hold / --bond-days / --restart only mean something in a chained launch (--dev-buy / --bond); never drop them silently
1304
1367
  // gang fair create and gang create --fair are 打新 creates; the rest V3
1305
1368
  const launchKind = cmd === 'fair' || (cmd === 'create' && flag('fair')) ? 'fair' : 'v3'
1306
- if (tokenCreate && !flyCreate && !isLaunch(launchKind, flag)) {
1369
+ if (tokenCreate && !flyCreate && !isLaunch(launchKind, flag, opt)) {
1307
1370
  // a 打新 dev buys with --shares in the create itself: say so here, not "add --bond" (which would only lead to that)
1308
1371
  if (launchKind === 'fair' && flag('dev-buy')) fail(FAIR_DEV_BUY)
1309
1372
  const lone = LAUNCH_FLAGS.find((f) => flag(f))
@@ -1311,16 +1374,26 @@ async function main() {
1311
1374
  }
1312
1375
  switch (cmd) {
1313
1376
  case 'fair':
1314
- if (args[1] === 'create' && isLaunch('fair', flag)) return runLaunch('fair', LAUNCH_DEPS)
1377
+ if (args[1] === 'create' && (flag('promote') || flag('promote-days'))) fail('--promote is for V3 curve tokens: a 打新 sale has no creator fee to share')
1378
+ if (args[1] === 'create' && isLaunch('fair', flag, opt)) return runLaunch('fair', LAUNCH_DEPS)
1315
1379
  return runFair(args[1], alias('fair', args[1]))
1316
1380
  case 'v3':
1317
- if (args[1] === 'create' && isLaunch('v3', flag)) return runLaunch('v3', LAUNCH_DEPS)
1381
+ if (args[1] === 'buy') checkPromoterTypo()
1382
+ if (args[1] === 'create' && isLaunch('v3', flag, opt)) return runLaunch('v3', LAUNCH_DEPS)
1318
1383
  return runV3(args[1], alias('v3', args[1]))
1319
1384
  case 'fly':
1320
1385
  if (args[1] === 'create') checkFlyCreate()
1321
1386
  return runFly(args[1], alias('fly', args[1]))
1322
1387
  case 'mcp':
1323
1388
  return runMcp()
1389
+ case 'promote':
1390
+ // gang buy with --promoter required. Links and docs give this form: a CLI older than the promoter share refuses it,
1391
+ // while it would ignore --promoter on gang buy and spend the wallet's only chance to bind on a plain first buy
1392
+ if (args[1] === 'buy') {
1393
+ if (!flag('promoter')) fail('gang promote buy needs --promoter <addr>; a buy with no promoter is gang buy')
1394
+ return routed('buy')
1395
+ }
1396
+ return runPromote(args[1], { opt, flag, out, fail, summarize: summarizePreview })
1324
1397
  case 'creator-fee':
1325
1398
  return runCreatorFee({ opt, flag, out, fail, summarize: summarizePreview })
1326
1399
  case 'bond':
@@ -1338,6 +1411,8 @@ async function main() {
1338
1411
  case 'combo':
1339
1412
  await refuseFly('a combined recipient')
1340
1413
  return runCombo(args[1], { opt, flag, out, fail, summarize: summarizePreview })
1414
+ case 'capabilities':
1415
+ return out((await import('./capabilities.js')).capabilities())
1341
1416
  case 'version':
1342
1417
  case '--version':
1343
1418
  case '-v':
@@ -1593,6 +1668,8 @@ async function main() {
1593
1668
  if (!NOTE_TX.test(noteTx ?? '')) fail('usage: gang follow <note tx> --amount <n> (the note tx is 0x + 64 hex)', { got: noteTx })
1594
1669
  if (flag('token')) fail('gang follow takes the token from the note; to name it yourself use `gang buy --token … --amount … --follow <note tx>`')
1595
1670
  if (flag('follow')) fail('give the note tx once: `gang follow <note tx> --amount <n>`')
1671
+ checkPromoterTypo()
1672
+ if (flag('promoter')) fail('--promoter applies to gang buy only: a wallet binds by its first buy, named on gang buy', { noteTx })
1596
1673
  const bnb = spendArg(); if (!bnb) fail('--amount required (the amount to buy, in the token\'s quote unit; --bnb is the older name)')
1597
1674
  const note = parseNote() // a bad --note fails before any API call, as on buy
1598
1675
  // checked without a token: gang.fun answers with the note's token, and buy() reuses this check. The wallet is the
@@ -1663,7 +1740,7 @@ async function main() {
1663
1740
  ...(share && { share }),
1664
1741
  next: pending
1665
1742
  ? 'Ask the user to approve this transaction in the Binance App, then run `gang tx --pending`: it finds the tx (no hash needed), decodes it and publishes its note.'
1666
- : (d.txHash ? `gang tx --hash ${d.txHash}` : undefined),
1743
+ : (d.txHash ? `gang tx --hash ${d.txHash}` : 'No tx hash and nothing pending: do not count this as sent. Read status, and check the balance before trying again.'),
1667
1744
  })
1668
1745
  }
1669
1746
  case 'tx': {
@@ -1685,7 +1762,7 @@ async function main() {
1685
1762
  return out(await txReport(hash))
1686
1763
  }
1687
1764
  default:
1688
- console.log(HELP); process.exit(cmd ? 1 : 0)
1765
+ console.log(HELP); process.exit(!cmd || cmd === '--help' || cmd === '-h' || cmd === 'help' ? 0 : 1)
1689
1766
  }
1690
1767
  }
1691
1768
 
package/src/launch.js CHANGED
@@ -8,6 +8,7 @@ import { bondAddress, BOND_ABI } from './bond.js'
8
8
  import { walletFor } from './fair.js'
9
9
  import { parseAmount, parseIntIn, step } from './steps.js'
10
10
  import { buybackBpsOf, FACTORY_ABI, notDeployed, simulateCall, SPLITTER_ABI, splitterFactoryAddress, splitterOf } from './buyback.js'
11
+ import { parsePromote, poolFactoryAddress, poolNotDeployed, poolOf, POOL_ABI, POOL_FACTORY_ABI, PROMOTE_PAD_ABI, revertOf as promoteRevertOf, simulatePool, wantsPoolModule } from './promote.js'
11
12
  import { parseSplitSpec, simulateSplit, SPLIT_ABI, SPLIT_FACTORY_ABI, splitFactoryAddress, splitLine, splitNotDeployed, splitOf } from './split.js'
12
13
  import { LP_ABI, LP_FACTORY_ABI, lpBpsOf, lpFactoryAddress, lpNotDeployed, lpOf, simulateLp } from './lp.js'
13
14
  import { claimCmd, notThroughModule } from './creatorfee.js'
@@ -47,7 +48,7 @@ import { COMBO_ABI, COMBO_FACTORY_ABI, comboFactoryAddress, comboLine, comboNotD
47
48
  */
48
49
 
49
50
  // the dev's recipient modules by flag, as the creator-fee note names them
50
- const MODULE_NAMES = { buyback: 'buy-back splitter', split: 'split module', lp: 'LP splitter', combo: 'combined recipient' }
51
+ const MODULE_NAMES = { buyback: 'buy-back splitter', split: 'split module', lp: 'LP splitter', combo: 'combined recipient', promote: 'promoter pool module' }
51
52
  const LAUNCH_DIR = process.env.GANG_LAUNCH_DIR || join(dirname(DIR), 'launch')
52
53
  const TTL_MS = 7 * 24 * 3600_000
53
54
  const PAD_ABI = parseAbi([
@@ -86,6 +87,10 @@ const UNTRUSTED = {
86
87
  why: '--lp needs WBNB, GANG or a quote listed in the pad\'s QuoteRegistry: the keeper adds liquidity only over those quotes, and an unlisted quote may tax or block the transfers into the pair every chunk makes',
87
88
  hint: 'drop --quote (WBNB), use a listed quote, or launch without --lp',
88
89
  },
90
+ promote: {
91
+ why: '--promote on a taxed token makes the recipient a promoter pool module, which needs WBNB, GANG or a quote listed in the pad\'s QuoteRegistry: its escrow counts on the quote arriving in full, and the keeper splits only those quotes',
92
+ hint: 'drop --quote (WBNB), use a listed quote, or name a recipient with --recipient (the share then stays on the curve)',
93
+ },
89
94
  combo: {
90
95
  why: 'a combined recipient (more than one of --buyback / --lp / --split) needs WBNB, GANG or a quote listed in the pad\'s QuoteRegistry: its buy-backs and liquidity adds price on what the pair receives (a quote that taxes transfers into the pair fails every chunk), the keeper serves only those quotes, and an unlisted quote may call a payee back on transfer',
91
96
  hint: 'drop --quote (WBNB), use a listed quote, or launch without --buyback / --lp / --split',
@@ -114,11 +119,11 @@ const NOTE_FLAGS = ['note', 'conf', 'reveal-after']
114
119
  export const FAIR_DEV_BUY = 'a 打新 dev buys its shares in the create itself: use --shares <n> (not --dev-buy)'
115
120
 
116
121
  /** The run asks for a chained launch (`kind` 'v3' | 'fair'). */
117
- export const isLaunch = (kind, flag) => flag('bond') || flag('buyback') || flag('split') || flag('lp') || (kind === 'v3' && flag('dev-buy'))
122
+ export const isLaunch = (kind, flag, opt = () => undefined) => flag('bond') || flag('buyback') || flag('split') || flag('lp') || (kind === 'v3' && flag('dev-buy')) || wantsPoolModule(kind, flag, opt)
118
123
  /** The recipient modules a launch can clone (their flags): one alone clones its own module, several a combined one. */
119
124
  const MODULE_FLAGS = ['buyback', 'split', 'lp']
120
125
  /** How a module's flags read in a message. */
121
- const MOD_FLAG = { buyback: '--buyback', split: '--split', lp: '--lp', combo: 'more than one of --buyback / --lp / --split' }
126
+ const MOD_FLAG = { buyback: '--buyback', split: '--split', lp: '--lp', combo: 'more than one of --buyback / --lp / --split', promote: '--promote on a taxed token' }
122
127
 
123
128
  const planPath = (key) => join(LAUNCH_DIR, `${createHash('sha256').update(key).digest('hex').slice(0, 32)}.json`)
124
129
 
@@ -276,7 +281,28 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
276
281
  }
277
282
  lp = { bps: lpBpsOf(fail, opt('lp')), factory, payee }
278
283
  }
279
- const mod = comboSpec ? 'combo' : buyback ? 'buyback' : split ? 'split' : lp ? 'lp' : null
284
+ // --promote on a taxed token with no recipient named: its recipient is the dev's promoter pool module
285
+ if (flag('promote')) {
286
+ const terms = parsePromote(opt('promote'), opt('promote-days'))
287
+ if (terms.error) {
288
+ const { error, ...extra } = terms
289
+ fail(error, extra)
290
+ }
291
+ } else if (flag('promote-days')) fail('--promote-days goes with --promote <pct>')
292
+ let poolMod = null
293
+ if (wantsPoolModule(kind, flag, opt)) {
294
+ const factory = poolFactoryAddress(testnet)
295
+ if (!factory) fail(poolNotDeployed(testnet))
296
+ // what the create would refuse, said before a module is cloned for it
297
+ const inRange = (f) => flag(f) && Number(opt(f)) >= 1 && Number(opt(f)) <= 5
298
+ if (!inRange('buy-tax') || !inRange('sell-tax')) {
299
+ fail('--promote on a taxed token needs both --buy-tax and --sell-tax, each 1–5 (in %): the pool share is paid from the tax. For an untaxed token leave them out', { buyTax: opt('buy-tax') ?? null, sellTax: opt('sell-tax') ?? null })
300
+ }
301
+ const div = Number(opt('dividend', '0'))
302
+ if (!(div >= 0 && div <= 100)) fail('--dividend must be a number between 0 and 100 (in %)', { got: opt('dividend') })
303
+ poolMod = { factory }
304
+ }
305
+ const mod = comboSpec ? 'combo' : buyback ? 'buyback' : split ? 'split' : lp ? 'lp' : poolMod ? 'promote' : null
280
306
 
281
307
  const client = createPublicClient({ chain: net.chain, transport: rpcTransport(net.rpcs) })
282
308
  const read = (address, abi, functionName, args = []) => client.readContract({ address, abi, functionName, args })
@@ -287,7 +313,7 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
287
313
  if (!tiers.includes(Number(opt('grad')))) fail(`--grad must be one of ${tiers.join(' / ')} (BNB raised)`, { got: opt('grad') ?? null })
288
314
  }
289
315
  const key = [net.chainId, net.pad, me.toLowerCase(), kind, name, symbol].join('|')
290
- const cloneStep = { buyback: 'buyback-splitter', split: 'split-module', lp: 'lp-splitter', combo: 'combo-module' }[mod]
316
+ const cloneStep = { buyback: 'buyback-splitter', split: 'split-module', lp: 'lp-splitter', combo: 'combo-module', promote: 'promote-module' }[mod]
291
317
  const steps = [...(mod ? [cloneStep] : []), kind === 'v3' ? 'create' : 'create (dev shares included)', ...(mod ? ['bind'] : []),
292
318
  ...(devBuy ? ['dev-buy'] : []), ...(bond ? ['bond'] : [])]
293
319
  const rerun = 're-run this same command after executing it'
@@ -316,8 +342,8 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
316
342
  // ---- a launch keeps the mode it began with (the create, once built, is never redone by a changed flag)
317
343
  const created = plan?.startCount !== undefined
318
344
  // the module this plan cloned: 'split' / 'lp' / 'combo' when it says so, else a --buyback splitter (plans from before --split)
319
- const planMod = plan?.salt ? (['split', 'lp', 'combo'].includes(plan.module) ? plan.module : 'buyback') : null
320
- const modNoun = { buyback: 'splitter', split: 'split module', lp: 'LP splitter', combo: 'combined recipient' }
345
+ const planMod = plan?.salt ? (['split', 'lp', 'combo', 'promote'].includes(plan.module) ? plan.module : 'buyback') : null
346
+ const modNoun = { buyback: 'splitter', split: 'split module', lp: 'LP splitter', combo: 'combined recipient', promote: 'promoter pool module' }
321
347
  if (mod && created && !plan.splitter) {
322
348
  return fail(`this launch was created without ${MOD_FLAG[mod]} (its recipient is fixed): run it again without ${mod === 'combo' ? '--buyback / --lp / --split' : MOD_FLAG[mod]}, or add --restart for a new token`)
323
349
  }
@@ -507,12 +533,51 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
507
533
  }
508
534
  }
509
535
 
536
+ // ---- promoter pool module: cloned for the dev before the create, at predict(dev, plan.salt)
537
+ if (poolMod && !created) {
538
+ if (!plan?.salt) {
539
+ const refused = await untrustedBuybackQuote(read, net, flag('quote') ? opt('quote') : net.wbnb, 'promote')
540
+ if (refused) {
541
+ const { error, ...extra } = refused
542
+ return fail(error, extra)
543
+ }
544
+ if ((await client.getCode({ address: poolMod.factory }) ?? '0x') === '0x') {
545
+ return fail(`GangPromotePoolModuleFactory has no code at ${poolMod.factory} on ${testnet ? 'the BSC testnet' : 'BSC mainnet'}: name a recipient with --recipient for now (the share then stays on the curve)`)
546
+ }
547
+ const salt = `0x${randomBytes(32).toString('hex')}`
548
+ const at = await read(poolMod.factory, POOL_FACTORY_ABI, 'predict', [me, salt])
549
+ const sim = await simulatePool(client, me, poolMod.factory, POOL_FACTORY_ABI, 'create', [salt])
550
+ if (sim.failed) return out({ success: false, step: 'promote-module', factory: poolMod.factory, ...tag('promote-module'), ...sim.failed })
551
+ writePlan(key, { ...base, salt, splitter: at, factory: poolMod.factory, module: 'promote' })
552
+ const data = encodeFunctionData({ abi: POOL_FACTORY_ABI, functionName: 'create', args: [salt] })
553
+ return out({
554
+ ...step({ chainId: net.chainId }, { from: me, to: poolMod.factory, data }, {
555
+ step: 'promote-module', chainId: Number(net.chainId), factory: poolMod.factory, module: at,
556
+ note: 'clones your promoter pool module (listed as a tax recipient in the same tx). The token\'s promoter terms, set at the create, decide how much of the recipient\'s part it escrows for promoters; the rest is pushed to you. PERMANENT once the token names it: a token has one recipient',
557
+ }, flag('calldata'), io.summarize),
558
+ ...tag('promote-module', { module: at, next: `${rerun}: it then builds the create with the module as the recipient` }),
559
+ })
560
+ }
561
+ if ((await client.getCode({ address: plan.splitter }) ?? '0x') === '0x') {
562
+ return out({
563
+ success: false, ...tag('promote-module', { module: plan.splitter }), error: 'the promoter pool module is not on chain yet',
564
+ hint: `if the clone was executed, wait for it to land and ${rerun.replace(' after executing it', '')}; if it was not, add --restart to build it again`,
565
+ })
566
+ }
567
+ const s = await poolOf(read, (a) => client.getCode({ address: a }), plan.splitter, plan.factory)
568
+ if (!s || s.dev.toLowerCase() !== me.toLowerCase() || s.token) {
569
+ return fail('the module at this launch\'s address is not an unbound promoter pool module of this wallet: add --restart', { module: plan.splitter })
570
+ }
571
+ }
572
+
510
573
  // ---- create
511
574
  if (!created) {
512
575
  const startCount = (await read(net.pad, PAD_ABI, 'tokenCount')).toString()
513
576
  const createIo = {
514
577
  ...io,
515
578
  ...argsWith(io, plan?.splitter ? { recipient: plan.splitter } : {}, LAUNCH_FLAGS),
579
+ // the module this launch cloned and will bind: runV3 tells it from a --recipient someone typed
580
+ ...(plan?.module === 'promote' && { launchPoolModule: plan.splitter }),
516
581
  out: (o) => {
517
582
  // the plan starts with the create tx itself: a wrap / approve step before it (or a failed preview) leaves none,
518
583
  // so the next run builds the create again
@@ -522,7 +587,7 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
522
587
  return out({
523
588
  ...o,
524
589
  // 2.0: the creator fee is the dev's own, not the module's
525
- ...(o.creatorFee && mod && { creatorFee: `${o.creatorFee} ${notThroughModule(MODULE_NAMES[mod], { at: plan?.splitter, net: testnet ? ' --testnet' : '', kind: mod })}` }),
590
+ ...(o.creatorFee && mod && { creatorFee: `${o.creatorFee} ${notThroughModule(MODULE_NAMES[mod], { at: mod === 'promote' ? undefined : plan?.splitter, net: testnet ? ' --testnet' : '', kind: mod })}` }),
526
591
  ...tag('create', built ? { next: `${rerun}: it finds the new token and continues with ${after ?? 'nothing'}` } : o.success ? { next: `${rerun}: it then builds the create` } : {}),
527
592
  })
528
593
  },
@@ -554,13 +619,27 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
554
619
  })
555
620
  }
556
621
 
622
+ // a launch keeps the terms it began with: the create is never redone by a changed flag
623
+ if (flag('promote') && kind === 'v3') {
624
+ const want = parsePromote(opt('promote'), opt('promote-days'))
625
+ // only a revert means no terms: after an RPC error, "add --restart" would make a second token for nothing
626
+ const [share, window] = await read(net.pad, PROMOTE_PAD_ABI, 'promoteOf', [token]).catch((e) => {
627
+ if (promoteRevertOf(e)) return [0, 0]
628
+ return fail('could not read this launch\'s promoter terms (RPC error)', { token, retry: 'same command again' })
629
+ })
630
+ if (Number(share) !== want.shareBps || Number(window) !== want.window) {
631
+ return fail(`this launch's token has ${Number(share) ? `a ${Number(share) / 100}% promoter share for ${Number(window) / 86_400} days` : 'no promoter terms'}, fixed at its create: run it again without changing them, or add --restart for a new token`, { token })
632
+ }
633
+ }
634
+
557
635
  // later steps carry no note (it went on the create) and take the token from the plan
558
636
  const stepIo = (over) => ({ ...io, ...argsWith(io, { ...over, token }, [...LAUNCH_FLAGS, ...NOTE_FLAGS, 'name', 'symbol']) })
559
637
  const bal = await read(token, ERC20_ABI, 'balanceOf', [me])
560
638
  const isSplit = plan.module === 'split'
561
639
  const isLp = plan.module === 'lp'
562
640
  const isCombo = plan.module === 'combo'
563
- const buybackState = () => (plan.splitter && !isSplit && !isLp && !isCombo ? splitterOf(read, plan.splitter) : null)
641
+ const isPromote = plan.module === 'promote'
642
+ const buybackState = () => (plan.splitter && !isSplit && !isLp && !isCombo && !isPromote ? splitterOf(read, plan.splitter) : null)
564
643
  const comboState = () => (plan.splitter && isCombo ? comboOf(read, plan.splitter, { wbnb: net.wbnb, pad: net.pad, ref: `--token ${token}${testnet ? ' --testnet' : ''}` }) : null)
565
644
  const lpState = () => (plan.splitter && isLp ? lpOf(read, plan.splitter, { pad: net.pad }) : null)
566
645
  const splitState = () => (plan.splitter && isSplit ? splitOf(read, plan.splitter, { wbnb: net.wbnb, ref: `--token ${token}${testnet ? ' --testnet' : ''}` }) : null)
@@ -579,10 +658,12 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
579
658
  if (lps) done.lp = lps
580
659
  const cs = await comboState()
581
660
  if (cs) done.combo = cs
661
+ if (plan.splitter && isPromote) done.promote = { module: plan.splitter, next: `gang promote status --token ${token}${testnet ? ' --testnet' : ''}`, note: `your part of the pool tax comes two ways: pushed to you at once, and what the escrow holds for trades with no promoter, which stays in the module until you claim it: gang promote claim-pool --token ${token}${testnet ? ' --testnet' : ''}` }
582
662
  // 2.0: where the creator fee of a V3 token is claimed (and that a module does not get it)
583
663
  const share = kind === 'v3' ? await creatorFeeShareOf({ chainId: net.chainId, pad: net.pad, read }).catch(() => null) : null
584
664
  if (share != null) {
585
- done.creatorFee = `${share / 100}% of the 1% curve fee is kept for you, the creator: ${claimCmd(token, testnet ? ' --testnet' : '')}${plan.splitter ? `. ${notThroughModule(MODULE_NAMES[planMod], { token, at: plan.splitter, net: testnet ? ' --testnet' : '', kind: planMod })}` : ''}`
665
+ const [promoterShare] = await read(net.pad, PROMOTE_PAD_ABI, 'promoteOf', [token]).catch(() => [0])
666
+ done.creatorFee = `${share / 100}% of the 1% curve fee is kept for you, the creator${Number(promoterShare) ? `, less the ${Number(promoterShare) / 100}% of it you gave promoters on their bound wallets' trades` : ''}: ${claimCmd(token, testnet ? ' --testnet' : '')}${plan.splitter ? `. ${notThroughModule(MODULE_NAMES[planMod], { token, at: isPromote ? undefined : plan.splitter, net: testnet ? ' --testnet' : '', kind: planMod })}` : ''}`
586
667
  }
587
668
  if (!bond) return out({ ...done, note: `launched: gang ${kind} info --token ${token}${testnet ? ' --testnet' : ''}` })
588
669
  return runBond('status', { ...stepIo({}), out: (o) => out({ ...done, bondStatus: o, note: `launched and bonded: gang bond status --token ${token}${testnet ? ' --testnet' : ''}` }) })
@@ -591,16 +672,18 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
591
672
 
592
673
  // ---- bind the splitter / split module / LP splitter / combined recipient to the token (anyone may; the launch does it right after the create)
593
674
  if (plan.splitter) {
594
- const abi = isCombo ? COMBO_ABI : isSplit ? SPLIT_ABI : isLp ? LP_ABI : SPLITTER_ABI
675
+ const abi = isPromote ? POOL_ABI : isCombo ? COMBO_ABI : isSplit ? SPLIT_ABI : isLp ? LP_ABI : SPLITTER_ABI
595
676
  const bound = await read(plan.splitter, abi, 'token')
596
677
  if (bound === zeroAddress) {
597
- const sim = await (isCombo ? simulateCombo : isSplit ? simulateSplit : isLp ? simulateLp : simulateCall)(client, me, plan.splitter, abi, 'bind', [token])
678
+ const sim = await (isPromote ? simulatePool : isCombo ? simulateCombo : isSplit ? simulateSplit : isLp ? simulateLp : simulateCall)(client, me, plan.splitter, abi, 'bind', [token])
598
679
  if (sim.failed) return out({ success: false, step: 'bind', ...tag('bind', { token }), ...sim.failed })
599
680
  const data = encodeFunctionData({ abi, functionName: 'bind', args: [token] })
600
681
  return out({
601
682
  ...step({ chainId: net.chainId }, { from: me, to: plan.splitter, data }, {
602
- step: 'bind', chainId: Number(net.chainId), token, ...(isSplit || isCombo ? { module: plan.splitter } : { splitter: plan.splitter }),
603
- note: isCombo
683
+ step: 'bind', chainId: Number(net.chainId), token, ...(isSplit || isCombo || isPromote ? { module: plan.splitter } : { splitter: plan.splitter }),
684
+ note: isPromote
685
+ ? 'ties the promoter pool module to this token for good, reading its promoter terms. It must happen before graduation: a token bound later has no pool share'
686
+ : isCombo
604
687
  ? 'ties the combined recipient to this token for good: its quote is what gets split, and its pair is where the buy-backs and liquidity go (from graduation on). Nothing is split before this'
605
688
  : isSplit
606
689
  ? 'ties the split module to this token for good: the keeper then splits its quote among the payees'
@@ -612,7 +695,7 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
612
695
  })
613
696
  }
614
697
  if (bound.toLowerCase() !== token.toLowerCase()) {
615
- return out({ success: false, ...tag('bind', { token }), error: `the ${isCombo ? 'combined recipient' : isSplit ? 'split module' : isLp ? 'LP splitter' : 'splitter'} is bound to another token`, [isSplit || isCombo ? 'module' : 'splitter']: plan.splitter, boundTo: bound })
698
+ return out({ success: false, ...tag('bind', { token }), error: `the ${isPromote ? 'promoter pool module' : isCombo ? 'combined recipient' : isSplit ? 'split module' : isLp ? 'LP splitter' : 'splitter'} is bound to another token`, [isSplit || isCombo || isPromote ? 'module' : 'splitter']: plan.splitter, boundTo: bound })
616
699
  }
617
700
  }
618
701