@gangfun/cli 0.29.0 → 0.30.1
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 -20
- package/README.zh-CN.md +21 -19
- package/package.json +1 -1
- package/src/bond.js +15 -3
- package/src/chain.js +28 -11
- package/src/combo.js +7 -3
- package/src/creatorfee.js +6 -5
- package/src/fair.js +10 -4
- package/src/fly.js +83 -35
- package/src/gangpad.js +102 -14
- package/src/index.js +27 -26
- package/src/mcp.js +3 -3
- package/src/portfolio.js +1 -1
- package/src/v3.js +45 -21
package/src/index.js
CHANGED
|
@@ -245,7 +245,7 @@ const followSkipped = (follow) =>
|
|
|
245
245
|
const HELP = `gang — agent-only launchpad on BNB Chain (Binance Agentic Wallet) · new tokens on GangLaunchpad (V3 / 打新)
|
|
246
246
|
|
|
247
247
|
One command per action, whatever pad the token is on: buy / sell / info / status / claim / mint / withdraw / release
|
|
248
|
-
read the token's kind (GangLaunchpad kindOf: V3 curve
|
|
248
|
+
read the token's kind (GangLaunchpad kindOf: V3 curve, 打新 sale or 3.0's 铸币飞轮; GangFlywheelPad: 铸币飞轮; otherwise the V2 / Soft /
|
|
249
249
|
U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tokens carry kind: "v3" | "fair" | "fly". --testnet
|
|
250
250
|
= BSC testnet (GangLaunchpad and GangFlywheelPad only); --calldata prints the raw tx instead of a baw preview; --from
|
|
251
251
|
<addr> reads / builds for that wallet (V2 / Soft: graduated tokens only).
|
|
@@ -330,17 +330,18 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
330
330
|
gang create --name <n> --symbol <s> [--buy-tax <1-5> --sell-tax <1-5> [--dividend 0-100] [--recipient <0x…>]]
|
|
331
331
|
[--grad 6|9|12|15] [--vault <0x…>] [--quote 0x… --ref-pool 0x…] [--logo <file> | --logo-uri URL]
|
|
332
332
|
[--website URL] [--twitter @handle] [--description <text>] [--testnet]
|
|
333
|
-
a V3 token on GangLaunchpad (LaunchpadV2 / Soft / U / S take no new tokens; --taxed,
|
|
333
|
+
a V3 token on GangLaunchpad 3.0 (LaunchpadV2 / Soft / U / S take no new tokens; --taxed,
|
|
334
334
|
the old V2 track, is refused). No --buy-tax / --sell-tax: untaxed (no pool tax, no
|
|
335
335
|
dividend, no recipient). Taxed: own buy / sell tax in % (fixed at create), only in the
|
|
336
336
|
pool after graduation: 0.5% of volume to the platform; of the rest --dividend % to
|
|
337
337
|
holders, the remainder to --recipient (default: you, the creator; or a partner on the
|
|
338
338
|
platform whitelist) in the quote. Curve trades pay only the 1% fee, no tax.
|
|
339
|
-
--grad (GangLaunchpad 2.0): the graduation target in BNB raised, 6 / 9 / 12 / 15
|
|
339
|
+
--grad (GangLaunchpad 2.0 / 3.0): the graduation target in BNB raised, 6 / 9 / 12 / 15
|
|
340
340
|
(default 9; market cap at graduation ≈ 5×); 1.0 graduates every curve at 15 and
|
|
341
341
|
refuses --grad. info / status show each token's graduationTargetBnb
|
|
342
|
-
--vault
|
|
343
|
-
|
|
342
|
+
--vault: the token bound for good to this vault gang listed, from the wallet gang
|
|
343
|
+
named for it (one token per naming); on 3.0 once its vault mode is live (asked of the
|
|
344
|
+
chain), else on the 2.0 金库版 pad. Until
|
|
344
345
|
graduation the vault locks / releases holders' tokens through the pad (locked
|
|
345
346
|
tokens count in the 1% cap: gang status → lockedInVault). Alone: no --fair / --fly,
|
|
346
347
|
no --dev-buy / --bond / --buyback / --split / --lp
|
|
@@ -365,8 +366,8 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
365
366
|
[--tier flat|standard|linear [--step-pct 0-10 --step-shares 100-100000 --max-mul 1-10]] [--supply-cap 10-500]
|
|
366
367
|
[--guard off|15|20|30] [--twap-window 15|30] [--dev-shares <n>] [--quote 0x… --ref-pool 0x…] [--logo …]
|
|
367
368
|
[--website URL] [--twitter @handle] [--description …]
|
|
368
|
-
a 铸币飞轮 (Mint Flywheel
|
|
369
|
-
|
|
369
|
+
a 铸币飞轮 (Mint Flywheel) sale on GangLaunchpad 3.0 (mainnet; --testnet = BSC
|
|
370
|
+
testnet). 10,000 shares at raise / 10,000 each; a quota per wallet
|
|
370
371
|
(--quota + --invite-bonus per wallet it invites), --max-per-tx per mint, Agent ID
|
|
371
372
|
only. Fills (or the creator opens early at ≥ 30%), launches --launch-delay s later
|
|
372
373
|
(anyone; gang.fun's keeper too) into PancakeSwap at the mint price, then --window s
|
|
@@ -469,9 +470,9 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
469
470
|
past the deadline, --settle-first settles the bond before the sell (asks first;
|
|
470
471
|
settles 1 hour later).
|
|
471
472
|
|
|
472
|
-
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
|
|
473
|
+
CREATOR FEE (GangLaunchpad 2.0 / 3.0: of the 1% fee on every V3 curve buy and sell, 70% is kept on the pad for the token's
|
|
473
474
|
creator, before and after graduation, no deadline; 1.0 tokens and 打新 sales have none):
|
|
474
|
-
gang creator-fee [--from <creator>] every 2.0 V3 token this wallet created and what it can claim (read on chain), with
|
|
475
|
+
gang creator-fee [--from <creator>] every 2.0 / 3.0 V3 token this wallet created and what it can claim (read on chain), with
|
|
475
476
|
totals per quote
|
|
476
477
|
gang creator-fee --token <addr> one token: padGen, sharePct, claimable
|
|
477
478
|
gang creator-fee --token <addr> --claim [--to <addr>]
|
|
@@ -486,7 +487,8 @@ BOND (押金承诺, GangBond; any GangLaunchpad token, from create on; GANG_BOND
|
|
|
486
487
|
keeps at least --hold tokens (N% = of the 1B supply) from now on. The --days clock
|
|
487
488
|
starts when the token graduates / launches (at once if it already has). --cover 100 =
|
|
488
489
|
exactly what dumping X fetches now (only once on the pair). No early withdrawal;
|
|
489
|
-
below X anyone reports it, on the curve too
|
|
490
|
+
below X anyone reports it, on the curve too. A token bound to a lock vault
|
|
491
|
+
(gang create --vault) is refused: a lock takes tokens out of the wallet the bond watches
|
|
490
492
|
gang bond topup --token <addr> (--amount <quote> | --cover <target %>) | gang bond raise-hold --token <addr> --hold <tokens|N%>
|
|
491
493
|
gang bond extend --token <addr> --days <n>
|
|
492
494
|
creator only: the bond only grows, X only rises, the commitment only gets longer (90
|
|
@@ -607,7 +609,7 @@ COMBO (a V3 token whose recipient is a combined recipient, combo-v1; GANG_COMBO_
|
|
|
607
609
|
gang tx --pending a trade that waited for Binance App approval (execute: pendingConfirmation): find its tx
|
|
608
610
|
in the wallet's history by the exact call previewed, then as gang tx --hash below
|
|
609
611
|
gang tx --hash <0x..> [--testnet] wait for receipt and decode Gang events: V2 / Soft / U / S, GangLaunchpad (V3 /
|
|
610
|
-
打新, tax
|
|
612
|
+
打新, 铸币飞轮, tax routers, vaults), GangFlywheelPad (铸币飞轮 pads), split modules,
|
|
611
613
|
LP splitters and combined recipients (publishes a queued --note; mainnet). GangLaunchpad events
|
|
612
614
|
carry units: "raw" (amounts in wei, 18 decimals; bps / shares as is)
|
|
613
615
|
|
|
@@ -634,13 +636,13 @@ GANG_LOGO_API, GANG_API (default ${API}), GANG_NOTES_DIR (default ~/.gang/notes)
|
|
|
634
636
|
GANG_PAD / GANG_TESTNET_PAD (the GangLaunchpad new tokens go to, behind both gang v3 and gang fair; old names GANG_V3_PAD /
|
|
635
637
|
GANG_FAIR_PAD and GANG_V3_TESTNET_PAD / GANG_FAIR_TESTNET_PAD still work as aliases), GANG_TESTNET_RPC_URL (aliases
|
|
636
638
|
GANG_V3_TESTNET_RPC_URL / GANG_FAIR_TESTNET_RPC_URL), GANG_ROUTER / GANG_TESTNET_ROUTER (alias GANG_ROUTER_TESTNET; GangRouter
|
|
637
|
-
for BNB buys / mints and every pool trade). Built in: GangLaunchpad
|
|
638
|
-
|
|
639
|
+
for BNB buys / mints and every pool trade). Built in: GangLaunchpad 3.0 (where new tokens go), 2.0, 1.0 and 2.0 金库版 on
|
|
640
|
+
mainnet and the testnet. A token is always served by its own generation's pad, router, GangBond and module factories; these
|
|
639
641
|
variables (and GANG_BOND / GANG_*_FACTORY) set the create target's only,
|
|
640
642
|
GANG_FLY_PAD / GANG_TESTNET_FLY_PAD (GangFlywheelPad V1; default: the built-in mainnet / testnet set 2 addresses),
|
|
641
|
-
GANG_FLY_PAD_V2 / GANG_TESTNET_FLY_PAD_V2 (V2
|
|
642
|
-
(V2
|
|
643
|
-
wallet bounds it); --guard 15|20|30 pauses mints while the pool is that % below its average over --twap-window (30)
|
|
643
|
+
GANG_FLY_PAD_V2 / GANG_TESTNET_FLY_PAD_V2 (V2; default: the built-in mainnet / testnet V2); new 铸币飞轮 tokens go to the built-in
|
|
644
|
+
GangLaunchpad 3.0. --guard / --twap-window (3.0 and V2): the guard is off by default (post-launch minting does not pause
|
|
645
|
+
on a price drop; the quota cap of 10 per wallet bounds it); --guard 15|20|30 pauses mints while the pool is that % below its average over --twap-window (30)
|
|
644
646
|
|
|
645
647
|
Private RPC: this CLI never broadcasts itself. Trades go out through the Agentic Wallet (gang execute), which picks its
|
|
646
648
|
own RPC; a --calldata tx is sent by whatever signs it. To keep a large pool buy out of the public mempool (front-running),
|
|
@@ -1015,7 +1017,7 @@ const NOT_FOR = {
|
|
|
1015
1017
|
}
|
|
1016
1018
|
|
|
1017
1019
|
/**
|
|
1018
|
-
* 'v3' | 'fair' on GangLaunchpad, 'fly' on GangFlywheelPad (mainnet, or BSC testnet with --testnet); else 'legacy'
|
|
1020
|
+
* 'v3' | 'fair' | 'fly' on GangLaunchpad, 'fly' on GangFlywheelPad (mainnet, or BSC testnet with --testnet); else 'legacy'
|
|
1019
1021
|
* (mainnet V2 / Soft / U / S).
|
|
1020
1022
|
* kindOf unreadable (RPC): 'legacy' only for a verb that code checks again (LEGACY_VERBS), a retry hint otherwise.
|
|
1021
1023
|
*/
|
|
@@ -1023,10 +1025,10 @@ async function padKind(token, verb) {
|
|
|
1023
1025
|
const testnet = flag('testnet')
|
|
1024
1026
|
let ctx
|
|
1025
1027
|
try { ctx = v3Ctx(testnet) } catch (e) { fail(e.message) }
|
|
1026
|
-
// every GangLaunchpad generation of this network (1.0, 2.0) is asked
|
|
1028
|
+
// every GangLaunchpad generation of this network (3.0, 2.0, 1.0, 2.0 金库版) is asked
|
|
1027
1029
|
const { kind } = await genOf(ctx, token)
|
|
1028
|
-
if (kind === 'v3' || kind === 'fair') return kind
|
|
1029
|
-
// not GangLaunchpad's: the 铸币飞轮
|
|
1030
|
+
if (kind === 'v3' || kind === 'fair' || kind === 'fly') return kind
|
|
1031
|
+
// not GangLaunchpad's: the older 铸币飞轮 pads (GangFlywheelPad V1 / V2) are asked next
|
|
1030
1032
|
const fly = await isFlyToken(flyCtx(testnet), token)
|
|
1031
1033
|
if (fly) return 'fly'
|
|
1032
1034
|
if (fly === null && (testnet || !LEGACY_VERBS.has(verb))) {
|
|
@@ -1065,8 +1067,7 @@ const captured = (r) => {
|
|
|
1065
1067
|
}
|
|
1066
1068
|
async function portfolioStatus(kind, token, wallet, indexed) {
|
|
1067
1069
|
if (kind === 'legacy') {
|
|
1068
|
-
// an old token none of today's V2 / Soft / U / S reads know
|
|
1069
|
-
// balance alone, from the token
|
|
1070
|
+
// an old token none of today's V2 / Soft / U / S reads know: the balance alone, from the token
|
|
1070
1071
|
return tokenInfo(token, wallet).catch(async (e) => {
|
|
1071
1072
|
if (!/not a Gang token/.test(e.message)) throw e
|
|
1072
1073
|
return { graduated: indexed.status === 'graduated', myBalanceRaw: (await balanceOf(token, wallet)).toString() }
|
|
@@ -1159,9 +1160,9 @@ function checkFlyCreate() {
|
|
|
1159
1160
|
: `--${wrong} is a V3 tax setting; a 铸币飞轮 token's tax goes to holders, the platform and the creator in fixed parts`)
|
|
1160
1161
|
}
|
|
1161
1162
|
}
|
|
1162
|
-
const VAULT_ALONE = 'a --vault create stands alone:
|
|
1163
|
-
// --grad picks a V3 curve's graduation target (2.0); a 打新 / 铸币飞轮 sale ends at its own --raise
|
|
1164
|
-
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`
|
|
1163
|
+
const VAULT_ALONE = 'a --vault create stands alone: no chained dev buy, GangBond or buy-back / split / LP / combined recipient (the 2.0 金库版 pad has none of them); a dev buy is its own gang buy after the create lands'
|
|
1164
|
+
// --grad picks a V3 curve's graduation target (2.0 / 3.0); a 打新 / 铸币飞轮 sale ends at its own --raise
|
|
1165
|
+
const GRAD_ONLY_V3 = (what) => `--grad is a V3 curve setting (the graduation target, 2.0 / 3.0): ${what} fills at its --raise instead, so leave --grad out`
|
|
1165
1166
|
function create() {
|
|
1166
1167
|
if (flag('grad') && (flag('fly') || flag('fair'))) fail(GRAD_ONLY_V3(flag('fly') ? 'a 铸币飞轮 sale' : 'a 打新 sale'))
|
|
1167
1168
|
if (flag('fly')) {
|
|
@@ -1283,7 +1284,7 @@ async function main() {
|
|
|
1283
1284
|
const launch = LAUNCH_FLAGS.find((f) => flag(f))
|
|
1284
1285
|
if (launch) fail(`--${launch}: ${FLY_NO_BOND}`)
|
|
1285
1286
|
}
|
|
1286
|
-
// --vault (2.0 金库版): a V3 create bound to a listed vault, alone: no 打新 / 铸币飞轮, no chained launch
|
|
1287
|
+
// --vault (3.0 vault mode / 2.0 金库版): a V3 create bound to a listed vault, alone: no 打新 / 铸币飞轮, no chained launch
|
|
1287
1288
|
if (flag('vault')) {
|
|
1288
1289
|
if (!tokenCreate || cmd === 'fair') fail('--vault only applies to a V3 create: gang create --vault <vault> …')
|
|
1289
1290
|
if (flyCreate || flag('fair')) fail(`--vault binds a V3 curve token to a listed vault: leave --${flyCreate ? 'fly' : 'fair'} out`)
|
package/src/mcp.js
CHANGED
|
@@ -46,8 +46,8 @@ export const RULES = [
|
|
|
46
46
|
'A gang_execute that timed out or was cancelled on your side keeps running here (the wallet may have sent it): never execute it again or build a new preview for the same trade before checking gang_status or gang_tx with pending: true; then gang_tx (hash, or pending: true) for the result and the note.',
|
|
47
47
|
'Notes (--note) are public and permanent: write one by default on every buy, sell, mint, withdraw (one line: what you saw, why now) and every create (the launch manifesto). Base it on data you checked, show its text with the preview, leave it out only when the user says so. No links. --conf is an honest 0-100.',
|
|
48
48
|
'Permanent token data: the logo, website, X link and description go on-chain at create and can never change. Use only links the user gave; ask once if they have not said. Never host a logo on a temporary file host. Local files (--logo, upload-logo --file) are read by this MCP server: pass an absolute path, or --logo-uri <image URL>.',
|
|
49
|
-
'New tokens go on GangLaunchpad only: create (V3, untaxed unless --buy-tax / --sell-tax; on GangLaunchpad 2.0 --grad 6|9|12|15 picks the graduation target in BNB, default 9; --vault <vault> only from the wallet gang named for that listed vault, alone, never on your own initiative) or create --fair (fair mint)
|
|
50
|
-
'Bonds: before a bond post, tell the user there is no early withdrawal and any sell below the promised holding before settle, anywhere, loses the whole bond. Posted before graduation / launch, the promise binds at once and its days start at graduation / launch; only if there is still no pair 30 days after the post can the creator ask for it back (bond refund; it returns 3 days after asking, and a graduation meanwhile voids that). Relay warning. breakBond (--break-bond) only when the user, told that, still says sell. bond report only when the user asks.',
|
|
49
|
+
'New tokens go on GangLaunchpad only: create (V3, untaxed unless --buy-tax / --sell-tax; on GangLaunchpad 3.0 (and 2.0) --grad 6|9|12|15 picks the graduation target in BNB, default 9; --vault <vault> only from the wallet gang named for that listed vault, alone, never on your own initiative) or create --fair (fair mint) or create --fly (Mint Flywheel). Never an older pad.',
|
|
50
|
+
'Bonds: before a bond post, tell the user there is no early withdrawal and any sell below the promised holding before settle, anywhere, loses the whole bond. Posted before graduation / launch, the promise binds at once and its days start at graduation / launch; only if there is still no pair 30 days after the post can the creator ask for it back (bond refund; it returns 3 days after asking, and a graduation meanwhile voids that). Relay warning. breakBond (--break-bond) only when the user, told that, still says sell. bond report only when the user asks. A token bound to a lock vault (gang info → vault) takes no bond: never suggest one (bond post refuses it; a lock empties the wallet the bond watches).',
|
|
51
51
|
'Fair mint holder reward: before a sell or transfer of a fair-mint token check sellableBeforeOut (gang_status); going past it ends the reward for good. confirmOut (--confirm-out) only with the user\'s yes.',
|
|
52
52
|
'Mint Flywheel (fly): the same hold line, but a wallet that falls below it earns again after its next mint. An inviter (--ref) only counts on a wallet\'s first mint in that token; never invent one, use the address or link the user gave.',
|
|
53
53
|
'Sells may need Binance App approval (pendingConfirmation): tell the user to approve in the App, then call gang_tx with pending: true; it finds the approved tx in the wallet\'s history by the exact call (no hash needed), decodes it and publishes its note. state waiting = not approved yet: ask again later.',
|
|
@@ -178,7 +178,7 @@ export const TOOLS = [
|
|
|
178
178
|
{ hash: HASH, pending: { type: 'boolean', description: 'Find the txs of trades approved in the Binance App (no hash needed)' }, testnet: TESTNET },
|
|
179
179
|
(a) => (a.pending ? ['tx', '--pending'] : ['tx', '--hash', a.hash, ...bool('testnet', a.testnet)]), PREVIEW),
|
|
180
180
|
tool('gang_cli', 'Other gang commands',
|
|
181
|
-
'Every other gang command, its flags as separate items (gang_help lists them all): create (V3; create --fair = fair mint; create --fly = Mint Flywheel; launch in one command with --dev-buy / --bond / --buyback / --split / --lp, several of the last three = one combined recipient), mint (--ref <inviter> on a Mint Flywheel token), withdraw, claim, release, fly open-early|launch|invite, quote, list, upload-logo, bond post|topup|raise-hold|extend|status|start|report|settle|refund|burn|tx, buyback status|set|set-payee|apply|bind|release|split|sweep, split status|distribute|release|set-payee|bind, lp status|set|set-payee|apply|bind|release|split|sweep|add, combo status|distribute|release|set-payee|bind|chunk, creator-fee [--token] [--claim [--to]] (GangLaunchpad 2.0: 70% of the curve fee, kept for the creator), v3 income, version; the flags no other tool takes (--calldata, --from, …) too. E.g. ["create","--name","My Token","--symbol","MYT","--logo","/Users/me/avatar.png"], ["bond","status","--token","0x…"]. Local files are read by this server: absolute paths, or --logo-uri <image URL>. Writes only preview, as above. execute / watch / help have their own tools.',
|
|
181
|
+
'Every other gang command, its flags as separate items (gang_help lists them all): create (V3; create --fair = fair mint; create --fly = Mint Flywheel; launch in one command with --dev-buy / --bond / --buyback / --split / --lp, several of the last three = one combined recipient), mint (--ref <inviter> on a Mint Flywheel token), withdraw, claim, release, fly open-early|launch|invite, quote, list, upload-logo, bond post|topup|raise-hold|extend|status|start|report|settle|refund|burn|tx, buyback status|set|set-payee|apply|bind|release|split|sweep, split status|distribute|release|set-payee|bind, lp status|set|set-payee|apply|bind|release|split|sweep|add, combo status|distribute|release|set-payee|bind|chunk, creator-fee [--token] [--claim [--to]] (GangLaunchpad 2.0 / 3.0: 70% of the curve fee, kept for the creator), v3 income, version; the flags no other tool takes (--calldata, --from, …) too. E.g. ["create","--name","My Token","--symbol","MYT","--logo","/Users/me/avatar.png"], ["bond","status","--token","0x…"]. Local files are read by this server: absolute paths, or --logo-uri <image URL>. Writes only preview, as above. execute / watch / help have their own tools.',
|
|
182
182
|
{ args: { type: 'array', items: { type: 'string' }, minItems: 1 } }, (a) => a.args, { readOnlyHint: false, destructiveHint: false, openWorldHint: true }, ['args']),
|
|
183
183
|
]
|
|
184
184
|
const BY_NAME = new Map(TOOLS.map((t) => [t.name, t]))
|
package/src/portfolio.js
CHANGED
|
@@ -250,7 +250,7 @@ function creatorFeeRows(fees) {
|
|
|
250
250
|
creatorFees: {
|
|
251
251
|
tokens: due.map((x) => ({ token: x.token, symbol: x.symbol, quote: x.quoteSymbol, claimable: num(x.claimable), padGen: x.padGen, next: `gang creator-fee --token ${x.token} --claim` })),
|
|
252
252
|
totals: fees.totals.filter((x) => num(x.claimable) > 0),
|
|
253
|
-
note: 'GangLaunchpad 2.0
|
|
253
|
+
note: 'GangLaunchpad 2.0 / 3.0 keep 70% of the 1% curve fee of your V3 tokens for you; gang creator-fee lists every one of them',
|
|
254
254
|
},
|
|
255
255
|
}
|
|
256
256
|
}
|
package/src/v3.js
CHANGED
|
@@ -3,7 +3,7 @@ import { decimalsOf, defaultRefPool, dividendOf, VAULT_ABI, fundingStep as fund,
|
|
|
3
3
|
import { API } from './discover.js'
|
|
4
4
|
import { UA } from './version.js'
|
|
5
5
|
import { walletFor } from './fair.js'
|
|
6
|
-
import { atTokenPad, CREATOR_FEE_ABI, genFields, GRAD_TARGET_ABI, gradTargetBnbOf, gradTiersOf, KIND_UNREAD, MERGED_ERRORS_ABI, MERGED_HINTS, NOT_ON_MAINNET, notThisKind, padNets, rpcTransport, VAULT_GEN, vaultGenOf } from './gangpad.js'
|
|
6
|
+
import { atTokenPad, CREATOR_FEE_ABI, genFields, GRAD_TARGET_ABI, gradTargetBnbOf, gradTiersOf, KIND_UNREAD, MERGED_ERRORS_ABI, MERGED_HINTS, NOT_ON_MAINNET, notThisKind, PAD3_GEN, padNets, rpcTransport, tokenVaultOf, VAULT_GEN, VAULT_NO_BOND, vaultGenOf, vaultModeOf } from './gangpad.js'
|
|
7
7
|
import { createNote, curveCreatorFee } from './creatorfee.js'
|
|
8
8
|
import { poolPayBnb, poolTrade } from './pool.js'
|
|
9
9
|
import { bondGuard } from './bond.js'
|
|
@@ -25,12 +25,15 @@ const TAX = '(uint16 buyTaxBps, uint16 sellTaxBps, uint16 dividendBps, address r
|
|
|
25
25
|
const PAD_ABI = parseAbi([
|
|
26
26
|
`function create(string name, string symbol, string logoURI, string metaURI, address quote, address refPool, ${TAX} tax) returns (address)`,
|
|
27
27
|
`function createWithGradTarget(string name, string symbol, string logoURI, string metaURI, address quote, address refPool, ${TAX} tax, uint256 gradBnb) returns (address)`,
|
|
28
|
-
// 2.0 金库版 (GangVaultLaunchpad): its only create, binding the token to a listed vault for good
|
|
28
|
+
// 2.0 金库版 (GangVaultLaunchpad): its only create, binding the token to a listed vault for good; 3.0 has the same once
|
|
29
|
+
// an upgrade added its vault mode (vaultModeOf), beside its other creates
|
|
29
30
|
`function createWithVault(string name, string symbol, string logoURI, string metaURI, address quote, address refPool, ${TAX} tax, uint256 gradBnb, address vault) returns (address)`,
|
|
30
31
|
'function isVault(address vault) view returns (bool)',
|
|
31
32
|
'function vaultOf(address token) view returns (address)',
|
|
32
33
|
'function vaultCreator(address vault) view returns (address)',
|
|
33
34
|
'function lockedOf(address token, address user) view returns (uint256)',
|
|
35
|
+
// 3.0: the rule set the token was created under (0 = not this pad's token)
|
|
36
|
+
'function tokenVersionOf(address token) view returns (uint8)',
|
|
34
37
|
'function buy(address token, uint256 quoteIn, uint256 minTokensOut) returns (uint256)',
|
|
35
38
|
'function sell(address token, uint256 tokensIn, uint256 minQuoteOut) returns (uint256)',
|
|
36
39
|
`function checkTaxConfig(${TAX} tax) view returns (bool ok, string reason)`,
|
|
@@ -66,6 +69,13 @@ const PAD_ABI = parseAbi([
|
|
|
66
69
|
'event VaultReleased(address indexed token, address indexed vault, address indexed user, uint256 amount)',
|
|
67
70
|
'event VaultSet(address indexed vault, bool enabled)',
|
|
68
71
|
'event VaultCreatorSet(address indexed vault, address indexed creator)',
|
|
72
|
+
// 3.0, beside 2.0's events: the rule set at create, every curve trade's fee split and price, the aggregator entry
|
|
73
|
+
'event TokenVersionSet(address indexed token, uint8 version)',
|
|
74
|
+
'event TradeV1(address indexed token, address indexed trader, bool isBuy, uint256 quoteAmount, uint256 tokenAmount, uint256 protocolFee, uint256 creatorFee, uint256 postPrice, uint256 realQuote, uint256 sold)',
|
|
75
|
+
'event GatewayBuy(address indexed token, address indexed trader, address indexed caller, uint256 fundsUsed, uint256 amountOut)',
|
|
76
|
+
'event GatewaySell(address indexed token, address indexed trader, address indexed caller, uint256 amount, uint256 funds, uint256 fundsToSeller, uint256 routerFee, address feeRecipient)',
|
|
77
|
+
'event GatewaySellTo(address indexed token, address indexed trader, address indexed to, address caller, uint256 amount, uint256 funds)',
|
|
78
|
+
'event Routed(address indexed token, address indexed pad, address indexed trader, bool isBuy, uint256 quoteAmount, uint256 tokenAmount)',
|
|
69
79
|
])
|
|
70
80
|
const TAX_ROUTER_ABI = parseAbi([
|
|
71
81
|
'function owedOf(address token) view returns (uint256)',
|
|
@@ -110,8 +120,8 @@ const HINTS = {
|
|
|
110
120
|
RouterNeedsGate: 'the router path is off while the Agent gate is off; re-run with --use-wbnb to buy directly',
|
|
111
121
|
// not a create flag: the shared dividend vault's holding floor for this pad was raised above what V3 allows (10,000 tokens)
|
|
112
122
|
VaultFloorTooHigh: 'the platform\'s dividend vault requires a larger holding than V3 dividends allow (10,000 tokens), so a dividend token can\'t be created right now; --dividend 0 still works, or ask gang to fix the vault setting',
|
|
113
|
-
//
|
|
114
|
-
NotVault: '--vault is not a vault listed on
|
|
123
|
+
// the vault mode (gang create --vault): 3.0 once upgraded, or the 2.0 金库版 pad
|
|
124
|
+
NotVault: '--vault is not a vault listed on this pad: gang lists each vault before its token is created',
|
|
115
125
|
NotVaultCreator: 'this wallet is not the one gang named for this vault (each named wallet creates one token): create from that wallet, or ask gang to name this one',
|
|
116
126
|
UseVaultCreate: 'the 2.0 金库版 pad creates only tokens bound to a listed vault: gang create --vault <vault> …',
|
|
117
127
|
VaultCannotTrade: 'a token\'s own vault never buys or sells it on the curve',
|
|
@@ -188,12 +198,17 @@ async function labelOf(ctx, registry, recipient) {
|
|
|
188
198
|
try { return (await ctx.read(registry, REGISTRY_ABI, 'entries', [recipient]))[2] || null } catch { return null }
|
|
189
199
|
}
|
|
190
200
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
201
|
+
const vaultOfToken = tokenVaultOf
|
|
202
|
+
|
|
203
|
+
/** The token's vault and what it means for holders (2.0 金库版, or a 3.0 token created with --vault); null without one. */
|
|
204
|
+
async function vaultView(ctx, token, c, net = '') {
|
|
205
|
+
let address
|
|
206
|
+
try { address = await vaultOfToken(ctx, token) } catch (e) {
|
|
207
|
+
return { error: `could not read the token's vault (${e.shortMessage || e.message.split('\n')[0]})`, retry: `gang info --token ${token}${net}` }
|
|
208
|
+
}
|
|
209
|
+
if (!address) return null
|
|
195
210
|
return {
|
|
196
|
-
address, padGen: ctx.gen,
|
|
211
|
+
address, padGen: ctx.gen, bond: `none: ${VAULT_NO_BOND}`,
|
|
197
212
|
note: c.graduated
|
|
198
213
|
? 'graduated: a plain token now, the vault moves it like any other contract'
|
|
199
214
|
: 'until graduation the token moves only through the pad: this vault locks a holder\'s tokens (counted in the holder\'s 1% cap, see gang status → lockedInVault) and releases them, for the wallet that sends the tx and holds an Agent ID',
|
|
@@ -356,12 +371,14 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
356
371
|
? { warning: `this token pays its tax to the split module, but the module is bound to another token (${split.token}): the keeper never splits this token's tax (${c.quote}); it is split only by hand (gang split distribute --token ${token}${net} --asset ${c.quote})` } : null
|
|
357
372
|
// 2.0: the creator's part of the curve fee, waiting on the pad
|
|
358
373
|
const gen = await curveCreatorFee(ctx, token, c, net)
|
|
359
|
-
const vault = await vaultView(ctx, token, c)
|
|
374
|
+
const vault = await vaultView(ctx, token, c, net)
|
|
375
|
+
// 3.0: the rule set the token was created under (fixed for good; an upgrade adds rules for new tokens only)
|
|
376
|
+
const tokenVersion = ctx.gen === PAD3_GEN ? await ctx.read(ctx.pad, PAD_ABI, 'tokenVersionOf', [token]).then(Number).catch(() => null) : null
|
|
360
377
|
const nonWbnb = c.quote.toLowerCase() !== String(ctx.wbnb).toLowerCase()
|
|
361
378
|
const graduationNote = c.graduationTargetBnb != null && !c.graduated
|
|
362
379
|
? gradLine(c.graduationTargetBnb, nonWbnb ? `${c.graduationAt} ${c.quoteSymbol || 'of the quote'}` : null) : null
|
|
363
380
|
return out({
|
|
364
|
-
success: true, chainId: Number(ctx.chainId), ...fees, ...pub, ...gen, ...(vault && { vault }), ...(graduationNote && { graduationNote }), taxNote, ...(swapBack && { swapBack }), ...(buyback && { buyback }),
|
|
381
|
+
success: true, chainId: Number(ctx.chainId), ...fees, ...pub, ...gen, ...(tokenVersion != null && { tokenVersion }), ...(vault && { vault }), ...(graduationNote && { graduationNote }), taxNote, ...(swapBack && { swapBack }), ...(buyback && { buyback }),
|
|
365
382
|
...(split && { split: { ...split, ...splitWarn } }), ...(lp && { lp: { ...lp, ...lpWarn } }),
|
|
366
383
|
...(combo && { combo: { ...combo, ...(comboWarning && { warning: comboWarning }) } }),
|
|
367
384
|
})
|
|
@@ -379,8 +396,8 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
379
396
|
const q = c.graduated && c.pair && bal > 0n ? await poolSellQuote(ctx, c.taxHandler, token, bal) : null
|
|
380
397
|
// the creator's own view also shows its creator fee (2.0)
|
|
381
398
|
const { creatorFee } = me.toLowerCase() === c.creator.toLowerCase() ? await curveCreatorFee(ctx, token, c, net) : {}
|
|
382
|
-
// 2.0 金库版, before graduation: what this wallet has in
|
|
383
|
-
const locked =
|
|
399
|
+
// a token with a vault (2.0 金库版, 3.0 --vault), before graduation: what this wallet has in it, counted in its 1% cap
|
|
400
|
+
const locked = !c.graduated && (await vaultOfToken(ctx, token).catch(() => null)) ? await ctx.read(ctx.pad, PAD_ABI, 'lockedOf', [token, me]) : null
|
|
384
401
|
return out({
|
|
385
402
|
success: true, chainId: Number(ctx.chainId), wallet: me, token, quote: c.quoteSymbol, graduated: c.graduated,
|
|
386
403
|
balance: formatUnits(bal, 18), ...(locked !== null && { lockedInVault: formatUnits(locked, 18) }), dividendPct: c.dividendPct, ...(creatorFee && { creatorFee }),
|
|
@@ -437,7 +454,8 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
437
454
|
if (!(n >= 1 && n <= 5)) fail(`--${f} must be a number between 1 and 5 (in %); for an untaxed token leave out both tax flags (or give both as 0)`, { got: opt(f) ?? null })
|
|
438
455
|
return n
|
|
439
456
|
}
|
|
440
|
-
// --vault
|
|
457
|
+
// --vault: the listed vault the token is bound to for good (createWithVault): on the create target when it serves the
|
|
458
|
+
// vault mode (3.0 once upgraded), else on the 2.0 金库版 pad
|
|
441
459
|
const vault = flag('vault') ? addrArg(opt, fail, 'vault', 'the vault gang listed for your token') : null
|
|
442
460
|
// --grad: the graduation target in BNB raised, one of the pad's GRAD_BNB_TIERS (2.0); left out: the pad's default
|
|
443
461
|
const grad = flag('grad') ? Number(opt('grad')) : null
|
|
@@ -447,12 +465,18 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
447
465
|
const dividend = taxed ? parseNum(fail, 'dividend', opt('dividend', '0'), 0, 100) : 0
|
|
448
466
|
const me = walletFor(ctx, opt('from'))
|
|
449
467
|
if (vault) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
468
|
+
let here
|
|
469
|
+
try { here = await vaultModeOf(ctx) } catch (e) {
|
|
470
|
+
return fail(`could not read whether GangLaunchpad ${ctx.gen ?? ctx.pad} serves --vault (RPC error)`, { detail: e.shortMessage || e.message.split('\n')[0], retry: 'same command again' })
|
|
471
|
+
}
|
|
472
|
+
if (!here) {
|
|
473
|
+
// the vault pad, its own router, tax handler and fees
|
|
474
|
+
const vg = vaultGenOf(ctx.gens ?? [])
|
|
475
|
+
if (!vg) fail(`--vault: GangLaunchpad ${ctx.gen ?? ctx.pad} has no vault mode yet and this CLI version knows no 2.0 金库版 pad on ${testnet ? 'the BSC testnet' : 'BSC mainnet'}`)
|
|
476
|
+
Object.assign(ctx, genFields(vg))
|
|
477
|
+
delete ctx._tax
|
|
478
|
+
delete ctx.fees
|
|
479
|
+
}
|
|
456
480
|
// asked before any upload: the pad would refuse the create anyway (NotVault / NotVaultCreator)
|
|
457
481
|
const [listed, named] = await Promise.all([ctx.read(ctx.pad, PAD_ABI, 'isVault', [vault]), ctx.read(ctx.pad, PAD_ABI, 'vaultCreator', [vault])])
|
|
458
482
|
if (!listed) fail(HINTS.NotVault, { vault, pad: ctx.pad })
|
|
@@ -529,7 +553,7 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
529
553
|
...(creatorFee && { creatorFee }),
|
|
530
554
|
...(vault && {
|
|
531
555
|
padGen: ctx.gen, pad: ctx.pad, vault,
|
|
532
|
-
vaultNote: 'the token is bound to this vault for good. Until graduation the token moves only through the pad: the vault locks a holder\'s tokens (counted in that holder\'s 1% cap) and releases them through the pad, for the holder that sends the tx and holds an Agent ID; after graduation it is a plain token. This create uses up the wallet\'s naming for the vault: one token per naming',
|
|
556
|
+
vaultNote: 'the token is bound to this vault for good. Until graduation the token moves only through the pad: the vault locks a holder\'s tokens (counted in that holder\'s 1% cap) and releases them through the pad, for the holder that sends the tx and holds an Agent ID; after graduation it is a plain token. This create uses up the wallet\'s naming for the vault: one token per naming. A vault-bound token takes no GangBond (gang bond post refuses it): a lock moves tokens out of the creator\'s wallet, which would forfeit a bond',
|
|
533
557
|
}),
|
|
534
558
|
note: `${taxed ? 'tax rates and recipient are' : 'untaxed is'} fixed at create. Curve trades pay only the ${fees.curveFeePct}% fee, no tax${taxed ? ': the tax starts in the pool after graduation' : ''}. tokenIfNext changes if another create lands first: the real address is the Created event from \`gang tx --hash …\`.`,
|
|
535
559
|
}, 'create'))
|