@gangfun/cli 0.43.2 → 0.45.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 +4 -2
- package/README.zh-CN.md +5 -3
- package/package.json +1 -1
- package/src/campaign.js +155 -0
- package/src/capabilities.js +3 -0
- package/src/gradreward.js +38 -11
- package/src/index.js +23 -6
- package/src/launch.js +11 -4
- package/src/mcp.js +4 -3
- package/src/telemetry.js +2 -2
- package/src/v3.js +22 -9
- package/src/weekly.js +2 -2
package/README.md
CHANGED
|
@@ -24,9 +24,9 @@ Operate [gang.fun](https://gang.fun) from a Binance **Agentic Wallet**. Curve bu
|
|
|
24
24
|
|
|
25
25
|
**Opening base (0.40.0+, open on BSC mainnet and testnet):** `gang create … --base <5|10> --base-vest <30|90|180> [--grad 6|9|12|15]` creates a GangLaunchpad 3.0 curve token whose very first trade buys 5% or 10% of the supply for the token's own base vault (GangBaseVault, `base-v1`). The create pays exactly the pad's `previewBaseCost` in BNB as the tx value (5% at 6 / 9 / 12 / 15 BNB: 0.0994 / 0.1490 / 0.1987 / 0.2484 BNB; 10%: 0.2090 / 0.3135 / 0.4180 / 0.5225; the 1% fee included, 70% of it back as your creator fee). The vault never trades: the base is locked until graduation, then the first `gang base release` (anyone may call it) starts the clock and the base is released linearly over `--base-vest` days to the creator's wallet (5%: 30 / 90 / 180 days; 10%: 90 / 180; fixed for good). **If the token never graduates, the base and its cost stay locked for good.** The preview shows the cost, the schedule and the spec's payoff figures (the least you get, at the graduation price, days to recover the cost, the daily release, what other buyers pay more), and that GangBond does not constrain the base (the vault keeps refilling the creator's wallet, so a bond is no promise about it). WBNB quote only, no dividend, not with `--vault` / `--promote` / `--fair` / `--fly` or a launch in one command; on a taxed token the recipient is usually the creator. With abcd on, the create goes through `createWithSalt` with the BNB. The CLI asks the pad (`baseVaultImpl`) and refuses `--base` where it is not live. `gang base status --token 0x…` shows the vault, size, period, start (or not started), total, released, releasable and unreleased (counted by time); `gang base release --token 0x…` starts the release, then sends what has vested to the creator.
|
|
26
26
|
|
|
27
|
-
**Graduation reward (冲毕业奖励, 0.42.0+, open on BSC mainnet and testnet since 2026-11-17;
|
|
27
|
+
**Graduation reward (冲毕业奖励, 0.42.0+, open on BSC mainnet and testnet since 2026-11-17; with `--countdown-reward` and its carry 0.44.0+, open on mainnet and testnet since 2026-11-17):** `gang create … --grad-reward <seed> [--gr-min-buy <amount>] [--gr-entries <1-20>] [--gr-last <0-50>] [--gr-refund-days <30-180>]` creates a GangLaunchpad 3.0 curve token with a reward pool you seed in the token's quote (pulled in the create, so the CLI asks you to approve it first; at least 0.1 BNB worth). The pad keeps the last `--gr-entries` curve buys (default 10) that each actually spend `--gr-min-buy` (default 0.01 BNB worth), with the Agent gate on; the buy that graduates the token always counts. At graduation that buy gets `--gr-last` % of the pool on top (default 30), and all entries, it included, split the rest by what each spent. A curve sell takes out that wallet's earlier entries (a later buy counts again). Buyers claim for 180 days after graduation, then anyone sweeps the rest back to you. If the token does not graduate, `--gr-refund-days` (default 90) after the create you may ask for the pool back: the request is public for 7 days (a graduation in that time pays the buyers as usual), then you have 3 days to take it, else it lapses. Buyers pay only the usual price and fee: the pool is your money, paid to the last buys before graduation by a fixed public rule. Works with `--promote` on an untaxed token or with `--recipient`, and with `--countdown-reward`: then `--gr-carry` % of the pool (default 20) goes into the token's countdown reward module at graduation, and the unclaimed rest goes there too. Not with `--vault` / `--base` / `--fair` / `--fly` or a launch in one command. `gang buy` / `gang sell` previews say under `rewards.gradReward` whether the buy counts and what a sell takes out. `gang grad-reward status --token 0x…` shows the pool, rules, list, refund state and what you can claim; `claim`, `settle`, `sweep`, `retry-carry`, `refund-request`, `refund-cancel` and `refund` do the rest.
|
|
28
28
|
|
|
29
|
-
**Countdown reward (倒计时奖励, 0.43.2+, BSC mainnet and testnet):** `gang create … --buy-tax 3 --sell-tax 3 --countdown-reward --cd-max-payout <amount> [--cd-window 60m] [--cd-max-round 6h] [--cd-idle 30d] [--cd-payout 30] [--cd-last 20] [--cd-dev 0] [--cd-entries 10] [--cd-min-buy 0.05] [--cd-min-pot 0.1] [--cd-seed <amount>]` makes the token's tax recipient its own GangCountdownReward module (`countdown-v1`): your share of the pool tax becomes a reward for buyers. After graduation, each buy of at least `--cd-min-buy` through the module puts the countdown `--cd-window` ahead, but a round never runs past `--cd-max-round` from its first counted buy. When the countdown runs out, the round's last `--cd-entries` counted buys share `--cd-payout` % of the pool, never more than `--cd-max-payout` (required): equal shares, the very last buy `--cd-last` % of the payout on top; a round that ends at its cap pays equal shares only, since its end time was public. No round starts under `--cd-min-pot`; after `--cd-idle` days with no counted buy anyone may pay the last round once more. `--cd-dev` % of the arriving tax stays yours. `--cd-min-buy` / `--cd-min-pot` default to 0.05 / 0.1 BNB on a WBNB-quoted token and must be given for another quote. The preview shows what share of pool volume reaches the pool, what a round can pay at most and what taking every slot costs (slots × minimum buy × buy tax). Be clear with buyers: anyone, the creator included, can take slots with several wallets, and only buys through the module count, as the gang CLI and MCP send them (`gang buy`; not PancakeSwap's router, aggregators or GangRouter; the gang.fun site only shows the countdown). Like `--floor`, the module is cloned for the token's address first, then the token is created there, bound, and `--cd-seed` (if any) approved and funded: one tx per run, re-run the same command. A changed tax rate or `--cd-*` setting is refused. A fund preview that doesn't show up in the module's books is built again only with `--cd-seed-again`; the first may still be waiting for approval in the Binance App, so approve only one.
|
|
29
|
+
**Countdown reward (倒计时奖励, 0.43.2+, BSC mainnet and testnet):** `gang create … --buy-tax 3 --sell-tax 3 --countdown-reward --cd-max-payout <amount> [--cd-window 60m] [--cd-max-round 6h] [--cd-idle 30d] [--cd-payout 30] [--cd-last 20] [--cd-dev 0] [--cd-entries 10] [--cd-min-buy 0.05] [--cd-min-pot 0.1] [--cd-seed <amount>]` makes the token's tax recipient its own GangCountdownReward module (`countdown-v1`): your share of the pool tax becomes a reward for buyers. After graduation, each buy of at least `--cd-min-buy` through the module puts the countdown `--cd-window` ahead, but a round never runs past `--cd-max-round` from its first counted buy. When the countdown runs out, the round's last `--cd-entries` counted buys share `--cd-payout` % of the pool, never more than `--cd-max-payout` (required): equal shares, the very last buy `--cd-last` % of the payout on top; a round that ends at its cap pays equal shares only, since its end time was public. No round starts under `--cd-min-pot`; after `--cd-idle` days with no counted buy anyone may pay the last round once more. `--cd-dev` % of the arriving tax stays yours. `--cd-min-buy` / `--cd-min-pot` default to 0.05 / 0.1 BNB on a WBNB-quoted token and must be given for another quote. The preview shows what share of pool volume reaches the pool, what a round can pay at most and what taking every slot costs (slots × minimum buy × buy tax). Be clear with buyers: anyone, the creator included, can take slots with several wallets, and only buys through the module count, as the gang CLI and MCP send them (`gang buy`; not PancakeSwap's router, aggregators or GangRouter; the gang.fun site only shows the countdown). Like `--floor`, the module is cloned for the token's address first, then the token is created there, bound, and `--cd-seed` (if any) approved and funded: one tx per run, re-run the same command. A changed tax rate or `--cd-*` setting is refused. A fund preview that doesn't show up in the module's books is built again only with `--cd-seed-again`; the first may still be waiting for approval in the Binance App, so approve only one. With `--grad-reward` too (0.44.0+): `--gr-carry` % of that pool (default 20) goes into this module at graduation (see the graduation reward above). `gang buy` of a graduated countdown token goes through the module with `mustCount` (a buy that would not count is refused before anything is built; `--cd-uncounted` buys anyway); its preview's `rewards.countdown` says whether it counts and why, the round, its deadline and cap, the pool and your estimated share. `gang countdown status|claim|settle|finalize|claim-dev --token 0x… [--to 0x…]` does the rest. Factories: mainnet `0xa1e3117a59104de7D97667cF22f9AB886a5f2957`, testnet `0x0f83ABC7d39C0d043d3f5612E304D9395B5fe582`.
|
|
30
30
|
|
|
31
31
|
**Call bond and follow binding (0.37.0+):** an agent can back its own call — a buy note on a GangLaunchpad 3.0 curve token — with a bond: buy with `--note`, then within 10 minutes `gang call-bond post --token 0x… --amount 0.1 --for 48h` (the note defaults to the wallet's latest buy of the token; `--hold` defaults to the whole balance). Until settle the wallet's balance of the token stays ≥ hold; one sell, vault lock or transfer below it — also after the deadline, until `gang call-bond settle` has run (two steps, 1 hour apart) — and anyone can `gang call-bond report` it: 1% to the reporter, half burnt, the rest paid to the note's followers by their loss (`gang call-bond claim` once the root's 2-day dispute window is over). Nothing of a broken bond comes back to the caller. Quotes: WBNB, USDT, USDC, USD1. A caller's `gang v3 sell` below its hold is refused unless `--break-call-bond`. On a token with a promoter share, `gang follow` binds the note's author as the wallet's promoter for good (it builds `buyWithPromoter`; same price and fee; `--no-promoter` for a plain follow). GangCallBond is live on BSC mainnet (`0x6d6e4A36e9a231cCc932151cdbFb087Cf3860c3D`, deployed 2026-11-09, owned by the platform's Safe; built in) and the BSC testnet (`0xBE2B8519278E9D31B6c4040bAd35f727fD5d2A70`).
|
|
32
32
|
|
|
@@ -75,6 +75,8 @@ gang trending # what other agents buy now (0.24.0+)
|
|
|
75
75
|
gang weekly # Gang's Launch Day event (0.36.0+): open issue, current pick, my applications
|
|
76
76
|
gang weekly apply --name <name> --symbol <SYM> --logo ./logo.png --description "…" --contact <handle> [--twitter …] [--telegram …] [--website …] [--modules lp,buyback] # preview; --yes signs (EIP-712, no tx) and submits
|
|
77
77
|
gang weekly withdraw [--yes]
|
|
78
|
+
gang campaign [<slug>] # gang.fun reward campaigns (0.45.0+): rules summary, tickets, lottery, my progress
|
|
79
|
+
gang campaign join [<slug>] # free sign-up preview; --yes signs (EIP-712, no tx, no gas) and submits
|
|
78
80
|
gang hot [--limit 10] [--track all|v3|fair|fly|v2|soft] [--include-graduated] # 24h USD volume
|
|
79
81
|
gang new [--limit 10] [--max-age 2h]
|
|
80
82
|
gang near-grad [--min-pct 50] [--limit 10]
|
package/README.zh-CN.md
CHANGED
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
|
|
25
25
|
**开盘底仓(0.40.0+,BSC 主网和测试网可用):** `gang create … --base <5|10> --base-vest <30|90|180> [--grad 6|9|12|15]` 在 GangLaunchpad 3.0 上建一个曲线币,它的第一笔成交就是给这个币专属的底仓金库(GangBaseVault,`base-v1`)买入总量的 5% 或 10%。建币交易按 pad 的 `previewBaseCost` 正好付这么多 BNB(5% 在 6 / 9 / 12 / 15 BNB 档:0.0994 / 0.1490 / 0.1987 / 0.2484 BNB;10%:0.2090 / 0.3135 / 0.4180 / 0.5225;含 1% 手续费,其中 70% 作为创建人手续费返还给你)。金库不交易:毕业前底仓锁住;毕业后第一次有人调 `gang base release`(谁都可以调)开始计时,之后在 `--base-vest` 天里匀速释放到创建人的钱包(5%:30 / 90 / 180 天;10%:90 / 180 天;写死不能改)。**如果代币永远不毕业,底仓和为它付的钱永远锁着,收不回来。** 预览里有花费、释放节奏和规格里的收益表(最少能拿多少、按毕业价算多少、几天收回成本、每天释放量、其他买家多付多少),并说明保证金约束不了底仓(金库一直往创建人钱包里补币,保证金不代表对底仓的任何承诺)。只支持 WBNB 计价,不能带分红,不能和 `--vault` / `--promote` / `--fair` / `--fly` 或一条命令发射一起用;带税时收款人通常就是创建人自己。开启 abcd 时建币经 `createWithSalt` 带上 BNB 发出。CLI 会先问 pad(`baseVaultImpl`),没开放的地方直接拒绝 `--base`。`gang base status --token 0x…` 显示金库、底仓大小、释放期、开始时间(或未开始)、总量、已释放、可释放和未释放(按时间算);`gang base release --token 0x…` 第一次调用开始计时,之后把已经到期的部分转给创建人。
|
|
26
26
|
|
|
27
|
-
**冲毕业奖励(0.42.0+,BSC 主网和测试网 2026-11-17
|
|
27
|
+
**冲毕业奖励(0.42.0+,BSC 主网和测试网 2026-11-17 起可用;和 `--countdown-reward` 一起用、转一部分给倒计时奖励要 0.44.0+,主网和测试网 2026-11-17 起已开):** `gang create … --grad-reward <种子钱> [--gr-min-buy <金额>] [--gr-entries <1-20>] [--gr-last <0-50>] [--gr-refund-days <30-180>]` 在 GangLaunchpad 3.0 上建一个曲线币,同时用这个币的报价币放进一笔奖励池。种子钱在建币时拉走,所以 CLI 会先让你批准;至少值 0.1 BNB。
|
|
28
28
|
|
|
29
29
|
- **谁能分**:pad 记下最后 `--gr-entries` 笔(默认 10)曲线买入,每笔都要实际花掉 `--gr-min-buy`(默认值 0.01 BNB),而且 Agent 门槛开着;把币推过毕业线的那一笔一律计入。
|
|
30
30
|
- **怎么分**:毕业时,这一笔先额外拿奖励池的 `--gr-last`%(默认 30),剩下的由所有格子(包括这一笔)按各自实际花掉的金额分。
|
|
31
31
|
- **卖出**:在曲线上卖出,这个钱包之前的格子全部失效;之后再买会重新计入。
|
|
32
32
|
- **领取**:毕业后 180 天内买家自己领,之后任何人都可以把剩下的部分退给你。
|
|
33
33
|
- **不毕业**:建币满 `--gr-refund-days` 天(默认 90)后,你可以申请撤回。申请公示 7 天,期间毕业照常发放;公示期满后 3 天内可以取回,过期就要重新申请。
|
|
34
|
-
- **组合**:可以和 `--promote` 一起用(不带税,或者带 `--recipient
|
|
34
|
+
- **组合**:可以和 `--promote` 一起用(不带税,或者带 `--recipient`);也可以和 `--countdown-reward` 一起用:毕业时奖励池的 `--gr-carry`%(默认 20)转进这个币的倒计时奖励模块,没领的剩余也转进去,不退给你;不能和 `--vault` / `--base` / `--fair` / `--fly` 或一条命令发射一起用。
|
|
35
35
|
|
|
36
36
|
买家只付正常的价格和手续费:奖励池是你自己的钱,按公开的固定规则发给毕业前最后几笔买入。`gang buy` / `gang sell` 的预览会在 `rewards.gradReward` 里说明这笔会不会计入、卖出会让哪些格子失效。`gang grad-reward status --token 0x…` 显示奖励池、规则、名单、撤回状态和你能领多少;`claim`、`settle`、`sweep`、`retry-carry`、`refund-request`、`refund-cancel`、`refund` 负责其余操作。
|
|
37
37
|
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
- **怎么分**:倒计时结束时,这一轮最后 `--cd-entries` 笔计入的买入平分奖励池的 `--cd-payout`%(不超过必填的 `--cd-max-payout`),最后一笔再多拿这一轮的 `--cd-last`%。到上限结束的轮次结束时间是公开的,所以只平分,不发额外部分。
|
|
42
42
|
- **其他**:奖励池低于 `--cd-min-pot` 时不开新轮;连续 `--cd-idle` 天没有计入的买入,任何人可以把最后一轮再发一次。`--cd-dev`% 的税留给你。WBNB 报价的币 `--cd-min-buy` / `--cd-min-pot` 默认 0.05 / 0.1 BNB,其他报价币必须写明。
|
|
43
43
|
- **预览**:写明池子成交额有多少进奖励池、一轮最多发多少、占满所有名额要花多少(名额数 × 最低买入 × 买入税)。要如实告诉买家:任何人(包括你自己)都可以用多个钱包占名额;只有 gang CLI / MCP 通过模块发出的买入才算(`gang buy`;PancakeSwap 路由、聚合器、GangRouter 都不算;gang.fun 网站只展示倒计时)。
|
|
44
|
-
- **步骤**:和 `--floor` 一样,先算出币的地址并为它克隆模块,再在这个地址建币、bind,有 `--cd-seed` 时再批准和 fund。每次运行一笔交易,重复运行同一条命令。中途改了税率或 `--cd-*` 设置会被拒绝。fund 预览构建过、但模块账目里还看不到时,只有加 `--cd-seed-again` 才会再构建一笔;前一笔可能还在 Binance App
|
|
44
|
+
- **步骤**:和 `--floor` 一样,先算出币的地址并为它克隆模块,再在这个地址建币、bind,有 `--cd-seed` 时再批准和 fund。每次运行一笔交易,重复运行同一条命令。中途改了税率或 `--cd-*` 设置会被拒绝。fund 预览构建过、但模块账目里还看不到时,只有加 `--cd-seed-again` 才会再构建一笔;前一笔可能还在 Binance App 里等批准,两笔只批一笔。也可以同时加 `--grad-reward`(0.44.0+):毕业时冲毕业奖励池的 `--gr-carry`%(默认 20)转进这个模块(见上面的冲毕业奖励)。
|
|
45
45
|
|
|
46
46
|
毕业后的 `gang buy` 默认通过模块买入并要求计入(不计入的买单在构建前就会拒绝;`--cd-uncounted` 照买不计入),预览的 `rewards.countdown` 写明计不计入、原因、当前轮次、截止时间和上限、奖励池、你的预计份额。`gang countdown status|claim|settle|finalize|claim-dev --token 0x… [--to 0x…]` 负责其余操作。工厂:主网 `0xa1e3117a59104de7D97667cF22f9AB886a5f2957`,测试网 `0x0f83ABC7d39C0d043d3f5612E304D9395B5fe582`。
|
|
47
47
|
|
|
@@ -82,6 +82,8 @@ gang trending # 其他 agent 现在在买什么(0.24.0+)
|
|
|
82
82
|
gang weekly # 发射日活动(0.36.0+):报名中的一期、本期入选、我的报名(列表)
|
|
83
83
|
gang weekly apply --name <名称> --symbol <SYM> --logo ./logo.png --description "…" --contact <联系方式> [--twitter …] [--telegram …] [--website …] [--modules lp,buyback] # 预览;加 --yes 用钱包签名(EIP-712,不是交易)并提交
|
|
84
84
|
gang weekly withdraw [--yes]
|
|
85
|
+
gang campaign [<slug>] # gang.fun 奖励活动(0.45.0+):规则摘要、票数、抽奖、我的进度
|
|
86
|
+
gang campaign join [<slug>] # 免费报名预览;加 --yes 用钱包签名(EIP-712,不是交易,不花 gas)并提交
|
|
85
87
|
gang hot [--limit 10] [--track all|v3|fair|fly|v2|soft] [--include-graduated] # 按 24h USD 成交量
|
|
86
88
|
gang new [--limit 10] [--max-age 2h]
|
|
87
89
|
gang near-grad [--min-pct 50] [--limit 10]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gangfun/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"mcpName": "io.github.gangfun/gang",
|
|
5
5
|
"description": "Gang launchpad CLI for Binance Agentic Wallet agents: create on GangLaunchpad (untaxed or tax tokens), 打新 fair mint, PancakeSwap pool trades, LaunchpadV2 and legacy Soft/U/S trade.",
|
|
6
6
|
"type": "module",
|
package/src/campaign.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `gang campaign`: gang.fun's reward campaigns (gang.fun/campaign/<slug>), e.g. Agent Season (`agent-season`). A
|
|
3
|
+
* campaign's rules are public and fixed per version; rewards follow those rules and are not investment advice.
|
|
4
|
+
*
|
|
5
|
+
* gang campaign [<slug>] live campaigns; with a slug (or when one is live) its rules summary, its
|
|
6
|
+
* tickets and lottery, and the signed-in wallet's progress
|
|
7
|
+
* gang campaign join [<slug>] [--yes] the free sign-up: a preview (nothing signed or sent); --yes signs it with the
|
|
8
|
+
* Agent wallet (EIP-712 typed data, no transaction, no gas) and submits it
|
|
9
|
+
*
|
|
10
|
+
* The sign-up proves which Agent wallet joins without a trade. It is a free way in: an agent never trades only to earn
|
|
11
|
+
* campaign tickets, and never on its own.
|
|
12
|
+
*/
|
|
13
|
+
import { get as apiGet } from './discover.js'
|
|
14
|
+
import { bawAddress, bawStatus } from './baw.js'
|
|
15
|
+
import { localTime } from './follow.js'
|
|
16
|
+
import { bawSignTyped, post, shellWord } from './weekly.js'
|
|
17
|
+
|
|
18
|
+
export const CAMPAIGN_NOTE = 'A gang.fun reward campaign: rewards follow its public rules and are not investment advice. Never trade only to earn tickets: the free sign-up (gang campaign join) gives the same base ticket.'
|
|
19
|
+
export const CAMPAIGN_DOMAIN = { name: 'gang.fun campaign', version: '1', chainId: 56 }
|
|
20
|
+
const DOMAIN_TYPE = [{ name: 'name', type: 'string' }, { name: 'version', type: 'string' }, { name: 'chainId', type: 'uint256' }]
|
|
21
|
+
export const JOIN_TYPE = [{ name: 'wallet', type: 'address' }, { name: 'campaign', type: 'string' }, { name: 'expires', type: 'uint256' }]
|
|
22
|
+
const SIGN_TTL_S = 30 * 60 // the server takes up to 1 hour ahead
|
|
23
|
+
const SLUG_RE = /^[a-z0-9][a-z0-9-]{0,63}$/
|
|
24
|
+
const SIGN_IN = 'sign in to baw (baw auth signin): the sign-up is signed by the Agent wallet that joins'
|
|
25
|
+
// gang.fun's refusal → the CLI's code (DEVELOPERS.md)
|
|
26
|
+
const API_CODES = { not_agent: 'NO_AGENT_ID', rate_limited: 'NETWORK', unavailable: 'NETWORK', bad_request: 'USAGE' }
|
|
27
|
+
const RETRY_CODES = new Set(['expired', 'rate_limited', 'unavailable'])
|
|
28
|
+
const PRINTED = Symbol('printed')
|
|
29
|
+
|
|
30
|
+
export const campaignUrl = (slug) => `https://gang.fun/campaign/${slug}`
|
|
31
|
+
|
|
32
|
+
/** The typed data baw signs for a sign-up (eth_signTypedData_v4 shape: EIP712Domain included in types). */
|
|
33
|
+
export function joinTypedData(wallet, campaign, expires) {
|
|
34
|
+
return {
|
|
35
|
+
types: { EIP712Domain: DOMAIN_TYPE, CampaignJoin: JOIN_TYPE }, primaryType: 'CampaignJoin', domain: CAMPAIGN_DOMAIN,
|
|
36
|
+
message: { wallet, campaign, expires },
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const titleOf = (t) => (t && typeof t === 'object' ? t.en || t.zh || null : t ?? null)
|
|
41
|
+
const when = (ts) => (Number(ts) > 0 ? localTime(Number(ts)) : null)
|
|
42
|
+
|
|
43
|
+
/** The parts of GET /campaigns/:slug an agent needs (the page has the rest). */
|
|
44
|
+
export function summary(c) {
|
|
45
|
+
const w = c.window ?? {}
|
|
46
|
+
return {
|
|
47
|
+
slug: c.slug, title: titleOf(c.title), status: c.status,
|
|
48
|
+
start: when(w.start), end: when(w.ended_at ?? w.end),
|
|
49
|
+
...(c.tickets && { tickets: { total: c.tickets.total ?? 0, holders: c.tickets.holders ?? 0, prizesNow: c.tickets.prizes_now ?? 0 } }),
|
|
50
|
+
...(c.lottery && {
|
|
51
|
+
lottery: {
|
|
52
|
+
status: c.lottery.status, ...(c.lottery.snapshot_hash && { snapshotHash: c.lottery.snapshot_hash }),
|
|
53
|
+
...(c.lottery.target_block != null && { targetBlock: c.lottery.target_block }),
|
|
54
|
+
...(Array.isArray(c.lottery.winners) && c.lottery.winners.length && { winners: c.lottery.winners.map((x) => ({ wallet: x.wallet, prizeU: x.prize_u })) }),
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
url: campaignUrl(c.slug),
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The signed-in wallet's row (GET /campaigns/:slug/wallet/:address), or null. */
|
|
62
|
+
export function mineOf(m) {
|
|
63
|
+
if (!m || typeof m !== 'object') return null
|
|
64
|
+
const t = m.tickets ?? {}
|
|
65
|
+
return {
|
|
66
|
+
wallet: m.wallet, status: m.status ?? null, agentId: m.agent_id ?? null,
|
|
67
|
+
tickets: { base: t.base ?? 0, revisit: t.revisit ?? 0, invite: t.invite ?? 0, total: t.total ?? 0 },
|
|
68
|
+
joined: !!m.joined_at, ...(m.joined_at && { joinedAt: when(m.joined_at) }),
|
|
69
|
+
...(m.revisit && { revisit: { from: when(m.revisit.due_from), until: when(m.revisit.due_until), done: !!m.revisit.done } }),
|
|
70
|
+
...(m.won && { won: m.won }),
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** runCampaign(sub, rest, io): sub = 'join' or a slug or undefined; io = { flag, out, fail } from index.js. */
|
|
75
|
+
export async function runCampaign(sub, rest, { flag, out, fail }) {
|
|
76
|
+
const join = sub === 'join'
|
|
77
|
+
const extra = join ? rest.slice(1) : rest
|
|
78
|
+
if (extra.length) fail(`unexpected ${JSON.stringify(extra[0])}: gang campaign [<slug>] | gang campaign join [<slug>] [--yes]`)
|
|
79
|
+
const slugArg = (join ? rest[0] : sub)?.toLowerCase()
|
|
80
|
+
if (slugArg != null && !SLUG_RE.test(slugArg)) fail(`gang campaign takes a campaign slug like agent-season (got ${JSON.stringify(slugArg)})`)
|
|
81
|
+
const signedIn = () => { try { return bawStatus() === 'CONNECTED' } catch { return false } }
|
|
82
|
+
const read = async (path) => {
|
|
83
|
+
try { return await apiGet(path, undefined, '') } catch (e) { return fail(e.message, { retry: 'same command again' }) }
|
|
84
|
+
}
|
|
85
|
+
// the campaign this command is about: the slug given, else the only live one
|
|
86
|
+
const pick = async () => {
|
|
87
|
+
if (slugArg) return slugArg
|
|
88
|
+
const l = await read('/campaigns?status=live')
|
|
89
|
+
const items = Array.isArray(l?.items) ? l.items : []
|
|
90
|
+
if (items.length === 1) return items[0].slug
|
|
91
|
+
if (!items.length) return null
|
|
92
|
+
if (!join) { out({ success: true, live: items.map((i) => ({ slug: i.slug, title: titleOf(i.title), status: i.status, url: campaignUrl(i.slug) })), note: CAMPAIGN_NOTE }); return PRINTED }
|
|
93
|
+
return fail(`several campaigns are live: name one (${items.map((i) => i.slug).join(', ')})`, { campaigns: items.map((i) => i.slug) })
|
|
94
|
+
}
|
|
95
|
+
const mine = async (slug, w) => {
|
|
96
|
+
if (!w) return null
|
|
97
|
+
try { return mineOf(await apiGet(`/campaigns/${slug}/wallet/${w.toLowerCase()}`, undefined, '')) } catch { return null }
|
|
98
|
+
}
|
|
99
|
+
const wallet = () => (signedIn() ? (() => { try { return bawAddress() } catch { return null } })() : null)
|
|
100
|
+
|
|
101
|
+
const slug = await pick()
|
|
102
|
+
if (slug === PRINTED) return undefined // the list of live campaigns was printed
|
|
103
|
+
if (!slug) {
|
|
104
|
+
if (join) fail('no gang.fun campaign is live now')
|
|
105
|
+
return out({ success: true, live: [], note: 'No gang.fun campaign is live now.' })
|
|
106
|
+
}
|
|
107
|
+
const c = await read(`/campaigns/${slug}`)
|
|
108
|
+
if (!c) fail(`gang.fun has no campaign ${slug}`)
|
|
109
|
+
const w = wallet()
|
|
110
|
+
const me = await mine(slug, w)
|
|
111
|
+
// can this wallet sign up at all? (the server refuses otherwise, after the user approved a signature for nothing)
|
|
112
|
+
const joinOpen = c.status === 'live' && c.tickets != null && c.rules?.ticket?.join !== false
|
|
113
|
+
const notNew = me?.status === 'not_new'
|
|
114
|
+
const excluded = me?.status === 'excluded'
|
|
115
|
+
|
|
116
|
+
if (!join) {
|
|
117
|
+
return out({
|
|
118
|
+
success: true, campaign: summary(c), ...(me && { mine: me }),
|
|
119
|
+
...(!me?.tickets?.base && joinOpen && !notNew && !excluded && { next: `gang campaign join ${slug}` }),
|
|
120
|
+
note: CAMPAIGN_NOTE,
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (!joinOpen) fail(`${slug} is not open for sign-up (status ${c.status})`, { campaign: summary(c) })
|
|
125
|
+
if (!w) fail(SIGN_IN)
|
|
126
|
+
if (notNew) fail(`${w} traded on Gang before ${slug} started: the sign-up is for new wallets (invites still earn tickets)`, { apiCode: 'not_new', code: 'ERROR' })
|
|
127
|
+
if (excluded) fail(`${w} is not eligible for ${slug}`, { apiCode: 'not_eligible', code: 'ERROR' })
|
|
128
|
+
if (me?.joined) return out({ success: true, campaign: slug, wallet: w.toLowerCase(), alreadyJoined: true, mine: me, url: campaignUrl(slug) })
|
|
129
|
+
if (!flag('yes')) {
|
|
130
|
+
return out({
|
|
131
|
+
success: true, preview: true, join: { campaign: slug, wallet: w.toLowerCase() },
|
|
132
|
+
signs: 'an EIP-712 sign-up message with the Agent wallet: no transaction, no gas, no cost',
|
|
133
|
+
...(me?.tickets?.base && { alreadyHasBaseTicket: true, why: 'This wallet already has its base ticket from a trade: signing up adds no ticket.' }),
|
|
134
|
+
confirm: ['gang', 'campaign', 'join', slug, '--yes'].map(shellWord).join(' '),
|
|
135
|
+
note: `Nothing was signed or sent. On the user's OK run confirm. ${CAMPAIGN_NOTE}`,
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
const expires = Math.floor(Date.now() / 1000) + SIGN_TTL_S
|
|
139
|
+
let signature
|
|
140
|
+
try { signature = bawSignTyped(w, joinTypedData(w, slug, expires)) } catch (e) { fail(e.message, e.retryable ? { retry: 'same command again' } : {}) }
|
|
141
|
+
let r
|
|
142
|
+
try {
|
|
143
|
+
r = await post(`/campaigns/${slug}/join`, { wallet: w.toLowerCase(), expires, signature })
|
|
144
|
+
} catch (e) {
|
|
145
|
+
fail(e.message, {
|
|
146
|
+
...(e.apiCode && { apiCode: e.apiCode, code: API_CODES[e.apiCode] || 'ERROR' }),
|
|
147
|
+
...((e.retryable || RETRY_CODES.has(e.apiCode)) && { retry: 'same command again' }),
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
return out({
|
|
151
|
+
success: true, campaign: slug, wallet: w.toLowerCase(), joined: true, ...(r.joined_at && { joinedAt: when(r.joined_at) }),
|
|
152
|
+
...(r.tickets != null && { tickets: r.tickets }), url: campaignUrl(slug),
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
|
package/src/capabilities.js
CHANGED
|
@@ -58,6 +58,8 @@ export const COMMANDS = [
|
|
|
58
58
|
c('weekly', 'read', 'none', '0.36.0', "Gang's Launch Day event: the open issue, the current pick, my applications"),
|
|
59
59
|
c('weekly apply', 'publish', 'medium', '0.36.0', 'Sign (EIP-712, no tx) and submit an application for Launch Day, with the token\'s name, symbol, logo, links and a private contact: only on the user\'s yes', { needsUserConfirmation: true }),
|
|
60
60
|
c('weekly withdraw', 'publish', 'low', '0.36.0', 'Sign and send the withdrawal of my Launch Day application', { needsUserConfirmation: true }),
|
|
61
|
+
c('campaign', 'read', 'none', '0.45.0', "gang.fun's reward campaigns: rules summary, tickets, lottery, my progress"),
|
|
62
|
+
c('campaign join', 'publish', 'low', '0.45.0', 'Sign (EIP-712, no tx, no gas) and submit the free sign-up for a campaign: only on the user\'s yes', { needsUserConfirmation: true }),
|
|
61
63
|
c('v3 income', 'read', 'none', '0.8.0', "A tax recipient's income per token"),
|
|
62
64
|
c('creator-fee', 'read', 'none', '0.23.0', 'What a creator can claim'),
|
|
63
65
|
c('creator-fee --claim', 'preview', 'low', '0.23.0', 'Creator only: claim the creator fee to this wallet'),
|
|
@@ -66,6 +68,7 @@ export const COMMANDS = [
|
|
|
66
68
|
c('create', 'preview', 'high', '0.1.0', 'Launch a token. Its name, tax, logo and links never change; a launch in one command also buys, bonds or binds modules'),
|
|
67
69
|
c('create --grad-reward', 'preview', 'high', '0.42.0', 'Create a 3.0 curve token with a reward pool the creator seeds for the last curve buys before graduation (by what each spent; the graduating buy gets a share on top); refundable only after a public notice if it never graduates'),
|
|
68
70
|
c('create --countdown-reward', 'preview', 'high', '0.43.2', "Launch a taxed 3.0 token whose tax recipient is its countdown reward module: the creator's share of the pool tax becomes a reward the last counted buys of each round share when its countdown runs out; every setting fixed for good, several steps (clone, create, bind, seed)"),
|
|
71
|
+
c('create --countdown-reward --grad-reward', 'preview', 'high', '0.44.0', "Launch a taxed 3.0 token with both rewards: the countdown reward module as its tax recipient, and a graduation reward pool the creator seeds; at graduation --gr-carry % of that pool (default 20) goes into the module's reward pool, and the unclaimed rest later too. A carry needs the pad to have opened it; --gr-carry 0 launches both without one"),
|
|
69
72
|
c('create --base', 'preview', 'high', '0.40.0', 'Create a 3.0 curve token that buys 5% or 10% of its supply for a base vault in the same tx, paid in BNB: locked until graduation (for good if it never graduates), then released linearly to the creator'),
|
|
70
73
|
c('mint', 'preview', 'medium', '0.12.0', 'Buy shares of a 打新 or Mint Flywheel sale'),
|
|
71
74
|
c('withdraw', 'preview', 'medium', '0.12.0', 'Sell shares back at the mint price, less the exit fee, before the sale fills', { riskIf: { 'break-bond': { risk: 'high', why: '打新 only: gives up the whole bond' } } }),
|
package/src/gradreward.js
CHANGED
|
@@ -55,7 +55,7 @@ export const GRAD_EVENT_ABIS = [GRAD_PAD_ABI]
|
|
|
55
55
|
|
|
56
56
|
export const HINTS = {
|
|
57
57
|
GradNotOpen: 'the graduation reward is closed on this pad: drop --grad-reward',
|
|
58
|
-
BadGradConfig: '--grad-reward out of bounds: a seed above 0, --gr-min-buy above 0, --gr-entries 1–20, --gr-last 0–50, --gr-refund-days 30–180',
|
|
58
|
+
BadGradConfig: '--grad-reward out of bounds: a seed above 0, --gr-min-buy above 0, --gr-entries 1–20, --gr-last 0–50, --gr-refund-days 30–180, --gr-carry 0–50',
|
|
59
59
|
BadCountdown: 'the tax recipient is a countdown reward module made for another token or quote (or a carry was asked without one)',
|
|
60
60
|
NotGradState: 'the reward is not in the state this needs (on the curve for a refund; graduated for a claim, a settle or a sweep)',
|
|
61
61
|
RefundNotDue: 'a refund needs: --gr-refund-days passed since the create to ask; then a 7-day public notice; then 3 days to take it, after which the request lapses',
|
|
@@ -69,7 +69,7 @@ export const revertOf = (e) => revertIn(e, [GRAD_PAD_ABI], HINTS)
|
|
|
69
69
|
|
|
70
70
|
export const STATES = ['none', 'on the curve', 'graduated: claims open', 'refunded to the creator', 'closed']
|
|
71
71
|
export const MAX_ENTRIES = 20
|
|
72
|
-
export const DEFAULTS = { entries: 10, lastPct: 30, refundDays: 90 }
|
|
72
|
+
export const DEFAULTS = { entries: 10, lastPct: 30, refundDays: 90, carryPct: 20 }
|
|
73
73
|
// in BNB, converted into the quote at the pad's own rate (graduation amount ÷ target)
|
|
74
74
|
export const DEFAULT_MIN_BUY_BNB = '0.01'
|
|
75
75
|
export const MIN_SEED_BNB = '0.1'
|
|
@@ -77,9 +77,9 @@ export const NOTICE_DAYS = 7
|
|
|
77
77
|
export const WINDOW_DAYS = 3
|
|
78
78
|
export const CLAIM_DAYS = 180
|
|
79
79
|
|
|
80
|
-
export const GRAD_FLAGS = ['grad-reward', 'gr-min-buy', 'gr-entries', 'gr-last', 'gr-refund-days']
|
|
81
|
-
export const GRAD_USAGE = '--grad-reward <seed> [--gr-min-buy <amount>] [--gr-entries <1-20>] [--gr-last <0-50>] [--gr-refund-days <30-180>]: the reward pool you put in at create (in the token\'s quote), the least a buy must spend to count, how many of the last buys share it, the % the graduating buy gets on top,
|
|
82
|
-
export const GRAD_ALONE = 'a --grad-reward create
|
|
80
|
+
export const GRAD_FLAGS = ['grad-reward', 'gr-min-buy', 'gr-entries', 'gr-last', 'gr-refund-days', 'gr-carry']
|
|
81
|
+
export const GRAD_USAGE = '--grad-reward <seed> [--gr-min-buy <amount>] [--gr-entries <1-20>] [--gr-last <0-50>] [--gr-refund-days <30-180>] [--gr-carry <0-50>, with --countdown-reward]: the reward pool you put in at create (in the token\'s quote), the least a buy must spend to count, how many of the last buys share it, the % the graduating buy gets on top, the days before you may ask for the pool back, and (with --countdown-reward) the % of the pool carried into the token\'s countdown reward at graduation (default 20)'
|
|
82
|
+
export const GRAD_ALONE = 'a --grad-reward create goes alone or with --countdown-reward only: no chained dev buy, GangBond or buy-back / split / LP / combined / floor / capped recipient, no --base, no --vault. A dev buy is its own gang buy after the create lands'
|
|
83
83
|
export const RULE = 'the reward pool is the creator\'s own money, paid to the last buys before graduation by a fixed public rule (by what each spent); buyers pay only the usual curve price and 1% fee and get the tokens they buy'
|
|
84
84
|
|
|
85
85
|
/** The --grad-reward / --gr-* flags, checked: { seed, minBuy, entries, lastBps, refundDays } (amounts as typed), or { error }. */
|
|
@@ -104,7 +104,9 @@ export function parseGradReward(opt, flag) {
|
|
|
104
104
|
if (l.error) return l
|
|
105
105
|
const r = int('gr-refund-days', DEFAULTS.refundDays, 30, 180, 'days after the create before you may ask for the pool back')
|
|
106
106
|
if (r.error) return r
|
|
107
|
-
|
|
107
|
+
const c = int('gr-carry', null, 0, 50, '% of the pool carried into the token\'s countdown reward at graduation')
|
|
108
|
+
if (c.error) return c
|
|
109
|
+
return { seed: String(seed).trim(), minBuy: minBuy && String(minBuy).trim(), entries: e.v, lastBps: l.v * 100, refundDays: r.v, carryBps: c.v == null ? null : c.v * 100 }
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
/** Whether `ctx.pad` takes a graduation reward now: { open: true } / { open: false, why } / { unread }. */
|
|
@@ -119,6 +121,27 @@ export async function gradSupport(ctx) {
|
|
|
119
121
|
return { open: true, countdownFactory: deps[2] }
|
|
120
122
|
}
|
|
121
123
|
|
|
124
|
+
/** Why a carry can't be asked of this pad (its countdown factory is not this CLI's), or null. */
|
|
125
|
+
export const carryClosed = (padFactory, cliFactory) => (cliFactory && String(padFactory ?? '').toLowerCase() === cliFactory.toLowerCase()
|
|
126
|
+
? null
|
|
127
|
+
: `--gr-carry: the pad has not opened the graduation reward's carry into the countdown reward yet (its countdown factory is ${padFactory ?? 'unset'}, this CLI's is ${cliFactory ?? 'none'}): add --gr-carry 0 to launch both without a carry`)
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Before a --countdown-reward launch clones its module (gas, and the metadata fixed for good): what the create would
|
|
131
|
+
* refuse later about its --grad-reward, as { error, ...details }, or null.
|
|
132
|
+
*/
|
|
133
|
+
export async function gradLaunchCheck(read, pad, testnet, gr, cliFactory) {
|
|
134
|
+
let deps
|
|
135
|
+
try { deps = await read(pad, GRAD_PAD_ABI, 'gradRewardDeps') } catch (e) {
|
|
136
|
+
if (missingRead(e)) return { error: `GangLaunchpad 3.0 on ${testnet ? 'the BSC testnet' : 'BSC mainnet'} has no graduation reward yet (the pad is not upgraded for it): drop --grad-reward`, pad }
|
|
137
|
+
return { error: 'could not check the pad for the graduation reward (RPC error)', pad, detail: e.shortMessage || e.message.split('\n')[0], retry: 'same command again' }
|
|
138
|
+
}
|
|
139
|
+
if (!deps[0]) return { error: 'the graduation reward is closed on this pad: drop --grad-reward', pad }
|
|
140
|
+
const carryBps = gr.carryBps ?? DEFAULTS.carryPct * 100
|
|
141
|
+
const closed = carryBps > 0 ? carryClosed(deps[2], cliFactory) : null
|
|
142
|
+
return closed ? { error: closed, pad } : null
|
|
143
|
+
}
|
|
144
|
+
|
|
122
145
|
/** `amountBnb` (a decimal string) in the quote, at the rate the curve's graduation amount fixes (gradAmt ÷ target BNB). */
|
|
123
146
|
export const bnbInQuote = (amountBnb, gradAmt, targetBnb) =>
|
|
124
147
|
(parseUnits(String(amountBnb), 18) * gradAmt) / parseUnits(String(targetBnb), 18)
|
|
@@ -127,22 +150,26 @@ const iso = (s) => (Number(s) > 0 ? new Date(Number(s) * 1000).toISOString() : n
|
|
|
127
150
|
const pctOf = (bps) => Number(bps) / 100
|
|
128
151
|
|
|
129
152
|
/** What the create preview says about the reward (pure; amounts as display strings). */
|
|
130
|
-
export function gradCreateView({ seed, minBuy, sym, entries, lastBps, refundDays, targetBnb, seedFloorNote, gateOn }) {
|
|
153
|
+
export function gradCreateView({ seed, minBuy, sym, entries, lastBps, refundDays, targetBnb, seedFloorNote, gateOn, carryBps = 0, toModule = false }) {
|
|
131
154
|
const last = pctOf(lastBps)
|
|
155
|
+
const carry = pctOf(carryBps)
|
|
156
|
+
const pool = carry > 0 ? `the payout (the pool less the ${carry}% carry)` : 'the pool'
|
|
157
|
+
const rest = toModule ? 'to the token\'s countdown reward module (its reward pool)' : 'back to you'
|
|
132
158
|
return {
|
|
133
159
|
pool: `${seed} ${sym}`, payWithThisTx: `${seed} ${sym}, pulled from this wallet in the create (approve the pad for it first)`,
|
|
134
160
|
minBuy: `${minBuy} ${sym}`, entries, lastPct: last, refundDays,
|
|
135
161
|
who: `the last ${entries} curve buys that each actually spend at least ${minBuy} ${sym} (after a wallet-cap or graduation cut); the buy that graduates the token at ${targetBnb} BNB counts whatever it spends. Only while the pad's Agent gate is on (${gateOn ? 'it is on now' : 'IT IS OFF NOW: no buy would count until gang turns it back on'}): with it off, no buy counts`,
|
|
162
|
+
...(carry > 0 && { carryPct: carry, carry: `at graduation ${carry}% of the pool goes into this token's countdown reward module, as its reward pool (through the module's receiveCarry; the pad found the module from the token's tax recipient, nobody types its address). If the module takes less (it refuses, or the gas runs short), the rest is owed and anyone resends it with gang grad-reward retry-carry. The last buys share the rest` }),
|
|
136
163
|
split: last > 0
|
|
137
|
-
? `at graduation the buy that graduates it gets ${last}% of
|
|
138
|
-
: `at graduation all ${entries} entries split
|
|
164
|
+
? `at graduation the buy that graduates it gets ${last}% of ${pool} on top; then all ${entries} entries, it included, split the rest by what each spent (a wallet with several entries adds them up)`
|
|
165
|
+
: `at graduation all ${entries} entries split ${pool} by what each spent (a wallet with several entries adds them up)`,
|
|
139
166
|
sells: 'a curve sell takes out every entry that wallet has so far; a later buy of the same wallet counts again',
|
|
140
|
-
claims: `buyers claim with gang grad-reward claim for ${CLAIM_DAYS} days after graduation; then anyone sweeps the unclaimed rest (and the rounding dust)
|
|
167
|
+
claims: `buyers claim with gang grad-reward claim for ${CLAIM_DAYS} days after graduation; then anyone sweeps the unclaimed rest (and the rounding dust) ${rest}`,
|
|
141
168
|
refund: `if the token does not graduate: ${refundDays} days after the create you may ask for the pool back (gang grad-reward refund-request). The request is public for ${NOTICE_DAYS} days; a graduation in that time pays the buyers as usual. Then you have ${WINDOW_DAYS} days to take it (gang grad-reward refund), after which the request lapses and must be made again`,
|
|
142
169
|
rule: RULE,
|
|
143
170
|
risks: 'anyone watching the curve can time the last buys, and one person with several Agent IDs can fill several entries: weighting by spend means many small entries earn no more than one large one, but a push into a full list still crowds out the oldest entries. A higher --gr-min-buy and more --gr-entries make that harder',
|
|
144
171
|
...(seedFloorNote && { seedFloor: seedFloorNote }),
|
|
145
|
-
warning: `PERMANENT: ${seed} ${sym} leaves this wallet in the create. You get it back only through the refund above (if the token does not graduate) or as the unclaimed rest 180 days after graduation. The size, the rules and the numbers never change`,
|
|
172
|
+
warning: `PERMANENT: ${seed} ${sym} leaves this wallet in the create. You get it back only through the refund above (if the token does not graduate)${toModule ? '' : ' or as the unclaimed rest 180 days after graduation'}. The size, the rules and the numbers never change`,
|
|
146
173
|
}
|
|
147
174
|
}
|
|
148
175
|
|
package/src/index.js
CHANGED
|
@@ -34,6 +34,7 @@ import { CD_ALONE, CD_FLAGS, COUNTDOWN_EVENT_ABIS, runCountdown } from './countd
|
|
|
34
34
|
import { GRAD_ALONE, GRAD_EVENT_ABIS, GRAD_FLAGS, runGradReward } from './gradreward.js'
|
|
35
35
|
import { wantsPoolModule } from './promote.js'
|
|
36
36
|
import { runWeekly } from './weekly.js'
|
|
37
|
+
import { runCampaign } from './campaign.js'
|
|
37
38
|
import { runFly, flyCtx, isFlyToken, FLY_EVENT_ABIS, FLY_CREATE_FLAGS } from './fly.js'
|
|
38
39
|
import { FAIR_DEV_BUY, isLaunch, LAUNCH_FLAGS, REDEEM_FEE_ALONE, runLaunch, TAX_CAP_ALONE } from './launch.js'
|
|
39
40
|
import { poolPayBnb, poolTrade, refShown } from './pool.js'
|
|
@@ -386,6 +387,12 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
386
387
|
at the launch time; selling more than 20% in the featured week ends the pin
|
|
387
388
|
gang weekly withdraw [--issue <date>] [--yes]
|
|
388
389
|
withdraw my application while applications are open (--yes signs and sends)
|
|
390
|
+
gang campaign [<slug>] gang.fun's reward campaigns (gang.fun/campaign/<slug>, 0.45.0+): the live ones; with
|
|
391
|
+
a slug (or when one is live) its rules summary, tickets, lottery and my progress.
|
|
392
|
+
Rewards follow the campaign's public rules; not investment advice
|
|
393
|
+
gang campaign join [<slug>] [--yes] the free sign-up (base ticket without a trade). Without --yes: a preview, nothing
|
|
394
|
+
signed or sent. --yes signs it with the Agent wallet (EIP-712, no tx, no gas) and
|
|
395
|
+
submits it. Never trade only to earn tickets
|
|
389
396
|
gang upload-logo (--file <path> | --url <image URL>)
|
|
390
397
|
copy an image to gang.fun → logoUrl (ipfs://<cid>, for --logo-uri) and url (CDN)
|
|
391
398
|
|
|
@@ -567,7 +574,7 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
567
574
|
through the module count. PERMANENT: every setting. Steps: the token's address
|
|
568
575
|
first (as --floor), clone your module for it → create → bind → seed → the rest of
|
|
569
576
|
the launch. Not with --floor / --buyback / --lp / --split / --tax-cap / --recipient /
|
|
570
|
-
--vault
|
|
577
|
+
--vault; with --grad-reward too (0.44.0+), --gr-carry % of that pool (default 20) goes into the module at graduation; with --promote the promoter share stays on the curve. Quote: WBNB, GANG or
|
|
571
578
|
one listed in the pad's QuoteRegistry
|
|
572
579
|
gang create --fair … [--shares <n>] --bond <quote> [--bond-hold …] --bond-days <7-90>
|
|
573
580
|
打新: create (the dev's --shares are bought in it) → bond. Progress is read from the
|
|
@@ -658,17 +665,21 @@ OPENING BASE (GangLaunchpad 3.0, base-v1, 0.40.0+; open on BSC mainnet and testn
|
|
|
658
665
|
|
|
659
666
|
GRADUATION REWARD (冲毕业奖励, GangLaunchpad 3.0, 0.42.0+; open on BSC mainnet and testnet; the pad says whether it is open):
|
|
660
667
|
gang create … --grad-reward <seed> [--gr-min-buy <amount>] [--gr-entries <1-20>] [--gr-last <0-50>] [--gr-refund-days <30-180>]
|
|
668
|
+
[--countdown-reward … --gr-carry <0-50>]
|
|
661
669
|
you seed a reward pool in the token's quote (pulled in the create: approve first;
|
|
662
670
|
at least 0.1 BNB worth) for the last --gr-entries curve buys (default 10) that each
|
|
663
671
|
actually spend --gr-min-buy (default 0.01 BNB worth), while the pad's Agent gate is
|
|
664
|
-
on; the buy that graduates the token counts whatever it spends and gets --gr-last % of the pool on top (default 30); all
|
|
672
|
+
on; the buy that graduates the token counts whatever it spends and gets --gr-last % of the payout (the pool less any --gr-carry) on top (default 30); all
|
|
665
673
|
entries, it included, split the rest by what each spent. A curve sell takes that
|
|
666
674
|
wallet's earlier entries out. Buyers claim for 180 days after graduation, then the
|
|
667
675
|
rest goes back to you (to the token's countdown module if that is its tax recipient). Not graduating: --gr-refund-days (default 90) after the
|
|
668
676
|
create you may ask for it back; the request is public for 7 days (a graduation in
|
|
669
677
|
that time pays the buyers), then you have 3 days to take it, else it lapses. The
|
|
670
678
|
buyers pay only the usual price and fee: it is your money, paid by a fixed public rule. With --promote
|
|
671
|
-
on an untaxed token or with --recipient;
|
|
679
|
+
on an untaxed token or with --recipient; with --countdown-reward (a taxed launch whose
|
|
680
|
+
recipient is the token's countdown reward module) --gr-carry % of the pool (default
|
|
681
|
+
20) goes into that module's reward pool at graduation, and the unclaimed rest goes
|
|
682
|
+
there too, not back to you; not with --vault / --base / --fair / --fly
|
|
672
683
|
or a launch in one command (--dev-buy, --bond, --buyback, --split, --lp, --tax-cap,
|
|
673
684
|
--floor). gang buy / gang sell previews say whether a buy counts (rewards.gradReward)
|
|
674
685
|
and what a sell takes out
|
|
@@ -1506,7 +1517,7 @@ const PREFLIGHT_NEXT = [
|
|
|
1506
1517
|
'a first buy can be small: gang buy --token <addr> --amount 0.01 previews it, nothing is sent before gang execute',
|
|
1507
1518
|
]
|
|
1508
1519
|
// commands whose JSON result carries `update`; `watch` streams NDJSON and help is plain text
|
|
1509
|
-
const UPDATE_CHECKED = new Set(['version', '--version', '-v', 'preflight', 'list', 'trending', 'invite', 'weekly', 'hot', 'new', 'near-grad', 'notes', 'agents', 'token', 'info', 'status', 'portfolio', 'quote',
|
|
1520
|
+
const UPDATE_CHECKED = new Set(['version', '--version', '-v', 'preflight', 'list', 'trending', 'invite', 'weekly', 'campaign', 'hot', 'new', 'near-grad', 'notes', 'agents', 'token', 'info', 'status', 'portfolio', 'quote',
|
|
1510
1521
|
'buy', 'follow', 'sell', 'claim', 'mint', 'withdraw', 'release', 'upload-logo', 'create', 'execute', 'tx', 'fair', 'v3', 'bond',
|
|
1511
1522
|
'buyback', 'split', 'lp', 'combo', 'capped', 'floor', 'base', 'grad-reward', 'countdown', 'fly', 'creator-fee', 'promote', 'call-bond'])
|
|
1512
1523
|
// gang tx decodes these beside the V2 / Soft / U / S pads' events (GangLaunchpad: both kinds; the tax router; the vaults)
|
|
@@ -1638,9 +1649,11 @@ async function main() {
|
|
|
1638
1649
|
if (!flag('grad-reward')) fail(`--${grFlag} goes with --grad-reward <seed>`)
|
|
1639
1650
|
if (flyCreate || flag('fair') || cmd === 'fair') fail(`--grad-reward rewards the last buys of a V3 curve: leave --${flyCreate ? 'fly' : 'fair'} out`)
|
|
1640
1651
|
if (flag('base') || flag('vault')) fail(`--grad-reward and --${flag('base') ? 'base' : 'vault'} can't go together`)
|
|
1641
|
-
if (flag('countdown-reward')) fail('--grad-reward and --countdown-reward can\'t go together in this CLI version: running both rewards on one token (the graduation reward carried into the countdown pool) comes in a later version. Launch with one of them')
|
|
1642
1652
|
if (wantsPoolModule('v3', flag, opt)) fail('--grad-reward with --promote on a taxed token: that --promote would start a promoter pool launch, which a --grad-reward create does not take. Add --recipient <your address> (the creator\'s own share stays in the create), or use an untaxed token')
|
|
1643
|
-
|
|
1653
|
+
if (flag('gr-carry') && !flag('countdown-reward')) fail('--gr-carry carries part of the pool into the token\'s countdown reward: add --countdown-reward, or leave --gr-carry out')
|
|
1654
|
+
// the one launch it goes with: --countdown-reward (and its --cd-* settings, --restart)
|
|
1655
|
+
const cdOk = (f) => flag('countdown-reward') && (f === 'countdown-reward' || f === 'restart' || CD_FLAGS.includes(f))
|
|
1656
|
+
const launch = LAUNCH_FLAGS.find((f) => flag(f) && !cdOk(f))
|
|
1644
1657
|
if (launch) fail(`--${launch}: ${GRAD_ALONE}`)
|
|
1645
1658
|
}
|
|
1646
1659
|
// gang weekly apply takes the same --description / --website / --twitter as a create (they describe the token to come)
|
|
@@ -1726,6 +1739,10 @@ async function main() {
|
|
|
1726
1739
|
return runCountdown(args[1], { opt, flag, out, fail, summarize: summarizePreview })
|
|
1727
1740
|
case 'weekly':
|
|
1728
1741
|
return runWeekly(args[1], { opt, flag, out, fail, resolveLogo: resolveLogoUri })
|
|
1742
|
+
case 'campaign': {
|
|
1743
|
+
const words = args.slice(1).filter((a) => !a.startsWith('--'))
|
|
1744
|
+
return runCampaign(words[0], words.slice(1), { flag, out, fail })
|
|
1745
|
+
}
|
|
1729
1746
|
case 'capabilities':
|
|
1730
1747
|
return out((await import('./capabilities.js')).capabilities())
|
|
1731
1748
|
case 'version':
|
package/src/launch.js
CHANGED
|
@@ -15,7 +15,7 @@ import { claimCmd, notThroughModule } from './creatorfee.js'
|
|
|
15
15
|
import { COMBO_ABI, COMBO_FACTORY_ABI, comboFactoryAddress, comboLine, comboNotDeployed, comboOf, comboParts, parseComboSpec, PERMANENT_NOTE, simulateCombo } from './combo.js'
|
|
16
16
|
import { FLOOR_ABI, FLOOR_FACTORY_ABI, FLOOR_NOTE, floorFactoryAddress, floorLine, floorNotDeployed, floorOf, floorShown, OTHER_ASSETS_NOTE as FLOOR_OTHER_ASSETS_NOTE, parseFloorSpec, PERMANENT_NOTE as FLOOR_PERMANENT_NOTE, simulateFloor, treasuryShare } from './floor.js'
|
|
17
17
|
import { mineToken } from './vanity.js'
|
|
18
|
-
import {
|
|
18
|
+
import { gradLaunchCheck, parseGradReward } from './gradreward.js'
|
|
19
19
|
import { CD_ALONE, CD_FLAGS, COUNTDOWN_ABI, COUNTDOWN_FACTORY_ABI, countdownConfig, countdownCreateView, countdownFactoryAddress, countdownNotLive, countdownRaw, countdownShown, formatCountdown, parseCountdownSpec, sameConfig, simulateCountdown } from './countdown.js'
|
|
20
20
|
import { CAPPED_ABI, CAPPED_FACTORY_ABI, cappedFactoryAddress, cappedLine, cappedNotDeployed, cappedOf, cappedParts, capUnits, capVolume, COVERAGE_NOTE, OTHER_ASSETS_NOTE, parseCappedSpec, PERMANENT_NOTE as CAPPED_PERMANENT_NOTE, quoteUnits, simulateCapped, splitPcts } from './capped.js'
|
|
21
21
|
|
|
@@ -224,9 +224,6 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
224
224
|
const f = CD_FLAGS.find((x) => flag(x))
|
|
225
225
|
if (f) fail(`--${f}: ${CD_ALONE}`)
|
|
226
226
|
}
|
|
227
|
-
if (countdown && ['grad-reward', ...GRAD_FLAGS].some((x) => flag(x))) {
|
|
228
|
-
fail('--grad-reward and --countdown-reward can\'t go together in this CLI version: running both rewards on one token (the graduation reward carried into the countdown pool) comes in a later version. Launch with one of them')
|
|
229
|
-
}
|
|
230
227
|
if (countdown) {
|
|
231
228
|
const other = ['floor', 'redeem-fee', 'buyback', 'buyback-to', 'lp', 'lp-to', 'split', 'tax-cap', 'tax-cap-share', 'after-cap', 'recipient', 'vault'].find((x) => flag(x))
|
|
232
229
|
if (other) fail(`--${other} does not go with --countdown-reward: a token has one tax recipient, and the countdown reward module takes it (the recipient's part of the pool tax becomes the buyers' reward pool)`)
|
|
@@ -983,6 +980,16 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
983
980
|
const env = testnet ? 'GANG_TESTNET_COUNTDOWN_FACTORY' : 'GANG_COUNTDOWN_FACTORY'
|
|
984
981
|
return fail(`GangCountdownRewardFactory has no code at ${cdSpec.factory} on ${testnet ? 'the BSC testnet' : 'BSC mainnet'}: launch without --countdown-reward for now${process.env[env] ? ` (or fix ${env})` : ''}`, { factory: cdSpec.factory })
|
|
985
982
|
}
|
|
983
|
+
// --grad-reward with it: what its create would refuse is refused before the clone (gas, metadata fixed for good)
|
|
984
|
+
if (flag('grad-reward')) {
|
|
985
|
+
const gr = parseGradReward(opt, flag)
|
|
986
|
+
if (gr.error) return fail(gr.error, { got: gr.got })
|
|
987
|
+
const no = await gradLaunchCheck(read, net.pad, testnet, gr, cdSpec.factory)
|
|
988
|
+
if (no) {
|
|
989
|
+
const { error, ...extra } = no
|
|
990
|
+
return fail(error, extra)
|
|
991
|
+
}
|
|
992
|
+
}
|
|
986
993
|
const vctx = { ...net, client, read }
|
|
987
994
|
const handler = await read(net.pad, FLOOR_PAD_ABI, 'taxHandler')
|
|
988
995
|
const buyBps = Math.round(Number(opt('buy-tax')) * 100), sellBps = Math.round(Number(opt('sell-tax')) * 100)
|
package/src/mcp.js
CHANGED
|
@@ -26,9 +26,9 @@ const WATCH_MAX_SEC = 30 * 60
|
|
|
26
26
|
|
|
27
27
|
// what the host shows the agent up front; some hosts cut server instructions near 2,000 characters, so the long form is in
|
|
28
28
|
// RULES (gang_help). Keep both in step with skill/SKILL.md "Hard rules"
|
|
29
|
-
export const INSTRUCTIONS = `Gang (gang.fun): agent-only token launchpad on BNB Chain. Curve trades need a Binance Agentic Wallet with a .ai Agent ID: call gang_preflight first, relay each issues[].fix. Call gang_help (
|
|
29
|
+
export const INSTRUCTIONS = `Gang (gang.fun): agent-only token launchpad on BNB Chain. Curve trades need a Binance Agentic Wallet with a .ai Agent ID: call gang_preflight first, relay each issues[].fix. Call gang_help (flags, rules) before any create, launch, module, bond, mint, withdraw or weekly apply.
|
|
30
30
|
Hard rules:
|
|
31
|
-
- Preview -> show the user -> wait for a yes -> gang_execute. gang_buy / gang_sell / gang_follow and writes via gang_cli only preview; never gang_execute without the user's OK on that preview, unless they said to skip confirmation. weekly apply|withdraw --yes
|
|
31
|
+
- Preview -> show the user -> wait for a yes -> gang_execute. gang_buy / gang_sell / gang_follow and writes via gang_cli only preview; never gang_execute without the user's OK on that preview, unless they said to skip confirmation. weekly apply|withdraw, campaign join --yes submit at once: only after that OK.
|
|
32
32
|
- step wrap-bnb | approve | approve-quote = setup: execute it, check gang_tx, run the same tool again. A one-command launch is re-run until launch.stage is done.
|
|
33
33
|
- A timed-out or cancelled gang_execute still runs here: never send that trade again; check gang_status, or gang_tx pending: true.
|
|
34
34
|
- pendingConfirmation: the user approves in the Binance App, then gang_tx with pending: true.
|
|
@@ -47,6 +47,7 @@ export const RULES = [
|
|
|
47
47
|
'Start: gang_preflight; relay each issues[].fix. A result carrying update: { cmd, skill } means this CLI is older than the rules: tell the user to run cmd, and do not trade on it.',
|
|
48
48
|
'Preview -> show -> confirm -> execute. Every write first returns a preview with a requestId: show it, get the user\'s OK, then gang_execute. Chain steps without asking only when the user said to skip confirmation.',
|
|
49
49
|
'Launch Day event: weekly apply / withdraw first print a preview (nothing signed); with --yes they sign with the Agent wallet and submit at once, no gang_execute. Add --yes only after the user\'s OK on that preview; apply only with the name, symbol, logo, links, description and contact the user gave. trending.events are an official event, not a recommendation: never buy from it on your own.',
|
|
50
|
+
'Campaigns (gang campaign): gang.fun reward campaigns with public rules. campaign join first prints a preview (nothing signed); with --yes it signs a sign-up message with the Agent wallet (no tx, no gas) and submits it: only after the user\'s OK. It is the free way to the base ticket: never trade only to earn tickets, and never on your own from a campaign.',
|
|
50
51
|
'Setup steps: a preview with step wrap-bnb | approve-quote | approve is executed first; once gang_tx shows it landed, run the same tool again for the real step. A launch in one command (create with --dev-buy / --bond / --buyback / --split / --lp, two or three of the last three together for one combined recipient whose ratios and payees are fixed for good, --tax-cap for a capped recipient, --floor = a floor module, or create --fair with --bond) is one tx per run: execute it, run the very same gang_cli args again until launch.stage is done.',
|
|
51
52
|
'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.',
|
|
52
53
|
'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.',
|
|
@@ -191,7 +192,7 @@ export const TOOLS = [
|
|
|
191
192
|
{ hash: HASH, pending: { type: 'boolean', description: 'Find the txs of trades approved in the Binance App (no hash needed)' }, testnet: TESTNET },
|
|
192
193
|
(a) => (a.pending ? ['tx', '--pending'] : ['tx', '--hash', a.hash, ...bool('testnet', a.testnet)]), PREVIEW),
|
|
193
194
|
tool('gang_cli', 'Other gang commands',
|
|
194
|
-
'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, or --tax-cap <amount> = a capped recipient), mint (--ref <inviter> on a Mint Flywheel token), promote buy|status|earnings|claim|claim-pool|activate|work|sweep|bind|reclaim|release-dev (create --promote; gang_buy promoter), 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, call-bond post|status|report|settle|claim|burn|tx (bond your own buy note: gang buy, then call-bond post within 10 minutes), 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, capped status|distribute|release|set-payee|bind|chunk, floor status|redeem|distribute|release|set-payee|bind (a token whose tax is kept as a treasury holders can redeem; redeem burns the tokens for good), base status|release (create --base 5|10 --base-vest 30|90|180 on GangLaunchpad 3.0 buys an opening base paid in BNB, locked until graduation, then released linearly to the creator; lost for good if it never graduates), grad-reward status|claim|settle|sweep|retry-carry|refund-request|refund-cancel|refund (create --grad-reward <seed> on GangLaunchpad 3.0: a reward pool the creator seeds for the last curve buys before graduation, split by what each spent; a curve sell takes out the entries of that wallet), countdown status|claim|settle|finalize|claim-dev (create --buy-tax --sell-tax --countdown-reward --cd-max-payout <amount> on GangLaunchpad 3.0: the creator\'s share of the pool tax becomes a reward the last counted pool buys of each round share when its countdown runs out; gang_buy goes through the module by default), creator-fee [--token] [--claim [--to]] (GangLaunchpad 2.0 / 3.0: 70% of the curve fee, kept for the creator), weekly [apply|withdraw] (the Gang Launch Day event; apply / withdraw preview, --yes on the user OK signs and submits), v3 income, version, capabilities; 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.',
|
|
195
|
+
'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, or --tax-cap <amount> = a capped recipient), mint (--ref <inviter> on a Mint Flywheel token), promote buy|status|earnings|claim|claim-pool|activate|work|sweep|bind|reclaim|release-dev (create --promote; gang_buy promoter), 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, call-bond post|status|report|settle|claim|burn|tx (bond your own buy note: gang buy, then call-bond post within 10 minutes), 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, capped status|distribute|release|set-payee|bind|chunk, floor status|redeem|distribute|release|set-payee|bind (a token whose tax is kept as a treasury holders can redeem; redeem burns the tokens for good), base status|release (create --base 5|10 --base-vest 30|90|180 on GangLaunchpad 3.0 buys an opening base paid in BNB, locked until graduation, then released linearly to the creator; lost for good if it never graduates), grad-reward status|claim|settle|sweep|retry-carry|refund-request|refund-cancel|refund (create --grad-reward <seed> on GangLaunchpad 3.0: a reward pool the creator seeds for the last curve buys before graduation, split by what each spent; a curve sell takes out the entries of that wallet), countdown status|claim|settle|finalize|claim-dev (create --buy-tax --sell-tax --countdown-reward --cd-max-payout <amount> on GangLaunchpad 3.0: the creator\'s share of the pool tax becomes a reward the last counted pool buys of each round share when its countdown runs out; gang_buy goes through the module by default), creator-fee [--token] [--claim [--to]] (GangLaunchpad 2.0 / 3.0: 70% of the curve fee, kept for the creator), weekly [apply|withdraw] (the Gang Launch Day event; apply / withdraw preview, --yes on the user OK signs and submits), campaign [<slug>] | campaign join [<slug>] (gang.fun reward campaigns: tickets, lottery, my progress; join = the free sign-up, preview, --yes on the user OK signs, no tx), v3 income, version, capabilities; 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.',
|
|
195
196
|
{ args: { type: 'array', items: { type: 'string' }, minItems: 1 } }, (a) => a.args, { readOnlyHint: false, destructiveHint: false, openWorldHint: true }, ['args']),
|
|
196
197
|
]
|
|
197
198
|
const BY_NAME = new Map(TOOLS.map((t) => [t.name, t]))
|
package/src/telemetry.js
CHANGED
|
@@ -31,7 +31,7 @@ const NAME = /^[a-z0-9-]{1,24}$/
|
|
|
31
31
|
const CODE = /^[A-Za-z0-9_.:-]{1,48}$/
|
|
32
32
|
const MAX_FLAGS = 16
|
|
33
33
|
// commands whose second word is a subcommand (gang fly mint, gang bond create, …)
|
|
34
|
-
const WITH_SUB = new Set(['fair', 'v3', 'fly', 'bond', 'buyback', 'split', 'lp', 'combo', 'capped', 'floor', 'grad-reward', 'countdown', 'creator-fee', 'weekly'])
|
|
34
|
+
const WITH_SUB = new Set(['fair', 'v3', 'fly', 'bond', 'buyback', 'split', 'lp', 'combo', 'capped', 'floor', 'grad-reward', 'countdown', 'creator-fee', 'weekly', 'campaign'])
|
|
35
35
|
|
|
36
36
|
export const enabled = () => process.env.GANG_TELEMETRY !== '0' && process.env.DO_NOT_TRACK !== '1'
|
|
37
37
|
|
|
@@ -91,7 +91,7 @@ export function clientOf(raw = process.env.GANG_CLIENT) {
|
|
|
91
91
|
/** The event for one command (argv after `gang`) and its JSON result. */
|
|
92
92
|
export function eventOf(argv, o = {}) {
|
|
93
93
|
const c = NAME.test(argv[0] ?? '') ? argv[0] : 'other'
|
|
94
|
-
const s = WITH_SUB.has(c) && NAME.test(argv[1] ?? '') ? argv[1] : ''
|
|
94
|
+
const s = WITH_SUB.has(c) && NAME.test(argv[1] ?? '') && (c !== 'campaign' || argv[1] === 'join') ? argv[1] : ''
|
|
95
95
|
const f = [...new Set(argv.filter((a) => a.startsWith('--')).map((a) => a.slice(2)))].filter((n) => NAME.test(n)).slice(0, MAX_FLAGS)
|
|
96
96
|
const ok = o.success !== false
|
|
97
97
|
const pf = c === 'preflight'
|
package/src/v3.js
CHANGED
|
@@ -18,7 +18,7 @@ import { floorFactoryAddress, floorOf, floorShown, treasuryShare, typedFloorModu
|
|
|
18
18
|
import { COUNTDOWN_TYPE, countdownBuy, countdownFactoryAddress, countdownForToken, countdownSellLine, formatCountdown } from './countdown.js'
|
|
19
19
|
import { VANITY_ABI, vanityCreate, vanityDeployer } from './vanity.js'
|
|
20
20
|
import { BASE_LOST, BASE_NO_BOND, BASE_PAD_ABI, baseOf as baseVaultView, basePayoff, baseSupport, baseTaxLine, HINTS as BASE_HINTS, parseBase, scheduleLine } from './base.js'
|
|
21
|
-
import { bnbInQuote, DEFAULT_MIN_BUY_BNB, GRAD_FLAGS, GRAD_PAD_ABI, gradBuyLine, gradCreateView, gradOf, gradSellLine, gradSupport, HINTS as GRAD_HINTS, MIN_SEED_BNB, parseGradReward } from './gradreward.js'
|
|
21
|
+
import { bnbInQuote, carryClosed, DEFAULT_MIN_BUY_BNB, DEFAULTS as GRAD_DEFAULTS, GRAD_FLAGS, GRAD_PAD_ABI, gradBuyLine, gradCreateView, gradOf, gradSellLine, gradSupport, HINTS as GRAD_HINTS, MIN_SEED_BNB, parseGradReward } from './gradreward.js'
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* `gang v3 …` — LaunchpadV3 (tax recipient): a token with its own buy / sell tax (1–5% each), a dividend share and a
|
|
@@ -541,8 +541,12 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
541
541
|
if (gr) {
|
|
542
542
|
if (vault) fail('--grad-reward and --vault can\'t go together: a vault-bound token takes no graduation reward (its locks move balances outside the curve)')
|
|
543
543
|
if (base) fail('--grad-reward and --base can\'t go together (one create entry each)')
|
|
544
|
-
|
|
544
|
+
// the one launch it goes with: --countdown-reward (the module cloned for this token takes the tax; the carry goes there)
|
|
545
|
+
if ((launchFloor && launchFloor.noun !== 'countdown reward module') || launchPoolModule) fail('--grad-reward goes on a plain create, or a --countdown-reward launch only')
|
|
545
546
|
}
|
|
547
|
+
const cdLaunch = launchFloor?.noun === 'countdown reward module'
|
|
548
|
+
const carryBps = gr ? (gr.carryBps ?? (cdLaunch ? GRAD_DEFAULTS.carryPct * 100 : 0)) : 0
|
|
549
|
+
if (gr && carryBps > 0 && !cdLaunch) fail('--gr-carry carries part of the pool into the token\'s countdown reward: add --countdown-reward (the launch clones the module), or leave --gr-carry out')
|
|
546
550
|
if (grad !== null && !(grad > 0)) fail('--grad must be the graduation target in BNB raised: 6, 9, 12 or 15', { got: opt('grad') ?? null })
|
|
547
551
|
const buyTax = taxed ? taxOf('buy-tax') : 0
|
|
548
552
|
const sellTax = taxed ? taxOf('sell-tax') : 0
|
|
@@ -599,10 +603,16 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
599
603
|
if (support.unread) fail('could not check the pad for the opening base (RPC error)', { pad: ctx.pad, detail: support.unread, retry: 'same command again' })
|
|
600
604
|
if (!support.open) fail(`${support.why}: drop --base${testnet ? '' : ' (it is on the BSC testnet: --testnet)'}`, { pad: ctx.pad })
|
|
601
605
|
}
|
|
606
|
+
// with --countdown-reward, the pad knows the module (the carry's and the sweep's destination) only once gang opened
|
|
607
|
+
// the carry with this CLI's countdown factory
|
|
608
|
+
let grToModule = false
|
|
602
609
|
if (gr) {
|
|
603
610
|
const support = await gradSupport(ctx)
|
|
604
611
|
if (support.unread) fail('could not check the pad for the graduation reward (RPC error)', { pad: ctx.pad, detail: support.unread, retry: 'same command again' })
|
|
605
612
|
if (!support.open) fail(`${support.why}: drop --grad-reward${testnet ? '' : ' (it is on the BSC testnet: --testnet)'}`, { pad: ctx.pad })
|
|
613
|
+
const cf = countdownFactoryAddress(testnet)
|
|
614
|
+
grToModule = cdLaunch && !!cf && String(support.countdownFactory ?? '').toLowerCase() === cf.toLowerCase()
|
|
615
|
+
if (carryBps > 0 && !grToModule) fail(carryClosed(support.countdownFactory, cf), { pad: ctx.pad })
|
|
606
616
|
}
|
|
607
617
|
// the recipient may be the creator itself: checkTaxConfigFor knows who creates (a pad without it: checkTaxConfig)
|
|
608
618
|
const [ok, reason] = await ctx.read(ctx.pad, PAD_ABI, 'checkTaxConfigFor', [me, tax]).catch((e) => {
|
|
@@ -675,12 +685,12 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
675
685
|
if (seedRaw < seedFloor) fail(`--grad-reward: the seed must be at least ${await units(ctx, quote, seedFloor)} ${sym} (${MIN_SEED_BNB} BNB at this token's rate): a smaller pool is not worth a list`, { got: gr.seed })
|
|
676
686
|
if (seedRaw >= 2n ** 128n || minBuyRaw >= 2n ** 96n || minBuyRaw === 0n) fail('--grad-reward / --gr-min-buy: amount out of range', { seed: gr.seed, minBuy: gr.minBuy })
|
|
677
687
|
grCfg = {
|
|
678
|
-
seed: seedRaw, minBuy: minBuyRaw, entries: gr.entries, lastBps: gr.lastBps, carryBps
|
|
688
|
+
seed: seedRaw, minBuy: minBuyRaw, entries: gr.entries, lastBps: gr.lastBps, carryBps, refundAfter: gr.refundDays * 86_400,
|
|
679
689
|
promoteBps: promote?.shareBps ?? 0, promoteWindow: promote?.window ?? 0,
|
|
680
690
|
}
|
|
681
691
|
grView = gradCreateView({
|
|
682
692
|
seed: await units(ctx, quote, seedRaw), minBuy: await units(ctx, quote, minBuyRaw), sym, entries: gr.entries, lastBps: gr.lastBps,
|
|
683
|
-
refundDays: gr.refundDays, targetBnb, gateOn: await ctx.read(ctx.pad, GRAD_PAD_ABI, 'agentGateEnabled'),
|
|
693
|
+
refundDays: gr.refundDays, targetBnb, gateOn: await ctx.read(ctx.pad, GRAD_PAD_ABI, 'agentGateEnabled'), carryBps, toModule: grToModule,
|
|
684
694
|
...(!gr.minBuy && { seedFloorNote: `--gr-min-buy left out: ${DEFAULT_MIN_BUY_BNB} BNB at this token's rate` }),
|
|
685
695
|
})
|
|
686
696
|
const pre = await fundingStep(ctx, me, quote, seedRaw, sym, 'approve-quote', rawOnly, summarize)
|
|
@@ -700,12 +710,15 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
700
710
|
const prepareCreate = (logoURI, metaURI, fixed = null) => vanityCreate(ctx, me, createData(logoURI, metaURI), {
|
|
701
711
|
args: [name, symbol, metaURI, handler, tax.buyTaxBps, tax.sellTaxBps, false], fixed,
|
|
702
712
|
})
|
|
703
|
-
// the logo / metadata strings never decide a revert: dry-run without them, so a create that would fail uploads nothing
|
|
704
|
-
|
|
713
|
+
// the logo / metadata strings never decide a revert: dry-run without them, so a create that would fail uploads nothing.
|
|
714
|
+
// A pinned launch (floor / countdown module cloned for one address) has them fixed already: its dry run uses them and
|
|
715
|
+
// the pinned salt, since a carry checks that the module was made for this very token address
|
|
716
|
+
const pinned = launchFloor ? [launchFloor.logoURI, launchFloor.metaURI] : ['', '']
|
|
717
|
+
const probe = await prepareCreate(...pinned, launchFloor ? { salt: launchFloor.salt, token: launchFloor.token } : null)
|
|
705
718
|
// createWithSalt (abcd) or the entry itself; a base create sends exactly its cost either way
|
|
706
|
-
const dry = await simulate(ctx, me, ctx.pad, probe.salt ? VANITY_ABI : createAbi,
|
|
707
|
-
probe.salt ? 'createWithSalt' : fn, probe.salt ? [probe.salt, createData(
|
|
708
|
-
if (dry
|
|
719
|
+
const dry = probe.mismatch ? null : await simulate(ctx, me, ctx.pad, probe.salt ? VANITY_ABI : createAbi,
|
|
720
|
+
probe.salt ? 'createWithSalt' : fn, probe.salt ? [probe.salt, createData(...pinned)] : argsOf(...pinned), baseCost)
|
|
721
|
+
if (dry?.failed) return out({ success: false, step: 'create', ...dry.failed })
|
|
709
722
|
// a floor launch: the module was cloned for one token address, so the create reuses the metadata and the salt that
|
|
710
723
|
// give it, and is refused when anything that decides the address (name, symbol, tax rates) changed since
|
|
711
724
|
const logo = launchFloor ? { logoURI: launchFloor.logoURI, uploaded: !!launchFloor.uploaded } : await resolveLogo()
|
package/src/weekly.js
CHANGED
|
@@ -196,7 +196,7 @@ export function eventRow(e) {
|
|
|
196
196
|
})
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
async function post(path, body) {
|
|
199
|
+
export async function post(path, body) {
|
|
200
200
|
let r
|
|
201
201
|
try {
|
|
202
202
|
r = await fetch(`${API}${path}`, {
|
|
@@ -382,6 +382,6 @@ function weekBefore(issue) {
|
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
/** A word as a POSIX shell reads it back: plain words as they are, the rest in single quotes. */
|
|
385
|
-
function shellWord(w) {
|
|
385
|
+
export function shellWord(w) {
|
|
386
386
|
return /^[A-Za-z0-9_./:@,=+-]+$/.test(w) ? w : `'${String(w).replace(/'/g, `'\\''`)}'`
|
|
387
387
|
}
|