@gangfun/cli 0.38.0 → 0.39.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/gangpad.js CHANGED
@@ -58,6 +58,9 @@ export const GANG_GENS = {
58
58
  // capped-v1, 2026-11-08, block 132418984; the Safe allowed it on GangHandlerAdmin at block 132420220
59
59
  // (docs/MAINNET-CAPPED-MODULE-2026-11-08.md)
60
60
  cappedFactory: '0x294E901ecb66af280C1cDD26fD871601d89a2Dca',
61
+ // floor-v1, 2026-11-12, block 133121257; the Safe allowed it on GangHandlerAdmin at block 133123169
62
+ // (docs/MAINNET-FLOOR-MODULE-2026-11-12.md)
63
+ floorFactory: '0x057d2C1557a0E8298a1E00834D6064497f5DC2fC',
61
64
  // the pool side of the promoter share, 2026-11-07, block 132218466; the Safe allowed it on GangHandlerAdmin at block
62
65
  // 132219892 (docs/MAINNET-GANG-LAUNCHPAD-3-PROMOTE-2026-11-07.md)
63
66
  promotePoolFactory: '0xA633e499ADcD69A4F91dc83587096b2c1903167A',
@@ -109,6 +112,9 @@ export const GANG_GENS = {
109
112
  comboFactory: '0xdc1687961c8aAf5A0340c1A73b604cf3a2be543C',
110
113
  // capped-v1, 2026-11-08 (deployed at block 141527185, allowed on the GangHandlerAdmin at block 141527190)
111
114
  cappedFactory: '0xe3f61865d98993dd39c136Af19651C6F6686498A',
115
+ // floor-v1, 2026-11-11 (deployed at block 142099242, allowed on the GangHandlerAdmin at block 142099247;
116
+ // docs/TESTNET-FLOOR-MODULE-2026-11-11.md)
117
+ floorFactory: '0x0804C018201D8fFe378b873b41B67f136dbdc3F8',
112
118
  // the pool side of the promoter share, 2026-11-05 (docs/TESTNET-GANG-LAUNCHPAD-3-2026-11-03.md)
113
119
  promotePoolFactory: '0x7a68A65d27591a21C44f91015F930422BA79F1c2',
114
120
  // GangCallBond, 2026-11-09, block 141708762 (docs/TESTNET-CALL-BOND-2026-11-09.md)
@@ -151,19 +157,19 @@ export const GANG_GENS = {
151
157
  ],
152
158
  }
153
159
  // 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)
154
- const GEN_FIELDS = ['gen', 'pad', 'router', 'bond', 'splitterFactory', 'splitFactory', 'lpFactory', 'comboFactory', 'cappedFactory', 'promotePoolFactory', 'callBond']
160
+ const GEN_FIELDS = ['gen', 'pad', 'router', 'bond', 'splitterFactory', 'splitFactory', 'lpFactory', 'comboFactory', 'cappedFactory', 'floorFactory', 'promotePoolFactory', 'callBond']
155
161
  // the env names of each field, per network (new name first; the old per-command names still work as aliases)
156
162
  const GEN_ENV = {
157
163
  mainnet: {
158
164
  pad: ['GANG_PAD', 'GANG_V3_PAD', 'GANG_FAIR_PAD'], router: ['GANG_ROUTER'], bond: ['GANG_BOND'],
159
165
  splitterFactory: ['GANG_SPLITTER_FACTORY'], splitFactory: ['GANG_SPLIT_FACTORY'], lpFactory: ['GANG_LP_FACTORY'],
160
- comboFactory: ['GANG_COMBO_FACTORY'], cappedFactory: ['GANG_CAPPED_FACTORY'], promotePoolFactory: ['GANG_PROMOTE_POOL_FACTORY'],
166
+ comboFactory: ['GANG_COMBO_FACTORY'], cappedFactory: ['GANG_CAPPED_FACTORY'], floorFactory: ['GANG_FLOOR_FACTORY'], promotePoolFactory: ['GANG_PROMOTE_POOL_FACTORY'],
161
167
  callBond: ['GANG_CALL_BOND'],
162
168
  },
163
169
  testnet: {
164
170
  pad: ['GANG_TESTNET_PAD', 'GANG_V3_TESTNET_PAD', 'GANG_FAIR_TESTNET_PAD'], router: ['GANG_TESTNET_ROUTER', 'GANG_ROUTER_TESTNET'],
165
171
  bond: ['GANG_TESTNET_BOND'], splitterFactory: ['GANG_TESTNET_SPLITTER_FACTORY'], splitFactory: ['GANG_TESTNET_SPLIT_FACTORY'],
166
- lpFactory: ['GANG_TESTNET_LP_FACTORY'], comboFactory: ['GANG_TESTNET_COMBO_FACTORY'], cappedFactory: ['GANG_TESTNET_CAPPED_FACTORY'],
172
+ lpFactory: ['GANG_TESTNET_LP_FACTORY'], comboFactory: ['GANG_TESTNET_COMBO_FACTORY'], cappedFactory: ['GANG_TESTNET_CAPPED_FACTORY'], floorFactory: ['GANG_TESTNET_FLOOR_FACTORY'],
167
173
  promotePoolFactory: ['GANG_TESTNET_PROMOTE_POOL_FACTORY'], callBond: ['GANG_TESTNET_CALL_BOND'],
168
174
  },
169
175
  }
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CONFIG, ADDR, listTokens, tokenInfo, quoteBuy, quoteSell, isAgent, balanceOf, allowance,
4
- calldata, decodeTx, decodeLogs, parseEther, fmt, fmtTok, resolvePad, isAddress, client,
4
+ calldata, decodeTx, decodeLogs, firstByModuleType, parseEther, fmt, fmtTok, resolvePad, isAddress, client,
5
5
  } from './chain.js'
