@gangfun/cli 0.41.0 → 0.43.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 +6 -3
- package/README.zh-CN.md +15 -2
- package/package.json +1 -1
- package/src/capabilities.js +9 -0
- package/src/flags.js +2 -1
- package/src/gradreward.js +314 -0
- package/src/index.js +56 -8
- package/src/mcp.js +2 -2
- package/src/trending.js +2 -2
- package/src/v3.js +70 -7
- package/src/weekly.js +39 -9
package/README.md
CHANGED
|
@@ -24,6 +24,8 @@ Operate [gang.fun](https://gang.fun) from a Binance **Agentic Wallet**. Curve bu
|
|
|
24
24
|
|
|
25
25
|
**Opening base (0.40.0+, BSC testnet; on mainnet the pad is upgraded and the base opens with an owner (Safe) call — until then `--base` stops with "closed"):** `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+, BSC testnet; on mainnet once the pad is upgraded and the Safe opens it):** `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 nothing extra: the pool is your money, split by a fixed public rule, with no draw. Works with `--promote` on an untaxed token or with `--recipient`; 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
|
+
|
|
27
29
|
**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`).
|
|
28
30
|
|
|
29
31
|
**GangLaunchpad 2.0, the creator fee and the graduation target (0.23.0+):** 2.0 is a new generation of the same pad (the same V3 curves and 打新 sales); of the 1% fee on every V3 curve buy and sell, 70% is kept on the pad for the token's creator, who claims it any time, before or after graduation: `gang creator-fee` lists a creator's 2.0 tokens and what each holds, `gang creator-fee --token <addr> --claim [--to <addr>]` claims it. It is the creator's own, never the tax recipient's or a buy-back / split / LP module's; 1.0 tokens and 打新 sales have none. 2.0 also lets the creator pick the V3 graduation target: `gang create --grad 6|9|12|15` (BNB raised, default 9; market cap at graduation ≈ 5×); `gang info` / `gang status` show each token's `graduationTargetBnb`. New tokens go to the newest generation built in for the network (`gang preflight` → `createPadGen`); a token keeps trading on its own generation's pad, GangRouter, GangBond and module factories, found by asking each pad's `kindOf`. On the BSC testnet 2.0 is live and the create target (pad `0xb14d415f70D7F99f0D93Bd3BF76e0D6b38b53B3E`, GangRouter `0x5a4FA2D91638a305EdF027894753c943f095dDAA`; the first testnet 2.0, `0x6381…39be`, no longer creates, and its tokens keep trading and claiming there). On BSC mainnet 2.0 is live and the create target since 2026-10-31 (pad `0x770331a9accdb53ACb4a45B6c5B7D151fADCe557`, GangRouter `0xa83209d6bfC2B220cD86410cCDDC71FEb354844a`); 1.0 tokens keep trading on 1.0 (pad `0x15CF…4365`).
|
|
@@ -150,6 +152,8 @@ gang create … --buy-tax 3 --sell-tax 3 --floor [--redeem-fee 2] [--tax-cap 20
|
|
|
150
152
|
gang floor status|redeem|distribute|release|set-payee|bind --token 0x… [--amount <tokens>|all] [--to 0x…] [--asset 0x…] [--index <i>] [--break-bond] [--break-call-bond] [--settle-first] # the floor module: treasury, what a token redeems for, fee, cap and payees; redeem burns the tokens (0xdead) for their share of the treasury
|
|
151
153
|
gang create … --base 5|10 --base-vest 30|90|180 [--grad 6|9|12|15] # 3.0 opening base: the create also buys 5% / 10% for a base vault, paid in BNB; locked until graduation (for good if it never graduates), then released linearly to you
|
|
152
154
|
gang base status|release --token 0x… # the base vault: size, period, start, released, releasable, unreleased; release starts the clock, then sends what has vested to the creator
|
|
155
|
+
gang create … --grad-reward <seed> [--gr-min-buy <amt>] [--gr-entries 1-20] [--gr-last 0-50] [--gr-refund-days 30-180] # 3.0 graduation reward: a pool you seed for the last buys before graduation, by what each spent
|
|
156
|
+
gang grad-reward status|claim|settle|sweep|retry-carry|refund-request|refund-cancel|refund --token 0x… # the pool, list and claims; the creator's refund with a 7-day notice
|
|
153
157
|
gang create --fair … [--shares <n>] --bond <quote> [--bond-hold …] --bond-days <7-90> # 打新: create (dev shares) → bond
|
|
154
158
|
gang execute --request-id <id>
|
|
155
159
|
gang tx --pending # trades approved in the Binance App: found by the exact call previewed, then as below
|
|
@@ -208,7 +212,7 @@ Without it, it emits `new_token` / `near_grad` (crosses `--min-pct`) / `graduate
|
|
|
208
212
|
gang watch --events new_token,near_grad --max-events 1 --timeout 30m
|
|
209
213
|
```
|
|
210
214
|
|
|
211
|
-
**Weekly launch event (0.36.0+):**
|
|
215
|
+
**Weekly launch event (0.36.0+):** gang.fun picks from the applications; the pick creates its token on GangLaunchpad 3.0 at the issue's launch time from the wallet that applied and is featured for 7 days (gang.fun homepage, X / TG posts, `events` first in `trending`). An official event: being picked is not an endorsement or investment advice. `gang weekly apply` signs the application with the Agent wallet as EIP-712 typed data (domain `gang.fun weekly launch`, no transaction); `--contact` is only seen by the gang.fun team. When `gang weekly` shows `hold: true` (0.43.0+), applications stay open with no closing date and no launch time is set: the team selects from the open pool and contacts the pick, and the launch time is announced on gang.fun/weekly. Teams can also launch on Gang any time on their own schedule. Rules: `skill/references/discover.md`.
|
|
212
216
|
|
|
213
217
|
`gang trending` (0.24.0+) lists what other agents buy now: up to 5 tokens with the most distinct agent buyers in the last 6h
|
|
214
218
|
(creators, bulk-buying bots and platform wallets left out) and up to 3 notes you can follow now by authors who hit 60%+ of
|
|
@@ -248,8 +252,7 @@ page for newcomers) and how many new agents it brought (`invited`, `qualified` =
|
|
|
248
252
|
A newcomer's agent buys with `--ref <inviter>` on `gang buy` / `gang mint` / `gang follow`: the CLI asks gang.fun
|
|
249
253
|
(`GET /api/ref/eligible`) and, only on the wallet's first Gang trade, appends `"gang" 05 <referrer>` (25 bytes) to the
|
|
250
254
|
calldata before the follow ref and the note, which the contracts ignore. The result's `ref` says whether it was attached;
|
|
251
|
-
`gang tx` shows `invitedBy`. Without a ref, a first trade is credited to the token's creator.
|
|
252
|
-
qualified new agents is featured on gang.fun. 铸币飞轮 mints keep their own inviter in the contract call.
|
|
255
|
+
`gang tx` shows `invitedBy`. Without a ref, a first trade is credited to the token's creator. 铸币飞轮 mints keep their own inviter in the contract call.
|
|
253
256
|
|
|
254
257
|
### Follow a note (`--follow`, 0.6.0+)
|
|
255
258
|
|
package/README.zh-CN.md
CHANGED
|
@@ -24,6 +24,17 @@
|
|
|
24
24
|
|
|
25
25
|
**开盘底仓(0.40.0+,BSC 测试网;主网 pad 已升级,等多签开放后可用,开放前 `--base` 会提示未开放):** `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 测试网;主网等 pad 升级、多签开放后可用):** `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
|
+
|
|
29
|
+
- **谁能分**:pad 记下最后 `--gr-entries` 笔(默认 10)曲线买入,每笔都要实际花掉 `--gr-min-buy`(默认值 0.01 BNB),而且 Agent 门槛开着;把币推过毕业线的那一笔一律计入。
|
|
30
|
+
- **怎么分**:毕业时,这一笔先额外拿奖励池的 `--gr-last`%(默认 30),剩下的由所有格子(包括这一笔)按各自实际花掉的金额分。
|
|
31
|
+
- **卖出**:在曲线上卖出,这个钱包之前的格子全部失效;之后再买会重新计入。
|
|
32
|
+
- **领取**:毕业后 180 天内买家自己领,之后任何人都可以把剩下的部分退给你。
|
|
33
|
+
- **不毕业**:建币满 `--gr-refund-days` 天(默认 90)后,你可以申请撤回。申请公示 7 天,期间毕业照常发放;公示期满后 3 天内可以取回,过期就要重新申请。
|
|
34
|
+
- **组合**:可以和 `--promote` 一起用(不带税,或者带 `--recipient`);不能和 `--vault` / `--base` / `--fair` / `--fly` 或一条命令发射一起用。
|
|
35
|
+
|
|
36
|
+
买家不额外付钱:奖励池是你自己的钱,按公开的固定规则分配,不抽签。`gang buy` / `gang sell` 的预览会在 `rewards.gradReward` 里说明这笔会不会计入、卖出会让哪些格子失效。`gang grad-reward status --token 0x…` 显示奖励池、规则、名单、撤回状态和你能领多少;`claim`、`settle`、`sweep`、`retry-carry`、`refund-request`、`refund-cancel`、`refund` 负责其余操作。
|
|
37
|
+
|
|
27
38
|
**喊单保证金和跟单绑定(0.37.0+):** agent 可以给自己的喊单(GangLaunchpad 3.0 内盘币上的一条买入 note)押保证金:带 `--note` 买入,10 分钟内执行 `gang call-bond post --token 0x… --amount 0.1 --for 48h`(note 默认取这个钱包最近一次买这个币的交易;`--hold` 默认是全部余额)。结算前,这个钱包的持仓不能低于 hold:只要一次卖出、锁进 vault 或转出让余额低于它(过了截止时间、`gang call-bond settle` 还没执行完之前也算;结算分两步,间隔 1 小时),任何人都能 `gang call-bond report`:举报人拿 1%,一半销毁,其余按损失赔给这条 note 的跟单者(root 的 2 天争议期过后用 `gang call-bond claim` 领取)。违约的保证金一分都不会回到喊单者。报价币:WBNB、USDT、USDC、USD1。喊单者用 `gang v3 sell` 卖到低于 hold 会被拒,除非加 `--break-call-bond`。在开了推广分成的币上,`gang follow` 会把 note 作者永久绑成这个钱包的推广人(走 `buyWithPromoter`,价格和手续费不变;加 `--no-promoter` 就是普通跟单)。GangCallBond 已在 BSC 主网上线(`0x6d6e4A36e9a231cCc932151cdbFb087Cf3860c3D`,2026-11-09 部署,owner 是平台多签;已内置),测试网也有(`0xBE2B8519278E9D31B6c4040bAd35f727fD5d2A70`)。
|
|
28
39
|
|
|
29
40
|
**GangLaunchpad 2.0、creator 分成和毕业目标(0.23.0+):** 2.0 是同一个内盘的新一代(V3 曲线和打新都一样)。V3 内盘每笔买卖收的 1% 手续费里,70% 留在内盘上归这个币的 creator,creator 毕业前后随时可以领:`gang creator-fee` 列出这个 creator 所有 2.0 币各自可领多少,`gang creator-fee --token <addr> --claim [--to <addr>]` 领取。这笔钱只归 creator 本人,不给税收接收地址,也不经过回购 / 分账 / 加池模块;1.0 的币和打新没有这项。2.0 还允许 creator 自选 V3 毕业目标:`gang create --grad 6|9|12|15`(内盘募到的 BNB,默认 9;毕业时市值约为目标的 5 倍);`gang info` / `gang status` 显示每个币的 `graduationTargetBnb`。新币发到这条链上内置的最新一代(`gang preflight` 的 `createPadGen`);已有的币始终用它自己那一代的内盘、GangRouter、GangBond 和模块工厂(CLI 逐个问各代内盘的 `kindOf` 找到它)。BSC 测试网上 2.0 已上线并且是发币目标(内盘 `0xb14d415f70D7F99f0D93Bd3BF76e0D6b38b53B3E`,GangRouter `0x5a4FA2D91638a305EdF027894753c943f095dDAA`;测试网第一版 2.0 `0x6381…39be` 不再发新币,上面的币照常交易和领取)。BSC 主网 2026-10-31 起 2.0 已上线并且是发币目标(内盘 `0x770331a9accdb53ACb4a45B6c5B7D151fADCe557`,GangRouter `0xa83209d6bfC2B220cD86410cCDDC71FEb354844a`);1.0 的币照常在 1.0(内盘 `0x15CF…4365`)上交易。
|
|
@@ -129,6 +140,8 @@ gang create … --buy-tax 3 --sell-tax 3 --floor [--redeem-fee 2] [--tax-cap 20
|
|
|
129
140
|
gang floor status|redeem|distribute|release|set-payee|bind --token 0x… [--amount <数量>|all] [--to 0x…] [--asset 0x…] [--index <i>] [--break-bond] [--break-call-bond] [--settle-first] # 底价模块:金库、每枚能赎回多少、手续费、上限和收款人;redeem 把代币打进 0xdead,换回金库里按比例的一份
|
|
130
141
|
gang create … --base 5|10 --base-vest 30|90|180 [--grad 6|9|12|15] # 3.0 开盘底仓:建币时用 BNB 给底仓金库买 5% / 10%;毕业前锁住(不毕业就永远锁着),毕业后匀速释放给你
|
|
131
142
|
gang base status|release --token 0x… # 底仓金库:大小、释放期、开始时间、已释放、可释放、未释放;release 第一次开始计时,之后把到期的部分转给创建人
|
|
143
|
+
gang create … --grad-reward <种子钱> [--gr-min-buy <金额>] [--gr-entries 1-20] [--gr-last 0-50] [--gr-refund-days 30-180] # 3.0 冲毕业奖励:你出钱奖励毕业前最后几笔买入,按花费分
|
|
144
|
+
gang grad-reward status|claim|settle|sweep|retry-carry|refund-request|refund-cancel|refund --token 0x… # 奖励池、名单和领取;创建人撤回要先公示 7 天
|
|
132
145
|
gang create --fair … [--shares <n>] --bond <数量> [--bond-hold …] --bond-days <7-90> # 打新:发币(含 dev 份额)→ 押金
|
|
133
146
|
gang execute --request-id <id>
|
|
134
147
|
gang tx --pending # 在 Binance App 里批准过的交易:按预览时的调用自动找到交易,再按下面这条处理
|
|
@@ -185,7 +198,7 @@ x.com / twitter.com 链接(主页、帖子、社区),统一存成 `https:/
|
|
|
185
198
|
`gang watch` 输出 NDJSON:带 `<addr>` 时轮询(最短 3s),推 `trade` / `progress`(25/50/75/90%)/ `graduated`;不带则推 `new_token` / `near_grad`(越过 `--min-pct`)/ `graduated`,由 gang.fun 通过一条长连接推送(Server-Sent Events,`GET /api/stream`,0.17.0+;`watching` 行带 `transport: "stream"`)。服务端没有推送接口或加了 `--poll` 时,按 `--interval` 轮询(最短 10s)。
|
|
186
199
|
`--max-events 1` = 阻塞到下一个事件;`--webhook` 把每个事件 POST 出去。详见 [skill/references/discover.md](https://github.com/gangfun/gang-launchpad/blob/main/skill/references/discover.md)。
|
|
187
200
|
|
|
188
|
-
**每周发射活动(0.36.0+):** gang.fun
|
|
201
|
+
**每周发射活动(0.36.0+):** gang.fun 从报名里挑选,入选的 dev 在这一期的发射时间用报名的钱包在 GangLaunchpad 3.0 上发币,精选 7 天(gang.fun 首页、X / TG 推送、`trending` 最前面的 `events`)。是官方活动:入选不代表平台背书,也不构成投资建议。`gang weekly apply` 用 Agent 钱包把报名签成 EIP-712 数据(域名 `gang.fun weekly launch`,不发交易);`--contact` 只有 gang.fun 团队能看到。`gang weekly` 显示 `hold: true` 时(0.43.0+),报名持续开放、没有截止时间,发射时间待定:团队从报名里挑选并联系入选者,发射时间在 gang.fun/weekly 公布。有自己计划的团队也可以随时在 Gang 上发射。规则见 `skill/references/discover.md`。
|
|
189
202
|
|
|
190
203
|
`gang trending`(0.24.0+)列出其他 agent 现在在买什么:最近 6 小时独立 agent 买家最多的至多 5 个币(不算创建者、批量扫币的机器人和平台钱包),以及至多 3 条现在能跟的想法,作者的已判定命中率不低于 60%(`GET /api/trending`,在 `~/.gang/trending.json` 缓存 5 分钟)。有内容时,`gang preflight` 和 `gang list` 的输出里也带同样的 `trending`。这不是推荐。0.28.0 起,如果登录的钱包还没在 Gang 交易过(`GET /api/ref/eligible`),列表里不放铸币飞轮的币和关于它们的想法,并用 `firstTrade: { flyLeftOut, note }` 说明:第一笔交易引导到曲线上的币。`gang list --kind fly` 仍会列出它们。`gang preflight` 查出问题时,输出里还带 `guide: { url, note }`(0.28.0+):`https://gang.fun/start`,给用户看的分步设置页。
|
|
191
204
|
|
|
@@ -212,7 +225,7 @@ gang buy --token 0x… --amount 0.1 --note "消息面发酵前先建仓" --revea
|
|
|
212
225
|
### 邀请(`--ref`、`gang invite`,0.26.0+)
|
|
213
226
|
|
|
214
227
|
`gang invite [--token <addr>]` 输出这个钱包的邀请链接(`https://gang.fun/start?ref=…[&token=…]`,给新人的开通引导页),以及它带来了多少新 agent(`invited`;`qualified` = 7 天内、第一笔交易一天之后又交易过)。
|
|
215
|
-
新人的 agent 在 `gang buy` / `gang mint` / `gang follow` 上带 `--ref <邀请人>`:CLI 先问 gang.fun(`GET /api/ref/eligible`),只有这是钱包在 Gang 的第一笔交易时,才在 calldata 末尾、跟单标记和附言之前附上 `"gang" 05 <邀请人>`(25 字节),合约会忽略它。输出里的 `ref` 说明有没有附上;`gang tx` 显示 `invitedBy
|
|
228
|
+
新人的 agent 在 `gang buy` / `gang mint` / `gang follow` 上带 `--ref <邀请人>`:CLI 先问 gang.fun(`GET /api/ref/eligible`),只有这是钱包在 Gang 的第一笔交易时,才在 calldata 末尾、跟单标记和附言之前附上 `"gang" 05 <邀请人>`(25 字节),合约会忽略它。输出里的 `ref` 说明有没有附上;`gang tx` 显示 `invitedBy`。不带邀请人时,第一笔交易算给所买代币的创建者。铸币飞轮的 mint 仍用合约自带的邀请人参数。
|
|
216
229
|
|
|
217
230
|
### 跟单(`--follow`,0.6.0+)
|
|
218
231
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gangfun/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.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/capabilities.js
CHANGED
|
@@ -64,6 +64,7 @@ export const COMMANDS = [
|
|
|
64
64
|
c('creator-fee --claim --to', 'preview', 'high', '0.23.0', 'Creator only: claim the creator fee to another address'),
|
|
65
65
|
c('upload-logo', 'publish', 'medium', '0.2.0', 'Publish a local image or a URL on gang.fun, at once: only a file the user named', { needsUserConfirmation: true }),
|
|
66
66
|
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
|
+
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'),
|
|
67
68
|
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'),
|
|
68
69
|
c('mint', 'preview', 'medium', '0.12.0', 'Buy shares of a 打新 or Mint Flywheel sale'),
|
|
69
70
|
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' } } }),
|
|
@@ -102,6 +103,14 @@ export const COMMANDS = [
|
|
|
102
103
|
]),
|
|
103
104
|
c('base status', 'read', 'none', '0.40.0', "A 3.0 token's opening base: its vault, size, release period, start, released, releasable and unreleased (by time)"),
|
|
104
105
|
c('base release', 'preview', 'low', '0.40.0', "Anyone, after graduation: start the base's linear release (first call), then send what has vested to the creator"),
|
|
106
|
+
c('grad-reward status', 'read', 'none', '0.42.0', "A 3.0 token's graduation reward: the pool, the rules, the list of the last counted buys, the refund state and what a wallet can claim"),
|
|
107
|
+
c('grad-reward claim', 'preview', 'low', '0.42.0', 'After graduation: claim this wallet\'s share of the graduation reward (all its valid entries), once'),
|
|
108
|
+
c('grad-reward settle', 'preview', 'low', '0.42.0', 'Anyone, after graduation: count the valid entries (the first claim does too)'),
|
|
109
|
+
c('grad-reward sweep', 'preview', 'low', '0.42.0', 'Anyone, 180 days after graduation: send the unclaimed rest back to the creator and close the reward'),
|
|
110
|
+
c('grad-reward retry-carry', 'preview', 'low', '0.42.0', 'Anyone: resend a carry owed to the token\'s countdown reward module'),
|
|
111
|
+
c('grad-reward refund-request', 'preview', 'medium', '0.42.0', 'Creator, on the curve, after --gr-refund-days: ask for the pool back; starts a public 7-day notice'),
|
|
112
|
+
c('grad-reward refund-cancel', 'preview', 'low', '0.42.0', 'Creator: cancel a running refund request'),
|
|
113
|
+
c('grad-reward refund', 'preview', 'medium', '0.42.0', 'Creator, within 3 days after the notice, the token still on its curve: take the pool back; the reward ends for good'),
|
|
105
114
|
c('promote buy', 'preview', 'medium', '0.34.0', "Buy naming a promoter: a wallet's first trade of the token binds it for good, on the curve"),
|
|
106
115
|
c('promote status', 'read', 'none', '0.34.0', "A token's promoter terms, a wallet's binding and what it can claim"),
|
|
107
116
|
c('promote earnings', 'read', 'none', '0.34.0', 'A promoter wallet: shares to claim on the curve and in the pool'),
|
package/src/flags.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { FLY_CREATE_FLAGS } from './fly.js'
|
|
7
7
|
import { LAUNCH_FLAGS } from './launch.js'
|
|
8
|
+
import { GRAD_FLAGS } from './gradreward.js'
|
|
8
9
|
|
|
9
10
|
export const LINK_FLAGS = ['website', 'twitter']
|
|
10
11
|
// gang create: V3 by default, a 打新 sale with --fair; a setting of the other kind is refused, not ignored
|
|
@@ -13,7 +14,7 @@ export const FAIR_CREATE_FLAGS = ['raise', 'cap', 'hold', 'mint-fee', 'exit-fee'
|
|
|
13
14
|
|
|
14
15
|
export const CREATE_ACCEPTS = new Set([
|
|
15
16
|
'name', 'symbol', 'logo', 'logo-file', 'file-logo', 'logo-uri', 'keep-logo-uri', ...LINK_FLAGS, 'description',
|
|
16
|
-
'quote', 'ref-pool', 'grad', 'vault', 'base', 'base-vest', 'testnet', 'calldata', 'from', 'note', 'conf', 'reveal-after',
|
|
17
|
+
'quote', 'ref-pool', 'grad', 'vault', 'base', 'base-vest', ...GRAD_FLAGS, 'testnet', 'calldata', 'from', 'note', 'conf', 'reveal-after',
|
|
17
18
|
'fair', 'fly', ...V3_CREATE_FLAGS, ...FAIR_CREATE_FLAGS, ...FLY_CREATE_FLAGS,
|
|
18
19
|
// a launch in one command: its dev buy reads --slippage like gang buy, its bond --use-wbnb like gang bond post
|
|
19
20
|
...LAUNCH_FLAGS, 'slippage', 'use-wbnb',
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { createPublicClient, encodeFunctionData, isAddress, parseAbi, parseUnits } from 'viem'
|
|
2
|
+
import { walletFor } from './fair.js'
|
|
3
|
+
import { atTokenPad, KIND_UNREAD, NOT_ON_MAINNET, PAD3_GEN, padNets, rpcTransport } from './gangpad.js'
|
|
4
|
+
import { missingRead } from './base.js'
|
|
5
|
+
import { revertOf as revertIn, step, units } from './steps.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 冲毕业奖励, the graduation reward of a GangLaunchpad 3.0 curve token (docs/SPEC-GRAD-REWARD-2026-11-17.md §13). The
|
|
9
|
+
* creator seeds a reward pool at create, in the token's quote (`gang create … --grad-reward <amount>`). The pad keeps
|
|
10
|
+
* the last N counted curve buys. A buy counts when the Agent gate is on and it actually spends at least minBuy; the buy
|
|
11
|
+
* that graduates the token always counts. A curve sell takes that wallet's earlier entries out. At graduation the
|
|
12
|
+
* newest valid entry gets lastBps of the pool on top; all valid entries, the newest included, split the rest by what
|
|
13
|
+
* each actually spent. Buyers claim for 180 days, then the rest is swept back to the creator. A token that does not
|
|
14
|
+
* graduate: the creator may ask for the pool back after refundAfter, and takes it only after a public 7-day notice,
|
|
15
|
+
* within 3 days (else the request lapses); a graduation during the notice pays as usual.
|
|
16
|
+
*
|
|
17
|
+
* Not a bet: buyers buy the token as on any curve and pay nothing extra; the pool is the creator's own money.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const TAX = '(uint16 buyTaxBps, uint16 sellTaxBps, uint16 dividendBps, address recipient)'
|
|
21
|
+
const CFG = '(uint128 seed, uint96 minBuy, uint8 entries, uint16 lastBps, uint16 carryBps, uint32 refundAfter, uint16 promoteBps, uint32 promoteWindow)'
|
|
22
|
+
const VIEW = '(uint8 state, uint128 pot, uint96 minBuy, uint8 entries, uint16 lastBps, uint16 carryBps, uint32 refundAfter, uint40 createdAt, uint40 refundAt, uint40 gradAt, uint64 seq, address countdown, uint128 claimed, uint128 carryOwed, bool settled, uint16 valid, uint128 validSpent, bool refundPending)'
|
|
23
|
+
export const GRAD_PAD_ABI = parseAbi([
|
|
24
|
+
`function createWithGradReward(string name, string symbol, string logoURI, string metaURI, address quote, address refPool, ${TAX} tax, uint256 gradBnb, ${CFG} cfg) returns (address token)`,
|
|
25
|
+
'function gradRewardDeps() view returns (bool open, address handlerAdmin, address countdownFactory)',
|
|
26
|
+
`function gradReward(address token) view returns (${VIEW})`,
|
|
27
|
+
'function gradEntries(address token) view returns (address[] buyers, uint64[] seqs, uint96[] spent, bool[] valid)',
|
|
28
|
+
'function gradClaimable(address token, address wallet) view returns (uint256)',
|
|
29
|
+
'function agentGateEnabled() view returns (bool)',
|
|
30
|
+
'function claimGradReward(address token) returns (uint256 amount)',
|
|
31
|
+
'function settleGradReward(address token)',
|
|
32
|
+
'function sweepGradReward(address token)',
|
|
33
|
+
'function retryCarry(address token)',
|
|
34
|
+
'function requestGradRefund(address token)',
|
|
35
|
+
'function cancelGradRefund(address token)',
|
|
36
|
+
'function gradRefund(address token) returns (uint256 amount)',
|
|
37
|
+
'error GradNotOpen()', 'error BadGradConfig()', 'error BadCountdown()', 'error NotGradState()', 'error RefundNotDue()',
|
|
38
|
+
'error AlreadyClaimed()', 'error NothingToClaim()', 'error SweepNotDue()', 'error NoCarryOwed()', 'error CarryGasLow()',
|
|
39
|
+
'event GradRewardSet(address indexed token, uint256 seed, uint256 minBuy, uint8 entries, uint16 lastBps, uint16 carryBps, uint32 refundAfter, address countdown)',
|
|
40
|
+
'event GradEntry(address indexed token, address indexed buyer, uint64 seq, uint256 spent, uint256 tokens)',
|
|
41
|
+
'event GradDisqualified(address indexed token, address indexed wallet, uint64 seq)',
|
|
42
|
+
'event GradRewardBooked(address indexed token, uint256 pot, uint256 carry, uint64 seq)',
|
|
43
|
+
'event GradSettled(address indexed token, uint256 valid, uint64 lastSeq, uint256 lastShare, uint256 restPay, uint256 validSpent)',
|
|
44
|
+
'event GradClaimed(address indexed token, address indexed wallet, uint256 amount)',
|
|
45
|
+
'event GradSwept(address indexed token, address indexed to, uint256 amount)',
|
|
46
|
+
'event RefundRequested(address indexed token, uint256 executableAt, uint256 expiresAt)',
|
|
47
|
+
'event RefundCancelled(address indexed token)',
|
|
48
|
+
'event Refunded(address indexed token, address indexed dev, uint256 amount)',
|
|
49
|
+
'event CarrySent(address indexed token, address indexed module, uint256 amount)',
|
|
50
|
+
'event CarryOwed(address indexed token, address indexed module, uint256 amount)',
|
|
51
|
+
'event GradRewardDepsSet(bool open, address handlerAdmin, address countdownFactory)',
|
|
52
|
+
])
|
|
53
|
+
/** What `gang tx` decodes the graduation reward's logs with. */
|
|
54
|
+
export const GRAD_EVENT_ABIS = [GRAD_PAD_ABI]
|
|
55
|
+
|
|
56
|
+
export const HINTS = {
|
|
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',
|
|
59
|
+
BadCountdown: 'the tax recipient is a countdown reward module made for another token or quote (or a carry was asked without one)',
|
|
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
|
+
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',
|
|
62
|
+
AlreadyClaimed: 'this wallet already claimed its graduation reward for this token',
|
|
63
|
+
NothingToClaim: 'this wallet has no valid entry in the list: it was not among the last buys counted, or it sold on the curve after its buys',
|
|
64
|
+
SweepNotDue: 'the unclaimed rest can be swept 180 days after graduation',
|
|
65
|
+
NoCarryOwed: 'no carry is owed to the countdown module',
|
|
66
|
+
CarryGasLow: 'too little gas for the countdown module\'s receiveCarry: send the tx with more gas',
|
|
67
|
+
}
|
|
68
|
+
export const revertOf = (e) => revertIn(e, [GRAD_PAD_ABI], HINTS)
|
|
69
|
+
|
|
70
|
+
export const STATES = ['none', 'on the curve', 'graduated: claims open', 'refunded to the creator', 'closed']
|
|
71
|
+
export const MAX_ENTRIES = 20
|
|
72
|
+
export const DEFAULTS = { entries: 10, lastPct: 30, refundDays: 90 }
|
|
73
|
+
// in BNB, converted into the quote at the pad's own rate (graduation amount ÷ target)
|
|
74
|
+
export const DEFAULT_MIN_BUY_BNB = '0.01'
|
|
75
|
+
export const MIN_SEED_BNB = '0.1'
|
|
76
|
+
export const NOTICE_DAYS = 7
|
|
77
|
+
export const WINDOW_DAYS = 3
|
|
78
|
+
export const CLAIM_DAYS = 180
|
|
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, and the days before you may ask for the pool back'
|
|
82
|
+
export const GRAD_ALONE = 'a --grad-reward create stands alone in this CLI: 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
|
+
export const NOT_A_BET = 'the reward pool is the creator\'s own money; buyers pay only the usual curve price and 1% fee, nothing extra, and get the tokens they buy. Who gets what follows a fixed public rule (the last buys counted, by what each spent): no randomness, no draw'
|
|
84
|
+
|
|
85
|
+
/** The --grad-reward / --gr-* flags, checked: { seed, minBuy, entries, lastBps, refundDays } (amounts as typed), or { error }. */
|
|
86
|
+
export function parseGradReward(opt, flag) {
|
|
87
|
+
const num = (s) => /^(\d+(\.\d*)?|\.\d+)$/.test(String(s ?? '').trim())
|
|
88
|
+
const seed = opt('grad-reward')
|
|
89
|
+
if (!num(seed) || !(Number(seed) > 0)) return { error: `--grad-reward needs the seed: a positive amount of the token's quote (e.g. --grad-reward 0.5). ${GRAD_USAGE}`, got: seed ?? null }
|
|
90
|
+
let minBuy = null
|
|
91
|
+
if (flag('gr-min-buy')) {
|
|
92
|
+
minBuy = opt('gr-min-buy')
|
|
93
|
+
if (!num(minBuy) || !(Number(minBuy) > 0)) return { error: '--gr-min-buy must be a positive amount of the quote (the least a buy must actually spend to count)', got: minBuy ?? null }
|
|
94
|
+
}
|
|
95
|
+
const int = (name, def, lo, hi, what) => {
|
|
96
|
+
if (!flag(name)) return { v: def }
|
|
97
|
+
const n = Number(opt(name))
|
|
98
|
+
if (!Number.isInteger(n) || n < lo || n > hi) return { error: `--${name} must be an integer between ${lo} and ${hi} (${what})`, got: opt(name) ?? null }
|
|
99
|
+
return { v: n }
|
|
100
|
+
}
|
|
101
|
+
const e = int('gr-entries', DEFAULTS.entries, 1, MAX_ENTRIES, 'how many of the last counted buys share the pool')
|
|
102
|
+
if (e.error) return e
|
|
103
|
+
const l = int('gr-last', DEFAULTS.lastPct, 0, 50, '% of the payout the graduating buy gets on top')
|
|
104
|
+
if (l.error) return l
|
|
105
|
+
const r = int('gr-refund-days', DEFAULTS.refundDays, 30, 180, 'days after the create before you may ask for the pool back')
|
|
106
|
+
if (r.error) return r
|
|
107
|
+
return { seed: String(seed).trim(), minBuy: minBuy && String(minBuy).trim(), entries: e.v, lastBps: l.v * 100, refundDays: r.v }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Whether `ctx.pad` takes a graduation reward now: { open: true } / { open: false, why } / { unread }. */
|
|
111
|
+
export async function gradSupport(ctx) {
|
|
112
|
+
if (ctx.gen !== PAD3_GEN) return { open: false, why: `GangLaunchpad ${ctx.gen ?? ctx.pad} has no graduation reward (3.0 only)` }
|
|
113
|
+
let deps
|
|
114
|
+
try { deps = await ctx.read(ctx.pad, GRAD_PAD_ABI, 'gradRewardDeps') } catch (e) {
|
|
115
|
+
if (missingRead(e)) return { open: false, why: `GangLaunchpad 3.0 on ${ctx.chainId === '97' ? 'the BSC testnet' : 'BSC mainnet'} has no graduation reward yet (the pad is not upgraded for it)` }
|
|
116
|
+
return { unread: e.shortMessage || e.message.split('\n')[0] }
|
|
117
|
+
}
|
|
118
|
+
if (!deps[0]) return { open: false, why: 'the graduation reward is closed on this pad' }
|
|
119
|
+
return { open: true, countdownFactory: deps[2] }
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** `amountBnb` (a decimal string) in the quote, at the rate the curve's graduation amount fixes (gradAmt ÷ target BNB). */
|
|
123
|
+
export const bnbInQuote = (amountBnb, gradAmt, targetBnb) =>
|
|
124
|
+
(parseUnits(String(amountBnb), 18) * gradAmt) / parseUnits(String(targetBnb), 18)
|
|
125
|
+
|
|
126
|
+
const iso = (s) => (Number(s) > 0 ? new Date(Number(s) * 1000).toISOString() : null)
|
|
127
|
+
const pctOf = (bps) => Number(bps) / 100
|
|
128
|
+
|
|
129
|
+
/** 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 }) {
|
|
131
|
+
const last = pctOf(lastBps)
|
|
132
|
+
return {
|
|
133
|
+
pool: `${seed} ${sym}`, payWithThisTx: `${seed} ${sym}, pulled from this wallet in the create (approve the pad for it first)`,
|
|
134
|
+
minBuy: `${minBuy} ${sym}`, entries, lastPct: last, refundDays,
|
|
135
|
+
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`,
|
|
136
|
+
split: last > 0
|
|
137
|
+
? `at graduation the buy that graduates it gets ${last}% of the pool on top; then all ${entries} entries, it included, split the rest by what each spent (a wallet with several entries adds them up)`
|
|
138
|
+
: `at graduation all ${entries} entries split the pool by what each spent (a wallet with several entries adds them up)`,
|
|
139
|
+
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) back to you (to the token's countdown reward module instead, if its tax recipient is one)`,
|
|
141
|
+
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
|
+
notABet: NOT_A_BET,
|
|
143
|
+
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
|
+
...(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`,
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The token's reward as the pad says (null: none). `me`: a wallet to report its entries and claim for. All amounts in
|
|
151
|
+
* the quote's units.
|
|
152
|
+
*/
|
|
153
|
+
export async function gradOf(ctx, token, quote, me = null) {
|
|
154
|
+
if (ctx.gen !== PAD3_GEN) return null
|
|
155
|
+
let v
|
|
156
|
+
try { v = await ctx.read(ctx.pad, GRAD_PAD_ABI, 'gradReward', [token]) } catch (e) {
|
|
157
|
+
if (missingRead(e)) return null
|
|
158
|
+
throw e
|
|
159
|
+
}
|
|
160
|
+
if (Number(v.state) === 0) return null
|
|
161
|
+
const [ent, gated, block] = await Promise.all([
|
|
162
|
+
ctx.read(ctx.pad, GRAD_PAD_ABI, 'gradEntries', [token]), ctx.read(ctx.pad, GRAD_PAD_ABI, 'agentGateEnabled'), ctx.client.getBlock(),
|
|
163
|
+
])
|
|
164
|
+
const u = (x) => units(ctx, quote, x)
|
|
165
|
+
const [buyers, seqs, spent, valid] = ent
|
|
166
|
+
const list = await Promise.all(buyers.map(async (b, i) => ({ buyer: b, seq: Number(seqs[i]), spent: await u(spent[i]), valid: valid[i], ...(me && b.toLowerCase() === me.toLowerCase() && { you: true }) })))
|
|
167
|
+
const now = Number(block.timestamp)
|
|
168
|
+
const state = Number(v.state)
|
|
169
|
+
const refundAt = Number(v.refundAt)
|
|
170
|
+
const claimable = me && state === 2 ? await ctx.read(ctx.pad, GRAD_PAD_ABI, 'gradClaimable', [token, me]) : 0n
|
|
171
|
+
return {
|
|
172
|
+
state: STATES[state] ?? String(state), pool: await u(v.pot), minBuy: await u(v.minBuy), entries: Number(v.entries), lastPct: pctOf(v.lastBps),
|
|
173
|
+
...(Number(v.carryBps) > 0 && { carryPct: pctOf(v.carryBps) }),
|
|
174
|
+
...(v.countdown !== '0x0000000000000000000000000000000000000000' && { countdown: v.countdown, restGoesTo: 'the token\'s countdown reward module (the rest after the claim window, or the whole payout if no entry is valid)' }),
|
|
175
|
+
counted: Number(v.seq), gateOn: gated, list,
|
|
176
|
+
createdAt: iso(v.createdAt), refundAskableAt: iso(Number(v.createdAt) + Number(v.refundAfter)),
|
|
177
|
+
...(refundAt > 0 && state === 1 && {
|
|
178
|
+
refund: v.refundPending
|
|
179
|
+
? { requestedAt: iso(refundAt), takeableFrom: iso(refundAt + NOTICE_DAYS * 86400), lapsesAt: iso(refundAt + (NOTICE_DAYS + WINDOW_DAYS) * 86400), note: 'the creator asked for the pool back: if the token graduates before the creator takes it, the buyers are paid as usual' }
|
|
180
|
+
: { lapsed: true, note: 'a refund request lapsed: the creator would have to ask again (a fresh 7-day notice)' },
|
|
181
|
+
}),
|
|
182
|
+
...(state >= 2 && Number(v.gradAt) > 0 && { graduatedAt: iso(v.gradAt), sweepableAt: iso(Number(v.gradAt) + CLAIM_DAYS * 86400), claimed: await u(v.claimed) }),
|
|
183
|
+
...(v.carryOwed > 0n && { carryOwed: await u(v.carryOwed) }),
|
|
184
|
+
...(v.settled && { validEntries: Number(v.valid) }),
|
|
185
|
+
...(me && { wallet: me, ...(state === 2 && { claimable: await u(claimable) }) }),
|
|
186
|
+
raw: { state, settled: v.settled, countdown: v.countdown, pot: v.pot, minBuy: v.minBuy, lastBps: Number(v.lastBps), refundAt, refundPending: v.refundPending, refundAfter: Number(v.refundAfter), createdAt: Number(v.createdAt), gradAt: Number(v.gradAt), carryOwed: v.carryOwed, claimable, now, gated, buyers, valid },
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* What a curve buy preview says about the reward: whether it would count, the pool, and what the list looks like.
|
|
192
|
+
* `spent`: what the buy actually spends (fee included, after a cut); `graduates`: it is the graduating buy.
|
|
193
|
+
*/
|
|
194
|
+
export async function gradBuyLine(ctx, token, quote, sym, me, spent, graduates) {
|
|
195
|
+
let g
|
|
196
|
+
try { g = await gradOf(ctx, token, quote, me) } catch (e) {
|
|
197
|
+
return { error: 'could not read the token\'s graduation reward (RPC error): whether this buy counts is unknown', detail: e.shortMessage || e.message.split('\n')[0], retry: 'same command again' }
|
|
198
|
+
}
|
|
199
|
+
if (!g || g.raw.state !== 1) return null
|
|
200
|
+
const counts = g.raw.gated && (spent >= g.raw.minBuy || graduates)
|
|
201
|
+
const why = !g.raw.gated ? 'the Agent gate is off now: no buy counts'
|
|
202
|
+
: counts ? (graduates ? 'this buy graduates the token: it counts, and gets the graduating buy\'s share on top' : `it spends at least the ${g.minBuy} ${sym} minimum`)
|
|
203
|
+
: `it spends less than the ${g.minBuy} ${sym} minimum`
|
|
204
|
+
const asOf = 'as the curve stands now: a buy landing first can change it (e.g. who graduates the token)'
|
|
205
|
+
return {
|
|
206
|
+
counts, why, asOf, pool: `${g.pool} ${sym}`, entries: g.entries, lastPct: g.lastPct, countedSoFar: g.counted,
|
|
207
|
+
note: `${g.entries} entries share the pool at graduation by what each spent${g.lastPct > 0 ? `, the graduating buy ${g.lastPct}% on top` : ''}. Selling on the curve before graduation takes this wallet's entries out. ${NOT_A_BET}`,
|
|
208
|
+
...(g.refund && { refund: g.refund }),
|
|
209
|
+
more: `gang grad-reward status --token ${token}${ctx.chainId === '97' ? ' --testnet' : ''}`,
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** What a curve sell preview warns about: the seller's valid entries it takes out (null: nothing to say). */
|
|
214
|
+
export async function gradSellLine(ctx, token, quote, sym, me) {
|
|
215
|
+
let g
|
|
216
|
+
try { g = await gradOf(ctx, token, quote, me) } catch (e) {
|
|
217
|
+
return { warning: 'could not read the token\'s graduation reward (RPC error): if it has one, this sell takes out your entries in its list. Re-run before you sell to see them', detail: e.shortMessage || e.message.split('\n')[0], retry: 'same command again' }
|
|
218
|
+
}
|
|
219
|
+
if (!g || g.raw.state !== 1) return null
|
|
220
|
+
const mine = g.list.filter((x) => x.you && x.valid).length
|
|
221
|
+
if (!mine) return null
|
|
222
|
+
return { warning: `this sell takes out your ${mine} entr${mine === 1 ? 'y' : 'ies'} in the graduation reward list (pool ${g.pool} ${sym}): only a later buy of yours would count again`, entriesLost: mine }
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function gradCtx(testnet) {
|
|
226
|
+
const net = padNets('v3')[testnet ? 'testnet' : 'mainnet']
|
|
227
|
+
if (!net.pad) throw new Error(NOT_ON_MAINNET)
|
|
228
|
+
const client = createPublicClient({ chain: net.chain, transport: rpcTransport(net.rpcs) })
|
|
229
|
+
return { ...net, client, read: (address, abi, functionName, args = []) => client.readContract({ address, abi, functionName, args }) }
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const CURVE_ABI = parseAbi(['function curves(address token) view returns (address creator, address quote, uint128 realQuote, uint128 sold, uint128 gradAmt, uint128 virtualQuote, bool graduated, uint16 buyTaxBps, uint16 sellTaxBps, uint16 dividendBps, address pair, address refPair)',
|
|
233
|
+
'function symbol() view returns (string)'])
|
|
234
|
+
|
|
235
|
+
const SUBS = ['status', 'claim', 'settle', 'sweep', 'retry-carry', 'refund-request', 'refund-cancel', 'refund']
|
|
236
|
+
const USAGE = 'usage: gang grad-reward <status|claim|settle|sweep|retry-carry|refund-request|refund-cancel|refund> --token <addr> [--testnet] [--calldata] [--from <addr>] — see gang help'
|
|
237
|
+
const FN = {
|
|
238
|
+
claim: 'claimGradReward', settle: 'settleGradReward', sweep: 'sweepGradReward', 'retry-carry': 'retryCarry',
|
|
239
|
+
'refund-request': 'requestGradRefund', 'refund-cancel': 'cancelGradRefund', refund: 'gradRefund',
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** `gang grad-reward <sub>`: a 3.0 curve token's graduation reward. */
|
|
243
|
+
export async function runGradReward(sub, { opt, flag, out, fail, summarize }) {
|
|
244
|
+
if (!SUBS.includes(sub)) return fail(USAGE, { got: sub ?? null })
|
|
245
|
+
const testnet = flag('testnet')
|
|
246
|
+
let ctx
|
|
247
|
+
try { ctx = gradCtx(testnet) } catch (e) { return fail(e.message) }
|
|
248
|
+
const chainId = Number(ctx.chainId)
|
|
249
|
+
const tn = testnet ? ' --testnet' : ''
|
|
250
|
+
const token = opt('token')
|
|
251
|
+
if (!isAddress(token ?? '')) return fail('--token must be a 3.0 curve token address (0x…)', { got: token ?? null })
|
|
252
|
+
const kind = await atTokenPad(ctx, token)
|
|
253
|
+
if (kind === null) return fail(KIND_UNREAD.error, { token, retry: KIND_UNREAD.retry })
|
|
254
|
+
if (kind !== 'v3') return fail(`not a V3 curve token on a GangLaunchpad (${testnet ? 'BSC testnet' : 'BSC mainnet; add --testnet for a testnet token'})`, { token, chainId, ...(kind && kind !== 'none' && { kind }) })
|
|
255
|
+
let creator, quote
|
|
256
|
+
try { [creator, quote] = await ctx.read(ctx.pad, CURVE_ABI, 'curves', [token]) } catch (e) {
|
|
257
|
+
return fail('could not read the token\'s curve (RPC error)', { token, detail: e.shortMessage || e.message.split('\n')[0], retry: 'same command again' })
|
|
258
|
+
}
|
|
259
|
+
const sym = await ctx.read(quote, CURVE_ABI, 'symbol').catch(() => 'quote')
|
|
260
|
+
let me = null
|
|
261
|
+
try { me = walletFor(ctx, opt('from')) } catch { /* status works without a wallet */ }
|
|
262
|
+
let g
|
|
263
|
+
try { g = await gradOf(ctx, token, quote, me) } catch (e) {
|
|
264
|
+
return fail('could not read the token\'s graduation reward (RPC error)', { token, detail: e.shortMessage || e.message.split('\n')[0], retry: 'same command again' })
|
|
265
|
+
}
|
|
266
|
+
if (!g) return fail('this token has no graduation reward (it was not created with --grad-reward)', { token, pad: ctx.pad, padGen: ctx.gen })
|
|
267
|
+
const { raw, ...shown } = g
|
|
268
|
+
const isCreator = me && me.toLowerCase() === creator.toLowerCase()
|
|
269
|
+
if (sub === 'status') {
|
|
270
|
+
const next = raw.state === 2 && raw.claimable > 0n ? `gang grad-reward claim --token ${token}${tn}`
|
|
271
|
+
: raw.state === 2 && raw.now >= raw.gradAt + CLAIM_DAYS * 86400 ? `gang grad-reward sweep --token ${token}${tn}`
|
|
272
|
+
: raw.carryOwed > 0n ? `gang grad-reward retry-carry --token ${token}${tn}` : null
|
|
273
|
+
return out({ success: true, chainId, token, pad: ctx.pad, quote: sym, creator, ...shown, notABet: NOT_A_BET, ...(next && { next }) })
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (!me) return fail('no wallet: sign in to baw, or pass --from <addr> with --calldata')
|
|
277
|
+
// what each write needs, said before the simulation (which says it too, with the pad's own error)
|
|
278
|
+
const dest = raw.countdown && raw.countdown !== '0x0000000000000000000000000000000000000000' ? `the token's countdown reward module ${raw.countdown}` : `the creator ${creator}`
|
|
279
|
+
const closed = raw.state === 4 ? 'the reward is closed: the claim window is over (or no entry was valid) and the rest was sent on'
|
|
280
|
+
: raw.state === 3 ? 'the creator took the pool back (the token did not graduate in time): there is nothing to claim' : null
|
|
281
|
+
const lapsesAt = raw.refundAt + (NOTICE_DAYS + WINDOW_DAYS) * 86400
|
|
282
|
+
const need = {
|
|
283
|
+
claim: () => closed ?? (raw.state !== 2 ? HINTS.NotGradState : raw.claimable === 0n ? 'nothing to claim for this wallet: it already claimed, or it has no valid entry in the list (not among the last buys counted, or it sold on the curve after its buys)' : null),
|
|
284
|
+
settle: () => closed ?? (raw.state !== 2 ? HINTS.NotGradState : raw.settled ? 'already settled: the entries are counted (claims read them)' : null),
|
|
285
|
+
sweep: () => closed ?? (raw.state !== 2 ? HINTS.NotGradState : raw.now < raw.gradAt + CLAIM_DAYS * 86400 ? HINTS.SweepNotDue : null),
|
|
286
|
+
'retry-carry': () => (raw.carryOwed === 0n ? HINTS.NoCarryOwed : null),
|
|
287
|
+
'refund-request': () => (!isCreator ? 'only the token\'s creator may ask for the pool back' : raw.state !== 1 ? HINTS.NotGradState
|
|
288
|
+
: raw.now < raw.createdAt + raw.refundAfter ? `too early: the pool can be asked back from ${g.refundAskableAt}` : raw.refundPending ? 'a refund request is already running' : null),
|
|
289
|
+
'refund-cancel': () => (!isCreator ? 'only the token\'s creator may cancel its refund request' : !raw.refundPending ? 'no refund request is running' : null),
|
|
290
|
+
refund: () => (!isCreator ? 'only the token\'s creator takes the pool back' : raw.state !== 1 ? HINTS.NotGradState
|
|
291
|
+
: !raw.refundPending ? 'no running refund request: ask first (gang grad-reward refund-request), then wait the 7-day notice'
|
|
292
|
+
: raw.now < raw.refundAt + NOTICE_DAYS * 86400 ? `the 7-day notice runs until ${iso(raw.refundAt + NOTICE_DAYS * 86400)}` : null),
|
|
293
|
+
}[sub]()
|
|
294
|
+
if (need) return fail(need, { token, state: g.state })
|
|
295
|
+
const fn = FN[sub]
|
|
296
|
+
try { await ctx.client.simulateContract({ account: me, address: ctx.pad, abi: GRAD_PAD_ABI, functionName: fn, args: [token] }) } catch (e) {
|
|
297
|
+
const rv = revertOf(e)
|
|
298
|
+
return out({ success: false, step: `grad-reward-${sub}`, ...(rv ? { reverted: true, ...rv } : { reverted: false, error: e.shortMessage || e.message.split('\n')[0] }) })
|
|
299
|
+
}
|
|
300
|
+
const data = encodeFunctionData({ abi: GRAD_PAD_ABI, functionName: fn, args: [token] })
|
|
301
|
+
const note = {
|
|
302
|
+
claim: `pays this wallet ${g.claimable} ${sym}: all its valid entries in the list, once`,
|
|
303
|
+
settle: `counts the valid entries once (the first claim does this too); with none, the payout goes to ${dest}`,
|
|
304
|
+
sweep: `closes the reward: the unclaimed rest goes to ${dest}; no claim after this`,
|
|
305
|
+
'retry-carry': `sends the owed ${g.carryOwed} ${sym} to the countdown reward module again`,
|
|
306
|
+
'refund-request': `starts a public ${NOTICE_DAYS}-day notice: a graduation in that time pays the buyers as usual. Then you have ${WINDOW_DAYS} days to take the pool (gang grad-reward refund), else the request lapses`,
|
|
307
|
+
'refund-cancel': 'cancels the running refund request: the reward stays as it is',
|
|
308
|
+
refund: `takes the whole pool (${g.pool} ${sym}) back to you and ends the reward for good: a later graduation pays nobody. Send it before ${iso(lapsesAt)}: the request lapses then, and the tx would revert`,
|
|
309
|
+
}[sub]
|
|
310
|
+
return out(step(ctx, { from: me, to: ctx.pad, data }, {
|
|
311
|
+
step: `grad-reward-${sub}`, chainId, token, quote: sym, pool: g.pool, ...(sub === 'claim' && { amount: g.claimable }), ...(sub === 'refund' && { lapsesAt: iso(lapsesAt) }), note,
|
|
312
|
+
}, flag('calldata'), summarize))
|
|
313
|
+
}
|
|
314
|
+
|
package/src/index.js
CHANGED
|
@@ -30,6 +30,8 @@ import { runCombo, COMBO_EVENT_ABIS } from './combo.js'
|
|
|
30
30
|
import { runCapped, CAPPED_EVENT_ABIS } from './capped.js'
|
|
31
31
|
import { runFloor, FLOOR_ABI, FLOOR_EVENT_ABIS } from './floor.js'
|
|
32
32
|
import { runBase, BASE_EVENT_ABIS } from './base.js'
|
|
33
|
+
import { GRAD_ALONE, GRAD_EVENT_ABIS, GRAD_FLAGS, runGradReward } from './gradreward.js'
|
|
34
|
+
import { wantsPoolModule } from './promote.js'
|
|
33
35
|
import { runWeekly } from './weekly.js'
|
|
34
36
|
import { runFly, flyCtx, isFlyToken, FLY_EVENT_ABIS, FLY_CREATE_FLAGS } from './fly.js'
|
|
35
37
|
import { FAIR_DEV_BUY, isLaunch, LAUNCH_FLAGS, REDEEM_FEE_ALONE, runLaunch, TAX_CAP_ALONE } from './launch.js'
|
|
@@ -367,14 +369,15 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
367
369
|
gang invite [--token <addr>] [--who <addr|handle>]
|
|
368
370
|
my invite link (https://gang.fun/start?ref=…[&token=…]) and how many new agents it
|
|
369
371
|
brought (invited / qualified: traded again a day later within 7 days), this week and
|
|
370
|
-
per token
|
|
372
|
+
per token
|
|
371
373
|
gang weekly Gang's weekly launch event (gang.fun/weekly, 0.36.0+): the issue open for
|
|
372
|
-
applications, the current pick (launches
|
|
373
|
-
featured 7 days), past issues, and my applications.
|
|
374
|
+
applications, the current pick (launches on GangLaunchpad 3.0 at the launch time
|
|
375
|
+
gang.fun/weekly announces, featured 7 days), past issues, and my applications.
|
|
376
|
+
hold: true = applications stay open, no launch time set yet. Not investment advice
|
|
374
377
|
gang weekly apply --name <name> --symbol <SYM> (--logo <file> | --logo-uri <gang.fun logo>) --description <text>
|
|
375
378
|
--contact <handle> [--twitter <@x|url>] [--telegram <@tg|url>] [--website <url>] [--modules lp,buyback,…]
|
|
376
|
-
[--issue <
|
|
377
|
-
apply to be
|
|
379
|
+
[--issue <issue date>] [--yes]
|
|
380
|
+
apply to be a pick with the token you will create. Without --yes: a preview,
|
|
378
381
|
nothing signed or sent. --yes uploads a local logo, signs the application with the
|
|
379
382
|
Agent wallet (EIP-712, no tx) and submits it; again while open = replace it. Only the
|
|
380
383
|
gang.fun team sees --contact. If picked: create it from this wallet with this symbol
|
|
@@ -627,6 +630,38 @@ OPENING BASE (GangLaunchpad 3.0, base-v1, 0.40.0+; the pad says whether it is op
|
|
|
627
630
|
ones send what has vested to the creator (never to the caller). --testnet,
|
|
628
631
|
--calldata, --from as elsewhere
|
|
629
632
|
|
|
633
|
+
GRADUATION REWARD (冲毕业奖励, GangLaunchpad 3.0, 0.42.0+; the pad says whether it is open: BSC testnet now; mainnet once the Safe opens it):
|
|
634
|
+
gang create … --grad-reward <seed> [--gr-min-buy <amount>] [--gr-entries <1-20>] [--gr-last <0-50>] [--gr-refund-days <30-180>]
|
|
635
|
+
you seed a reward pool in the token's quote (pulled in the create: approve first;
|
|
636
|
+
at least 0.1 BNB worth) for the last --gr-entries curve buys (default 10) that each
|
|
637
|
+
actually spend --gr-min-buy (default 0.01 BNB worth), while the pad's Agent gate is
|
|
638
|
+
on; the buy that graduates the token counts whatever it spends and gets --gr-last % of the pool on top (default 30); all
|
|
639
|
+
entries, it included, split the rest by what each spent. A curve sell takes that
|
|
640
|
+
wallet's earlier entries out. Buyers claim for 180 days after graduation, then the
|
|
641
|
+
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
|
|
642
|
+
create you may ask for it back; the request is public for 7 days (a graduation in
|
|
643
|
+
that time pays the buyers), then you have 3 days to take it, else it lapses. The
|
|
644
|
+
buyers pay nothing extra: it is your money, by a fixed rule, no draw. With --promote
|
|
645
|
+
on an untaxed token or with --recipient; not with --vault / --base / --fair / --fly
|
|
646
|
+
or a launch in one command (--dev-buy, --bond, --buyback, --split, --lp, --tax-cap,
|
|
647
|
+
--floor). gang buy / gang sell previews say whether a buy counts (rewards.gradReward)
|
|
648
|
+
and what a sell takes out
|
|
649
|
+
gang grad-reward status --token <addr> the pool, the rules, the list (newest first, valid or not), the refund state and,
|
|
650
|
+
after graduation, what this wallet can claim
|
|
651
|
+
gang grad-reward claim --token <addr> after graduation: this wallet's share (all its valid entries), once
|
|
652
|
+
gang grad-reward settle --token <addr> anyone, after graduation: count the valid entries (the first claim does too)
|
|
653
|
+
gang grad-reward sweep --token <addr> anyone, 180 days after graduation: the unclaimed rest back to the creator (or the
|
|
654
|
+
token's countdown module); closes the reward
|
|
655
|
+
gang grad-reward retry-carry --token <addr>
|
|
656
|
+
anyone: resend a carry owed to the token's countdown reward module
|
|
657
|
+
gang grad-reward refund-request --token <addr>
|
|
658
|
+
the creator, on the curve, --gr-refund-days after the create: ask for the pool back
|
|
659
|
+
(starts the public 7-day notice)
|
|
660
|
+
gang grad-reward refund-cancel --token <addr>
|
|
661
|
+
the creator: cancel a running refund request
|
|
662
|
+
gang grad-reward refund --token <addr> the creator, within 3 days after the notice, still on the curve: take the pool back.
|
|
663
|
+
--testnet, --calldata, --from as elsewhere
|
|
664
|
+
|
|
630
665
|
BOND (押金承诺, GangBond; any GangLaunchpad token, from create on; GANG_BOND / GANG_TESTNET_BOND = its address):
|
|
631
666
|
gang bond post --token <addr> --hold <tokens|N%> --days <7-90> (--amount <quote> | --cover <coverage %>) [--use-wbnb]
|
|
632
667
|
creator only, any time after create (V3: buy on the curve first): bond in the token's
|
|
@@ -1423,9 +1458,9 @@ const PREFLIGHT_NEXT = [
|
|
|
1423
1458
|
// commands whose JSON result carries `update`; `watch` streams NDJSON and help is plain text
|
|
1424
1459
|
const UPDATE_CHECKED = new Set(['version', '--version', '-v', 'preflight', 'list', 'trending', 'invite', 'weekly', 'hot', 'new', 'near-grad', 'notes', 'agents', 'token', 'info', 'status', 'portfolio', 'quote',
|
|
1425
1460
|
'buy', 'follow', 'sell', 'claim', 'mint', 'withdraw', 'release', 'upload-logo', 'create', 'execute', 'tx', 'fair', 'v3', 'bond',
|
|
1426
|
-
'buyback', 'split', 'lp', 'combo', 'capped', 'floor', 'base', 'fly', 'creator-fee', 'promote', 'call-bond'])
|
|
1461
|
+
'buyback', 'split', 'lp', 'combo', 'capped', 'floor', 'base', 'grad-reward', 'fly', 'creator-fee', 'promote', 'call-bond'])
|
|
1427
1462
|
// gang tx decodes these beside the V2 / Soft / U / S pads' events (GangLaunchpad: both kinds; the tax router; the vaults)
|
|
1428
|
-
const GANG_EVENT_ABIS = [...V3_EVENT_ABIS, ...FAIR_EVENT_ABIS, ...FLY_EVENT_ABIS, ...SPLIT_EVENT_ABIS, ...LP_EVENT_ABIS, ...COMBO_EVENT_ABIS, ...CAPPED_EVENT_ABIS, ...FLOOR_EVENT_ABIS, ...BASE_EVENT_ABIS, ...PROMOTE_EVENT_ABIS, CALL_BOND_ABI]
|
|
1463
|
+
const GANG_EVENT_ABIS = [...V3_EVENT_ABIS, ...FAIR_EVENT_ABIS, ...FLY_EVENT_ABIS, ...SPLIT_EVENT_ABIS, ...LP_EVENT_ABIS, ...COMBO_EVENT_ABIS, ...CAPPED_EVENT_ABIS, ...FLOOR_EVENT_ABIS, ...BASE_EVENT_ABIS, ...GRAD_EVENT_ABIS, ...PROMOTE_EVENT_ABIS, CALL_BOND_ABI]
|
|
1429
1464
|
// Split with three amounts is the event of four module kinds, and the amounts mean different things in each (a buy-back
|
|
1430
1465
|
// splitter's toBuyback / toDev, an LP splitter's toLp / toDev, a promoter pool's toEscrow / toDev, a floor module's
|
|
1431
1466
|
// toTreasury / toPayees): gang tx asks the
|
|
@@ -1546,6 +1581,17 @@ async function main() {
|
|
|
1546
1581
|
const launch = LAUNCH_FLAGS.find((f) => flag(f))
|
|
1547
1582
|
if (launch) fail(`--${launch}: ${BASE_ALONE}`)
|
|
1548
1583
|
}
|
|
1584
|
+
// --grad-reward (3.0 graduation reward): a V3 create with a reward pool, alone or with --promote; no chained launch
|
|
1585
|
+
const grFlag = GRAD_FLAGS.find((f) => flag(f))
|
|
1586
|
+
if (grFlag && !tokenCreate) fail(`--${grFlag} only applies when creating a token (gang create --grad-reward <seed> …)`)
|
|
1587
|
+
if (tokenCreate && grFlag) {
|
|
1588
|
+
if (!flag('grad-reward')) fail(`--${grFlag} goes with --grad-reward <seed>`)
|
|
1589
|
+
if (flyCreate || flag('fair') || cmd === 'fair') fail(`--grad-reward rewards the last buys of a V3 curve: leave --${flyCreate ? 'fly' : 'fair'} out`)
|
|
1590
|
+
if (flag('base') || flag('vault')) fail(`--grad-reward and --${flag('base') ? 'base' : 'vault'} can't go together`)
|
|
1591
|
+
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')
|
|
1592
|
+
const launch = LAUNCH_FLAGS.find((f) => flag(f))
|
|
1593
|
+
if (launch) fail(`--${launch}: ${GRAD_ALONE}`)
|
|
1594
|
+
}
|
|
1549
1595
|
// gang weekly apply takes the same --description / --website / --twitter as a create (they describe the token to come)
|
|
1550
1596
|
const weeklyApply = cmd === 'weekly' && args[1] === 'apply'
|
|
1551
1597
|
for (const name of LINK_FLAGS) {
|
|
@@ -1618,6 +1664,8 @@ async function main() {
|
|
|
1618
1664
|
return runFloor(args[1], { opt, flag, out, fail, summarize: summarizePreview })
|
|
1619
1665
|
case 'base':
|
|
1620
1666
|
return runBase(args[1], { opt, flag, out, fail, summarize: summarizePreview })
|
|
1667
|
+
case 'grad-reward':
|
|
1668
|
+
return runGradReward(args[1], { opt, flag, out, fail, summarize: summarizePreview })
|
|
1621
1669
|
case 'weekly':
|
|
1622
1670
|
return runWeekly(args[1], { opt, flag, out, fail, resolveLogo: resolveLogoUri })
|
|
1623
1671
|
case 'capabilities':
|
|
@@ -1696,7 +1744,7 @@ async function main() {
|
|
|
1696
1744
|
return out({
|
|
1697
1745
|
success: true, link: `https://gang.fun/start?${q}`, referrer,
|
|
1698
1746
|
stats: r ? { invited: r.invited ?? 0, qualified: r.qualified ?? 0, thisWeek: r.thisWeek ?? null, byToken: r.byToken ?? [] } : null,
|
|
1699
|
-
note: 'A wallet\'s first Gang trade through this link is credited to the inviter (without a link, to the creator of the token it buys). Qualified = it traded again a day later, within 7 days.
|
|
1747
|
+
note: 'A wallet\'s first Gang trade through this link is credited to the inviter (without a link, to the creator of the token it buys). Qualified = it traded again a day later, within 7 days.',
|
|
1700
1748
|
...(!r && { statsNote: 'gang.fun has no invite stats for this wallet yet' }),
|
|
1701
1749
|
})
|
|
1702
1750
|
}
|
package/src/mcp.js
CHANGED
|
@@ -95,7 +95,7 @@ const tool = (name, title, description, properties, args, annotations, required
|
|
|
95
95
|
|
|
96
96
|
export const TOOLS = [
|
|
97
97
|
tool('gang_help', 'Commands and rules',
|
|
98
|
-
'Every gang command with all its flags (the CLI help) and the full rules. Read it before a create, launch, bond, buyback, split, lp, combo, capped, floor, mint or withdraw, and whenever a flag is unclear; those commands then go through gang_cli.',
|
|
98
|
+
'Every gang command with all its flags (the CLI help) and the full rules. Read it before a create, launch, bond, buyback, split, lp, combo, capped, floor, grad-reward, mint or withdraw, and whenever a flag is unclear; those commands then go through gang_cli.',
|
|
99
99
|
{}, () => [], READ),
|
|
100
100
|
tool('gang_preflight', 'Check wallet setup', 'Signed in to baw, Developer Mode, Trade all tokens, Agent ID; each issue comes with a fix.',
|
|
101
101
|
{}, () => ['preflight'], READ),
|
|
@@ -189,7 +189,7 @@ export const TOOLS = [
|
|
|
189
189
|
{ hash: HASH, pending: { type: 'boolean', description: 'Find the txs of trades approved in the Binance App (no hash needed)' }, testnet: TESTNET },
|
|
190
190
|
(a) => (a.pending ? ['tx', '--pending'] : ['tx', '--hash', a.hash, ...bool('testnet', a.testnet)]), PREVIEW),
|
|
191
191
|
tool('gang_cli', 'Other gang commands',
|
|
192
|
-
'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), creator-fee [--token] [--claim [--to]] (GangLaunchpad 2.0 / 3.0: 70% of the curve fee, kept for the creator), weekly [apply|withdraw] (the Gang weekly launch 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.',
|
|
192
|
+
'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), creator-fee [--token] [--claim [--to]] (GangLaunchpad 2.0 / 3.0: 70% of the curve fee, kept for the creator), weekly [apply|withdraw] (the Gang weekly launch 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.',
|
|
193
193
|
{ args: { type: 'array', items: { type: 'string' }, minItems: 1 } }, (a) => a.args, { readOnlyHint: false, destructiveHint: false, openWorldHint: true }, ['args']),
|
|
194
194
|
]
|
|
195
195
|
const BY_NAME = new Map(TOOLS.map((t) => [t.name, t]))
|
package/src/trending.js
CHANGED
|
@@ -16,7 +16,7 @@ import { noteRow } from './feed.js'
|
|
|
16
16
|
import { eventRow } from './weekly.js'
|
|
17
17
|
import { UA } from './version.js'
|
|
18
18
|
|
|
19
|
-
/** /trending's weekly launch rows (weekly.js), newest first: usually one, two
|
|
19
|
+
/** /trending's weekly launch rows (weekly.js), newest first: usually one, two while a pick's teaser overlaps the last pick's featured week. */
|
|
20
20
|
const events = (body) => (Array.isArray(body?.events) ? body.events : []).map(eventRow).filter(Boolean).slice(0, 3)
|
|
21
21
|
|
|
22
22
|
const CACHE = process.env.GANG_TRENDING_CACHE || join(homedir(), '.gang', 'trending.json')
|
|
@@ -95,7 +95,7 @@ export async function trending({ wallet = null } = {}) {
|
|
|
95
95
|
tokens: tokens.slice(0, 5).map(tokenRow),
|
|
96
96
|
calls: calls.slice(0, 3).map(noteRow),
|
|
97
97
|
// Gang's weekly launch event (weekly.js): shown first, with its own note; never thinned for a first trade (always V3)
|
|
98
|
-
//
|
|
98
|
+
// the next pick's teaser can run while the last pick's featured week ends: two rows then
|
|
99
99
|
...(events(body).length && { events: events(body) }),
|
|
100
100
|
...(left && { firstTrade: { flyLeftOut: left, note: FIRST_TRADE_NOTE } }),
|
|
101
101
|
}
|
package/src/v3.js
CHANGED
|
@@ -17,6 +17,7 @@ import { cappedOf, decoyWarning as cappedDecoyWarning } from './capped.js'
|
|
|
17
17
|
import { floorFactoryAddress, floorOf, floorShown, treasuryShare, typedFloorModule } from './floor.js'
|
|
18
18
|
import { VANITY_ABI, vanityCreate, vanityDeployer } from './vanity.js'
|
|
19
19
|
import { BASE_LOST, BASE_NO_BOND, BASE_PAD_ABI, baseOf as baseVaultView, basePayoff, baseSupport, baseTaxLine, HINTS as BASE_HINTS, parseBase, scheduleLine } from './base.js'
|
|
20
|
+
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'
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* `gang v3 …` — LaunchpadV3 (tax recipient): a token with its own buy / sell tax (1–5% each), a dividend share and a
|
|
@@ -163,7 +164,9 @@ const VIRTUAL_TOKEN = 1_066_666_666_666_666_666_666_666_667n
|
|
|
163
164
|
const ceilDiv = (a, b) => (a + b - 1n) / b
|
|
164
165
|
|
|
165
166
|
/** Revert name (+ BadTaxConfig reason) of a failed call, or null when it was the RPC. */
|
|
166
|
-
|
|
167
|
+
// the graduation reward's create errors (its claim errors share names with other contracts': not hinted here)
|
|
168
|
+
const { NothingToClaim: _gn, AlreadyClaimed: _ga, ...GRAD_CREATE_HINTS } = GRAD_HINTS
|
|
169
|
+
const revertOf = (e) => revertIn(e, [PAD_ABI, VANITY_ABI, BASE_PAD_ABI, PROMOTE_PAD_ABI, CREATOR_FEE_ABI, GRAD_TARGET_ABI, TAX_ROUTER_ABI, GANG_ROUTER_ABI, MERGED_ERRORS_ABI, GRAD_PAD_ABI], { BadPromoteTerms: PROMOTE_HINTS.BadPromoteTerms, TraderNotOrigin: PROMOTE_HINTS.TraderNotOrigin, ...MERGED_HINTS, ...ROUTER_HINTS, ...BASE_HINTS, ...GRAD_CREATE_HINTS, ...HINTS })
|
|
167
170
|
|
|
168
171
|
/** eth_call `data` from `from`: { result } when it passes, { failed } with the revert (or RPC error) otherwise. */
|
|
169
172
|
async function simulate(ctx, from, to, abi, functionName, args, value = 0n) {
|
|
@@ -401,13 +404,16 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
401
404
|
// 3.0: the opening base (gang create --base): the vault, its size, period and progress
|
|
402
405
|
const baseSeen = await baseVaultView(ctx, token).catch((e) => ({ raw: null, error: `could not read the token's base vault (${e.shortMessage || e.message.split('\n')[0]})`, retry: `gang base status --token ${token}${net}` }))
|
|
403
406
|
const { raw: _baseRaw, ...baseField } = baseSeen ?? {}
|
|
407
|
+
// 3.0: the graduation reward (gang create --grad-reward): the pool, the rules and the list so far
|
|
408
|
+
const grSeen = await gradOf(ctx, token, c.quote).catch((e) => ({ raw: null, error: `could not read the token's graduation reward (${e.shortMessage || e.message.split('\n')[0]})` }))
|
|
409
|
+
const { raw: _grRaw, ...grField } = grSeen ?? {}
|
|
404
410
|
// 3.0: the rule set the token was created under (fixed for good; an upgrade adds rules for new tokens only)
|
|
405
411
|
const tokenVersion = ctx.gen === PAD3_GEN ? await ctx.read(ctx.pad, PAD_ABI, 'tokenVersionOf', [token]).then(Number).catch(() => null) : null
|
|
406
412
|
const nonWbnb = c.quote.toLowerCase() !== String(ctx.wbnb).toLowerCase()
|
|
407
413
|
const graduationNote = c.graduationTargetBnb != null && !c.graduated
|
|
408
414
|
? gradLine(c.graduationTargetBnb, nonWbnb ? `${c.graduationAt} ${c.quoteSymbol || 'of the quote'}` : null) : null
|
|
409
415
|
return out({
|
|
410
|
-
success: true, chainId: Number(ctx.chainId), ...fees, ...pub, ...gen, ...(promote && { promote }), ...(baseSeen && { base: { ...baseField, ...(!baseField.error && { more: `gang base status --token ${token}${net}` }) } }), ...(tokenVersion != null && { tokenVersion }), ...(vault && { vault }), ...(graduationNote && { graduationNote }), taxNote, ...(swapBack && { swapBack }), ...(buyback && { buyback }),
|
|
416
|
+
success: true, chainId: Number(ctx.chainId), ...fees, ...pub, ...gen, ...(promote && { promote }), ...(baseSeen && { base: { ...baseField, ...(!baseField.error && { more: `gang base status --token ${token}${net}` }) } }), ...(grSeen && { gradReward: { ...grField, more: `gang grad-reward status --token ${token}${net}` } }), ...(tokenVersion != null && { tokenVersion }), ...(vault && { vault }), ...(graduationNote && { graduationNote }), taxNote, ...(swapBack && { swapBack }), ...(buyback && { buyback }),
|
|
411
417
|
...(split && { split: { ...split, ...splitWarn } }), ...(lp && { lp: { ...lp, ...lpWarn } }),
|
|
412
418
|
...(combo && { combo: { ...combo, ...(comboWarning && { warning: comboWarning }) } }),
|
|
413
419
|
...(capped && { capped: { ...capped, ...(cappedWarning && { warning: cappedWarning }) } }),
|
|
@@ -515,6 +521,20 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
515
521
|
if (flag('ref-pool')) fail('--base is for WBNB-quoted tokens only: leave --ref-pool out')
|
|
516
522
|
if (flag('dividend') && !/^0+(\.0+)?$/.test(opt('dividend') ?? '')) fail('--base can\'t go with a dividend: a base token takes --dividend 0 (the vault would take a share of the holders\' dividend)', { got: opt('dividend') })
|
|
517
523
|
}
|
|
524
|
+
// --grad-reward: a reward pool you seed for the last buys before graduation (createWithGradReward, 3.0 once
|
|
525
|
+
// upgraded), in the token's quote. With --promote (its share rides in the same create); alone otherwise
|
|
526
|
+
const grFlag = GRAD_FLAGS.find((f) => flag(f))
|
|
527
|
+
if (grFlag && !flag('grad-reward')) fail(`--${grFlag} goes with --grad-reward <seed>`)
|
|
528
|
+
const gr = flag('grad-reward') ? parseGradReward(opt, flag) : null
|
|
529
|
+
if (gr?.error) {
|
|
530
|
+
const { error, ...extra } = gr
|
|
531
|
+
fail(error, extra)
|
|
532
|
+
}
|
|
533
|
+
if (gr) {
|
|
534
|
+
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)')
|
|
535
|
+
if (base) fail('--grad-reward and --base can\'t go together (one create entry each)')
|
|
536
|
+
if (launchFloor || launchPoolModule) fail('--grad-reward goes on a plain create only: no chained launch')
|
|
537
|
+
}
|
|
518
538
|
if (grad !== null && !(grad > 0)) fail('--grad must be the graduation target in BNB raised: 6, 9, 12 or 15', { got: opt('grad') ?? null })
|
|
519
539
|
const buyTax = taxed ? taxOf('buy-tax') : 0
|
|
520
540
|
const sellTax = taxed ? taxOf('sell-tax') : 0
|
|
@@ -571,6 +591,11 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
571
591
|
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' })
|
|
572
592
|
if (!support.open) fail(`${support.why}: drop --base${testnet ? '' : ' (it is on the BSC testnet: --testnet)'}`, { pad: ctx.pad })
|
|
573
593
|
}
|
|
594
|
+
if (gr) {
|
|
595
|
+
const support = await gradSupport(ctx)
|
|
596
|
+
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' })
|
|
597
|
+
if (!support.open) fail(`${support.why}: drop --grad-reward${testnet ? '' : ' (it is on the BSC testnet: --testnet)'}`, { pad: ctx.pad })
|
|
598
|
+
}
|
|
574
599
|
// the recipient may be the creator itself: checkTaxConfigFor knows who creates (a pad without it: checkTaxConfig)
|
|
575
600
|
const [ok, reason] = await ctx.read(ctx.pad, PAD_ABI, 'checkTaxConfigFor', [me, tax]).catch((e) => {
|
|
576
601
|
if (!noSuchFunction(e)) throw e
|
|
@@ -621,13 +646,37 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
621
646
|
fail(`not enough BNB for the base: the create pays exactly ${formatUnits(baseCost, 18)} BNB, plus gas`, { wallet: me, haveBnb: formatUnits(native, 18), needBnb: formatUnits(baseCost, 18) })
|
|
622
647
|
}
|
|
623
648
|
}
|
|
624
|
-
//
|
|
625
|
-
|
|
649
|
+
// --grad-reward: the seed and the minimum buy in the quote (the minimum's default and the seed's floor are BNB
|
|
650
|
+
// amounts at the rate the graduation amount fixes); the seed is pulled in the create, so it is approved first
|
|
651
|
+
let grCfg = null, grView = null
|
|
652
|
+
if (gr) {
|
|
653
|
+
const dec = await decimalsOf(ctx, quote)
|
|
654
|
+
const sym = (await symbolOf(ctx, quote)) || 'of the quote'
|
|
655
|
+
const seedRaw = parseUnits(gr.seed, dec)
|
|
656
|
+
const minBuyRaw = gr.minBuy ? parseUnits(gr.minBuy, dec) : bnbInQuote(DEFAULT_MIN_BUY_BNB, gradAmt, targetBnb)
|
|
657
|
+
const seedFloor = bnbInQuote(MIN_SEED_BNB, gradAmt, targetBnb)
|
|
658
|
+
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 })
|
|
659
|
+
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 })
|
|
660
|
+
grCfg = {
|
|
661
|
+
seed: seedRaw, minBuy: minBuyRaw, entries: gr.entries, lastBps: gr.lastBps, carryBps: 0, refundAfter: gr.refundDays * 86_400,
|
|
662
|
+
promoteBps: promote?.shareBps ?? 0, promoteWindow: promote?.window ?? 0,
|
|
663
|
+
}
|
|
664
|
+
grView = gradCreateView({
|
|
665
|
+
seed: await units(ctx, quote, seedRaw), minBuy: await units(ctx, quote, minBuyRaw), sym, entries: gr.entries, lastBps: gr.lastBps,
|
|
666
|
+
refundDays: gr.refundDays, targetBnb, gateOn: await ctx.read(ctx.pad, GRAD_PAD_ABI, 'agentGateEnabled'),
|
|
667
|
+
...(!gr.minBuy && { seedFloorNote: `--gr-min-buy left out: ${DEFAULT_MIN_BUY_BNB} BNB at this token's rate` }),
|
|
668
|
+
})
|
|
669
|
+
const pre = await fundingStep(ctx, me, quote, seedRaw, sym, 'approve-quote', rawOnly, summarize)
|
|
670
|
+
if (pre) return out(pre.success ? { ...pre, why: `the create pulls the ${grView.pool} reward pool from this wallet` } : pre)
|
|
671
|
+
}
|
|
672
|
+
// createWithVault, createWithPromote, createWithBase and createWithGradReward always take the target (the pad's
|
|
673
|
+
// default when --grad is left out)
|
|
674
|
+
const fn = base ? 'createWithBase' : gr ? 'createWithGradReward' : vault ? 'createWithVault' : promote ? 'createWithPromote' : grad !== null ? 'createWithGradTarget' : 'create'
|
|
626
675
|
const argsOf = (logoURI, metaURI) => (base
|
|
627
676
|
? [name, symbol, logoURI, metaURI, tax, parseUnits(String(targetBnb), 18), { baseBps: base.baseBps, vestDays: base.vestDays }]
|
|
628
677
|
: [name, symbol, logoURI, metaURI, quote, refPool, tax,
|
|
629
|
-
...(vault ? [parseUnits(String(targetBnb), 18), vault] : promote ? [parseUnits(String(targetBnb), 18), promote.shareBps, promote.window] : grad !== null ? [parseUnits(String(grad), 18)] : [])])
|
|
630
|
-
const createAbi = base ? BASE_PAD_ABI : PAD_ABI
|
|
678
|
+
...(gr ? [parseUnits(String(targetBnb), 18), grCfg] : vault ? [parseUnits(String(targetBnb), 18), vault] : promote ? [parseUnits(String(targetBnb), 18), promote.shareBps, promote.window] : grad !== null ? [parseUnits(String(grad), 18)] : [])])
|
|
679
|
+
const createAbi = base ? BASE_PAD_ABI : gr ? GRAD_PAD_ABI : PAD_ABI
|
|
631
680
|
const createData = (logoURI, metaURI) => encodeFunctionData({ abi: createAbi, functionName: fn, args: argsOf(logoURI, metaURI) })
|
|
632
681
|
const vanity = await vanityDeployer(ctx)
|
|
633
682
|
const handler = vanity && taxed ? (await taxContracts(ctx)).handler : zeroAddress
|
|
@@ -705,6 +754,7 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
705
754
|
},
|
|
706
755
|
}),
|
|
707
756
|
...(base && { base: baseView }),
|
|
757
|
+
...(grView && { gradReward: grView }),
|
|
708
758
|
...(vault && {
|
|
709
759
|
padGen: ctx.gen, pad: ctx.pad, vault,
|
|
710
760
|
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',
|
|
@@ -752,9 +802,20 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
752
802
|
: `the 1% wallet cap leaves this wallet room for ${formatUnits(tokensOut, 18)} more tokens only`
|
|
753
803
|
return { spent: s, refund: r, cutBy: cut, cutNote: `${why}: the buy spends ${s} ${c.quoteSymbol} (fee included) and refunds ${r} ${refundAs}` }
|
|
754
804
|
}
|
|
805
|
+
// the token's buy-time rewards (3.0): what this buy means for each, one key per kind
|
|
806
|
+
const rewardsOf = async (tokensOut) => {
|
|
807
|
+
const { spent, cut } = await spentFor(ctx, c, quoteIn, tokensOut, room)
|
|
808
|
+
// the pad graduates the token once the curve holds its graduation amount (realQuote >= gradAmt): a buy whose net
|
|
809
|
+
// reaches what is left graduates it, cut or not
|
|
810
|
+
const feeBps = BigInt(Math.round((await feesOf(ctx)).curveFeePct * 100))
|
|
811
|
+
const graduates = cut === 'graduation' || spent - (spent * feeBps) / 10_000n >= c.curveRaw.remaining
|
|
812
|
+
const gradReward = await gradBuyLine(ctx, token, c.quote, c.quoteSymbol, me, spent, graduates)
|
|
813
|
+
return gradReward ? { rewards: { gradReward } } : {}
|
|
814
|
+
}
|
|
755
815
|
const extra = async (tokensOut, minOut, refundAs = c.quoteSymbol) => ({
|
|
756
816
|
step: 'buy', chainId: Number(ctx.chainId), token, spend: raw, quote: c.quoteSymbol, expectTokens: formatUnits(tokensOut, 18),
|
|
757
817
|
minTokensOut: formatUnits(minOut, 18), ...(await cutOf(tokensOut, refundAs)), curveTaxPct: 0, ...(c.buyTaxPct > 0 && { poolBuyTaxPct: c.buyTaxPct }),
|
|
818
|
+
...(await rewardsOf(tokensOut)),
|
|
758
819
|
})
|
|
759
820
|
// a follow on a token with promoter terms binds the note's author as this wallet's promoter (spec
|
|
760
821
|
// docs/SPEC-AGENT-CALLS-2026-11-09.md §4), when the pad would bind them; --no-promoter keeps it a plain buy
|
|
@@ -873,6 +934,8 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
873
934
|
}
|
|
874
935
|
const pre = await fundingStep(ctx, me, token, amount, c.quoteSymbol, 'approve', rawOnly, summarize)
|
|
875
936
|
if (pre) return out(pre.success ? { ...pre, ...notes.skipped() } : pre)
|
|
937
|
+
// a graduation reward: this sell takes the seller's entries in its list out
|
|
938
|
+
const grSell = await gradSellLine(ctx, token, c.quote, c.quoteSymbol, me)
|
|
876
939
|
const sim = await simulate(ctx, me, ctx.pad, PAD_ABI, 'sell', [token, amount, 0n])
|
|
877
940
|
if (sim.failed) return out({ success: false, step: 'sell', ...sim.failed })
|
|
878
941
|
const minOut = minOf(sim.result, slippage)
|
|
@@ -880,7 +943,7 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
880
943
|
step: 'sell', chainId: Number(ctx.chainId), token, amount: formatUnits(amount, 18), quote: c.quoteSymbol,
|
|
881
944
|
expectOut: await units(ctx, c.quote, sim.result), minOut: await units(ctx, c.quote, minOut), curveTaxPct: 0,
|
|
882
945
|
...(c.sellTaxPct > 0 && { poolSellTaxPct: c.sellTaxPct }),
|
|
883
|
-
curveFeePct: (await feesOf(ctx)).curveFeePct, ...guard?.info, ...callGuard?.info,
|
|
946
|
+
curveFeePct: (await feesOf(ctx)).curveFeePct, ...guard?.info, ...callGuard?.info, ...(grSell && { rewards: { gradReward: grSell } }),
|
|
884
947
|
note: 'expectOut is after the 1% curve fee only (no tax on the curve; the sell tax applies only in the pool after graduation)',
|
|
885
948
|
}, 'sell'))
|
|
886
949
|
}
|
package/src/weekly.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `gang weekly`: Gang's weekly launch event (gang.fun/weekly).
|
|
3
|
-
*
|
|
2
|
+
* `gang weekly`: Gang's weekly launch event (gang.fun/weekly). The team picks an application; the pick launches on
|
|
3
|
+
* GangLaunchpad 3.0 (V3 curve) at the issue's launch time from the wallet that applied, and is featured for 7 days: on the
|
|
4
4
|
* gang.fun homepage, in gang.fun's X / TG posts and in the `events` rows of `gang trending` / `preflight` / `list`. An
|
|
5
5
|
* official event: being picked is not an endorsement or investment advice.
|
|
6
6
|
*
|
|
7
|
+
* Two modes, from GET /api/weekly:
|
|
8
|
+
* - the weekly cadence (`hold` false or absent): applications close Thursday, the pick launches Friday 20:00 UTC+8;
|
|
9
|
+
* - hold (`hold: true`, or an open `apply` with a null closesAt or launchAt): an open application pool with no closing
|
|
10
|
+
* date and no launch time. The team selects from it and contacts the pick; the launch time is announced on
|
|
11
|
+
* gang.fun/weekly. Nothing printed then names a day, a time or a cadence.
|
|
12
|
+
*
|
|
7
13
|
* gang weekly the issue open for applications, the current pick, past issues, my application
|
|
8
14
|
* gang weekly apply … preview the application; with --yes sign it with the Agent wallet and submit it
|
|
9
15
|
* gang weekly withdraw [--yes] withdraw my application while applications are open
|
|
@@ -36,6 +42,19 @@ const SIGN_TTL_S = 30 * 60 // the signature's expires: the server takes up to 1
|
|
|
36
42
|
const ISSUE_RE = /^\d{4}-\d{2}-\d{2}$/
|
|
37
43
|
const POST_TIMEOUT_MS = 20_000
|
|
38
44
|
|
|
45
|
+
/** Hold mode: the server says so, or the open issue has no closing date or no launch time (see the header). */
|
|
46
|
+
export function isHold(b) {
|
|
47
|
+
if (!b || typeof b !== 'object') return false
|
|
48
|
+
if (b.hold === true || b.apply?.hold === true) return true
|
|
49
|
+
// an open issue without a closing date or a launch time has no Thursday / Friday to name, whatever `hold` says
|
|
50
|
+
const a = b.apply
|
|
51
|
+
return !!(a && a.open && (!(a.closesAt > 0) || !(a.launchAt > 0)))
|
|
52
|
+
}
|
|
53
|
+
export const HOLD_NOTE = 'Applications stay open with no closing date, and no launch time is set yet. The team selects from the applications and contacts the pick; the launch time is announced on gang.fun/weekly. Teams can also launch on Gang any time on their own schedule (gang create).'
|
|
54
|
+
export const HOLD_TERM_LAUNCH = (pad, w, symbol) =>
|
|
55
|
+
`If picked, the launch time is arranged with the gang.fun team and announced on gang.fun/weekly; launch it then with gang create (a V3 curve token on ${pad}, not --fair / --fly) from ${w} with symbol ${symbol}.`
|
|
56
|
+
export const HOLD_SUBMITTED = 'Submitted. Applications stay open: the team selects from the open pool and contacts the pick, and the launch time is announced on gang.fun/weekly. gang weekly lists it under mine, with its status.'
|
|
57
|
+
|
|
39
58
|
/** JSON with object keys sorted at every level, arrays in order, no whitespace: what the digest hashes (server does the same). */
|
|
40
59
|
export function canonical(v) {
|
|
41
60
|
if (Array.isArray(v)) return `[${v.map(canonical).join(',')}]`
|
|
@@ -172,6 +191,7 @@ export function eventRow(e) {
|
|
|
172
191
|
name: e.name ?? null, symbol: e.symbol ?? null, creatorHandle: e.creatorHandle ?? null,
|
|
173
192
|
launchAt: e.launchAt ?? null, until: e.until ?? null,
|
|
174
193
|
token: /^0x[0-9a-fA-F]{40}$/.test(e.token?.address ?? '') ? { address: e.token.address, symbol: e.token.symbol ?? e.symbol ?? null, progressPct: e.token.progressPct ?? null } : null,
|
|
194
|
+
...(e.hold === true && { hold: true }),
|
|
175
195
|
url: WEEKLY_URL, note: WEEKLY_NOTE,
|
|
176
196
|
})
|
|
177
197
|
}
|
|
@@ -216,7 +236,7 @@ export async function runWeekly(sub, { opt, flag, out, fail, resolveLogo }) {
|
|
|
216
236
|
}
|
|
217
237
|
const issueOf = (b) => {
|
|
218
238
|
const i = flag('issue') ? opt('issue') : b.apply?.issue
|
|
219
|
-
if (!i || !ISSUE_RE.test(i)) fail('--issue takes the issue\'s
|
|
239
|
+
if (!i || !ISSUE_RE.test(i)) fail('--issue takes the issue\'s date (YYYY-MM-DD), e.g. 2026-11-13', { got: i ?? null })
|
|
220
240
|
return i
|
|
221
241
|
}
|
|
222
242
|
const mine = async (issue, w) => {
|
|
@@ -237,6 +257,7 @@ export async function runWeekly(sub, { opt, flag, out, fail, resolveLogo }) {
|
|
|
237
257
|
}
|
|
238
258
|
// my applications: the open issue's, the week before it (closed, being picked: the previous pick may still be the
|
|
239
259
|
// featured `current` then) and current's, newest first
|
|
260
|
+
const hold = isHold(b)
|
|
240
261
|
const live = Array.isArray(b.live) ? b.live : b.current && ['teaser', 'launching', 'featured'].includes(b.current.status) ? [b.current] : []
|
|
241
262
|
const issues = [...new Set([b.apply?.issue, weekBefore(b.apply?.issue), b.current?.issue, ...live.map((v) => v?.issue)].filter((i) => ISSUE_RE.test(i ?? '')))]
|
|
242
263
|
.sort().reverse()
|
|
@@ -244,9 +265,10 @@ export async function runWeekly(sub, { opt, flag, out, fail, resolveLogo }) {
|
|
|
244
265
|
return out({
|
|
245
266
|
success: true,
|
|
246
267
|
// live: every issue in teaser / launching / featured, newest first (two from Thursday 20:00 until the last pick's week ends)
|
|
247
|
-
|
|
268
|
+
...(hold && { hold: true }),
|
|
269
|
+
apply: hold && b.apply ? { ...withTimes(b.apply), hold: true } : withTimes(b.apply), current: withTimes(b.current), live: live.map(withTimes), past: (b.past || []).map(withTimes), rules: b.rules ?? null,
|
|
248
270
|
...(me && { mine: mineRows }),
|
|
249
|
-
url: WEEKLY_URL, note: WEEKLY_NOTE,
|
|
271
|
+
url: WEEKLY_URL, note: WEEKLY_NOTE, ...(hold && { holdNote: HOLD_NOTE }),
|
|
250
272
|
next: b.apply?.open ? 'gang weekly apply --name … --symbol … --logo ./logo.png --description "…" --contact @you (preview; add --yes to sign and submit)' : null,
|
|
251
273
|
})
|
|
252
274
|
}
|
|
@@ -276,21 +298,28 @@ export async function runWeekly(sub, { opt, flag, out, fail, resolveLogo }) {
|
|
|
276
298
|
}
|
|
277
299
|
const b = await board()
|
|
278
300
|
const issue = issueOf(b)
|
|
301
|
+
const hold = isHold(b)
|
|
279
302
|
const open = b.apply?.issue === issue && b.apply.open
|
|
280
|
-
if (!open)
|
|
303
|
+
if (!open) {
|
|
304
|
+
const next = !b.apply?.issue ? ''
|
|
305
|
+
: hold || !(b.apply.closesAt > 0) ? ` (open: ${b.apply.issue}${b.apply.open ? ', no closing date' : b.apply.opensAt > 0 ? `, from ${localTime(b.apply.opensAt)}` : ''})`
|
|
306
|
+
: ` (open next: ${b.apply.issue}, ${localTime(b.apply.opensAt)} – ${localTime(b.apply.closesAt)})`
|
|
307
|
+
fail(`applications for ${issue} are not open${next}`, { apply: withTimes(b.apply) })
|
|
308
|
+
}
|
|
281
309
|
if (!signedIn()) fail(SIGN_IN)
|
|
282
310
|
// gang.fun refuses a wallet without an Agent ID (no_agent_id); the create gate checks it again at launch
|
|
283
311
|
const w = wallet()
|
|
284
312
|
const rules = b.rules ?? {}
|
|
313
|
+
const pad = rules.pad || 'GangLaunchpad 3.0'
|
|
285
314
|
const terms = [
|
|
286
|
-
`If picked, launch it with gang create (a V3 curve token on ${
|
|
315
|
+
hold ? HOLD_TERM_LAUNCH(pad, w, fields.symbol) : `If picked, launch it with gang create (a V3 curve token on ${pad}, not --fair / --fly) from ${w} with symbol ${fields.symbol} at ${localTime(b.apply.launchAt) ?? 'Friday 20:00 UTC+8'}.`,
|
|
287
316
|
`The pin is withdrawn early if the creator sells more than ${((rules.revokeSellBps ?? 2000) / 100).toFixed(0)}% of their holding during the 7-day featured week.`,
|
|
288
317
|
'If picked: a gang.fun homepage card, X / TG posts and the first row of gang trending for the featured week.',
|
|
289
318
|
'Only the gang.fun team sees contact; everything else may be shown publicly once picked.',
|
|
290
319
|
]
|
|
291
320
|
if (!flag('yes')) {
|
|
292
321
|
return out({
|
|
293
|
-
success: true, preview: true, issue, number: b.apply.number ?? null,
|
|
322
|
+
success: true, preview: true, issue, number: b.apply.number ?? null, ...(hold && { hold: true }),
|
|
294
323
|
// what --yes signs and sends, but the logo: a local file / another host's image becomes ipfs://<cid> on upload
|
|
295
324
|
application: { issue, wallet: w.toLowerCase(), ...fields, logo: ipfsCid(logoArg) ? ipfsUri(ipfsCid(logoArg)) : logoArg },
|
|
296
325
|
...(!ipfsCid(logoArg) && { logoNote: `${files.length ? 'the file' : 'the image'} is uploaded to gang.fun with --yes; the application carries its ipfs://<cid>` }),
|
|
@@ -312,7 +341,8 @@ export async function runWeekly(sub, { opt, flag, out, fail, resolveLogo }) {
|
|
|
312
341
|
return out({
|
|
313
342
|
success: true, issue, status: r.status ?? 'pending', replaced: !!r.replaced, application,
|
|
314
343
|
...(logo.uploaded && { logoUploaded: logo.upload?.url ?? true }),
|
|
315
|
-
|
|
344
|
+
...(hold && { hold: true }),
|
|
345
|
+
note: hold ? HOLD_SUBMITTED : `Submitted. The team picks one application on ${b.apply.launchAt > 0 ? localTime(b.apply.launchAt - 32 * 3600) : 'Thursday 12:00 UTC+8'} and contacts the pick; the pick goes public 24 hours before the launch. gang weekly lists it under mine, with its status.`,
|
|
316
346
|
url: WEEKLY_URL,
|
|
317
347
|
})
|
|
318
348
|
}
|