@gangfun/cli 0.19.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -5
- package/README.zh-CN.md +12 -5
- package/package.json +1 -1
- package/src/fly.js +217 -76
- package/src/index.js +48 -12
- package/src/launch.js +105 -14
- package/src/lp.js +305 -0
- package/src/mcp.js +4 -4
- package/src/v3.js +6 -1
package/src/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import { runV3, v3Ctx, V3_EVENT_ABIS } from './v3.js'
|
|
|
21
21
|
import { runBond } from './bond.js'
|
|
22
22
|
import { runBuyback } from './buyback.js'
|
|
23
23
|
import { runSplit, SPLIT_EVENT_ABIS } from './split.js'
|
|
24
|
+
import { runLp, LP_EVENT_ABIS } from './lp.js'
|
|
24
25
|
import { runFly, flyCtx, isFlyToken, FLY_EVENT_ABIS, FLY_CREATE_FLAGS } from './fly.js'
|
|
25
26
|
import { FAIR_DEV_BUY, isLaunch, LAUNCH_FLAGS, runLaunch } from './launch.js'
|
|
26
27
|
import { poolPayBnb, poolTrade } from './pool.js'
|
|
@@ -302,7 +303,8 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
302
303
|
[--max-per-tx 1-10] [--hold 60-90] [--mint-fee 1-3] [--exit-fee 1-2] [--dev-cut 0-10] [--buy-pct 0-50]
|
|
303
304
|
[--sell-tax 1-2] [--launch-delay 0-300] [--window 300-1800] [--cap-mul 1-2] [--post-mint | --no-post-mint]
|
|
304
305
|
[--tier flat|standard|linear [--step-pct 0-10 --step-shares 100-100000 --max-mul 1-10]] [--supply-cap 10-500]
|
|
305
|
-
[--dev-shares <n>] [--quote 0x… --ref-pool 0x…] [--logo …]
|
|
306
|
+
[--guard off|15|20|30] [--twap-window 15|30] [--dev-shares <n>] [--quote 0x… --ref-pool 0x…] [--logo …]
|
|
307
|
+
[--website URL] [--twitter @handle] [--description …]
|
|
306
308
|
a 铸币飞轮 (Mint Flywheel, GangFlywheelPad) sale (mainnet; --testnet = BSC testnet
|
|
307
309
|
set 2). 10,000 shares at raise / 10,000 each; a quota per wallet
|
|
308
310
|
(--quota + --invite-bonus per wallet it invites), --max-per-tx per mint, Agent ID
|
|
@@ -317,7 +319,7 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
317
319
|
600, cap ×1, standard tier, supply ×100; steady = no post-launch mint, quota 100, no
|
|
318
320
|
invites, dev cut 0, sell tax 1. Flags override the preset; checkConfig runs first.
|
|
319
321
|
--dev-shares (default 1, up to quota and max-per-tx) are minted in the create. No
|
|
320
|
-
--bond / --buyback / --dev-buy (phase 1)
|
|
322
|
+
--bond / --buyback / --split / --lp / --dev-buy (phase 1)
|
|
321
323
|
FLY (铸币飞轮; also gang fly <sub>): gang mint --token <a> --shares <n> [--ref <inviter>] [--min-shares <n>] [--slippage 2]
|
|
322
324
|
[--use-wbnb]: before launch the sale price (+ mint fee; WBNB sales pay BNB in one tx,
|
|
323
325
|
--use-wbnb from WBNB); after launch mintPost: minTokensOut = the preview less
|
|
@@ -350,9 +352,18 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
350
352
|
nobody (not you, not the platform) can change the payees or shares later; a payee can
|
|
351
353
|
only move its own slot (gang split set-payee). Steps: clone your split module
|
|
352
354
|
(GangSplitModuleFactory; listed as a recipient in the same tx) → create with it as the
|
|
353
|
-
recipient → bind → the rest of the launch. --split, --buyback and --recipient
|
|
354
|
-
exclusive. Quote: WBNB (default), GANG or one listed in the pad's QuoteRegistry
|
|
355
|
-
(the quotes the keeper splits; others are refused before the clone)
|
|
355
|
+
recipient → bind → the rest of the launch. --split, --buyback, --lp and --recipient
|
|
356
|
+
are exclusive. Quote: WBNB (default), GANG or one listed in the pad's QuoteRegistry
|
|
357
|
+
only (the quotes the keeper splits; others are refused before the clone)
|
|
358
|
+
gang create … --buy-tax <1-5> --sell-tax <1-5> --lp <0-100> [--lp-to <addr>] [--dev-buy … [--bond …]]
|
|
359
|
+
V3, taxed, auto-liquidity: --lp % of the recipient's part of the tax is added to the
|
|
360
|
+
token's PancakeSwap pair as liquidity whose LP goes to 0xdead (locked for good), the
|
|
361
|
+
rest to you (or --lp-to <addr>; changeable later with gang lp set-payee). After
|
|
362
|
+
graduation the keeper adds it in chunks (half buys the token, all of it goes back in
|
|
363
|
+
with the matching quote). Steps: clone your LP splitter (GangLiquiditySplitterFactory;
|
|
364
|
+
listed as a recipient in the same tx) → create with it as the recipient → bind → the
|
|
365
|
+
rest of the launch. Not with --buyback, --split or --recipient. Quote: WBNB
|
|
366
|
+
(default), GANG or one listed in the pad's QuoteRegistry only
|
|
356
367
|
gang create --fair … [--shares <n>] --bond <quote> [--bond-hold …] --bond-days <7-90>
|
|
357
368
|
打新: create (the dev's --shares are bought in it) → bond. Progress is read from the
|
|
358
369
|
chain (a token this wallet created with this symbol since the plan); a run that finds
|
|
@@ -446,11 +457,30 @@ SPLIT (a V3 token whose recipient is a split module, split-v1; GANG_SPLIT_FACTOR
|
|
|
446
457
|
Gas: the CLI never sets a gas limit on these; let the wallet estimate it. Each payee's
|
|
447
458
|
push needs ~365k gas left before it, so the limit is far above the gas used; a lower
|
|
448
459
|
limit reverts PushStarved. --testnet, --calldata, --from as in gang v3
|
|
460
|
+
LP (a V3 token whose recipient is an LP splitter, lp-burn-v1; GANG_LP_FACTORY / GANG_TESTNET_LP_FACTORY):
|
|
461
|
+
gang lp status --token <addr> ratio (lpPct), a cut asked for (applies from / lapses after), quote set aside for the
|
|
462
|
+
pool (lpLeft) and not split yet (unsplit), the payee and what is owed to it, the next
|
|
463
|
+
chunk (previewAdd) or what it waits for, the last chunk (lastAddAt)
|
|
464
|
+
gang lp set --token <addr> --pct <0-100>
|
|
465
|
+
dev only: a higher share applies at once; a lower one after a 3-day notice
|
|
466
|
+
gang lp set-payee --token <addr> --to <addr>
|
|
467
|
+
dev only: the part not added to the pool goes to --to from now on (at once)
|
|
468
|
+
gang lp apply --token <addr> anyone: apply a cut whose notice ran (within 7 days, or it lapses)
|
|
469
|
+
gang lp bind --token <addr> | gang lp release --token <addr>
|
|
470
|
+
anyone: bind the splitter to its token (the launch does it) / push the payee what a
|
|
471
|
+
failed payment left owed
|
|
472
|
+
gang lp add --token <addr> [--slippage 1]
|
|
473
|
+
anyone: one chunk now, as the keeper does (graduated tokens; one per 4 minutes; ≤ 0.5%
|
|
474
|
+
of the pair's quote reserve; waits for a 10-minute average and skips when the price is
|
|
475
|
+
> 2% above it): minimum tokens = previewAdd less --slippage. Not ready: a call that
|
|
476
|
+
only records the price. Gas: a chunk takes ~0.53–0.75M; the CLI never sets a gas
|
|
477
|
+
limit, let the wallet estimate it. --testnet, --calldata, --from as in gang v3
|
|
449
478
|
gang execute --request-id <id> broadcast a previewed call
|
|
450
479
|
gang tx --pending a trade that waited for Binance App approval (execute: pendingConfirmation): find its tx
|
|
451
480
|
in the wallet's history by the exact call previewed, then as gang tx --hash below
|
|
452
481
|
gang tx --hash <0x..> [--testnet] wait for receipt and decode Gang events: V2 / Soft / U / S, GangLaunchpad (V3 /
|
|
453
|
-
打新, tax router, vaults), GangFlywheelPad (铸币飞轮 pad and tax handler)
|
|
482
|
+
打新, tax router, vaults), GangFlywheelPad (铸币飞轮 pad and tax handler), split modules
|
|
483
|
+
and LP splitters (publishes a queued --note; mainnet). GangLaunchpad events
|
|
454
484
|
carry units: "raw" (amounts in wei, 18 decimals; bps / shares as is)
|
|
455
485
|
|
|
456
486
|
--note is PUBLIC: shown on gang.fun next to the trade. Its hash goes into the tx calldata, so it is provably written
|
|
@@ -477,7 +507,10 @@ GANG_PAD / GANG_TESTNET_PAD (the one GangLaunchpad behind both gang v3 and gang
|
|
|
477
507
|
and GANG_V3_TESTNET_PAD / GANG_FAIR_TESTNET_PAD still work as aliases), GANG_TESTNET_RPC_URL (aliases
|
|
478
508
|
GANG_V3_TESTNET_RPC_URL / GANG_FAIR_TESTNET_RPC_URL), GANG_ROUTER / GANG_TESTNET_ROUTER (alias GANG_ROUTER_TESTNET; GangRouter
|
|
479
509
|
for BNB buys / mints and every pool trade; both default to the built-in mainnet / testnet set 10 addresses),
|
|
480
|
-
GANG_FLY_PAD / GANG_TESTNET_FLY_PAD (GangFlywheelPad; default: the built-in mainnet / testnet set 2 addresses)
|
|
510
|
+
GANG_FLY_PAD / GANG_TESTNET_FLY_PAD (GangFlywheelPad V1; default: the built-in mainnet / testnet set 2 addresses),
|
|
511
|
+
GANG_FLY_PAD_V2 / GANG_TESTNET_FLY_PAD_V2 (V2, where new tokens go; default: the built-in mainnet / testnet V2). --guard / --twap-window
|
|
512
|
+
(V2 only): the guard is off by default (post-launch minting does not pause on a price drop; the quota cap of 10 per
|
|
513
|
+
wallet bounds it); --guard 15|20|30 pauses mints while the pool is that % below its average over --twap-window (30)
|
|
481
514
|
|
|
482
515
|
Private RPC: this CLI never broadcasts itself. Trades go out through the Agentic Wallet (gang execute), which picks its
|
|
483
516
|
own RPC; a --calldata tx is sent by whatever signs it. To keep a large pool buy out of the public mempool (front-running),
|
|
@@ -984,7 +1017,7 @@ const V3_CREATE_FLAGS = ['buy-tax', 'sell-tax', 'dividend', 'recipient']
|
|
|
984
1017
|
const FAIR_CREATE_FLAGS = ['raise', 'cap', 'hold', 'mint-fee', 'exit-fee', 'shares']
|
|
985
1018
|
// 铸币飞轮 settings beyond those it shares with 打新 (--raise / --hold / --mint-fee / --exit-fee) and V3 (--sell-tax)
|
|
986
1019
|
const FLY_ONLY_FLAGS = FLY_CREATE_FLAGS.filter((f) => !['raise', 'hold', 'mint-fee', 'exit-fee', 'sell-tax'].includes(f))
|
|
987
|
-
const FLY_NO_BOND = '铸币飞轮 tokens take no GangBond, buy-back splitter, split module or --dev-buy (phase 1): the creator mints its shares in the create with --dev-shares <n>'
|
|
1020
|
+
const FLY_NO_BOND = '铸币飞轮 tokens take no GangBond, buy-back splitter, split module, LP splitter or --dev-buy (phase 1): the creator mints its shares in the create with --dev-shares <n>'
|
|
988
1021
|
/** The flags a 铸币飞轮 create refuses (gang create --fly and gang fly create alike). */
|
|
989
1022
|
function checkFlyCreate() {
|
|
990
1023
|
if (flag('fair')) fail('give --fly (铸币飞轮) or --fair (打新), not both')
|
|
@@ -1018,11 +1051,11 @@ function create() {
|
|
|
1018
1051
|
// commands whose JSON result carries `update`; `watch` streams NDJSON and help is plain text
|
|
1019
1052
|
const UPDATE_CHECKED = new Set(['version', '--version', '-v', 'preflight', 'list', 'hot', 'new', 'near-grad', 'notes', 'agents', 'token', 'info', 'status', 'portfolio', 'quote',
|
|
1020
1053
|
'buy', 'follow', 'sell', 'claim', 'mint', 'withdraw', 'release', 'upload-logo', 'create', 'execute', 'tx', 'fair', 'v3', 'bond',
|
|
1021
|
-
'buyback', 'split', 'fly'])
|
|
1054
|
+
'buyback', 'split', 'lp', 'fly'])
|
|
1022
1055
|
// gang tx decodes these beside the V2 / Soft / U / S pads' events (GangLaunchpad: both kinds; the tax router; the vaults)
|
|
1023
|
-
const GANG_EVENT_ABIS = [...V3_EVENT_ABIS, ...FAIR_EVENT_ABIS, ...FLY_EVENT_ABIS, ...SPLIT_EVENT_ABIS]
|
|
1056
|
+
const GANG_EVENT_ABIS = [...V3_EVENT_ABIS, ...FAIR_EVENT_ABIS, ...FLY_EVENT_ABIS, ...SPLIT_EVENT_ABIS, ...LP_EVENT_ABIS]
|
|
1024
1057
|
|
|
1025
|
-
/** gang bond / gang buyback / gang split on a 铸币飞轮 token: those contracts refuse it, so say why before any step. */
|
|
1058
|
+
/** gang bond / gang buyback / gang split / gang lp on a 铸币飞轮 token: those contracts refuse it, so say why before any step. */
|
|
1026
1059
|
async function refuseFly(what) {
|
|
1027
1060
|
const token = opt('token')
|
|
1028
1061
|
if (!isAddress(token ?? '')) return
|
|
@@ -1113,7 +1146,7 @@ async function main() {
|
|
|
1113
1146
|
// a 打新 dev buys with --shares in the create itself: say so here, not "add --bond" (which would only lead to that)
|
|
1114
1147
|
if (launchKind === 'fair' && flag('dev-buy')) fail(FAIR_DEV_BUY)
|
|
1115
1148
|
const lone = LAUNCH_FLAGS.find((f) => flag(f))
|
|
1116
|
-
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>,…)'}`)
|
|
1149
|
+
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>)'}`)
|
|
1117
1150
|
}
|
|
1118
1151
|
switch (cmd) {
|
|
1119
1152
|
case 'fair':
|
|
@@ -1136,6 +1169,9 @@ async function main() {
|
|
|
1136
1169
|
case 'split':
|
|
1137
1170
|
await refuseFly('a split module')
|
|
1138
1171
|
return runSplit(args[1], { opt, flag, out, fail, summarize: summarizePreview })
|
|
1172
|
+
case 'lp':
|
|
1173
|
+
await refuseFly('an LP splitter')
|
|
1174
|
+
return runLp(args[1], { opt, flag, out, fail, summarize: summarizePreview })
|
|
1139
1175
|
case 'version':
|
|
1140
1176
|
case '--version':
|
|
1141
1177
|
case '-v':
|
package/src/launch.js
CHANGED
|
@@ -9,6 +9,7 @@ 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
11
|
import { parseSplitSpec, simulateSplit, SPLIT_ABI, SPLIT_FACTORY_ABI, splitFactoryAddress, splitLine, splitNotDeployed, splitOf } from './split.js'
|
|
12
|
+
import { LP_ABI, LP_FACTORY_ABI, lpBpsOf, lpFactoryAddress, lpNotDeployed, lpOf, simulateLp } from './lp.js'
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* One command for a launch: `gang create … [--buyback <pct>] [--dev-buy <quote> [--bond <quote> [--bond-hold <tokens|N%|all>]
|
|
@@ -31,7 +32,11 @@ import { parseSplitSpec, simulateSplit, SPLIT_ABI, SPLIT_FACTORY_ABI, splitFacto
|
|
|
31
32
|
* --split <addr>:<pct>[,…] (V3, taxed): the same three steps with GangSplitModuleFactory — the dev's split module (fixed
|
|
32
33
|
* payees and shares, split-v1) is cloned at predict(dev, salt), named as the recipient, then bound. The plan keeps which
|
|
33
34
|
* module it cloned (`module: 'split'`; a plan without it is a --buyback one), and a re-run with other payees or shares is
|
|
34
|
-
* refused rather than starting over.
|
|
35
|
+
* refused rather than starting over.
|
|
36
|
+
* --lp <pct> [--lp-to <addr>] (V3, taxed): the same three steps with GangLiquiditySplitterFactory — the dev's LP splitter
|
|
37
|
+
* (lp-burn-v1: --lp % of the recipient's part added to the pair as liquidity, the LP to 0xdead) is cloned at
|
|
38
|
+
* predict(dev, salt), named as the recipient, then bound (`module: 'lp'` in the plan). A launch keeps the ratio and payee
|
|
39
|
+
* it began with. --buyback, --split, --lp and --recipient are exclusive (each sets the recipient).
|
|
35
40
|
*/
|
|
36
41
|
|
|
37
42
|
const LAUNCH_DIR = process.env.GANG_LAUNCH_DIR || join(dirname(DIR), 'launch')
|
|
@@ -55,6 +60,8 @@ const REGISTRY_ABI = parseAbi(['function quoteRegistry() view returns (address)'
|
|
|
55
60
|
* and the buy-back part is stuck for good (GangBond re-review L-1, 2026-10-29; splitter v3 has the same pricing).
|
|
56
61
|
* --split takes the same quotes: a quote that calls the receiver back on transfer would let one payee make every split
|
|
57
62
|
* run out of gas, and the keeper splits only these quotes anyway (split spec §2.4).
|
|
63
|
+
* --lp takes the same quotes: the keeper adds liquidity only over these, and an unlisted quote may tax or block the
|
|
64
|
+
* transfers into the pair every chunk makes.
|
|
58
65
|
* null when trusted; otherwise the failure to report.
|
|
59
66
|
*/
|
|
60
67
|
const UNTRUSTED = {
|
|
@@ -66,6 +73,10 @@ const UNTRUSTED = {
|
|
|
66
73
|
why: '--split needs WBNB, GANG or a quote listed in the pad\'s QuoteRegistry: the keeper splits only those quotes, and an unlisted quote may call the receiver back on transfer, letting one payee make every split run out of gas',
|
|
67
74
|
hint: 'drop --quote (WBNB), use a listed quote, or launch without --split',
|
|
68
75
|
},
|
|
76
|
+
lp: {
|
|
77
|
+
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',
|
|
78
|
+
hint: 'drop --quote (WBNB), use a listed quote, or launch without --lp',
|
|
79
|
+
},
|
|
69
80
|
}
|
|
70
81
|
export async function untrustedBuybackQuote(read, net, quote, mode = 'buyback') {
|
|
71
82
|
if (!isAddress(quote ?? '')) return { error: '--quote must be a 0x address', got: quote ?? null }
|
|
@@ -84,13 +95,15 @@ export async function untrustedBuybackQuote(read, net, quote, mode = 'buyback')
|
|
|
84
95
|
}
|
|
85
96
|
}
|
|
86
97
|
|
|
87
|
-
export const LAUNCH_FLAGS = ['dev-buy', 'bond', 'bond-hold', 'bond-days', 'buyback', 'buyback-to', 'split', 'restart']
|
|
98
|
+
export const LAUNCH_FLAGS = ['dev-buy', 'bond', 'bond-hold', 'bond-days', 'buyback', 'buyback-to', 'split', 'lp', 'lp-to', 'restart']
|
|
88
99
|
const NOTE_FLAGS = ['note', 'conf', 'reveal-after']
|
|
89
100
|
/** `gang fair create --dev-buy`, with or without --bond (index.js stops the lone flag, runLaunch the chained one). */
|
|
90
101
|
export const FAIR_DEV_BUY = 'a 打新 dev buys its shares in the create itself: use --shares <n> (not --dev-buy)'
|
|
91
102
|
|
|
92
103
|
/** The run asks for a chained launch (`kind` 'v3' | 'fair'). */
|
|
93
|
-
export const isLaunch = (kind, flag) => flag('bond') || flag('buyback') || flag('split') || (kind === 'v3' && flag('dev-buy'))
|
|
104
|
+
export const isLaunch = (kind, flag) => flag('bond') || flag('buyback') || flag('split') || flag('lp') || (kind === 'v3' && flag('dev-buy'))
|
|
105
|
+
/** The recipient modules a launch can clone (their flags), at most one per launch. */
|
|
106
|
+
const MODULE_FLAGS = ['buyback', 'split', 'lp']
|
|
94
107
|
|
|
95
108
|
const planPath = (key) => join(LAUNCH_DIR, `${createHash('sha256').update(key).digest('hex').slice(0, 32)}.json`)
|
|
96
109
|
|
|
@@ -135,7 +148,10 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
135
148
|
if (kind === 'fair' && flag('dev-buy')) fail(FAIR_DEV_BUY)
|
|
136
149
|
if (kind === 'fair' && flag('buyback')) fail('--buyback is for V3 tokens: it makes the tax recipient a buy-back splitter, and a 打新 token has no recipient')
|
|
137
150
|
if (kind === 'fair' && flag('split')) fail('--split is for V3 tokens: it makes the tax recipient a split module, and a 打新 token has no recipient')
|
|
151
|
+
if (kind === 'fair' && flag('lp')) fail('--lp is for V3 tokens: it makes the tax recipient an LP splitter, and a 打新 token has no recipient')
|
|
138
152
|
if (flag('split') && flag('buyback')) fail('give --split or --buyback, not both: each makes the tax recipient its own module (a split with a buy-back is not supported)')
|
|
153
|
+
const mods = MODULE_FLAGS.filter((f) => flag(f))
|
|
154
|
+
if (mods.length > 1) fail(`give one of --${mods.join(' / --')}, not several: each makes the tax recipient its own module`)
|
|
139
155
|
|
|
140
156
|
// everything checked before the create, so a launch never stops half way on a bad flag
|
|
141
157
|
const devBuy = kind === 'v3' && flag('dev-buy') ? parseAmount(fail, 'dev-buy', opt('dev-buy')) : null
|
|
@@ -193,12 +209,32 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
193
209
|
}
|
|
194
210
|
split = { ...spec, factory }
|
|
195
211
|
}
|
|
196
|
-
|
|
212
|
+
|
|
213
|
+
// --lp: a taxed V3 token whose recipient is the dev's LP splitter (auto-liquidity, the LP to 0xdead)
|
|
214
|
+
let lp = null
|
|
215
|
+
if (flag('lp-to') && !flag('lp')) fail('--lp-to <addr> goes with --lp <pct>: it names where the part not added to the pool goes')
|
|
216
|
+
if (flag('lp')) {
|
|
217
|
+
const zero = (f) => /^0+(\.0+)?$/.test(opt(f) ?? '')
|
|
218
|
+
if (!flag('buy-tax') || !flag('sell-tax') || (zero('buy-tax') && zero('sell-tax'))) {
|
|
219
|
+
fail('--lp needs a taxed token: add --buy-tax and --sell-tax (each 1–5, in %); the liquidity is paid from the tax')
|
|
220
|
+
}
|
|
221
|
+
if (flag('recipient')) fail('--lp makes the recipient your LP splitter: leave --recipient out')
|
|
222
|
+
if (/^0*100(\.0+)?$/.test(opt('dividend', '0'))) fail('--dividend 100 leaves nothing for the recipient, so nothing to add to the pool: lower it or drop --lp')
|
|
223
|
+
const factory = lpFactoryAddress(testnet)
|
|
224
|
+
if (!factory) fail(lpNotDeployed(testnet))
|
|
225
|
+
let payee = null
|
|
226
|
+
if (flag('lp-to')) {
|
|
227
|
+
payee = opt('lp-to')
|
|
228
|
+
if (!isAddress(payee ?? '') || payee === zeroAddress) fail('--lp-to must be a 0x address, checksummed or all lowercase (where the part not added to the pool goes; leave it out for your own wallet)', { got: payee ?? null })
|
|
229
|
+
}
|
|
230
|
+
lp = { bps: lpBpsOf(fail, opt('lp')), factory, payee }
|
|
231
|
+
}
|
|
232
|
+
const mod = buyback ? 'buyback' : split ? 'split' : lp ? 'lp' : null
|
|
197
233
|
|
|
198
234
|
const client = createPublicClient({ chain: net.chain, transport: rpcTransport(net.rpcs) })
|
|
199
235
|
const read = (address, abi, functionName, args = []) => client.readContract({ address, abi, functionName, args })
|
|
200
236
|
const key = [net.chainId, net.pad, me.toLowerCase(), kind, name, symbol].join('|')
|
|
201
|
-
const cloneStep = buyback ? 'buyback-splitter' : 'split-module'
|
|
237
|
+
const cloneStep = buyback ? 'buyback-splitter' : split ? 'split-module' : 'lp-splitter'
|
|
202
238
|
const steps = [...(mod ? [cloneStep] : []), kind === 'v3' ? 'create' : 'create (dev shares included)', ...(mod ? ['bind'] : []),
|
|
203
239
|
...(devBuy ? ['dev-buy'] : []), ...(bond ? ['bond'] : [])]
|
|
204
240
|
const rerun = 're-run this same command after executing it'
|
|
@@ -210,13 +246,14 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
210
246
|
|
|
211
247
|
// ---- a launch keeps the mode it began with (the create, once built, is never redone by a changed flag)
|
|
212
248
|
const created = plan?.startCount !== undefined
|
|
213
|
-
// the module this plan cloned: 'split' when it says so, else a --buyback splitter (plans from before --split)
|
|
214
|
-
const planMod = plan?.salt ? (plan.module === 'split'
|
|
249
|
+
// the module this plan cloned: 'split' / 'lp' when it says so, else a --buyback splitter (plans from before --split)
|
|
250
|
+
const planMod = plan?.salt ? (plan.module === 'split' || plan.module === 'lp' ? plan.module : 'buyback') : null
|
|
251
|
+
const modNoun = { buyback: 'splitter', split: 'split module', lp: 'LP splitter' }
|
|
215
252
|
if (mod && created && !plan.splitter) {
|
|
216
253
|
return fail(`this launch was created without --${mod} (its recipient is fixed): run it again without --${mod}, or add --restart for a new token`)
|
|
217
254
|
}
|
|
218
255
|
if (planMod && mod !== planMod && (!created || mod)) {
|
|
219
|
-
return fail(`this launch began with --${planMod} (its ${planMod
|
|
256
|
+
return fail(`this launch began with --${planMod} (its ${modNoun[planMod]} is cloned or on the way): run it again with --${planMod}${mod ? ` instead of --${mod}` : ''}, or add --restart${mod ? '' : ` without it`}`)
|
|
220
257
|
}
|
|
221
258
|
|
|
222
259
|
// ---- buy-back splitter: cloned for the dev before the create, at predict(dev, plan.salt)
|
|
@@ -304,6 +341,54 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
304
341
|
}
|
|
305
342
|
}
|
|
306
343
|
|
|
344
|
+
// ---- LP splitter: cloned for the dev before the create, at predict(dev, plan.salt)
|
|
345
|
+
if (lp && !created) {
|
|
346
|
+
if (!plan?.salt) {
|
|
347
|
+
const refused = await untrustedBuybackQuote(read, net, flag('quote') ? opt('quote') : net.wbnb, 'lp')
|
|
348
|
+
if (refused) {
|
|
349
|
+
const { error, ...extra } = refused
|
|
350
|
+
return fail(error, extra)
|
|
351
|
+
}
|
|
352
|
+
if ((await client.getCode({ address: lp.factory }) ?? '0x') === '0x') {
|
|
353
|
+
return fail(`GangLiquiditySplitterFactory has no code at ${lp.factory} on ${testnet ? 'the BSC testnet' : 'BSC mainnet'} yet: launch without --lp for now${process.env[testnet ? 'GANG_TESTNET_LP_FACTORY' : 'GANG_LP_FACTORY'] ? ` (or fix ${testnet ? 'GANG_TESTNET_LP_FACTORY' : 'GANG_LP_FACTORY'})` : ''}`, { factory: lp.factory })
|
|
354
|
+
}
|
|
355
|
+
const salt = `0x${randomBytes(32).toString('hex')}`
|
|
356
|
+
const at = await read(lp.factory, LP_FACTORY_ABI, 'predict', [me, salt])
|
|
357
|
+
if (lp.payee && lp.payee.toLowerCase() === at.toLowerCase()) return fail('--lp-to: the payee cannot be the LP splitter itself', { splitter: at })
|
|
358
|
+
const args = [lp.bps, salt, lp.payee ?? zeroAddress]
|
|
359
|
+
const sim = await simulateLp(client, me, lp.factory, LP_FACTORY_ABI, 'create', args)
|
|
360
|
+
if (sim.failed) return out({ success: false, step: 'lp-splitter', factory: lp.factory, ...tag('lp-splitter'), ...sim.failed })
|
|
361
|
+
writePlan(key, { ...base, salt, splitter: at, factory: lp.factory, module: 'lp' })
|
|
362
|
+
const data = encodeFunctionData({ abi: LP_FACTORY_ABI, functionName: 'create', args })
|
|
363
|
+
return out({
|
|
364
|
+
...step({ chainId: net.chainId }, { from: me, to: lp.factory, data }, {
|
|
365
|
+
step: 'lp-splitter', chainId: Number(net.chainId), factory: lp.factory, lpPct: lp.bps / 100,
|
|
366
|
+
splitter: at, payee: lp.payee ?? me,
|
|
367
|
+
note: `clones your LP splitter (listed as a tax recipient in the same tx): ${lp.bps / 100}% of the recipient's part is added to the token's PancakeSwap pair as liquidity, the LP sent to 0xdead (locked for good), the rest goes to ${lp.payee ? `${lp.payee} (--lp-to)` : 'you'}. After graduation the keeper adds it in chunks. Later a raise applies at once, a cut only after a 3-day notice; the payee can be changed at once (gang lp set-payee)`,
|
|
368
|
+
}, flag('calldata'), io.summarize),
|
|
369
|
+
...tag('lp-splitter', { splitter: at, next: `${rerun}: it then builds the create with the LP splitter as the recipient` }),
|
|
370
|
+
})
|
|
371
|
+
}
|
|
372
|
+
if ((await client.getCode({ address: plan.splitter }) ?? '0x') === '0x') {
|
|
373
|
+
return out({
|
|
374
|
+
success: false, ...tag('lp-splitter', { splitter: plan.splitter }), error: 'the LP splitter is not on chain yet',
|
|
375
|
+
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`,
|
|
376
|
+
})
|
|
377
|
+
}
|
|
378
|
+
const s = await lpOf(read, plan.splitter)
|
|
379
|
+
if (!s || s.dev.toLowerCase() !== me.toLowerCase() || s.token) {
|
|
380
|
+
return fail('the LP splitter at this launch\'s address is not an unbound LP splitter of this wallet: add --restart', { splitter: plan.splitter })
|
|
381
|
+
}
|
|
382
|
+
if (s.lpBps !== lp.bps) {
|
|
383
|
+
return fail(`this launch's LP splitter adds ${s.lpPct}% to the pool, not ${lp.bps / 100}%: run it again with --lp ${s.lpPct}, or add --restart for a new splitter (gang lp set changes it after the create)`, { splitter: plan.splitter })
|
|
384
|
+
}
|
|
385
|
+
const wantPayee = (lp.payee ?? me).toLowerCase()
|
|
386
|
+
if (s.payee.toLowerCase() !== wantPayee) {
|
|
387
|
+
const was = s.payee.toLowerCase() === me.toLowerCase() ? 'leave --lp-to out' : `--lp-to ${s.payee}`
|
|
388
|
+
return fail(`this launch's LP splitter pays ${s.payee}, not ${lp.payee ?? me}: run it again with ${was}, or add --restart for a new splitter (gang lp set-payee changes it after the create)`, { splitter: plan.splitter })
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
307
392
|
// ---- create
|
|
308
393
|
if (!created) {
|
|
309
394
|
const startCount = (await read(net.pad, PAD_ABI, 'tokenCount')).toString()
|
|
@@ -353,7 +438,9 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
353
438
|
const stepIo = (over) => ({ ...io, ...argsWith(io, { ...over, token }, [...LAUNCH_FLAGS, ...NOTE_FLAGS, 'name', 'symbol']) })
|
|
354
439
|
const bal = await read(token, ERC20_ABI, 'balanceOf', [me])
|
|
355
440
|
const isSplit = plan.module === 'split'
|
|
356
|
-
const
|
|
441
|
+
const isLp = plan.module === 'lp'
|
|
442
|
+
const buybackState = () => (plan.splitter && !isSplit && !isLp ? splitterOf(read, plan.splitter) : null)
|
|
443
|
+
const lpState = () => (plan.splitter && isLp ? lpOf(read, plan.splitter, { pad: net.pad }) : null)
|
|
357
444
|
const splitState = () => (plan.splitter && isSplit ? splitOf(read, plan.splitter, { wbnb: net.wbnb, ref: `--token ${token}${testnet ? ' --testnet' : ''}` }) : null)
|
|
358
445
|
|
|
359
446
|
// ---- done: the report only, whatever happened to the balance or the bond since
|
|
@@ -366,17 +453,19 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
366
453
|
if (bb) done.buyback = bb
|
|
367
454
|
const sp = await splitState()
|
|
368
455
|
if (sp) done.split = sp
|
|
456
|
+
const lps = await lpState()
|
|
457
|
+
if (lps) done.lp = lps
|
|
369
458
|
if (!bond) return out({ ...done, note: `launched: gang ${kind} info --token ${token}${testnet ? ' --testnet' : ''}` })
|
|
370
459
|
return runBond('status', { ...stepIo({}), out: (o) => out({ ...done, bondStatus: o, note: `launched and bonded: gang bond status --token ${token}${testnet ? ' --testnet' : ''}` }) })
|
|
371
460
|
}
|
|
372
461
|
if (plan.done) return report()
|
|
373
462
|
|
|
374
|
-
// ---- bind the splitter / split module to the token (anyone may; the launch does it right after the create)
|
|
463
|
+
// ---- bind the splitter / split module / LP splitter to the token (anyone may; the launch does it right after the create)
|
|
375
464
|
if (plan.splitter) {
|
|
376
|
-
const abi = isSplit ? SPLIT_ABI : SPLITTER_ABI
|
|
465
|
+
const abi = isSplit ? SPLIT_ABI : isLp ? LP_ABI : SPLITTER_ABI
|
|
377
466
|
const bound = await read(plan.splitter, abi, 'token')
|
|
378
467
|
if (bound === zeroAddress) {
|
|
379
|
-
const sim = await (isSplit ? simulateSplit : simulateCall)(client, me, plan.splitter, abi, 'bind', [token])
|
|
468
|
+
const sim = await (isSplit ? simulateSplit : isLp ? simulateLp : simulateCall)(client, me, plan.splitter, abi, 'bind', [token])
|
|
380
469
|
if (sim.failed) return out({ success: false, step: 'bind', ...tag('bind', { token }), ...sim.failed })
|
|
381
470
|
const data = encodeFunctionData({ abi, functionName: 'bind', args: [token] })
|
|
382
471
|
return out({
|
|
@@ -384,13 +473,15 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
384
473
|
step: 'bind', chainId: Number(net.chainId), token, ...(isSplit ? { module: plan.splitter } : { splitter: plan.splitter }),
|
|
385
474
|
note: isSplit
|
|
386
475
|
? 'ties the split module to this token for good: the keeper then splits its quote among the payees'
|
|
387
|
-
:
|
|
476
|
+
: isLp
|
|
477
|
+
? 'ties the LP splitter to this token for good: its pair is where the liquidity goes (from graduation on)'
|
|
478
|
+
: 'ties the splitter to this token for good (what it buys back and burns)',
|
|
388
479
|
}, flag('calldata'), io.summarize),
|
|
389
480
|
...tag('bind', { token, next: `${rerun}${devBuy ? ': it continues with the dev buy' : bond ? ': it continues with the bond' : ': the launch is then done'}` }),
|
|
390
481
|
})
|
|
391
482
|
}
|
|
392
483
|
if (bound.toLowerCase() !== token.toLowerCase()) {
|
|
393
|
-
return out({ success: false, ...tag('bind', { token }), error: `the ${isSplit ? 'split module' : 'splitter'} is bound to another token`, [isSplit ? 'module' : 'splitter']: plan.splitter, boundTo: bound })
|
|
484
|
+
return out({ success: false, ...tag('bind', { token }), error: `the ${isSplit ? 'split module' : isLp ? 'LP splitter' : 'splitter'} is bound to another token`, [isSplit ? 'module' : 'splitter']: plan.splitter, boundTo: bound })
|
|
394
485
|
}
|
|
395
486
|
}
|
|
396
487
|
|