6
6
  import { baw, bawAddress, bawError, bawFailed, bawSettings, bawStatus, bawPreview, bawExecute } from './baw.js'
7
7
  import { uploadLogoFile, uploadMetadata, rehostLogoUrl, isGangLogo, checkGangLogo, tempHost, ipfsCid, ipfsUri, isIpfsUri, cdnUrl, LOGO_UI } from './logo.js'
@@ -27,9 +27,10 @@ import { runPromote, PROMOTE_EVENT_ABIS } from './promote.js'
27
27
  import { runLp, LP_EVENT_ABIS } from './lp.js'
28
28
  import { runCombo, COMBO_EVENT_ABIS } from './combo.js'
29
29
  import { runCapped, CAPPED_EVENT_ABIS } from './capped.js'
30
+ import { runFloor, FLOOR_ABI, FLOOR_EVENT_ABIS } from './floor.js'
30
31
  import { runWeekly } from './weekly.js'
31
32
  import { runFly, flyCtx, isFlyToken, FLY_EVENT_ABIS, FLY_CREATE_FLAGS } from './fly.js'
32
- import { FAIR_DEV_BUY, isLaunch, LAUNCH_FLAGS, runLaunch, TAX_CAP_ALONE } from './launch.js'
33
+ import { FAIR_DEV_BUY, isLaunch, LAUNCH_FLAGS, REDEEM_FEE_ALONE, runLaunch, TAX_CAP_ALONE } from './launch.js'
33
34
  import { poolPayBnb, poolTrade } from './pool.js'
34
35
  import { parseAmount, ROUTER_ABI, ROUTER_HINTS, revertOf as revertIn, step as writeStep } from './steps.js'
35
36
  import { MERGED_ERRORS_ABI, genOf, padNets } from './gangpad.js'
@@ -41,7 +42,7 @@ import { codeOf, record } from './telemetry.js'
41
42
  import { trending, trendingBlock, TRENDING_NOTE } from './trending.js'
42
43
  import { shareFor } from './share.js'
43
44
  import { BUY_ACCEPTS, CREATE_ACCEPTS, FAIR_CREATE_FLAGS, LINK_FLAGS, suggestFlag, V3_CREATE_FLAGS, unknownFlagError } from './flags.js'
44
- import { parseAbi } from 'viem'
45
+ import { encodeEventTopics, parseAbi } from 'viem'
45
46
 
46
47
  const args = process.argv.slice(2)
47
48
  const cmd = args[0]
@@ -516,6 +517,26 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
516
517
  recipient (GangCappedSplitterFactory; listed in the same tx) → create → bind → the
517
518
  rest of the launch. Quote: WBNB (default), GANG or one listed in the pad's
518
519
  QuoteRegistry only.
