@gangfun/cli 0.22.0 → 0.23.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 +22 -16
- package/README.zh-CN.md +21 -16
- package/package.json +1 -1
- package/src/bond.js +17 -15
- package/src/buyback.js +118 -19
- package/src/chain.js +2 -2
- package/src/combo.js +9 -9
- package/src/creatorfee.js +261 -0
- package/src/discover.js +2 -0
- package/src/fair.js +7 -4
- package/src/fly.js +4 -1
- package/src/gangpad.js +249 -24
- package/src/index.js +53 -14
- package/src/launch.js +33 -1
- package/src/lp.js +52 -15
- package/src/mcp.js +2 -2
- package/src/portfolio.js +25 -5
- package/src/split.js +7 -8
- package/src/v3.js +90 -29
package/src/gangpad.js
CHANGED
|
@@ -7,27 +7,90 @@ import { bsc, bscTestnet } from 'viem/chains'
|
|
|
7
7
|
* on the pad says which kind a token is (0 = not this pad's, 1 = V3 curve, 2 = 打新). The two `create` overloads keep
|
|
8
8
|
* their old selectors, so each command keeps its own ABI fragment.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Each network may have several generations of this pad (GANG_GENS: 1.0, 2.0); kindOf on each tells which one has a token.
|
|
11
|
+
*
|
|
12
|
+
* Env (new name first; the old per-command names still work as aliases). The contracts set the create target (gangGens):
|
|
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
|
|
12
15
|
* testnet: GANG_TESTNET_PAD (aliases GANG_V3_TESTNET_PAD / GANG_FAIR_TESTNET_PAD),
|
|
13
|
-
* GANG_TESTNET_ROUTER (alias GANG_ROUTER_TESTNET),
|
|
16
|
+
* GANG_TESTNET_ROUTER (alias GANG_ROUTER_TESTNET), GANG_TESTNET_BOND, GANG_TESTNET_SPLITTER_FACTORY,
|
|
17
|
+
* GANG_TESTNET_SPLIT_FACTORY, GANG_TESTNET_LP_FACTORY,
|
|
14
18
|
* GANG_TESTNET_RPC_URL (aliases GANG_V3_TESTNET_RPC_URL / GANG_FAIR_TESTNET_RPC_URL)
|
|
15
19
|
* An RPC variable takes one URL or a comma-separated list; set, it replaces the public nodes below.
|
|
16
20
|
*/
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
/**
|
|
23
|
+
* GangLaunchpad generations on each network, newest first. A create goes to the first; a token already out stays on the
|
|
24
|
+
* pad that created it and is served with that generation's GangRouter, GangBond and module factories (each of them is
|
|
25
|
+
* bound to one pad). 2.0 (docs/SPEC-CURVE-CREATOR-FEE-2026-10-31.md) has the same V3 curves and 打新 sales, and keeps
|
|
26
|
+
* 70% of the 1% curve fee for the token's creator (creatorFeeOf / claimCreatorFee); a 1.0 pad has neither.
|
|
27
|
+
*/
|
|
28
|
+
export const GANG_GENS = {
|
|
29
|
+
mainnet: [
|
|
30
|
+
// 2026-10-31, pad block 130874052: 2.0 with the creator fee and the graduation target the creator picks; its own
|
|
31
|
+
// GangRouter, GangBond, buy-back factory (buyback-burn-v4), split-v1, lp-burn-v1 and combo-v1 factories, all bound to
|
|
32
|
+
// this pad and listed on its own GangHandlerAdmin
|
|
33
|
+
{
|
|
34
|
+
gen: '2.0', pad: '0x770331a9accdb53ACb4a45B6c5B7D151fADCe557', router: '0xa83209d6bfC2B220cD86410cCDDC71FEb354844a',
|
|
35
|
+
bond: '0x231339463d04A2127E6dD5756756Dd56853AE0D8', splitterFactory: '0x77e499c892e5E6B3eEe1721e6821e9DA1293803C',
|
|
36
|
+
splitFactory: '0xa73dC3d63AAf72E70b1cb012e5f3A541360Bec59', lpFactory: '0x8ac85f150f87B536fb05eA163908b1077D95c0E4',
|
|
37
|
+
comboFactory: '0xcCeA388DbC0Edb206eC25C9715546d57029198Be',
|
|
38
|
+
},
|
|
39
|
+
// 2026-10-27, pad block 130104322. router = the GangRouter proxy: BNB buys and every PancakeSwap trade of a graduated
|
|
40
|
+
// token (V3, 打新 and V2 / Soft / U / S alike). GangBond 2026-10-29 with the re-review L-1 fix; it replaces 0xf26F…C817
|
|
41
|
+
// (never used; CLI 0.15.1–0.16.1) (docs/MAINNET-GANG-BOND-2026-10-29.md). Buy-back factory v3 (one chunk per 4 minutes;
|
|
42
|
+
// docs/MAINNET-BUYBACK-SPLITTER-2026-10-28.md; v2 0x9346…8F2f and v1 0x6bcd…8546 are stopped, their clones keep
|
|
43
|
+
// working). Split factory 2026-10-30 (docs/MAINNET-SPLIT-MODULE-2026-10-30.md), LP factory 2026-10-31
|
|
44
|
+
{
|
|
45
|
+
gen: '1.0', pad: '0x15CFD2dc8278Fb87a1783ef42111618E20874365', router: '0xE040445690Aa56C8b68B7f7038C7b2562B5079C4',
|
|
46
|
+
bond: '0xe92dC940CB23Dc328639A7334e69F9CCdf3a14E4', splitterFactory: '0xf1d5CA816d72e6F130f42662d11b238312A7F1Cd',
|
|
47
|
+
splitFactory: '0x27e08271E52B2D129c824CD245e69471a8d3067c', lpFactory: '0xE0436867dAFcf42Ee1418083251a9B8B61F0C248',
|
|
48
|
+
// combo-v1, 2026-10-31 (the Safe allowed it on GangHandlerAdmin at block 130811492)
|
|
49
|
+
comboFactory: '0xd33C38BE3f8472b3013167830F0638C1704e1DBd',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
testnet: [
|
|
53
|
+
// 2026-10-31, pad block 139940227: 2.0 with the graduation target the creator picks (GRAD_BNB_TIERS, createWithGradTarget;
|
|
54
|
+
// docs/SPEC-CURVE-GRAD-TARGET-2026-10-31.md); buy-back factory buyback-burn-v4, split-v1, lp-burn-v1, its own GangBond
|
|
55
|
+
{
|
|
56
|
+
gen: '2.0', pad: '0xb14d415f70D7F99f0D93Bd3BF76e0D6b38b53B3E', router: '0x5a4FA2D91638a305EdF027894753c943f095dDAA',
|
|
57
|
+
bond: '0x39749B59066d9cd1c55E2Fc48B31a3978C9951F9', splitterFactory: '0xDC9EdA9a29F4Ff66E7dAb6E5A2142df5a7aC0f6e',
|
|
58
|
+
splitFactory: '0xb9ab949C717a4F7f05c7B003C612C437280C3513', lpFactory: '0xAEec7e7948FfDb7a212E14c0b9cc1DA2922436E4',
|
|
59
|
+
comboFactory: '0x312c86F7139b3e3a75ee66b4D5Bfdbe5077584BD',
|
|
60
|
+
},
|
|
61
|
+
// 2026-10-31, pad block 139866088: the first 2.0 (creator fee, no graduation pick), no longer creating; its tokens trade
|
|
62
|
+
// and claim here. Its modules from the same scripts as 1.0's (docs/TESTNET-GANGLAUNCHPAD2-2026-10-31.md)
|
|
63
|
+
{
|
|
64
|
+
gen: '2.0', pad: '0x6381707406eb7E8EF8EdaF2DedBfFcEFFC0b39be', router: '0xb21828C49A526FA293C48990070a518e9ab9FC08',
|
|
65
|
+
bond: '0x913966122b9f8CC00C0d81000988A483c6B7F97f', splitterFactory: '0xBc26A6585B3Dc2Cbf1522475fB5b18df6C1033AE',
|
|
66
|
+
splitFactory: '0x860D51808E9FBB4f887FC7d0Aa9e1F8E19E00879', lpFactory: '0x4f1544e4e8853fC62088f0A4eCbEF409D2e11619',
|
|
67
|
+
comboFactory: null, // none: its tokens can't have a combined recipient
|
|
68
|
+
},
|
|
69
|
+
// set 10 (2026-10-27: §23 aggregator entries). GangBond 2026-10-29, block 139463214 — the audited version (earlier:
|
|
70
|
+
// 0x587f…5d7E, 0x5a99…d716, 0xB034…EBE3; docs/TESTNET-GANG-BOND-2026-10-28.md); split and LP factories
|
|
71
|
+
// docs/TESTNET-SPLIT-MODULE-2026-10-30.md, docs/TESTNET-LP-MODULE-2026-10-30.md
|
|
72
|
+
{
|
|
73
|
+
gen: '1.0', pad: '0xFebF58ba418ab4a3B3f054827eb11E99369C5BB1', router: '0x6bB660f310a9644Dc173E7Cf2F73498716D9C9F6',
|
|
74
|
+
bond: '0xd6a8dd5d1E6641a34A255f25Db2B3ED397CB1086', splitterFactory: '0x7E63fF8A9FB9Ab1BE4e2128e9f6C8D1054292BBe',
|
|
75
|
+
splitFactory: '0x5F7dC7502E945A860Cf49cca72dA8bD60Fb1567E', lpFactory: '0xA729C60FCa0Bd0D28a55E22126D3fE412AA41591',
|
|
76
|
+
comboFactory: '0x52a8f90a92E5C1828b4436a0B99C6b293f7F4CFE',
|
|
77
|
+
},
|
|
78
|
+
],
|
|
25
79
|
}
|
|
26
|
-
//
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
80
|
+
// what a generation brings to a ctx (gen: '1.0' | '2.0', null for a pad named by the env that this CLI does not know)
|
|
81
|
+
const GEN_FIELDS = ['gen', 'pad', 'router', 'bond', 'splitterFactory', 'splitFactory', 'lpFactory', 'comboFactory']
|
|
82
|
+
// the env names of each field, per network (new name first; the old per-command names still work as aliases)
|
|
83
|
+
const GEN_ENV = {
|
|
84
|
+
mainnet: {
|
|
85
|
+
pad: ['GANG_PAD', 'GANG_V3_PAD', 'GANG_FAIR_PAD'], router: ['GANG_ROUTER'], bond: ['GANG_BOND'],
|
|
86
|
+
splitterFactory: ['GANG_SPLITTER_FACTORY'], splitFactory: ['GANG_SPLIT_FACTORY'], lpFactory: ['GANG_LP_FACTORY'],
|
|
87
|
+
comboFactory: ['GANG_COMBO_FACTORY'],
|
|
88
|
+
},
|
|
89
|
+
testnet: {
|
|
90
|
+
pad: ['GANG_TESTNET_PAD', 'GANG_V3_TESTNET_PAD', 'GANG_FAIR_TESTNET_PAD'], router: ['GANG_TESTNET_ROUTER', 'GANG_ROUTER_TESTNET'],
|
|
91
|
+
bond: ['GANG_TESTNET_BOND'], splitterFactory: ['GANG_TESTNET_SPLITTER_FACTORY'], splitFactory: ['GANG_TESTNET_SPLIT_FACTORY'],
|
|
92
|
+
lpFactory: ['GANG_TESTNET_LP_FACTORY'], comboFactory: ['GANG_TESTNET_COMBO_FACTORY'],
|
|
93
|
+
},
|
|
31
94
|
}
|
|
32
95
|
|
|
33
96
|
// Public BSC nodes, tried in this order (2026-10-30: each answered eth_call with revert data, tx and receipt reads).
|
|
@@ -93,23 +156,45 @@ const env = (...names) => {
|
|
|
93
156
|
return null
|
|
94
157
|
}
|
|
95
158
|
|
|
96
|
-
|
|
159
|
+
const sameAddr = (a, b) => !!a && !!b && a.toLowerCase() === b.toLowerCase()
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The generations of a network as this run sees them, newest first. The env overrides the create target (the first):
|
|
163
|
+
* a GANG_PAD naming a known pad makes that generation the target, with its own contracts; an unknown pad gets only the
|
|
164
|
+
* router, bond and factories the env names. Every contract the env does not override stays the generation's own, so a
|
|
165
|
+
* pad is never paired with another generation's router or bond: a variable naming another built-in generation's
|
|
166
|
+
* contract (an old GANG_TESTNET_ROUTER set for set 10, say) is left out — that generation's tokens use it anyway.
|
|
167
|
+
*/
|
|
168
|
+
export function gangGens(testnet) {
|
|
169
|
+
const net = testnet ? 'testnet' : 'mainnet'
|
|
170
|
+
const set = Object.fromEntries(Object.entries(GEN_ENV[net]).map(([k, names]) => [k, env(...names)]))
|
|
171
|
+
const list = GANG_GENS[net]
|
|
172
|
+
const first = { ...(set.pad ? (list.find((g) => sameAddr(g.pad, set.pad)) ?? { gen: null, pad: set.pad }) : list[0]) }
|
|
173
|
+
for (const k of GEN_FIELDS.slice(2)) {
|
|
174
|
+
if (set[k] && !list.some((g) => !sameAddr(g.pad, first.pad) && sameAddr(g[k], set[k]))) first[k] = set[k]
|
|
175
|
+
}
|
|
176
|
+
return [first, ...list.filter((g) => !sameAddr(g.pad, first.pad))].map(genFields)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** A generation's contracts as ctx fields (missing ones null). */
|
|
180
|
+
export const genFields = (g) => Object.fromEntries(GEN_FIELDS.map((k) => [k, g?.[k] ?? null]))
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Network settings for `gang v3` (kind 'v3') or `gang fair` (kind 'fair'): the same pad on a merged deployment. pad,
|
|
184
|
+
* router, bond and the factories are the create target's; `gens` lists every generation (atTokenPad moves a ctx to the
|
|
185
|
+
* one that has a token).
|
|
186
|
+
*/
|
|
97
187
|
export function padNets(kind) {
|
|
98
188
|
const alias = kind === 'v3' ? 'V3' : 'FAIR'
|
|
99
|
-
|
|
100
|
-
const set = TESTNET_SET8.pad ? TESTNET_SET8 : { pad: TESTNET_SET7[kind], router: TESTNET_SET7.router }
|
|
189
|
+
const [main, test] = [gangGens(false), gangGens(true)]
|
|
101
190
|
return {
|
|
102
191
|
mainnet: {
|
|
103
|
-
chainId: '56', chain: bsc,
|
|
104
|
-
pad: env('GANG_PAD', `GANG_${alias}_PAD`) || MAINNET_GANG.pad || null,
|
|
192
|
+
chainId: '56', chain: bsc, ...genFields(main[0]), gens: main,
|
|
105
193
|
rpcs: rpcList(env('GANG_RPC_URL')) || MAINNET_RPCS,
|
|
106
194
|
wbnb: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', explorer: 'https://bscscan.com',
|
|
107
|
-
router: env('GANG_ROUTER') || MAINNET_GANG.router || null,
|
|
108
195
|
},
|
|
109
196
|
testnet: {
|
|
110
|
-
chainId: '97', chain: bscTestnet,
|
|
111
|
-
pad: env('GANG_TESTNET_PAD', `GANG_${alias}_TESTNET_PAD`) || set.pad,
|
|
112
|
-
router: env('GANG_TESTNET_ROUTER', 'GANG_ROUTER_TESTNET') || set.router || null,
|
|
197
|
+
chainId: '97', chain: bscTestnet, ...genFields(test[0]), gens: test,
|
|
113
198
|
rpcs: rpcList(env('GANG_TESTNET_RPC_URL', `GANG_${alias}_TESTNET_RPC_URL`)) || TESTNET_RPCS,
|
|
114
199
|
wbnb: '0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd', explorer: 'https://testnet.bscscan.com',
|
|
115
200
|
},
|
|
@@ -125,6 +210,8 @@ export const NOT_ON_MAINNET = 'no gang launchpad address for this network — se
|
|
|
125
210
|
export const MERGED_ERRORS_ABI = parseAbi([
|
|
126
211
|
'error Untaxed()', 'error NotReclaimable()', 'error NotLocked()', 'error WrongKind()', 'error TransfersLocked()',
|
|
127
212
|
'error StillLocked()', 'error SwapBackOutOfGas()', 'error SellDuringFlashSwap()', 'error BadKind()',
|
|
213
|
+
// 2.0, both kinds: the graduation amount / raise in the quote is more than a PancakeSwap pair can hold
|
|
214
|
+
'error QuoteAmountTooLarge()',
|
|
128
215
|
])
|
|
129
216
|
export const MERGED_HINTS = {
|
|
130
217
|
Untaxed: 'this token is untaxed (0% / 0%): it never gets a pool tax, a tax route or dividends; nothing to release or claim on it',
|
|
@@ -136,6 +223,7 @@ export const MERGED_HINTS = {
|
|
|
136
223
|
StillLocked: 'the token has not graduated / launched yet',
|
|
137
224
|
SwapBackOutOfGas: 'too little gas for the sell-time tax chunk: re-run with the estimated gas limit (do not cap it lower)',
|
|
138
225
|
SellDuringFlashSwap: 'a sell paid in from a flash swap callback is refused by this token',
|
|
226
|
+
QuoteAmountTooLarge: 'in this quote the graduation target / raise is more than a PancakeSwap pair can hold (the quote is priced far below BNB, often by a skewed --ref-pool): pick another quote or reference pool',
|
|
139
227
|
}
|
|
140
228
|
|
|
141
229
|
const KIND_ABI = parseAbi(['function kindOf(address token) view returns (uint8)'])
|
|
@@ -150,6 +238,143 @@ export async function kindOf(ctx, token) {
|
|
|
150
238
|
}
|
|
151
239
|
}
|
|
152
240
|
|
|
241
|
+
/**
|
|
242
|
+
* Which generation's pad has `token`, asked of every pad of ctx.gens at once: { g, kind } with kind 'v3' | 'fair';
|
|
243
|
+
* { g: null, kind: 'none' } when no pad has it; kind null when a pad could not be read and no other one has it.
|
|
244
|
+
*/
|
|
245
|
+
export async function genOf(ctx, token) {
|
|
246
|
+
const gens = ctx.gens ?? [ctx]
|
|
247
|
+
const kinds = await Promise.all(gens.map((g) => kindOf({ ...ctx, pad: g.pad }, token)))
|
|
248
|
+
const i = kinds.findIndex((k) => k === 'v3' || k === 'fair')
|
|
249
|
+
if (i >= 0) return { g: gens[i], kind: kinds[i] }
|
|
250
|
+
return { g: null, kind: kinds.includes(null) ? null : 'none' }
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Move ctx to the generation whose pad has `token`: its pad, router, GangBond and factories. ctx stays on the create
|
|
255
|
+
* target when no pad has the token (the caller then says what it is not). → the token's kind as genOf gives it (null:
|
|
256
|
+
* a pad could not be read, see KIND_UNREAD); undefined when `token` is not an address (the caller refuses it).
|
|
257
|
+
*/
|
|
258
|
+
export async function atTokenPad(ctx, token) {
|
|
259
|
+
if (!/^0x[0-9a-fA-F]{40}$/.test(token ?? '')) return undefined
|
|
260
|
+
const { g, kind } = await genOf(ctx, token)
|
|
261
|
+
if (g && !sameAddr(g.pad, ctx.pad)) {
|
|
262
|
+
Object.assign(ctx, genFields(g))
|
|
263
|
+
delete ctx._tax // the tax handler and the fee constants are the pad's
|
|
264
|
+
delete ctx.fees
|
|
265
|
+
}
|
|
266
|
+
return kind
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Point ctx at the generation whose pad is `pad` (a module's own pad()), as atTokenPad does for a token; false when `pad`
|
|
271
|
+
* is none of this network's GangLaunchpad pads.
|
|
272
|
+
*/
|
|
273
|
+
export function atPad(ctx, pad, testnet) {
|
|
274
|
+
const g = gangGens(testnet).find((x) => sameAddr(x.pad, pad))
|
|
275
|
+
if (!g) return false
|
|
276
|
+
if (!sameAddr(g.pad, ctx.pad)) {
|
|
277
|
+
Object.assign(ctx, genFields(g))
|
|
278
|
+
delete ctx._tax
|
|
279
|
+
delete ctx.fees
|
|
280
|
+
}
|
|
281
|
+
return true
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const LISTING_ABI = parseAbi([
|
|
285
|
+
'function taxHandler() view returns (address)',
|
|
286
|
+
'function owner() view returns (address)',
|
|
287
|
+
'function moduleOf(address module) view returns (address)',
|
|
288
|
+
])
|
|
289
|
+
/**
|
|
290
|
+
* The factory that listed `module` on ctx.pad's tax handler (GangHandlerAdmin, the handler's owner: moduleOf), or null
|
|
291
|
+
* when it never listed it: not one of the platform's modules, whatever its moduleType() says.
|
|
292
|
+
*/
|
|
293
|
+
export async function listedBy(ctx, module) {
|
|
294
|
+
const handler = await ctx.read(ctx.pad, LISTING_ABI, 'taxHandler')
|
|
295
|
+
const admin = await ctx.read(handler, LISTING_ABI, 'owner')
|
|
296
|
+
const factory = await ctx.read(admin, LISTING_ABI, 'moduleOf', [module])
|
|
297
|
+
return /^0x0{40}$/.test(factory) ? null : factory
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** What a command says when atTokenPad could not read every pad (null): retry rather than a wrong "not this kind". */
|
|
301
|
+
export const KIND_UNREAD = { error: 'could not read which GangLaunchpad has this token (kindOf; RPC error)', retry: 'same command again' }
|
|
302
|
+
|
|
303
|
+
/** The 2.0 creator fee: 70% of the 1% curve fee of each V3 curve trade, kept on the pad for the token's creator. */
|
|
304
|
+
export const CREATOR_FEE_ABI = parseAbi([
|
|
305
|
+
'function CREATOR_FEE_SHARE_BPS() view returns (uint256)',
|
|
306
|
+
'function creatorFeeOf(address token) view returns (uint256)',
|
|
307
|
+
'function claimCreatorFee(address token, address to) returns (uint256 amount)',
|
|
308
|
+
'error NotCreator()',
|
|
309
|
+
'event CreatorFeeAccrued(address indexed token, address indexed creator, uint256 amount)',
|
|
310
|
+
'event CreatorFeeClaimed(address indexed token, address indexed creator, address indexed to, uint256 amount)',
|
|
311
|
+
])
|
|
312
|
+
const feeShares = new Map()
|
|
313
|
+
// a call that hit a contract without the function: no return data, or a revert without data. An RPC's internal error
|
|
314
|
+
// (-32603) also comes back from viem as a revert, so it is told apart by its code
|
|
315
|
+
const noSuchFunction = (e) => !e?.walk?.((x) => x?.code === -32603)
|
|
316
|
+
&& !!e?.walk?.((x) => x?.name === 'ContractFunctionZeroDataError' || (x?.name === 'ContractFunctionRevertedError' && !x.data && (!x.raw || x.raw === '0x')))
|
|
317
|
+
/**
|
|
318
|
+
* The pad's creator share of the curve fee in bps (7000 on 2.0); null on a 1.0 pad. A built-in generation is known
|
|
319
|
+
* without a call (1.0: null); a pad named by the env is asked: a 1.0 pad has no CREATOR_FEE_SHARE_BPS (the call reverts
|
|
320
|
+
* without data). Any other error (the RPC) is thrown, so a 2.0 token is never shown as 1.0.
|
|
321
|
+
*/
|
|
322
|
+
export async function creatorFeeShareOf(ctx, pad = ctx.pad) {
|
|
323
|
+
const known = [...GANG_GENS.mainnet, ...GANG_GENS.testnet].find((g) => sameAddr(g.pad, pad))
|
|
324
|
+
if (known?.gen === '1.0') return null
|
|
325
|
+
const key = `${ctx.chainId}:${pad.toLowerCase()}`
|
|
326
|
+
if (!feeShares.has(key)) {
|
|
327
|
+
const p = ctx.read(pad, CREATOR_FEE_ABI, 'CREATOR_FEE_SHARE_BPS').then(Number).catch((e) => {
|
|
328
|
+
if (!known && noSuchFunction(e)) return null
|
|
329
|
+
feeShares.delete(key)
|
|
330
|
+
throw e
|
|
331
|
+
})
|
|
332
|
+
feeShares.set(key, p)
|
|
333
|
+
}
|
|
334
|
+
return feeShares.get(key)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* The V3 curve graduation target (GangLaunchpad 2.0): the creator picks one of GRAD_BNB_TIERS (BNB raised) with
|
|
339
|
+
* createWithGradTarget, create takes TARGET_GRAD_BNB (9 on 2.0). 1.0 has neither pick nor tiers: every curve 15 BNB.
|
|
340
|
+
*/
|
|
341
|
+
export const GRAD_TARGET_ABI = parseAbi([
|
|
342
|
+
'function GRAD_BNB_TIERS() pure returns (uint256[4])',
|
|
343
|
+
'function TARGET_GRAD_BNB() view returns (uint256)',
|
|
344
|
+
'function gradTargetOf(address token) view returns (uint256)',
|
|
345
|
+
'function graduationAmountFor(address quote, address refPool, uint256 gradBnb) view returns (uint256)',
|
|
346
|
+
'error BadGradTarget()',
|
|
347
|
+
'event GradTargetSet(address indexed token, uint256 gradBnb)',
|
|
348
|
+
])
|
|
349
|
+
const gradTiers = new Map()
|
|
350
|
+
const bnbNum = (wei) => Number(wei / 10n ** 15n) / 1000
|
|
351
|
+
/**
|
|
352
|
+
* The graduation targets a creator may pick on `pad`, in BNB ([6, 9, 12, 15]); null on a pad without the pick (1.0,
|
|
353
|
+
* known without a call, or an older 2.0 build: GRAD_BNB_TIERS reverts without data). An RPC error is thrown.
|
|
354
|
+
*/
|
|
355
|
+
export async function gradTiersOf(ctx, pad = ctx.pad) {
|
|
356
|
+
const known = [...GANG_GENS.mainnet, ...GANG_GENS.testnet].find((g) => sameAddr(g.pad, pad))
|
|
357
|
+
if (known?.gen === '1.0') return null
|
|
358
|
+
const key = `${ctx.chainId}:${pad.toLowerCase()}`
|
|
359
|
+
if (!gradTiers.has(key)) {
|
|
360
|
+
const p = ctx.read(pad, GRAD_TARGET_ABI, 'GRAD_BNB_TIERS').then((t) => t.map(bnbNum)).catch((e) => {
|
|
361
|
+
if (noSuchFunction(e)) return null
|
|
362
|
+
gradTiers.delete(key)
|
|
363
|
+
throw e
|
|
364
|
+
})
|
|
365
|
+
gradTiers.set(key, p)
|
|
366
|
+
}
|
|
367
|
+
return gradTiers.get(key)
|
|
368
|
+
}
|
|
369
|
+
/** A token's graduation target in BNB raised: its pick (gradTargetOf) where the pad has one, else the pad's TARGET_GRAD_BNB. */
|
|
370
|
+
export async function gradTargetBnbOf(ctx, token) {
|
|
371
|
+
if (await gradTiersOf(ctx)) {
|
|
372
|
+
const v = await ctx.read(ctx.pad, GRAD_TARGET_ABI, 'gradTargetOf', [token])
|
|
373
|
+
if (v > 0n) return bnbNum(v)
|
|
374
|
+
}
|
|
375
|
+
return bnbNum(await ctx.read(ctx.pad, GRAD_TARGET_ABI, 'TARGET_GRAD_BNB'))
|
|
376
|
+
}
|
|
377
|
+
|
|
153
378
|
/**
|
|
154
379
|
* Why `token` is not a `want` ('v3' | 'fair') token on this pad, as { error, hint, kind } for fail(): points at the right
|
|
155
380
|
* subcommand when kindOf says it is the other kind. `net` is appended to the suggested command (' --testnet' or '').
|
package/src/index.js
CHANGED
|
@@ -27,7 +27,8 @@ import { runFly, flyCtx, isFlyToken, FLY_EVENT_ABIS, FLY_CREATE_FLAGS } from './
|
|
|
27
27
|
import { FAIR_DEV_BUY, isLaunch, LAUNCH_FLAGS, runLaunch } from './launch.js'
|
|
28
28
|
import { poolPayBnb, poolTrade } from './pool.js'
|
|
29
29
|
import { parseAmount, ROUTER_ABI, ROUTER_HINTS, revertOf as revertIn, step as writeStep } from './steps.js'
|
|
30
|
-
import { MERGED_ERRORS_ABI,
|
|
30
|
+
import { MERGED_ERRORS_ABI, genOf, padNets } from './gangpad.js'
|
|
31
|
+
import { creatorFeeCtx, creatorFeeList, runCreatorFee } from './creatorfee.js'
|
|
31
32
|
import { V2_ABI } from './abi.js'
|
|
32
33
|
import { runMcp } from './mcp.js'
|
|
33
34
|
import { portfolio } from './portfolio.js'
|
|
@@ -278,14 +279,17 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
278
279
|
copy an image to gang.fun → logoUrl (ipfs://<cid>, for --logo-uri) and url (CDN)
|
|
279
280
|
|
|
280
281
|
gang create --name <n> --symbol <s> [--buy-tax <1-5> --sell-tax <1-5> [--dividend 0-100] [--recipient <0x…>]]
|
|
281
|
-
[--quote 0x… --ref-pool 0x…] [--logo <file> | --logo-uri URL] [--website URL]
|
|
282
|
-
[--description <text>] [--testnet]
|
|
282
|
+
[--grad 6|9|12|15] [--quote 0x… --ref-pool 0x…] [--logo <file> | --logo-uri URL] [--website URL]
|
|
283
|
+
[--twitter @handle] [--description <text>] [--testnet]
|
|
283
284
|
a V3 token on GangLaunchpad (LaunchpadV2 / Soft / U / S take no new tokens; --taxed,
|
|
284
285
|
the old V2 track, is refused). No --buy-tax / --sell-tax: untaxed (no pool tax, no
|
|
285
286
|
dividend, no recipient). Taxed: own buy / sell tax in % (fixed at create), only in the
|
|
286
287
|
pool after graduation: 0.5% of volume to the platform; of the rest --dividend % to
|
|
287
288
|
holders, the remainder to --recipient (default: you, the creator; or a partner on the
|
|
288
|
-
platform whitelist) in the quote. Curve trades pay only the 1% fee, no tax
|
|
289
|
+
platform whitelist) in the quote. Curve trades pay only the 1% fee, no tax.
|
|
290
|
+
--grad (GangLaunchpad 2.0): the graduation target in BNB raised, 6 / 9 / 12 / 15
|
|
291
|
+
(default 9; market cap at graduation ≈ 5×); 1.0 graduates every curve at 15 and
|
|
292
|
+
refuses --grad. info / status show each token's graduationTargetBnb
|
|
289
293
|
gang create --fair --name <n> --symbol <s> [--raise 15] [--cap 0.5] [--hold 60] [--mint-fee 1] [--exit-fee 1]
|
|
290
294
|
[--shares 1] [--quote 0x… --ref-pool 0x…] [--logo …] [--website URL] [--twitter @handle] [--description …]
|
|
291
295
|
a 打新 (fair mint) sale: one price per share both ways, the last share launches on
|
|
@@ -294,7 +298,7 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
294
298
|
mint fee 1–3%, withdraw fee 1–2% (none after 7 days without 10 new shares). Wraps /
|
|
295
299
|
approves first when needed (re-run after each)
|
|
296
300
|
both: --quote = WBNB (default) or any 18-decimal token; --ref-pool = a Pancake V2 pair
|
|
297
|
-
or V3 pool holding it, which prices the
|
|
301
|
+
or V3 pool holding it, which prices the graduation target / the raise (mainnet
|
|
298
302
|
USDT defaults to the USDT/WBNB pool) unless gang set a fixed rate. --website /
|
|
299
303
|
--twitter / --description and the logo go into the token's metadata JSON (uploaded to
|
|
300
304
|
gang.fun; the token's contractURI / metaURI, permanent). --logo-uri images are copied
|
|
@@ -410,6 +414,16 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
410
414
|
past the deadline, --settle-first settles the bond before the sell (asks first;
|
|
411
415
|
settles 1 hour later).
|
|
412
416
|
|
|
417
|
+
CREATOR FEE (GangLaunchpad 2.0: of the 1% fee on every V3 curve buy and sell, 70% is kept on the pad for the token's
|
|
418
|
+
creator, before and after graduation, no deadline; 1.0 tokens and 打新 sales have none):
|
|
419
|
+
gang creator-fee [--from <creator>] every 2.0 V3 token this wallet created and what it can claim (read on chain), with
|
|
420
|
+
totals per quote
|
|
421
|
+
gang creator-fee --token <addr> one token: padGen, sharePct, claimable
|
|
422
|
+
gang creator-fee --token <addr> --claim [--to <addr>]
|
|
423
|
+
claim all of it (the creator only), to this wallet or --to (not 0x0 or the pad).
|
|
424
|
+
The fee is the creator's own: never the tax recipient's or a buy-back / split / LP
|
|
425
|
+
module's. gang info / status (the creator's) and gang portfolio show it too
|
|
426
|
+
|
|
413
427
|
BOND (押金承诺, GangBond; any GangLaunchpad token, from create on; GANG_BOND / GANG_TESTNET_BOND = its address):
|
|
414
428
|
gang bond post --token <addr> --hold <tokens|N%> --days <7-90> (--amount <quote> | --cover <coverage %>) [--use-wbnb]
|
|
415
429
|
creator only, any time after create (V3: buy on the curve first): bond in the token's
|
|
@@ -453,7 +467,16 @@ BUYBACK (a V3 token whose recipient is a buy-back splitter; GANG_SPLITTER_FACTOR
|
|
|
453
467
|
gang buyback apply --token <addr> anyone: apply a cut whose notice ran (within 7 days, or it lapses)
|
|
454
468
|
gang buyback bind --token <addr> | gang buyback release --token <addr>
|
|
455
469
|
anyone: bind the splitter to its token (the launch does it) / push the payee what a
|
|
456
|
-
failed payment left owed
|
|
470
|
+
failed payment left owed
|
|
471
|
+
gang buyback split (--token <addr> | --module <splitter>)
|
|
472
|
+
anyone: split what arrived since the last split: the payee's part is pushed now, the
|
|
473
|
+
buy-back part set aside (the preview shows both). The keeper's chunks split first, so
|
|
474
|
+
after graduation it runs by itself; before it (a creator fee claimed --to the
|
|
475
|
+
splitter) only this pays the payee. Only a splitter a GangLaunchpad pad listed.
|
|
476
|
+
gang buyback sweep (--token <addr> | --module <splitter>) --asset <addr>|wbnb
|
|
477
|
+
anyone: send the splitter's whole balance of an asset that is not its own quote (a
|
|
478
|
+
creator fee or a tax in another quote) to the payee; split never moves it.
|
|
479
|
+
--testnet, --calldata, --from as in gang v3
|
|
457
480
|
SPLIT (a V3 token whose recipient is a split module, split-v1; GANG_SPLIT_FACTORY / GANG_TESTNET_SPLIT_FACTORY):
|
|
458
481
|
gang split status --token <addr> payees and shares (fixed), the dev, the bound token / quote, what waits to be split
|
|
459
482
|
and what each slot is owed (bound quote, WBNB, GANG, the token's quote), whether the
|
|
@@ -486,6 +509,11 @@ LP (a V3 token whose recipient is an LP splitter, lp-burn-v1; GANG_LP_FACTORY /
|
|
|
486
509
|
gang lp bind --token <addr> | gang lp release --token <addr>
|
|
487
510
|
anyone: bind the splitter to its token (the launch does it) / push the payee what a
|
|
488
511
|
failed payment left owed
|
|
512
|
+
gang lp split (--token <addr> | --module <splitter>)
|
|
513
|
+
anyone: split what arrived since the last split: the payee's part is pushed now, the
|
|
514
|
+
pool's part set aside (the preview shows both); as gang buyback split
|
|
515
|
+
gang lp sweep (--token <addr> | --module <splitter>) --asset <addr>|wbnb
|
|
516
|
+
anyone: another asset than the splitter's quote to the payee; as gang buyback sweep
|
|
489
517
|
gang lp add --token <addr> [--slippage 1]
|
|
490
518
|
anyone: one chunk now, as the keeper does (graduated tokens; one per 4 minutes; ≤ 0.5%
|
|
491
519
|
of the pair's quote reserve; waits for a 10-minute average and skips when the price is
|
|
@@ -547,10 +575,12 @@ off, GANG_UPDATE_URL points it at an npm mirror).
|
|
|
547
575
|
|
|
548
576
|
env: GANG_RPC_URL (one URL or a comma list; unset: five public BSC nodes, the next one tried when one fails),
|
|
549
577
|
GANG_LOGO_API, GANG_API (default ${API}), GANG_NOTES_DIR (default ~/.gang/notes), GANG_UPDATE_CHECK, GANG_UPDATE_URL,
|
|
550
|
-
GANG_PAD / GANG_TESTNET_PAD (the
|
|
551
|
-
and GANG_V3_TESTNET_PAD / GANG_FAIR_TESTNET_PAD still work as aliases), GANG_TESTNET_RPC_URL (aliases
|
|
578
|
+
GANG_PAD / GANG_TESTNET_PAD (the GangLaunchpad new tokens go to, behind both gang v3 and gang fair; old names GANG_V3_PAD /
|
|
579
|
+
GANG_FAIR_PAD and GANG_V3_TESTNET_PAD / GANG_FAIR_TESTNET_PAD still work as aliases), GANG_TESTNET_RPC_URL (aliases
|
|
552
580
|
GANG_V3_TESTNET_RPC_URL / GANG_FAIR_TESTNET_RPC_URL), GANG_ROUTER / GANG_TESTNET_ROUTER (alias GANG_ROUTER_TESTNET; GangRouter
|
|
553
|
-
for BNB buys / mints and every pool trade
|
|
581
|
+
for BNB buys / mints and every pool trade). Built in: GangLaunchpad 1.0 on mainnet; 2.0 (where new tokens go) and 1.0
|
|
582
|
+
on the testnet. A token is always served by its own generation's pad, router, GangBond and module factories; these
|
|
583
|
+
variables (and GANG_BOND / GANG_*_FACTORY) set the create target's only,
|
|
554
584
|
GANG_FLY_PAD / GANG_TESTNET_FLY_PAD (GangFlywheelPad V1; default: the built-in mainnet / testnet set 2 addresses),
|
|
555
585
|
GANG_FLY_PAD_V2 / GANG_TESTNET_FLY_PAD_V2 (V2, where new tokens go; default: the built-in mainnet / testnet V2). --guard / --twap-window
|
|
556
586
|
(V2 only): the guard is off by default (post-launch minting does not pause on a price drop; the quota cap of 10 per
|
|
@@ -937,7 +967,8 @@ async function padKind(token, verb) {
|
|
|
937
967
|
const testnet = flag('testnet')
|
|
938
968
|
let ctx
|
|
939
969
|
try { ctx = v3Ctx(testnet) } catch (e) { fail(e.message) }
|
|
940
|
-
|
|
970
|
+
// every GangLaunchpad generation of this network (1.0, 2.0) is asked
|
|
971
|
+
const { kind } = await genOf(ctx, token)
|
|
941
972
|
if (kind === 'v3' || kind === 'fair') return kind
|
|
942
973
|
// not GangLaunchpad's: the 铸币飞轮 pad (GangFlywheelPad, kind 3) is asked next
|
|
943
974
|
const fly = await isFlyToken(flyCtx(testnet), token)
|
|
@@ -1073,7 +1104,10 @@ function checkFlyCreate() {
|
|
|
1073
1104
|
: `--${wrong} is a V3 tax setting; a 铸币飞轮 token's tax goes to holders, the platform and the creator in fixed parts`)
|
|
1074
1105
|
}
|
|
1075
1106
|
}
|
|
1107
|
+
// --grad picks a V3 curve's graduation target (2.0); a 打新 / 铸币飞轮 sale ends at its own --raise
|
|
1108
|
+
const GRAD_ONLY_V3 = (what) => `--grad is a V3 curve setting (the graduation target, 2.0): ${what} fills at its --raise instead, so leave --grad out`
|
|
1076
1109
|
function create() {
|
|
1110
|
+
if (flag('grad') && (flag('fly') || flag('fair'))) fail(GRAD_ONLY_V3(flag('fly') ? 'a 铸币飞轮 sale' : 'a 打新 sale'))
|
|
1077
1111
|
if (flag('fly')) {
|
|
1078
1112
|
checkFlyCreate()
|
|
1079
1113
|
return runFly('create', { ...PAD_IO })
|
|
@@ -1095,7 +1129,7 @@ function create() {
|
|
|
1095
1129
|
// commands whose JSON result carries `update`; `watch` streams NDJSON and help is plain text
|
|
1096
1130
|
const UPDATE_CHECKED = new Set(['version', '--version', '-v', 'preflight', 'list', 'hot', 'new', 'near-grad', 'notes', 'agents', 'token', 'info', 'status', 'portfolio', 'quote',
|
|
1097
1131
|
'buy', 'follow', 'sell', 'claim', 'mint', 'withdraw', 'release', 'upload-logo', 'create', 'execute', 'tx', 'fair', 'v3', 'bond',
|
|
1098
|
-
'buyback', 'split', 'lp', 'combo', 'fly'])
|
|
1132
|
+
'buyback', 'split', 'lp', 'combo', 'fly', 'creator-fee'])
|
|
1099
1133
|
// gang tx decodes these beside the V2 / Soft / U / S pads' events (GangLaunchpad: both kinds; the tax router; the vaults)
|
|
1100
1134
|
const GANG_EVENT_ABIS = [...V3_EVENT_ABIS, ...FAIR_EVENT_ABIS, ...FLY_EVENT_ABIS, ...SPLIT_EVENT_ABIS, ...LP_EVENT_ABIS, ...COMBO_EVENT_ABIS]
|
|
1101
1135
|
|
|
@@ -1204,6 +1238,8 @@ async function main() {
|
|
|
1204
1238
|
return runFly(args[1], alias('fly', args[1]))
|
|
1205
1239
|
case 'mcp':
|
|
1206
1240
|
return runMcp()
|
|
1241
|
+
case 'creator-fee':
|
|
1242
|
+
return runCreatorFee({ opt, flag, out, fail, summarize: summarizePreview })
|
|
1207
1243
|
case 'bond':
|
|
1208
1244
|
await refuseFly('GangBond')
|
|
1209
1245
|
return runBond(args[1], { opt, flag, out, fail, summarize: summarizePreview })
|
|
@@ -1238,7 +1274,7 @@ async function main() {
|
|
|
1238
1274
|
return out({
|
|
1239
1275
|
success: issues.length === 0, cliVersion: VERSION, status, address: me,
|
|
1240
1276
|
// `launchpad` = createPad: kept for readers of the old field (it used to be the V2 create target)
|
|
1241
|
-
launchpad: padNets('v3').mainnet.pad, createPad: padNets('v3').mainnet.pad, isAgent: agent,
|
|
1277
|
+
launchpad: padNets('v3').mainnet.pad, createPad: padNets('v3').mainnet.pad, createPadGen: padNets('v3').mainnet.gen, isAgent: agent,
|
|
1242
1278
|
devMode: settings?.devMode?.enabled ?? null, tradeAllTokens: settings?.tradeAllTokens ?? null, issues,
|
|
1243
1279
|
note: 'New create → GangLaunchpad (gang create = gang v3 create; gang fair create for 打新). LaunchpadV2 / Soft / U / S take no new tokens: existing buy / sell only.',
|
|
1244
1280
|
})
|
|
@@ -1403,7 +1439,10 @@ async function main() {
|
|
|
1403
1439
|
case 'portfolio': {
|
|
1404
1440
|
if (flag('testnet')) fail('gang portfolio is mainnet only: gang.fun indexes no testnet trades (gang status --testnet reads one token)')
|
|
1405
1441
|
const me = fromArg() || bawAddress()
|
|
1406
|
-
return out(await portfolio({
|
|
1442
|
+
return out(await portfolio({
|
|
1443
|
+
wallet: me, get: (path) => apiGet(path, undefined, null), statusOf: portfolioStatus, bondOf: portfolioBond,
|
|
1444
|
+
creatorFeesOf: (w) => creatorFeeList(creatorFeeCtx(false), w),
|
|
1445
|
+
})
|
|
1407
1446
|
.catch((e) => fail(e.message, retryHint(e))))
|
|
1408
1447
|
}
|
|
1409
1448
|
case 'status':
|
|
@@ -1444,7 +1483,7 @@ async function main() {
|
|
|
1444
1483
|
const { token, follow } = await confirmFollow(noteTx, fromArg() || bawAddress())
|
|
1445
1484
|
if (!token) fail('gang.fun did not say which token this note is about', { noteTx })
|
|
1446
1485
|
// a GangLaunchpad token: the V3 curve buy (--amount / --bnb = the quote to spend)
|
|
1447
|
-
const onPad = await
|
|
1486
|
+
const { kind: onPad } = await genOf({ ...v2PoolCtx(), gens: padNets('v3').mainnet.gens }, token)
|
|
1448
1487
|
if (onPad === 'fair') fail('this note is on a 打新 (fair-mint) token: only curve buys can follow a note', { noteTx, token })
|
|
1449
1488
|
if (onPad !== 'v3' && (await isFlyToken(flyCtx(false), token))) fail('this note is on a 铸币飞轮 (Mint Flywheel) token: only curve buys can follow a note', { noteTx, token })
|
|
1450
1489
|
if (onPad === 'v3') {
|
package/src/launch.js
CHANGED
|
@@ -3,13 +3,14 @@ import { mkdirSync, readdirSync, readFileSync, renameSync, statSync, unlinkSync,
|
|
|
3
3
|
import { dirname, join } from 'node:path'
|
|
4
4
|
import { createPublicClient, parseAbi, formatUnits, encodeFunctionData, isAddress, zeroAddress } from 'viem'
|
|
5
5
|
import { DIR } from './notes.js'
|
|
6
|
-
import { padNets, NOT_ON_MAINNET, rpcTransport } from './gangpad.js'
|
|
6
|
+
import { creatorFeeShareOf, gradTiersOf, padNets, NOT_ON_MAINNET, rpcTransport } from './gangpad.js'
|
|
7
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
11
|
import { parseSplitSpec, simulateSplit, SPLIT_ABI, SPLIT_FACTORY_ABI, splitFactoryAddress, splitLine, splitNotDeployed, splitOf } from './split.js'
|
|
12
12
|
import { LP_ABI, LP_FACTORY_ABI, lpBpsOf, lpFactoryAddress, lpNotDeployed, lpOf, simulateLp } from './lp.js'
|
|
13
|
+
import { claimCmd, notThroughModule } from './creatorfee.js'
|
|
13
14
|
import { COMBO_ABI, COMBO_FACTORY_ABI, comboFactoryAddress, comboLine, comboNotDeployed, comboOf, comboParts, parseComboSpec, PERMANENT_NOTE, simulateCombo } from './combo.js'
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -45,6 +46,8 @@ import { COMBO_ABI, COMBO_FACTORY_ABI, comboFactoryAddress, comboLine, comboNotD
|
|
|
45
46
|
* is refused rather than starting over. --buyback-to / --lp-to don't apply (the payees are --split's).
|
|
46
47
|
*/
|
|
47
48
|
|
|
49
|
+
// 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' }
|
|
48
51
|
const LAUNCH_DIR = process.env.GANG_LAUNCH_DIR || join(dirname(DIR), 'launch')
|
|
49
52
|
const TTL_MS = 7 * 24 * 3600_000
|
|
50
53
|
const PAD_ABI = parseAbi([
|
|
@@ -277,6 +280,12 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
277
280
|
|
|
278
281
|
const client = createPublicClient({ chain: net.chain, transport: rpcTransport(net.rpcs) })
|
|
279
282
|
const read = (address, abi, functionName, args = []) => client.readContract({ address, abi, functionName, args })
|
|
283
|
+
// --grad (2.0): checked here, before a module clone, since the create that takes it comes later
|
|
284
|
+
if (kind === 'v3' && flag('grad')) {
|
|
285
|
+
const tiers = await gradTiersOf({ chainId: net.chainId, pad: net.pad, read })
|
|
286
|
+
if (!tiers) fail(`--grad: GangLaunchpad ${net.gen ?? net.pad} has no graduation target to pick: leave --grad out`)
|
|
287
|
+
if (!tiers.includes(Number(opt('grad')))) fail(`--grad must be one of ${tiers.join(' / ')} (BNB raised)`, { got: opt('grad') ?? null })
|
|
288
|
+
}
|
|
280
289
|
const key = [net.chainId, net.pad, me.toLowerCase(), kind, name, symbol].join('|')
|
|
281
290
|
const cloneStep = { buyback: 'buyback-splitter', split: 'split-module', lp: 'lp-splitter', combo: 'combo-module' }[mod]
|
|
282
291
|
const steps = [...(mod ? [cloneStep] : []), kind === 'v3' ? 'create' : 'create (dev shares included)', ...(mod ? ['bind'] : []),
|
|
@@ -286,6 +295,22 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
286
295
|
const withTag = (stage, extra) => (o) => out({ ...o, ...tag(stage, extra) })
|
|
287
296
|
|
|
288
297
|
let plan = flag('restart') ? null : readPlan(key)
|
|
298
|
+
// a launch begun on another generation's pad (an older CLI) and not done: its module and token belong to that pad, so
|
|
299
|
+
// it is never carried on here, nor started again without --restart
|
|
300
|
+
if (!plan && !flag('restart')) {
|
|
301
|
+
const old = net.gens.slice(1).map((g) => ({ g, p: readPlan([net.chainId, g.pad, me.toLowerCase(), kind, name, symbol].join('|')) })).find((x) => x.p && !x.p.done)
|
|
302
|
+
if (old) {
|
|
303
|
+
const tn = testnet ? ' --testnet' : ''
|
|
304
|
+
// two pads of one generation (testnet: 2.0 before and after the graduation pick) are told apart by address
|
|
305
|
+
const same = old.g.gen === net.gen
|
|
306
|
+
const lbl = (g) => (same ? `${g.gen ?? ''} pad ${g.pad}`.trim() : g.gen ?? g.pad)
|
|
307
|
+
const [was, now] = [lbl(old.g), lbl(net)]
|
|
308
|
+
return fail(`this launch began on GangLaunchpad ${was} and is not done; new tokens now go to ${now}`, {
|
|
309
|
+
...(old.p.token ? { token: old.p.token, hint: `the token is out on ${was}: finish its steps one by one (gang buy --token ${old.p.token} --amount <quote>${tn}, gang bond post --token ${old.p.token} …${tn}), or add --restart to launch a new token on ${now}` }
|
|
310
|
+
: { hint: `${old.p.splitter ? `its module ${old.p.splitter} was made for the ${was} pad and does not work with ${now}: ` : ''}add --restart to launch on ${now}` }),
|
|
311
|
+
})
|
|
312
|
+
}
|
|
313
|
+
}
|
|
289
314
|
const base = { kind, name, symbol, me, chainId: net.chainId, pad: net.pad }
|
|
290
315
|
|
|
291
316
|
// ---- a launch keeps the mode it began with (the create, once built, is never redone by a changed flag)
|
|
@@ -496,6 +521,8 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
496
521
|
const after = steps[steps.indexOf(kind === 'v3' ? 'create' : 'create (dev shares included)') + 1]
|
|
497
522
|
return out({
|
|
498
523
|
...o,
|
|
524
|
+
// 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 })}` }),
|
|
499
526
|
...tag('create', built ? { next: `${rerun}: it finds the new token and continues with ${after ?? 'nothing'}` } : o.success ? { next: `${rerun}: it then builds the create` } : {}),
|
|
500
527
|
})
|
|
501
528
|
},
|
|
@@ -552,6 +579,11 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
552
579
|
if (lps) done.lp = lps
|
|
553
580
|
const cs = await comboState()
|
|
554
581
|
if (cs) done.combo = cs
|
|
582
|
+
// 2.0: where the creator fee of a V3 token is claimed (and that a module does not get it)
|
|
583
|
+
const share = kind === 'v3' ? await creatorFeeShareOf({ chainId: net.chainId, pad: net.pad, read }).catch(() => null) : null
|
|
584
|
+
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 })}` : ''}`
|
|
586
|
+
}
|
|
555
587
|
if (!bond) return out({ ...done, note: `launched: gang ${kind} info --token ${token}${testnet ? ' --testnet' : ''}` })
|
|
556
588
|
return runBond('status', { ...stepIo({}), out: (o) => out({ ...done, bondStatus: o, note: `launched and bonded: gang bond status --token ${token}${testnet ? ' --testnet' : ''}` }) })
|
|
557
589
|
}
|