@gangfun/cli 0.21.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 +26 -15
- package/README.zh-CN.md +25 -15
- 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 +605 -0
- 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 +110 -24
- package/src/launch.js +154 -23
- package/src/lp.js +52 -15
- package/src/mcp.js +5 -5
- package/src/portfolio.js +25 -5
- package/src/split.js +7 -8
- package/src/v3.js +97 -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
|
@@ -22,11 +22,13 @@ import { runBond } from './bond.js'
|
|
|
22
22
|
import { runBuyback } from './buyback.js'
|
|
23
23
|
import { runSplit, SPLIT_EVENT_ABIS } from './split.js'
|
|
24
24
|
import { runLp, LP_EVENT_ABIS } from './lp.js'
|
|
25
|
+
import { runCombo, COMBO_EVENT_ABIS } from './combo.js'
|
|
25
26
|
import { runFly, flyCtx, isFlyToken, FLY_EVENT_ABIS, FLY_CREATE_FLAGS } from './fly.js'
|
|
26
27
|
import { FAIR_DEV_BUY, isLaunch, LAUNCH_FLAGS, runLaunch } from './launch.js'
|
|
27
28
|
import { poolPayBnb, poolTrade } from './pool.js'
|
|
28
29
|
import { parseAmount, ROUTER_ABI, ROUTER_HINTS, revertOf as revertIn, step as writeStep } from './steps.js'
|
|
29
|
-
import { MERGED_ERRORS_ABI,
|
|
30
|
+
import { MERGED_ERRORS_ABI, genOf, padNets } from './gangpad.js'
|
|
31
|
+
import { creatorFeeCtx, creatorFeeList, runCreatorFee } from './creatorfee.js'
|
|
30
32
|
import { V2_ABI } from './abi.js'
|
|
31
33
|
import { runMcp } from './mcp.js'
|
|
32
34
|
import { portfolio } from './portfolio.js'
|
|
@@ -277,14 +279,17 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
277
279
|
copy an image to gang.fun → logoUrl (ipfs://<cid>, for --logo-uri) and url (CDN)
|
|
278
280
|
|
|
279
281
|
gang create --name <n> --symbol <s> [--buy-tax <1-5> --sell-tax <1-5> [--dividend 0-100] [--recipient <0x…>]]
|
|
280
|
-
[--quote 0x… --ref-pool 0x…] [--logo <file> | --logo-uri URL] [--website URL]
|
|
281
|
-
[--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]
|
|
282
284
|
a V3 token on GangLaunchpad (LaunchpadV2 / Soft / U / S take no new tokens; --taxed,
|
|
283
285
|
the old V2 track, is refused). No --buy-tax / --sell-tax: untaxed (no pool tax, no
|
|
284
286
|
dividend, no recipient). Taxed: own buy / sell tax in % (fixed at create), only in the
|
|
285
287
|
pool after graduation: 0.5% of volume to the platform; of the rest --dividend % to
|
|
286
288
|
holders, the remainder to --recipient (default: you, the creator; or a partner on the
|
|
287
|
-
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
|
|
288
293
|
gang create --fair --name <n> --symbol <s> [--raise 15] [--cap 0.5] [--hold 60] [--mint-fee 1] [--exit-fee 1]
|
|
289
294
|
[--shares 1] [--quote 0x… --ref-pool 0x…] [--logo …] [--website URL] [--twitter @handle] [--description …]
|
|
290
295
|
a 打新 (fair mint) sale: one price per share both ways, the last share launches on
|
|
@@ -293,7 +298,7 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
293
298
|
mint fee 1–3%, withdraw fee 1–2% (none after 7 days without 10 new shares). Wraps /
|
|
294
299
|
approves first when needed (re-run after each)
|
|
295
300
|
both: --quote = WBNB (default) or any 18-decimal token; --ref-pool = a Pancake V2 pair
|
|
296
|
-
or V3 pool holding it, which prices the
|
|
301
|
+
or V3 pool holding it, which prices the graduation target / the raise (mainnet
|
|
297
302
|
USDT defaults to the USDT/WBNB pool) unless gang set a fixed rate. --website /
|
|
298
303
|
--twitter / --description and the logo go into the token's metadata JSON (uploaded to
|
|
299
304
|
gang.fun; the token's contractURI / metaURI, permanent). --logo-uri images are copied
|
|
@@ -352,9 +357,10 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
352
357
|
nobody (not you, not the platform) can change the payees or shares later; a payee can
|
|
353
358
|
only move its own slot (gang split set-payee). Steps: clone your split module
|
|
354
359
|
(GangSplitModuleFactory; listed as a recipient in the same tx) → create with it as the
|
|
355
|
-
recipient → bind → the rest of the launch. --
|
|
356
|
-
|
|
357
|
-
only (the quotes the keeper splits; others are refused before the
|
|
360
|
+
recipient → bind → the rest of the launch. Not with --recipient; with --buyback / --lp
|
|
361
|
+
it makes a combined recipient (below). Quote: WBNB (default), GANG or one listed in the
|
|
362
|
+
pad's QuoteRegistry only (the quotes the keeper splits; others are refused before the
|
|
363
|
+
clone)
|
|
358
364
|
gang create … --buy-tax <1-5> --sell-tax <1-5> --lp <0-100> [--lp-to <addr>] [--dev-buy … [--bond …]]
|
|
359
365
|
V3, taxed, auto-liquidity: --lp % of the recipient's part of the tax is added to the
|
|
360
366
|
token's PancakeSwap pair as liquidity whose LP goes to 0xdead (locked for good), the
|
|
@@ -362,8 +368,23 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
362
368
|
graduation the keeper adds it in chunks (half buys the token, all of it goes back in
|
|
363
369
|
with the matching quote). Steps: clone your LP splitter (GangLiquiditySplitterFactory;
|
|
364
370
|
listed as a recipient in the same tx) → create with it as the recipient → bind → the
|
|
365
|
-
rest of the launch. Not with --buyback
|
|
366
|
-
(default), GANG or one listed in the pad's QuoteRegistry
|
|
371
|
+
rest of the launch. Not with --recipient; with --buyback / --split it makes a combined
|
|
372
|
+
recipient (below). Quote: WBNB (default), GANG or one listed in the pad's QuoteRegistry
|
|
373
|
+
only
|
|
374
|
+
gang create … --buy-tax <1-5> --sell-tax <1-5> --buyback <0-100> --lp <0-100> [--split <addr>:<pct>[,…]] [--dev-buy …]
|
|
375
|
+
V3, taxed, combined recipient (GangComboSplitter, combo-v1): two or three of --buyback,
|
|
376
|
+
--lp, --split together. --buyback % of the recipient's part is bought back and burned,
|
|
377
|
+
--lp % added to the pair as liquidity (LP to 0xdead), the rest (100 − both) pushed to
|
|
378
|
+
the --split payees, whose shares are of that rest and add up to 100 (e.g. --buyback 30
|
|
379
|
+
--lp 30 --split self:70,0xKol…:30: 28% / 12% of the recipient's part); without --split
|
|
380
|
+
the rest goes to you. --buyback + --lp = 100 takes no --split; above 100 is refused.
|
|
381
|
+
--buyback-to / --lp-to don't apply (name payees with --split). PERMANENT: the ratios,
|
|
382
|
+
payees and shares can never change (unlike a lone --buyback / --lp, whose ratio the
|
|
383
|
+
dev can change); a payee can only move its own slot (gang combo set-payee). Any other
|
|
384
|
+
asset sent to it: its buy-back + LP share goes to 0xdead, the rest to the payees.
|
|
385
|
+
Steps: clone your combined recipient (GangComboSplitterFactory; listed in the same tx)
|
|
386
|
+
→ create → bind → the rest of the launch. Quote: WBNB (default), GANG or one listed
|
|
387
|
+
in the pad's QuoteRegistry only
|
|
367
388
|
gang create --fair … [--shares <n>] --bond <quote> [--bond-hold …] --bond-days <7-90>
|
|
368
389
|
打新: create (the dev's --shares are bought in it) → bond. Progress is read from the
|
|
369
390
|
chain (a token this wallet created with this symbol since the plan); a run that finds
|
|
@@ -393,6 +414,16 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
393
414
|
past the deadline, --settle-first settles the bond before the sell (asks first;
|
|
394
415
|
settles 1 hour later).
|
|
395
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
|
+
|
|
396
427
|
BOND (押金承诺, GangBond; any GangLaunchpad token, from create on; GANG_BOND / GANG_TESTNET_BOND = its address):
|
|
397
428
|
gang bond post --token <addr> --hold <tokens|N%> --days <7-90> (--amount <quote> | --cover <coverage %>) [--use-wbnb]
|
|
398
429
|
creator only, any time after create (V3: buy on the curve first): bond in the token's
|
|
@@ -436,7 +467,16 @@ BUYBACK (a V3 token whose recipient is a buy-back splitter; GANG_SPLITTER_FACTOR
|
|
|
436
467
|
gang buyback apply --token <addr> anyone: apply a cut whose notice ran (within 7 days, or it lapses)
|
|
437
468
|
gang buyback bind --token <addr> | gang buyback release --token <addr>
|
|
438
469
|
anyone: bind the splitter to its token (the launch does it) / push the payee what a
|
|
439
|
-
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
|
|
440
480
|
SPLIT (a V3 token whose recipient is a split module, split-v1; GANG_SPLIT_FACTORY / GANG_TESTNET_SPLIT_FACTORY):
|
|
441
481
|
gang split status --token <addr> payees and shares (fixed), the dev, the bound token / quote, what waits to be split
|
|
442
482
|
and what each slot is owed (bound quote, WBNB, GANG, the token's quote), whether the
|
|
@@ -469,18 +509,50 @@ LP (a V3 token whose recipient is an LP splitter, lp-burn-v1; GANG_LP_FACTORY /
|
|
|
469
509
|
gang lp bind --token <addr> | gang lp release --token <addr>
|
|
470
510
|
anyone: bind the splitter to its token (the launch does it) / push the payee what a
|
|
471
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
|
|
472
517
|
gang lp add --token <addr> [--slippage 1]
|
|
473
518
|
anyone: one chunk now, as the keeper does (graduated tokens; one per 4 minutes; ≤ 0.5%
|
|
474
519
|
of the pair's quote reserve; waits for a 10-minute average and skips when the price is
|
|
475
520
|
> 2% above it): minimum tokens = previewAdd less --slippage. Not ready: a call that
|
|
476
521
|
only records the price. Gas: a chunk takes ~0.53–0.75M; the CLI never sets a gas
|
|
477
522
|
limit, let the wallet estimate it. --testnet, --calldata, --from as in gang v3
|
|
523
|
+
COMBO (a V3 token whose recipient is a combined recipient, combo-v1; GANG_COMBO_FACTORY / GANG_TESTNET_COMBO_FACTORY):
|
|
524
|
+
gang combo status --token <addr> [--asset <addr>]
|
|
525
|
+
buy-back / LP / payees % (fixed for good), payees and shares, set aside for buy-back
|
|
526
|
+
(buybackLeft) and liquidity (lpLeft), not split yet (unsplit), what each slot is owed
|
|
527
|
+
(bound quote, WBNB, GANG, the token's quote, --asset), the next chunk (kind, ready or what it
|
|
528
|
+
waits for), the keeper (serves the quote or manual; due, and the planned action
|
|
529
|
+
decoded from previewWork: buy-back / liquidity / observe / split), next commands, and
|
|
530
|
+
a warning when the module is bound to another token than the one paying it
|
|
531
|
+
gang combo distribute --token <addr> [--asset <addr>|wbnb]
|
|
532
|
+
anyone, once bound: the bound quote (default) is split as the tax is; another asset's
|
|
533
|
+
buy-back + LP share goes to 0xdead, the rest to the payees
|
|
534
|
+
gang combo release --token <addr> [--asset <addr>] [--index <i>] [--max <amount>]
|
|
535
|
+
anyone: push a slot what a failed push left owed (--index = the contract's 0-based
|
|
536
|
+
slot, default your own slot or the only one owed)
|
|
537
|
+
gang combo set-payee --token <addr> --to <addr> [--index <i>]
|
|
538
|
+
only the slot's current payee (--index default: your wallet's slot): moves the slot
|
|
539
|
+
to --to at once, the share stays. Distributes other known assets waiting first (one
|
|
540
|
+
tx each, then re-run)
|
|
541
|
+
gang combo bind --token <addr> anyone: bind the module to its token (the launch does it)
|
|
542
|
+
gang combo chunk --token <addr> [--slippage 1]
|
|
543
|
+
anyone: one chunk now, as the keeper does (graduated tokens; one per 4 minutes for both
|
|
544
|
+
kinds; always the larger set-aside part): minimum tokens = previewChunk less --slippage
|
|
545
|
+
(default 1%). Not ready: a call that only records the price.
|
|
546
|
+
--module <addr> instead of --token names a module directly (not for bind). Gas: the
|
|
547
|
+
CLI never sets a gas limit; let the wallet estimate it (a chunk ~0.55–0.75M; each
|
|
548
|
+
payee push needs ~365k left before it, up to 10: a lower limit reverts PushStarved).
|
|
549
|
+
--testnet, --calldata, --from as in gang v3
|
|
478
550
|
gang execute --request-id <id> broadcast a previewed call
|
|
479
551
|
gang tx --pending a trade that waited for Binance App approval (execute: pendingConfirmation): find its tx
|
|
480
552
|
in the wallet's history by the exact call previewed, then as gang tx --hash below
|
|
481
553
|
gang tx --hash <0x..> [--testnet] wait for receipt and decode Gang events: V2 / Soft / U / S, GangLaunchpad (V3 /
|
|
482
|
-
打新, tax router, vaults), GangFlywheelPad (铸币飞轮 pad and tax handler), split modules
|
|
483
|
-
|
|
554
|
+
打新, tax router, vaults), GangFlywheelPad (铸币飞轮 pad and tax handler), split modules,
|
|
555
|
+
LP splitters and combined recipients (publishes a queued --note; mainnet). GangLaunchpad events
|
|
484
556
|
carry units: "raw" (amounts in wei, 18 decimals; bps / shares as is)
|
|
485
557
|
|
|
486
558
|
--note is PUBLIC: shown on gang.fun next to the trade. Its hash goes into the tx calldata, so it is provably written
|
|
@@ -503,10 +575,12 @@ off, GANG_UPDATE_URL points it at an npm mirror).
|
|
|
503
575
|
|
|
504
576
|
env: GANG_RPC_URL (one URL or a comma list; unset: five public BSC nodes, the next one tried when one fails),
|
|
505
577
|
GANG_LOGO_API, GANG_API (default ${API}), GANG_NOTES_DIR (default ~/.gang/notes), GANG_UPDATE_CHECK, GANG_UPDATE_URL,
|
|
506
|
-
GANG_PAD / GANG_TESTNET_PAD (the
|
|
507
|
-
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
|
|
508
580
|
GANG_V3_TESTNET_RPC_URL / GANG_FAIR_TESTNET_RPC_URL), GANG_ROUTER / GANG_TESTNET_ROUTER (alias GANG_ROUTER_TESTNET; GangRouter
|
|
509
|
-
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,
|
|
510
584
|
GANG_FLY_PAD / GANG_TESTNET_FLY_PAD (GangFlywheelPad V1; default: the built-in mainnet / testnet set 2 addresses),
|
|
511
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
|
|
512
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
|
|
@@ -893,7 +967,8 @@ async function padKind(token, verb) {
|
|
|
893
967
|
const testnet = flag('testnet')
|
|
894
968
|
let ctx
|
|
895
969
|
try { ctx = v3Ctx(testnet) } catch (e) { fail(e.message) }
|
|
896
|
-
|
|
970
|
+
// every GangLaunchpad generation of this network (1.0, 2.0) is asked
|
|
971
|
+
const { kind } = await genOf(ctx, token)
|
|
897
972
|
if (kind === 'v3' || kind === 'fair') return kind
|
|
898
973
|
// not GangLaunchpad's: the 铸币飞轮 pad (GangFlywheelPad, kind 3) is asked next
|
|
899
974
|
const fly = await isFlyToken(flyCtx(testnet), token)
|
|
@@ -1017,7 +1092,7 @@ const V3_CREATE_FLAGS = ['buy-tax', 'sell-tax', 'dividend', 'recipient']
|
|
|
1017
1092
|
const FAIR_CREATE_FLAGS = ['raise', 'cap', 'hold', 'mint-fee', 'exit-fee', 'shares']
|
|
1018
1093
|
// 铸币飞轮 settings beyond those it shares with 打新 (--raise / --hold / --mint-fee / --exit-fee) and V3 (--sell-tax)
|
|
1019
1094
|
const FLY_ONLY_FLAGS = FLY_CREATE_FLAGS.filter((f) => !['raise', 'hold', 'mint-fee', 'exit-fee', 'sell-tax'].includes(f))
|
|
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>'
|
|
1095
|
+
const FLY_NO_BOND = '铸币飞轮 tokens take no GangBond, buy-back splitter, split module, LP splitter, combined recipient or --dev-buy (phase 1): the creator mints its shares in the create with --dev-shares <n>'
|
|
1021
1096
|
/** The flags a 铸币飞轮 create refuses (gang create --fly and gang fly create alike). */
|
|
1022
1097
|
function checkFlyCreate() {
|
|
1023
1098
|
if (flag('fair')) fail('give --fly (铸币飞轮) or --fair (打新), not both')
|
|
@@ -1029,7 +1104,10 @@ function checkFlyCreate() {
|
|
|
1029
1104
|
: `--${wrong} is a V3 tax setting; a 铸币飞轮 token's tax goes to holders, the platform and the creator in fixed parts`)
|
|
1030
1105
|
}
|
|
1031
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`
|
|
1032
1109
|
function create() {
|
|
1110
|
+
if (flag('grad') && (flag('fly') || flag('fair'))) fail(GRAD_ONLY_V3(flag('fly') ? 'a 铸币飞轮 sale' : 'a 打新 sale'))
|
|
1033
1111
|
if (flag('fly')) {
|
|
1034
1112
|
checkFlyCreate()
|
|
1035
1113
|
return runFly('create', { ...PAD_IO })
|
|
@@ -1051,11 +1129,11 @@ function create() {
|
|
|
1051
1129
|
// commands whose JSON result carries `update`; `watch` streams NDJSON and help is plain text
|
|
1052
1130
|
const UPDATE_CHECKED = new Set(['version', '--version', '-v', 'preflight', 'list', 'hot', 'new', 'near-grad', 'notes', 'agents', 'token', 'info', 'status', 'portfolio', 'quote',
|
|
1053
1131
|
'buy', 'follow', 'sell', 'claim', 'mint', 'withdraw', 'release', 'upload-logo', 'create', 'execute', 'tx', 'fair', 'v3', 'bond',
|
|
1054
|
-
'buyback', 'split', 'lp', 'fly'])
|
|
1132
|
+
'buyback', 'split', 'lp', 'combo', 'fly', 'creator-fee'])
|
|
1055
1133
|
// gang tx decodes these beside the V2 / Soft / U / S pads' events (GangLaunchpad: both kinds; the tax router; the vaults)
|
|
1056
|
-
const GANG_EVENT_ABIS = [...V3_EVENT_ABIS, ...FAIR_EVENT_ABIS, ...FLY_EVENT_ABIS, ...SPLIT_EVENT_ABIS, ...LP_EVENT_ABIS]
|
|
1134
|
+
const GANG_EVENT_ABIS = [...V3_EVENT_ABIS, ...FAIR_EVENT_ABIS, ...FLY_EVENT_ABIS, ...SPLIT_EVENT_ABIS, ...LP_EVENT_ABIS, ...COMBO_EVENT_ABIS]
|
|
1057
1135
|
|
|
1058
|
-
/** gang bond / gang buyback / gang split / gang lp on a 铸币飞轮 token: those contracts refuse it, so say why before any step. */
|
|
1136
|
+
/** gang bond / gang buyback / gang split / gang lp / gang combo on a 铸币飞轮 token: those contracts refuse it, so say why before any step. */
|
|
1059
1137
|
async function refuseFly(what) {
|
|
1060
1138
|
const token = opt('token')
|
|
1061
1139
|
if (!isAddress(token ?? '')) return
|
|
@@ -1160,6 +1238,8 @@ async function main() {
|
|
|
1160
1238
|
return runFly(args[1], alias('fly', args[1]))
|
|
1161
1239
|
case 'mcp':
|
|
1162
1240
|
return runMcp()
|
|
1241
|
+
case 'creator-fee':
|
|
1242
|
+
return runCreatorFee({ opt, flag, out, fail, summarize: summarizePreview })
|
|
1163
1243
|
case 'bond':
|
|
1164
1244
|
await refuseFly('GangBond')
|
|
1165
1245
|
return runBond(args[1], { opt, flag, out, fail, summarize: summarizePreview })
|
|
@@ -1172,6 +1252,9 @@ async function main() {
|
|
|
1172
1252
|
case 'lp':
|
|
1173
1253
|
await refuseFly('an LP splitter')
|
|
1174
1254
|
return runLp(args[1], { opt, flag, out, fail, summarize: summarizePreview })
|
|
1255
|
+
case 'combo':
|
|
1256
|
+
await refuseFly('a combined recipient')
|
|
1257
|
+
return runCombo(args[1], { opt, flag, out, fail, summarize: summarizePreview })
|
|
1175
1258
|
case 'version':
|
|
1176
1259
|
case '--version':
|
|
1177
1260
|
case '-v':
|
|
@@ -1191,7 +1274,7 @@ async function main() {
|
|
|
1191
1274
|
return out({
|
|
1192
1275
|
success: issues.length === 0, cliVersion: VERSION, status, address: me,
|
|
1193
1276
|
// `launchpad` = createPad: kept for readers of the old field (it used to be the V2 create target)
|
|
1194
|
-
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,
|
|
1195
1278
|
devMode: settings?.devMode?.enabled ?? null, tradeAllTokens: settings?.tradeAllTokens ?? null, issues,
|
|
1196
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.',
|
|
1197
1280
|
})
|
|
@@ -1356,7 +1439,10 @@ async function main() {
|
|
|
1356
1439
|
case 'portfolio': {
|
|
1357
1440
|
if (flag('testnet')) fail('gang portfolio is mainnet only: gang.fun indexes no testnet trades (gang status --testnet reads one token)')
|
|
1358
1441
|
const me = fromArg() || bawAddress()
|
|
1359
|
-
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
|
+
})
|
|
1360
1446
|
.catch((e) => fail(e.message, retryHint(e))))
|
|
1361
1447
|
}
|
|
1362
1448
|
case 'status':
|
|
@@ -1397,7 +1483,7 @@ async function main() {
|
|
|
1397
1483
|
const { token, follow } = await confirmFollow(noteTx, fromArg() || bawAddress())
|
|
1398
1484
|
if (!token) fail('gang.fun did not say which token this note is about', { noteTx })
|
|
1399
1485
|
// a GangLaunchpad token: the V3 curve buy (--amount / --bnb = the quote to spend)
|
|
1400
|
-
const onPad = await
|
|
1486
|
+
const { kind: onPad } = await genOf({ ...v2PoolCtx(), gens: padNets('v3').mainnet.gens }, token)
|
|
1401
1487
|
if (onPad === 'fair') fail('this note is on a 打新 (fair-mint) token: only curve buys can follow a note', { noteTx, token })
|
|
1402
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 })
|
|
1403
1489
|
if (onPad === 'v3') {
|