520
+ gang create … --buy-tax <1-5> --sell-tax <1-5> --floor [--redeem-fee <0-5>] [--tax-cap <amount> [--tax-cap-share <0.01-100>]
521
+ [--split <addr>:<pct>[,…]]] [--dev-buy …]
522
+ V3, taxed, floor module (GangFloorModule, floor-v1): the
523
+ recipient's part of the pool tax is KEPT as a treasury, nothing is bought back or
524
+ added. After graduation any holder can give up tokens for their share of it:
525
+ amount × treasury ÷ (supply − what 0xdead holds), less --redeem-fee % (default 2)
526
+ that stays for the holders who remain (gang floor redeem; the tokens go to 0xdead).
527
+ With --tax-cap, --tax-cap-share % (default 100) of the recipient's part goes to the
528
+ --split payees (default: you) until they have been credited --tax-cap in all, as a
529
+ capped recipient pays them; the rest, and after the cap all of it, is the treasury.
530
+ Without --tax-cap nobody takes a share. The floor is not a price promise: it starts
531
+ at 0, grows only with pool volume and is usually far below the market price; the
532
+ preview shows the % of pool volume that reaches the treasury.
533
+ PERMANENT: the token it serves, the quote, the fee, the cap, payees and shares can
534
+ never change. Steps: the CLI computes the token's address (its name, symbol, tax
535
+ rates and metadata decide it: they are fixed from this step on), clones your floor
536
+ module for that address (GangFloorModuleFactory) → create (at that address, checked
537
+ with the pad before the tx) → bind → the rest of the launch. Not with --buyback /
538
+ --lp / --after-cap / --recipient / --vault; with --promote the promoter share stays
539
+ on the curve. Quote: WBNB (default), GANG or one listed in the pad's QuoteRegistry.
519
540
  gang create --fair … [--shares <n>] --bond <quote> [--bond-hold …] --bond-days <7-90>
520
541
  打新: create (the dev's --shares are bought in it) → bond. Progress is read from the
521
542
  chain (a token this wallet created with this symbol since the plan); a run that finds
@@ -747,12 +768,39 @@ CAPPED (a V3 token whose recipient is a capped recipient, capped-v1, 0.35.0+; GA
747
768
  gang capped chunk --token <addr> [--slippage 1]
748
769
  anyone: one chunk now, as gang combo chunk. --module <addr> instead of --token names
749
770
  a module directly (not for bind). Gas, --testnet, --calldata, --from as gang combo
771
+ FLOOR (a V3 token whose recipient is a floor module, floor-v1; GANG_FLOOR_FACTORY / GANG_TESTNET_FLOOR_FACTORY):
772
+ gang floor status --token <addr> [--asset <addr>]
773
+ the treasury, the supply it is measured against, what one token redeems for before
774
+ and after the fee, the fee, the cap and payees (if any), what waits to be split or
775
+ pushed, next commands — and whether GangFloorModuleFactory made this module
776
+ (verified) and whether it was cloned for this token: if not, a warning, and no
777
+ other gang floor command is built
778
+ gang floor redeem --token <addr> --amount <tokens>|all [--to <addr>] [--slippage 0]
779
+ a holder, after graduation: give up tokens (they go to 0xdead, IRREVERSIBLE) for
780
+ their share of the treasury less the fee, paid in the quote to --to (default: this
781
+ wallet). The preview shows what selling the same tokens in the pool would pay and
782
+ warns when that is more. Step approve first (the module pulls the tokens), then
783
+ the redemption; its minimum is the previewed amount (--slippage % under it).
784
+ For a creator's GangBond or call bond a redemption is a sell: one that would
785
+ break it is refused unless --break-bond / --break-call-bond (--settle-first as
786
+ in gang sell)
787
+ gang floor distribute --token <addr> [--asset <addr>|wbnb]
788
+ anyone, once bound: splits the quote that arrived and pushes the payees their part,
789
+ with what redemptions set aside for them (a redemption pushes nobody); any other
790
+ asset goes to 0xdead in full (BURNED, paid to nobody)
791
+ gang floor release --token <addr> [--index <i>] [--max <amount>]
792
+ anyone: push a slot what a failed push left owed (as gang capped release)
793
+ gang floor set-payee --token <addr> --to <addr> [--index <i>]
794
+ only the slot's current payee: moves the slot to --to at once
795
+ gang floor bind --token <addr> anyone: bind the module to the token it was cloned for (the launch does it).
796
+ --module <addr> instead of --token names a module directly (not for redeem).
797
+ Gas, --testnet, --calldata, --from as gang capped
750
798
  gang execute --request-id <id> broadcast a previewed call
751
799
  gang tx --pending a trade that waited for Binance App approval (execute: pendingConfirmation): find its tx
752
800
  in the wallet's history by the exact call previewed, then as gang tx --hash below
753
801
  gang tx --hash <0x..> [--testnet] wait for receipt and decode Gang events: V2 / Soft / U / S, GangLaunchpad (V3 /
754
802
  打新, 铸币飞轮, tax routers, vaults), GangFlywheelPad (铸币飞轮 pads), split modules,
755
- LP splitters, combined and capped recipients (publishes a queued --note; mainnet). GangLaunchpad events
803
+ LP splitters, combined and capped recipients, floor modules (publishes a queued --note; mainnet). GangLaunchpad events
756
804
  carry units: "raw" (amounts in wei, 18 decimals; bps / shares as is)
757
805
 
758
806
  --note is PUBLIC: shown on gang.fun next to the trade. Its hash goes into the tx calldata, so it is provably written
@@ -1294,7 +1342,7 @@ function alias(kind, sub) {
1294
1342
 
1295
1343
  // 铸币飞轮 settings beyond those it shares with 打新 (--raise / --hold / --mint-fee / --exit-fee) and V3 (--sell-tax)
1296
1344
  const FLY_ONLY_FLAGS = FLY_CREATE_FLAGS.filter((f) => !['raise', 'hold', 'mint-fee', 'exit-fee', 'sell-tax'].includes(f))
1297
- const FLY_NO_BOND = '铸币飞轮 tokens take no GangBond, buy-back splitter, split module, LP splitter, combined recipient, capped recipient or --dev-buy (phase 1): the creator mints its shares in the create with --dev-shares <n>'
1345
+ const FLY_NO_BOND = '铸币飞轮 tokens take no GangBond, buy-back splitter, split module, LP splitter, combined recipient, floor module, capped recipient or --dev-buy (phase 1): the creator mints its shares in the create with --dev-shares <n>'
1298
1346
  /** The flags a 铸币飞轮 create refuses (gang create --fly and gang fly create alike). */
1299
1347
  function checkFlyCreate() {
1300
1348
  if (flag('fair')) fail('give --fly (铸币飞轮) or --fair (打新), not both')
@@ -1307,7 +1355,7 @@ function checkFlyCreate() {
1307
1355
  : `--${wrong} is a V3 tax setting; a 铸币飞轮 token's tax goes to holders, the platform and the creator in fixed parts`)
1308
1356
  }
1309
1357
  }
1310
- const VAULT_ALONE = 'a --vault create stands alone: no chained dev buy, GangBond or buy-back / split / LP / combined / capped recipient (the 2.0 金库版 pad has none of them); a dev buy is its own gang buy after the create lands'
1358
+ const VAULT_ALONE = 'a --vault create stands alone: no chained dev buy, GangBond or buy-back / split / LP / combined / floor / capped recipient (the 2.0 金库版 pad has none of them); a dev buy is its own gang buy after the create lands'
1311
1359
  // --grad picks a V3 curve's graduation target (2.0 / 3.0); a 打新 / 铸币飞轮 sale ends at its own --raise
1312
1360
  const GRAD_ONLY_V3 = (what) => `--grad is a V3 curve setting (the graduation target, 2.0 / 3.0): ${what} fills at its --raise instead, so leave --grad out`
1313
1361
  function create() {
@@ -1341,9 +1389,19 @@ const PREFLIGHT_NEXT = [
1341
1389
  // commands whose JSON result carries `update`; `watch` streams NDJSON and help is plain text
1342
1390
  const UPDATE_CHECKED = new Set(['version', '--version', '-v', 'preflight', 'list', 'trending', 'invite', 'weekly', 'hot', 'new', 'near-grad', 'notes', 'agents', 'token', 'info', 'status', 'portfolio', 'quote',
1343
1391
  'buy', 'follow', 'sell', 'claim', 'mint', 'withdraw', 'release', 'upload-logo', 'create', 'execute', 'tx', 'fair', 'v3', 'bond',
1344
- 'buyback', 'split', 'lp', 'combo', 'capped', 'fly', 'creator-fee', 'promote', 'call-bond'])
1392
+ 'buyback', 'split', 'lp', 'combo', 'capped', 'floor', 'fly', 'creator-fee', 'promote', 'call-bond'])
1345
1393
  // gang tx decodes these beside the V2 / Soft / U / S pads' events (GangLaunchpad: both kinds; the tax router; the vaults)
1346
- 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, ...PROMOTE_EVENT_ABIS, CALL_BOND_ABI]
1394
+ 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, ...PROMOTE_EVENT_ABIS, CALL_BOND_ABI]
1395
+ // Split with three amounts is the event of four module kinds, and the amounts mean different things in each (a buy-back
1396
+ // splitter's toBuyback / toDev, an LP splitter's toLp / toDev, a promoter pool's toEscrow / toDev, a floor module's
1397
+ // toTreasury / toPayees): gang tx asks the
1398
+ // emitting module what it is before naming them
1399
+ const BUYBACK_SPLIT_ABI = [parseAbi(['event Split(uint256 incoming, uint256 toBuyback, uint256 toDev)'])]
1400
+ const SHARED_SPLIT = {
1401
+ topic: encodeEventTopics({ abi: FLOOR_ABI, eventName: 'Split' })[0],
1402
+ byType: (kind) => (kind === 'lp-burn-v1' ? LP_EVENT_ABIS : kind === 'promote-pool-v1' ? PROMOTE_EVENT_ABIS : kind === 'floor-v1' ? FLOOR_EVENT_ABIS
1403
+ : String(kind ?? '').startsWith('buyback-burn-') ? BUYBACK_SPLIT_ABI : null),
1404
+ }
1347
1405
 
1348
1406
  /** gang bond / gang buyback / gang split / gang lp / gang combo / gang capped on a 铸币飞轮 token: those contracts refuse it, so say why before any step. */
1349
1407
  async function refuseFly(what) {
@@ -1354,7 +1412,7 @@ async function refuseFly(what) {
1354
1412
 
1355
1413
  /** A mainnet tx decoded, its queued note published (or its state refreshed), its follow ref and token links. */
1356
1414
  async function txReport(hash) {
1357
- const t = await decodeTx(hash, GANG_EVENT_ABIS)
1415
+ const t = await decodeTx(hash, GANG_EVENT_ABIS, SHARED_SPLIT)
1358
1416
  // the input may carry a follow ref and a note commitment: a committed note is sent here if it's still in the
1359
1417
  // local queue (e.g. after PENDING_CONFIRMATION), or its state reported / refreshed if already sent
1360
1418
  const queued = hasQueued()
@@ -1455,8 +1513,11 @@ async function main() {
1455
1513
  const capFlag = ['tax-cap', 'tax-cap-share', 'after-cap'].find((f) => flag(f))
1456
1514
  if (capFlag && launchKind === 'fair') fail(`--${capFlag} is for V3 tokens: it makes the tax recipient a capped recipient, and a 打新 token has no recipient`)
1457
1515
  if (capFlag) fail(TAX_CAP_ALONE)
1516
+ const floorFlag = ['floor', 'redeem-fee'].find((f) => flag(f))
1517
+ if (floorFlag && launchKind === 'fair') fail(`--${floorFlag} is for V3 tokens: it makes the tax recipient a floor module, and a 打新 token has no recipient`)
1518
+ if (flag('redeem-fee')) fail(REDEEM_FEE_ALONE)
1458
1519
  const lone = LAUNCH_FLAGS.find((f) => flag(f))
1459
- 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>)'}`)
1520
+ 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)'}`)
1460
1521
  }
1461
1522
  switch (cmd) {
1462
1523
  case 'fair':
@@ -1502,6 +1563,9 @@ async function main() {
1502
1563
  case 'capped':
1503
1564
  await refuseFly('a capped recipient')
1504
1565
  return runCapped(args[1], { opt, flag, out, fail, summarize: summarizePreview })
1566
+ case 'floor':
1567
+ await refuseFly('a floor module')
1568
+ return runFloor(args[1], { opt, flag, out, fail, summarize: summarizePreview })
1505
1569
  case 'weekly':
1506
1570
  return runWeekly(args[1], { opt, flag, out, fail, resolveLogo: resolveLogoUri })
1507
1571
  case 'capabilities':
@@ -1849,7 +1913,7 @@ async function main() {
1849
1913
  const r = await ctx.client.waitForTransactionReceipt({ hash, timeout: 120_000 })
1850
1914
  return out({
1851
1915
  success: true, chainId: Number(ctx.chainId), hash, status: r.status, block: Number(r.blockNumber),
1852
- events: decodeLogs(r.logs, GANG_EVENT_ABIS), explorer: `${ctx.explorer}/tx/${hash}`,
1916
+ events: decodeLogs(r.logs, GANG_EVENT_ABIS, await firstByModuleType(ctx.client, r.logs, SHARED_SPLIT.topic, SHARED_SPLIT.byType)), explorer: `${ctx.explorer}/tx/${hash}`,
1853
1917
  })
1854
1918
  }
1855
1919
  return out(await txReport(hash))