@gangfun/cli 0.21.0 → 0.22.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 +7 -2
- package/README.zh-CN.md +7 -2
- package/package.json +1 -1
- package/src/combo.js +605 -0
- package/src/index.js +58 -11
- package/src/launch.js +121 -22
- package/src/mcp.js +4 -4
- package/src/v3.js +7 -0
package/README.md
CHANGED
|
@@ -14,6 +14,8 @@ Operate [gang.fun](https://gang.fun) from a Binance **Agentic Wallet**. Curve bu
|
|
|
14
14
|
|
|
15
15
|
**Auto-liquidity recipient (0.20.0+):** `gang create … --buy-tax … --sell-tax … --lp 70 [--lp-to 0x…]` makes a V3 token's tax recipient the dev's LP splitter (GangLiquiditySplitter, `lp-burn-v1`, the buy-back splitter's sibling): `--lp` % of the recipient's part of the tax is added to the token's PancakeSwap pair as liquidity whose LP goes to 0xdead (locked for good), the rest goes to the dev or `--lp-to`. After graduation the keeper adds it in chunks (half buys the token, all of it goes back in with the matching quote; one per 4 minutes). The ratio and payee change as for `--buyback` (a raise at once, a cut after a 3-day notice; the payee at once). Same quotes as `--buyback` / `--split`. `gang lp …` shows and drives it. Live on BSC mainnet (factory `0xE0436867dAFcf42Ee1418083251a9B8B61F0C248`, allowed by the platform's Safe on 2026-10-31, built in) and testnet set 10 (factory `0xA729C60FCa0Bd0D28a55E22126D3fE412AA41591`).
|
|
16
16
|
|
|
17
|
+
**Combined recipient (0.22.0+):** two or three of `--buyback`, `--lp`, `--split` on one taxed launch make a V3 token's tax recipient one GangComboSplitter (`combo-v1`): `gang create … --buy-tax 3 --sell-tax 3 --buyback 30 --lp 30 --split self:70,0x…:30` buys back and burns 30% of the recipient's part, adds 30% to the pair as liquidity (LP to 0xdead) and pushes the rest (40%) to the payees, whose `--split` shares are of that rest (here 28% / 12% of the recipient's part); without `--split` the rest goes to the dev, and `--buyback` + `--lp` = 100 takes no payees. **Everything is permanent**: the ratios, payees and shares can never change (unlike a lone `--buyback` / `--lp`, whose ratio the dev can change); a payee can only move its own slot. Any other asset sent to it: the buy-back + LP share to 0xdead, the rest to the payees. `--buyback-to` / `--lp-to` don't apply. One flag alone still uses its own module. `gang combo status|distribute|release|set-payee|bind|chunk` shows and drives it. On BSC mainnet (factory `0xd33C38BE3f8472b3013167830F0638C1704e1DBd`, deployed 2026-10-31, built in) and testnet set 10 (factory `0x52a8f90a92E5C1828b4436a0B99C6b293f7F4CFE`).
|
|
18
|
+
|
|
17
19
|
## Install
|
|
18
20
|
|
|
19
21
|
Node ≥ 18. Also install Binance Agentic Wallet CLI (`baw`):
|
|
@@ -112,6 +114,8 @@ gang create … --buy-tax 3 --sell-tax 3 --split self:60,0x…:30,0x…:10 [--de
|
|
|
112
114
|
gang split status|distribute|release|set-payee|bind --token 0x… [--asset 0x…] [--index <i>] [--to 0x…] # the split module: payees (slot --index from 0), what waits / is owed; split by hand; a payee moves its own slot
|
|
113
115
|
gang create … --buy-tax 3 --sell-tax 3 --lp 70 [--lp-to 0x…] [--dev-buy …] # V3: the recipient's part of the tax 70% added to the pool as liquidity (LP to 0xdead), the rest to you (or --lp-to)
|
|
114
116
|
gang lp status|set|set-payee|apply|bind|release|add --token 0x… [--pct 0-100] [--to 0x…] [--slippage 1] # the LP splitter: ratio, payee, what is set aside, the next chunk; add = one chunk now (anyone)
|
|
117
|
+
gang create … --buy-tax 3 --sell-tax 3 --buyback 30 --lp 30 [--split self:70,0x…:30] [--dev-buy …] # V3, combined recipient: 30% bought back + burned, 30% added as liquidity, the rest to the payees (shares of the rest; default you). PERMANENT
|
|
118
|
+
gang combo status|distribute|release|set-payee|bind|chunk --token 0x… [--asset 0x…] [--index <i>] [--to 0x…] [--slippage 1] # the combined recipient: ratios, payees, set aside, owed, the next chunk and the keeper's plan; chunk = one chunk now (anyone)
|
|
115
119
|
gang create --fair … [--shares <n>] --bond <quote> [--bond-hold …] --bond-days <7-90> # 打新: create (dev shares) → bond
|
|
116
120
|
gang execute --request-id <id>
|
|
117
121
|
gang tx --pending # trades approved in the Binance App: found by the exact call previewed, then as below
|
|
@@ -223,7 +227,7 @@ take MCP servers instead of a shell (Claude Desktop / Code, Cursor, …). Each t
|
|
|
223
227
|
|
|
224
228
|
| Tool | Runs |
|
|
225
229
|
|---|---|
|
|
226
|
-
| `gang_help` | this CLI's whole help (every command, every flag) and the full rules (0.17.2+): what an agent with no skill installed reads before a create, launch, bond, buyback, split, lp, mint or withdraw |
|
|
230
|
+
| `gang_help` | this CLI's whole help (every command, every flag) and the full rules (0.17.2+): what an agent with no skill installed reads before a create, launch, bond, buyback, split, lp, combo, mint or withdraw |
|
|
227
231
|
| `gang_preflight`, `gang_hot`, `gang_new`, `gang_near_grad`, `gang_info`, `gang_status`, `gang_portfolio`, `gang_notes`, `gang_agents` | the read commands of the same name (`gang_portfolio`: 0.17.6+) |
|
|
228
232
|
| `gang_tx` | `gang tx --hash …`: decode a tx, publish its queued note; `pending: true` = `gang tx --pending`, the trades approved in the Binance App (no hash needed) |
|
|
229
233
|
| `gang_watch` | `gang watch` until `maxEvents` (default 1) or `timeout` (default 50s, at most 30m): returns `{ events, meta }`, `timedOut: true` when nothing came; call it again to keep waiting |
|
|
@@ -288,8 +292,9 @@ timed-out `gang_execute`, check `gang_status` / the wallet history instead of ex
|
|
|
288
292
|
| `GANG_BOND` / `GANG_TESTNET_BOND` | GangBond (creator bonds, `gang bond`). Defaults: mainnet `0xe92d…14E4` (since 2026-10-29, CLI 0.16.2+), testnet `0xd6a8…1086` |
|
|
289
293
|
| `GANG_SPLIT_FACTORY` / `GANG_TESTNET_SPLIT_FACTORY` | GangSplitModuleFactory (`--split`). Defaults: mainnet `0x27e0…067c` (since 2026-10-30, CLI 0.19.0+), testnet set 10 `0x5F7d…567E` |
|
|
290
294
|
| `GANG_LP_FACTORY` / `GANG_TESTNET_LP_FACTORY` | GangLiquiditySplitterFactory (`--lp`). Defaults (CLI 0.20.0+): mainnet `0xE043…C248` (since 2026-10-31), testnet set 10 `0xA729…1591` |
|
|
295
|
+
| `GANG_COMBO_FACTORY` / `GANG_TESTNET_COMBO_FACTORY` | GangComboSplitterFactory (several of `--buyback` / `--lp` / `--split`). Defaults (CLI 0.22.0+): mainnet `0xd33C…1DBd` (since 2026-10-31), testnet set 10 `0x52a8…4CFE` |
|
|
291
296
|
| `GANG_ROUTER` / `GANG_TESTNET_ROUTER` | GangRouter proxy (native-BNB V3 buys / mints, and every PancakeSwap trade of a graduated token); old name `GANG_ROUTER_TESTNET` still works. Defaults: mainnet `0xE040…79C4`, testnet set 10 `0x6bB6…C9F6` |
|
|
292
297
|
|
|
293
298
|
## Version
|
|
294
299
|
|
|
295
|
-
`0.
|
|
300
|
+
`0.22.0` · repo [gangfun/cli](https://github.com/gangfun/cli) · published to [npm](https://www.npmjs.com/package/@gangfun/cli) on push to `main`
|
package/README.zh-CN.md
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
**自动加池子收款(0.20.0+):** `gang create … --buy-tax … --sell-tax … --lp 70 [--lp-to 0x…]` 把 V3 币的税收接收地址设成 dev 自己的加池合约(GangLiquiditySplitter,`lp-burn-v1`,和回购合约同一套规则):接收地址那份税的 `--lp`% 加进这个币的 PancakeSwap 池子做流动性,LP 打进 0xdead 永久锁定,其余给 dev(或 `--lp-to` 指定的地址)。毕业后由 keeper 分块加池(一半买币,买到的币全部连同对应的报价币放回池子;每 4 分钟最多一块)。比例和收款地址的改法同 `--buyback`(提高立即生效,下调 3 天公告后生效;收款地址立即生效)。报价币要求同 `--buyback` / `--split`。`gang lp …` 查看和操作。已在 BSC 主网(工厂 `0xE0436867dAFcf42Ee1418083251a9B8B61F0C248`,2026-10-31 平台多签已放行,已内置)和测试网第 10 套(工厂 `0xA729C60FCa0Bd0D28a55E22126D3fE412AA41591`)可用。
|
|
16
16
|
|
|
17
|
+
**组合收款(0.22.0+):** 一次有税发射里同时给 `--buyback`、`--lp`、`--split` 中的两个或三个,V3 币的税收接收地址就是一个组合合约(GangComboSplitter,`combo-v1`):`gang create … --buy-tax 3 --sell-tax 3 --buyback 30 --lp 30 --split self:70,0x…:30` 把接收地址那份税的 30% 回购销毁、30% 加进池子做流动性(LP 打进 0xdead),其余 40% 推给收款人;`--split` 的比例是「剩下那部分」的比例(这里分别是接收地址那份的 28% / 12%)。不给 `--split` 时剩下的全给 dev;`--buyback` + `--lp` = 100 时不能有收款人。**全部永久不可改**:比例、收款人和份额以后都不能改(不像单独的 `--buyback` / `--lp`,dev 可以调比例);收款人只能把自己那一份换到新地址。打进来的其他资产:回购 + 加池那部分比例打进 0xdead,其余给收款人。`--buyback-to` / `--lp-to` 不适用。只给一个参数时仍走各自的单独模块。`gang combo status|distribute|release|set-payee|bind|chunk` 查看和操作。已在 BSC 主网(工厂 `0xd33C38BE3f8472b3013167830F0638C1704e1DBd`,2026-10-31 部署,已内置)和测试网第 10 套(工厂 `0x52a8f90a92E5C1828b4436a0B99C6b293f7F4CFE`)可用。
|
|
18
|
+
|
|
17
19
|
## 安装
|
|
18
20
|
|
|
19
21
|
Node ≥ 18。另需 `baw`:
|
|
@@ -91,6 +93,8 @@ gang create … --buy-tax 3 --sell-tax 3 --split self:60,0x…:30,0x…:10 [--de
|
|
|
91
93
|
gang split status|distribute|release|set-payee|bind --token 0x… [--asset 0x…] [--index <i>] [--to 0x…] # 分账模块:名单(--index 从 0 开始)、待分和欠款;手动分账;收款人换自己的地址
|
|
92
94
|
gang create … --buy-tax 3 --sell-tax 3 --lp 70 [--lp-to 0x…] [--dev-buy …] # V3:接收地址那份税 70% 加进池子做流动性(LP 打进 0xdead),其余给你(或 --lp-to 指定的地址)
|
|
93
95
|
gang lp status|set|set-payee|apply|bind|release|add --token 0x… [--pct 0-100] [--to 0x…] [--slippage 1] # 加池合约:比例、收款地址、待加池金额、下一块;add = 现在手动加一块(任何人)
|
|
96
|
+
gang create … --buy-tax 3 --sell-tax 3 --buyback 30 --lp 30 [--split self:70,0x…:30] [--dev-buy …] # V3 组合收款:30% 回购销毁,30% 加池,其余给收款人(比例按剩下那部分算;默认给你)。永久不可改
|
|
97
|
+
gang combo status|distribute|release|set-payee|bind|chunk --token 0x… [--asset 0x…] [--index <i>] [--to 0x…] [--slippage 1] # 组合合约:比例、收款人、待回购 / 待加池、欠款、下一块和 keeper 的计划;chunk = 现在手动做一块(任何人)
|
|
94
98
|
gang create --fair … [--shares <n>] --bond <数量> [--bond-hold …] --bond-days <7-90> # 打新:发币(含 dev 份额)→ 押金
|
|
95
99
|
gang execute --request-id <id>
|
|
96
100
|
gang tx --pending # 在 Binance App 里批准过的交易:按预览时的调用自动找到交易,再按下面这条处理
|
|
@@ -199,7 +203,7 @@ gang agents --window 30d --sort follow
|
|
|
199
203
|
|
|
200
204
|
| 工具 | 对应 |
|
|
201
205
|
|---|---|
|
|
202
|
-
| `gang_help` | 本 CLI 的完整帮助(所有命令、所有参数)和完整规则(0.17.2+):没装 skill 的 Agent
|
|
206
|
+
| `gang_help` | 本 CLI 的完整帮助(所有命令、所有参数)和完整规则(0.17.2+):没装 skill 的 Agent 在发币、一条命令发射、押金、回购、分账、自动加池子、组合收款、打新认购 / 撤回之前先读它 |
|
|
203
207
|
| `gang_preflight`、`gang_hot`、`gang_new`、`gang_near_grad`、`gang_info`、`gang_status`、`gang_portfolio`、`gang_notes`、`gang_agents` | 同名的只读命令(`gang_portfolio`:0.17.6+) |
|
|
204
208
|
| `gang_tx` | `gang tx --hash …`:解码交易,发布排队中的想法;`pending: true` 即 `gang tx --pending`,找出在 Binance App 里批准过的交易(不用哈希) |
|
|
205
209
|
| `gang_watch` | `gang watch`,等到 `maxEvents`(默认 1)条或 `timeout`(默认 50s,最长 30m):返回 `{ events, meta }`,没等到时带 `timedOut: true`,再调一次接着等 |
|
|
@@ -252,8 +256,9 @@ Claude Code:`claude mcp add gang -- gang mcp`。同一台机器上 `baw` 要
|
|
|
252
256
|
| `GANG_BOND` / `GANG_TESTNET_BOND` | GangBond(押金承诺,`gang bond`)。默认:主网 `0xe92d…14E4`(2026-10-29 起,CLI 0.16.2+),测试网 `0xd6a8…1086` |
|
|
253
257
|
| `GANG_SPLIT_FACTORY` / `GANG_TESTNET_SPLIT_FACTORY` | GangSplitModuleFactory(`--split`)。默认:主网 `0x27e0…067c`(2026-10-30 起,CLI 0.19.0+),测试网第 10 套 `0x5F7d…567E` |
|
|
254
258
|
| `GANG_LP_FACTORY` / `GANG_TESTNET_LP_FACTORY` | GangLiquiditySplitterFactory(`--lp`)。默认(CLI 0.20.0+):主网 `0xE043…C248`(2026-10-31 起),测试网第 10 套 `0xA729…1591` |
|
|
259
|
+
| `GANG_COMBO_FACTORY` / `GANG_TESTNET_COMBO_FACTORY` | GangComboSplitterFactory(同时给 `--buyback` / `--lp` / `--split` 中的几个)。默认(CLI 0.22.0+):主网 `0xd33C…1DBd`(2026-10-31 起),测试网第 10 套 `0x52a8…4CFE` |
|
|
255
260
|
| `GANG_ROUTER` / `GANG_TESTNET_ROUTER` | GangRouter 代理(用原生 BNB 买 V3 / 打新,以及已毕业币的所有外盘买卖);旧名 `GANG_ROUTER_TESTNET` 仍可用。默认:主网 `0xE040…79C4`,测试网第 10 套 `0x6bB6…C9F6` |
|
|
256
261
|
|
|
257
262
|
## 版本
|
|
258
263
|
|
|
259
|
-
`0.
|
|
264
|
+
`0.22.0` · [gangfun/cli](https://github.com/gangfun/cli) · push 到 `main` 自动发布到 [npm](https://www.npmjs.com/package/@gangfun/cli)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gangfun/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"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.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
package/src/combo.js
ADDED
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
import { createPublicClient, parseAbi, encodeFunctionData, formatUnits, getAddress, hexToString, isAddress, maxUint128, maxUint256, parseUnits, zeroAddress } from 'viem'
|
|
2
|
+
import { padNets, NOT_ON_MAINNET, rpcTransport } from './gangpad.js'
|
|
3
|
+
import { walletFor } from './fair.js'
|
|
4
|
+
import { parseAmount, parseNum, revertOf as revertIn, step } from './steps.js'
|
|
5
|
+
import { parseSplitSpec } from './split.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `gang combo …` and `gang create … --buyback <pct> --lp <pct> [--split <addr>:<pct>,…]` (any two or three of them) —
|
|
9
|
+
* GangComboSplitter (组合:回购 + 加池 + 分账, `combo-v1`): one V3 token's tax recipient that does what the three
|
|
10
|
+
* single-purpose modules do, at once. Of each payment of the bound quote, `buybackBps` is set aside for buy-back-and-burn
|
|
11
|
+
* (GangBuybackSplitter v4's chunk), `lpBps` for liquidity whose LP goes to 0xdead (GangLiquiditySplitter's chunk), and the
|
|
12
|
+
* rest is pushed to 1–10 payees at fixed shares (GangSplitModule's push; none when buy-back + LP = 100%).
|
|
13
|
+
* EVERYTHING is fixed when it is cloned: nobody (not the dev, not the platform) can change the ratios, the payees or their
|
|
14
|
+
* shares — unlike a lone buy-back / LP splitter, whose dev can change its ratio. A payee can only move its own slot
|
|
15
|
+
* (`setPayee`). GangComboSplitterFactory clones one for the dev (`create(buybackBps, lpBps, payees, shares, salt)`, at
|
|
16
|
+
* `predict(dev, salt)`) and has GangHandlerAdmin list it, so the dev names it as the recipient at create (launch.js does
|
|
17
|
+
* the three steps: clone → create → bind, as for --buyback / --split / --lp).
|
|
18
|
+
* Chunks: one per 4 minutes for both kinds together, always of the larger set-aside part (`chunk`), ≤ 0.5% of the pair's
|
|
19
|
+
* quote reserve, none while the price is > 2% above the pair's 10-minute average. The keeper's `work(minOut)` does the one
|
|
20
|
+
* action `previewWork` planned, encoded in minOut's top byte (1 buy-back, 2 liquidity, 3 price observation, 4 split).
|
|
21
|
+
* Any other asset: the buy-back + LP share goes to 0xdead, the rest to the payees (`distribute(asset)`; NotBound before
|
|
22
|
+
* `bind`).
|
|
23
|
+
* Gas: a chunk takes ~0.55–0.75M, and a split pushes up to 10 payees, each needing ~365k gas left before it. The CLI never
|
|
24
|
+
* sets a gas limit: the wallet / node estimates it; a lower one reverts PushStarved (nothing moves) or the chunk.
|
|
25
|
+
* Env: GANG_COMBO_FACTORY / GANG_TESTNET_COMBO_FACTORY override the built-in factory addresses.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
// BSC 56: deployed 2026-10-31 (pad 0x15CF…4365); a clone reverts NotFactory until the platform's Safe allows the
|
|
29
|
+
// factory on GangHandlerAdmin
|
|
30
|
+
export const MAINNET_COMBO_FACTORY = '0xd33C38BE3f8472b3013167830F0638C1704e1DBd'
|
|
31
|
+
// BSC 97, set 10
|
|
32
|
+
export const TESTNET_COMBO_FACTORY = '0x52a8f90a92E5C1828b4436a0B99C6b293f7F4CFE'
|
|
33
|
+
export const COMBO_TYPE = 'combo-v1'
|
|
34
|
+
export const MAX_PAYEES = 10
|
|
35
|
+
const BPS = 10_000
|
|
36
|
+
const CHUNK_GAP_S = 4 * 60
|
|
37
|
+
|
|
38
|
+
/** previewWork's planned action, minOut's top byte (GangComboSplitter DO_*). */
|
|
39
|
+
export const WORK_ACTIONS = { 0: 'none', 1: 'buy-back', 2: 'liquidity', 3: 'observe', 4: 'split' }
|
|
40
|
+
const WORK_WHAT = {
|
|
41
|
+
none: 'nothing to do',
|
|
42
|
+
'buy-back': 'one buy-back chunk (buys the token in the pair and burns it at 0xdead)',
|
|
43
|
+
liquidity: 'one liquidity chunk (half buys the token, all of it goes back into the pair with the matching quote, LP to 0xdead)',
|
|
44
|
+
observe: 'a price observation (the 10-minute average a chunk needs)',
|
|
45
|
+
split: 'a split that pays the payees their part of the quote that arrived',
|
|
46
|
+
}
|
|
47
|
+
const LOW_248 = (1n << 248n) - 1n
|
|
48
|
+
|
|
49
|
+
/** previewWork's minOut → { code, action, minTokensOut (chunks only), what }. Pass minOut to work() as returned. */
|
|
50
|
+
export function decodeWorkPlan(minOut) {
|
|
51
|
+
const v = BigInt(minOut ?? 0n)
|
|
52
|
+
const code = Number(v >> 248n)
|
|
53
|
+
const action = WORK_ACTIONS[code] ?? `unknown (${code})`
|
|
54
|
+
const value = v & LOW_248
|
|
55
|
+
return {
|
|
56
|
+
code, action, ...((code === 1 || code === 2) && { minTokensOut: formatUnits(value, 18) }),
|
|
57
|
+
what: WORK_WHAT[action] ?? 'an action this CLI does not know',
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const ERRORS = [
|
|
62
|
+
'error ZeroAddress()', 'error NotClone()', 'error NotFactory()', 'error AlreadyInitialized()', 'error BadBps()',
|
|
63
|
+
'error BadPayees()', 'error BadShares()', 'error BadPayee()', 'error DuplicatePayee()', 'error BadIndex()',
|
|
64
|
+
'error NotPayee()', 'error AlreadyBound()', 'error NotBound()', 'error NotCurve()', 'error NotCreator()',
|
|
65
|
+
'error NotRecipient()', 'error NothingOwed()', 'error NothingToChunk()', 'error ChunkTooSoon()', 'error NotTradable()',
|
|
66
|
+
'error Slippage()', 'error PushStarved()',
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
export const COMBO_FACTORY_ABI = parseAbi([
|
|
70
|
+
'function create(uint16 buybackBps, uint16 lpBps, address[] payees, uint16[] shares, bytes32 salt) returns (address module)',
|
|
71
|
+
'function predict(address dev, bytes32 salt) view returns (address)',
|
|
72
|
+
'function pad() view returns (address)',
|
|
73
|
+
'error NotAgent()', 'error WrongHandler()',
|
|
74
|
+
'event Created(address indexed dev, address indexed module, uint16 buybackBps, uint16 lpBps, address[] payees, uint16[] shares)',
|
|
75
|
+
...ERRORS,
|
|
76
|
+
])
|
|
77
|
+
|
|
78
|
+
export const COMBO_ABI = parseAbi([
|
|
79
|
+
'function moduleType() view returns (bytes32)',
|
|
80
|
+
'function dev() view returns (address)',
|
|
81
|
+
'function token() view returns (address)',
|
|
82
|
+
'function quote() view returns (address)',
|
|
83
|
+
'function pair() view returns (address)',
|
|
84
|
+
'function gangQuote() view returns (address)',
|
|
85
|
+
'function buybackBps() view returns (uint16)',
|
|
86
|
+
'function lpBps() view returns (uint16)',
|
|
87
|
+
'function payeesOf() view returns (address[] payees, uint16[] shares)',
|
|
88
|
+
'function buybackLeft() view returns (uint256)',
|
|
89
|
+
'function lpLeft() view returns (uint256)',
|
|
90
|
+
'function owedOf(address asset, uint256 index) view returns (uint256)',
|
|
91
|
+
'function owedTotal(address asset) view returns (uint256)',
|
|
92
|
+
'function unsplit() view returns (uint256)',
|
|
93
|
+
'function undistributed(address asset) view returns (uint256)',
|
|
94
|
+
'function keeperServes(address q) view returns (bool)',
|
|
95
|
+
'function previewChunk() view returns (bool ready, bool burn, uint256 amount, uint256 tokensOut)',
|
|
96
|
+
'function previewWork() view returns (bool due, uint256 minOut)',
|
|
97
|
+
'function lastChunkAt() view returns (uint64)',
|
|
98
|
+
'function lastPaidAt() view returns (uint64)',
|
|
99
|
+
'function bind(address token)',
|
|
100
|
+
'function split()',
|
|
101
|
+
'function distribute(address asset) returns (uint256 incoming)',
|
|
102
|
+
'function release(address asset, uint256 index, uint256 maxAmount) returns (uint256 amount)',
|
|
103
|
+
'function setPayee(uint256 index, address newPayee)',
|
|
104
|
+
'function chunk(uint256 minTokensOut) returns (bool burn, uint256 quoteIn, uint256 tokensOut, uint256 liquidity)',
|
|
105
|
+
'function work(uint256 minOut)',
|
|
106
|
+
'event Bound(address indexed token, address indexed quote)',
|
|
107
|
+
'event Split(uint256 incoming, uint256 toBuyback, uint256 toLp, uint256 toPayees)',
|
|
108
|
+
'event Distributed(address indexed asset, uint256 incoming, uint256 toDead)',
|
|
109
|
+
'event PayeeOwed(address indexed asset, uint256 indexed index, uint256 amount)',
|
|
110
|
+
'event PayeeReleased(address indexed asset, uint256 indexed index, uint256 amount)',
|
|
111
|
+
'event PayeeChanged(uint256 indexed index, address indexed oldPayee, address indexed newPayee)',
|
|
112
|
+
'event Shortfall(address indexed asset, uint256 amount)',
|
|
113
|
+
'event BoughtBack(uint256 quoteIn, uint256 burned, uint256 left)',
|
|
114
|
+
'event LiquidityAdded(uint256 quoteIn, uint256 tokensIn, uint256 liquidity, uint256 left)',
|
|
115
|
+
...ERRORS,
|
|
116
|
+
])
|
|
117
|
+
/** gang tx decodes these (the factory's Created and the module's events). */
|
|
118
|
+
export const COMBO_EVENT_ABIS = [COMBO_FACTORY_ABI, COMBO_ABI]
|
|
119
|
+
|
|
120
|
+
const PAD_ABI = parseAbi([
|
|
121
|
+
'function taxConfigOf(address token) view returns (uint16 buyTaxBps, uint16 sellTaxBps, uint16 dividendBps, address recipient)',
|
|
122
|
+
'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)',
|
|
123
|
+
])
|
|
124
|
+
const ERC20_ABI = parseAbi(['function symbol() view returns (string)', 'function decimals() view returns (uint8)'])
|
|
125
|
+
|
|
126
|
+
export const COMBO_GAS_NOTE = 'let the wallet estimate the gas limit (eth_estimateGas) and do not set or lower it: a chunk takes about 0.55–0.75M gas, and a split pushes up to 10 payees, each needing about 365k gas left before it, so the limit is far above the gas used; a lower limit reverts (PushStarved: nothing moves)'
|
|
127
|
+
|
|
128
|
+
export const HINTS = {
|
|
129
|
+
NotAgent: 'only an Agent can create a V3 token, so only an Agent gets a combined recipient',
|
|
130
|
+
NotFactory: 'this combo factory is not allowed on the platform\'s GangHandlerAdmin: it cannot list a combined recipient as a tax recipient. If GANG_COMBO_FACTORY / GANG_TESTNET_COMBO_FACTORY is set, unset it to use the built-in factory; otherwise launch with one of --buyback / --lp / --split alone',
|
|
131
|
+
BadBps: '--buyback + --lp is at most 100%',
|
|
132
|
+
BadPayees: 'below 100% buy-back + LP: 1–10 payees (--split), one share each; at 100%: no payees',
|
|
133
|
+
BadShares: 'each payee share at least 0.01% (1 bps) of the rest, all adding up to 100% of it',
|
|
134
|
+
BadPayee: 'a payee cannot be the combined recipient itself',
|
|
135
|
+
DuplicatePayee: 'that address is a payee already (each address holds at most one slot)',
|
|
136
|
+
ZeroAddress: 'the zero address cannot be a payee',
|
|
137
|
+
BadIndex: 'no payee slot with that index (gang combo status lists them, from 0)',
|
|
138
|
+
NotPayee: 'only the current payee of a slot can move it to another address',
|
|
139
|
+
AlreadyBound: 'the combined recipient is bound to a token already',
|
|
140
|
+
NotBound: 'the combined recipient is not bound to a token yet (gang combo bind --token <the token>): nothing is split before that',
|
|
141
|
+
NotCurve: 'not a V3 (curve) token on this pad',
|
|
142
|
+
NotCreator: 'the token was not created by this combined recipient\'s dev',
|
|
143
|
+
NotRecipient: 'the token does not pay its tax to this combined recipient',
|
|
144
|
+
NothingOwed: 'nothing is owed to that slot in this asset (gang combo status shows what each slot is owed)',
|
|
145
|
+
NothingToChunk: 'nothing is set aside for a buy-back or liquidity chunk yet (buybackLeft / lpLeft): it fills as the tax arrives',
|
|
146
|
+
ChunkTooSoon: 'one chunk (buy-back or liquidity, together) per 4 minutes: wait until 4 minutes after the last one (lastChunkAt)',
|
|
147
|
+
NotTradable: 'the token has not graduated: chunks start once it trades in its PancakeSwap pair',
|
|
148
|
+
Slippage: 'the pool price moved since the preview (fewer tokens than the minimum): run gang combo chunk again',
|
|
149
|
+
PushStarved: `the tx's gas limit was too low for the payee pushes: ${COMBO_GAS_NOTE}`,
|
|
150
|
+
}
|
|
151
|
+
export const revertOf = (e) => revertIn(e, [COMBO_ABI, COMBO_FACTORY_ABI], HINTS)
|
|
152
|
+
|
|
153
|
+
/** Dry-run a call; { failed } with the revert when it would not pass. */
|
|
154
|
+
export async function simulateCombo(client, from, address, abi, functionName, args = []) {
|
|
155
|
+
try {
|
|
156
|
+
const { result } = await client.simulateContract({ account: from, address, abi, functionName, args })
|
|
157
|
+
return { result }
|
|
158
|
+
} catch (e) {
|
|
159
|
+
const r = revertOf(e)
|
|
160
|
+
return { failed: r ? { reverted: true, ...r } : { reverted: false, error: e.shortMessage || e.message.split('\n')[0] } }
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function comboFactoryAddress(testnet) {
|
|
165
|
+
return (testnet ? process.env.GANG_TESTNET_COMBO_FACTORY || TESTNET_COMBO_FACTORY
|
|
166
|
+
: process.env.GANG_COMBO_FACTORY || MAINNET_COMBO_FACTORY) || null
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export const comboNotDeployed = (testnet) => (testnet
|
|
170
|
+
? 'GangComboSplitterFactory (the combined recipient) is not deployed on the BSC testnet in this CLI version: set GANG_TESTNET_COMBO_FACTORY to its address, or give one of --buyback / --lp / --split alone'
|
|
171
|
+
: 'GangComboSplitterFactory (the combined recipient) is not deployed on BSC mainnet in this CLI version: set GANG_COMBO_FACTORY to its address, or give one of --buyback / --lp / --split alone')
|
|
172
|
+
|
|
173
|
+
const COMBO_REST_NOTE = 'in a combined launch --split lists the payees of what --buyback and --lp leave, their shares adding up to 100 (of that rest)'
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* A combined launch's flags → { buybackBps, lpBps, payees, shares, list } or { error, … }, checked as
|
|
177
|
+
* GangComboSplitter.initialize checks them. `buybackBps` / `lpBps`: the parsed --buyback / --lp (bps, 0 when absent);
|
|
178
|
+
* `split`: the raw --split (undefined when absent); `me`: the creating wallet (`self`, and the only payee by default).
|
|
179
|
+
* Payee shares are of the rest (10,000 − buyback − LP); the payee being the module itself is checked once its address is
|
|
180
|
+
* known (launch.js, from predict).
|
|
181
|
+
*/
|
|
182
|
+
export function parseComboSpec({ buybackBps = 0, lpBps = 0, split } = {}, me) {
|
|
183
|
+
const kept = buybackBps + lpBps
|
|
184
|
+
if (kept > BPS) return { error: `--buyback ${buybackBps / 100} + --lp ${lpBps / 100} is ${kept / 100}%, more than 100% of the recipient's part`, hint: 'lower one of them: the payees (--split) share what the two leave' }
|
|
185
|
+
if (kept === 0) return { error: '--buyback 0 and --lp 0 leave only the payees: give --split alone for a split module', hint: 'or raise --buyback / --lp' }
|
|
186
|
+
if (kept === BPS) {
|
|
187
|
+
if (split !== undefined) return { error: `--buyback + --lp is 100% of the recipient's part: nothing is left for payees, so --split is refused`, hint: 'drop --split, or lower --buyback / --lp so the payees get the rest' }
|
|
188
|
+
return { buybackBps, lpBps, payees: [], shares: [], list: [] }
|
|
189
|
+
}
|
|
190
|
+
let spec
|
|
191
|
+
if (split === undefined) {
|
|
192
|
+
if (!isAddress(me ?? '')) return { error: 'the rest of the recipient\'s part goes to your wallet: sign in with baw, or give --from (or name the payees with --split)' }
|
|
193
|
+
spec = { payees: [getAddress(me)], shares: [BPS], list: [{ index: 0, payee: getAddress(me), pct: 100, you: true }] }
|
|
194
|
+
} else {
|
|
195
|
+
spec = parseSplitSpec(split, me)
|
|
196
|
+
if (spec.error) return { ...spec, hint: spec.hint ? `${spec.hint}. ${COMBO_REST_NOTE}` : COMBO_REST_NOTE }
|
|
197
|
+
}
|
|
198
|
+
const rest = BPS - kept
|
|
199
|
+
return {
|
|
200
|
+
buybackBps, lpBps, payees: spec.payees, shares: spec.shares,
|
|
201
|
+
list: spec.list.map(({ pct: p, ...x }) => ({ ...x, pctOfRest: p, pctOfRecipient: ofRecipient(spec.shares[x.index], rest) })),
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** A payee's share of the rest (bps) as a % of the recipient's whole part. */
|
|
206
|
+
const ofRecipient = (share, rest) => Math.round((Number(share) * rest) / 1e2) / 1e4
|
|
207
|
+
|
|
208
|
+
/** The combo as one line: "30% buy-back, 30% liquidity, the rest (40%): 0xAb…: 70%, 0xCd…: 30%". */
|
|
209
|
+
export function comboLine(buybackBps, lpBps, payees, shares) {
|
|
210
|
+
const rest = BPS - buybackBps - lpBps
|
|
211
|
+
const parts = [`${buybackBps / 100}% buy-back and burn`, `${lpBps / 100}% liquidity (LP to 0xdead)`]
|
|
212
|
+
if (payees.length) parts.push(`the rest (${rest / 100}%) to ${payees.map((p, i) => `${p}: ${Number(shares[i]) / 100}% of it`).join(', ')}`)
|
|
213
|
+
return parts.join(', ')
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export const PERMANENT_NOTE = 'PERMANENT: the buy-back %, the LP %, the payees and their shares are fixed for good — nobody (not you, not the platform) can change them later, unlike a lone --buyback or --lp splitter whose dev can change its ratio; a payee can only move its own slot to another address (gang combo set-payee)'
|
|
217
|
+
|
|
218
|
+
/** What the combo does with each part, and with any other asset (the preview and status note). */
|
|
219
|
+
export function comboParts(buybackBps, lpBps, nPayees) {
|
|
220
|
+
const dead = (buybackBps + lpBps) / 100
|
|
221
|
+
return {
|
|
222
|
+
buyback: `${buybackBps / 100}% of each tax payment to this recipient (in the token's quote) is set aside and bought back in the PancakeSwap pair, the tokens burned (0xdead)`,
|
|
223
|
+
liquidity: `${lpBps / 100}% is set aside and added to the pair as liquidity (half buys the token, all of it goes back in with the matching quote), the LP sent to 0xdead (locked for good)`,
|
|
224
|
+
payees: nPayees ? `the rest (${(BPS - buybackBps - lpBps) / 100}%) is pushed to the payees at their shares (the first also takes the rounding dust)` : 'no payees: buy-back + liquidity take it all',
|
|
225
|
+
chunks: 'after graduation, one chunk per 4 minutes for both kinds together (always the larger set-aside part), at most 0.5% of the pair\'s quote reserve, none while the price is more than 2% above its 10-minute average',
|
|
226
|
+
otherAssets: nPayees
|
|
227
|
+
? `any other asset sent to it (not the token's quote) cannot be bought back or added: its buy-back + LP share (${dead}%) goes to 0xdead, the rest to the payees (gang combo distribute --asset <addr>)`
|
|
228
|
+
: 'any other asset sent to it (not the token\'s quote) goes to 0xdead in full (gang combo distribute --asset <addr>)',
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const iso = (s) => (Number(s) > 0 ? new Date(Number(s) * 1000).toISOString() : null)
|
|
233
|
+
const q18 = (x) => formatUnits(x, 18)
|
|
234
|
+
|
|
235
|
+
/** _kindOf: the larger set-aside part (a buy-back on a tie); a liquidity part under 2 wei has no half. */
|
|
236
|
+
function kindOf(bb, lp) {
|
|
237
|
+
const canBurn = bb !== 0n, canAdd = lp / 2n !== 0n
|
|
238
|
+
if (!canBurn && !canAdd) return null
|
|
239
|
+
if (!canAdd) return 'buy-back'
|
|
240
|
+
if (!canBurn) return 'liquidity'
|
|
241
|
+
return bb >= lp ? 'buy-back' : 'liquidity'
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* The module's state for printing, from the raw reads (pure: unit-tested). `raw`: { module, dev, token, quote,
|
|
246
|
+
* quoteSymbol, buybackBps, lpBps, payees, shares, buybackLeft, lpLeft, unsplit, lastChunkAt, lastPaidAt,
|
|
247
|
+
* keeperServesQuote, preview: [ready, burn, amount, tokensOut] | null, work: [due, minOut] | null, graduated: bool | null,
|
|
248
|
+
* assets: [{ asset, symbol, decimals, undistributed, owedTotal, owed: bigint[] | null }], now (unix s) }. `ref`: how later
|
|
249
|
+
* commands name it (e.g. `--token 0x… --testnet`).
|
|
250
|
+
*/
|
|
251
|
+
export function formatCombo(raw, ref) {
|
|
252
|
+
const token = raw.token && raw.token !== zeroAddress ? raw.token : null
|
|
253
|
+
const quote = token && raw.quote && raw.quote !== zeroAddress ? raw.quote : null
|
|
254
|
+
const isQuote = (a) => !!quote && a.toLowerCase() === quote.toLowerCase()
|
|
255
|
+
const bbBps = Number(raw.buybackBps), lpBps = Number(raw.lpBps)
|
|
256
|
+
const rest = BPS - bbBps - lpBps
|
|
257
|
+
const dev = String(raw.dev).toLowerCase()
|
|
258
|
+
const payees = raw.payees.map((payee, index) => ({
|
|
259
|
+
index, payee, pctOfRest: Number(raw.shares[index]) / 100, pctOfRecipient: ofRecipient(raw.shares[index], rest),
|
|
260
|
+
bps: Number(raw.shares[index]), ...(payee.toLowerCase() === dev && { isDev: true }),
|
|
261
|
+
}))
|
|
262
|
+
const now = Number(raw.now ?? Math.floor(Date.now() / 1000))
|
|
263
|
+
const last = Number(raw.lastChunkAt ?? 0n)
|
|
264
|
+
|
|
265
|
+
// the set-aside parts once the waiting quote is split (as the contract's _afterSplit, without a shortfall)
|
|
266
|
+
const unsplit = BigInt(raw.unsplit ?? 0n)
|
|
267
|
+
let toBb = (unsplit * BigInt(bbBps)) / 10_000n, toLp = (unsplit * BigInt(lpBps)) / 10_000n
|
|
268
|
+
if (!payees.length) {
|
|
269
|
+
const pay = unsplit - toBb - toLp
|
|
270
|
+
if (bbBps !== 0) toBb += pay
|
|
271
|
+
else toLp += pay
|
|
272
|
+
}
|
|
273
|
+
const bbAfter = BigInt(raw.buybackLeft) + toBb, lpAfter = BigInt(raw.lpLeft) + toLp
|
|
274
|
+
const kind = kindOf(bbAfter, lpAfter)
|
|
275
|
+
const [ready, burn, amount, tokensOut] = raw.preview ?? [false, false, 0n, 0n]
|
|
276
|
+
let waiting = null
|
|
277
|
+
if (!ready) {
|
|
278
|
+
waiting = !token ? 'not bound to a token yet (gang combo bind --token <the token>)'
|
|
279
|
+
: raw.graduated === false ? 'the token has not graduated: chunks start once it trades in its PancakeSwap pair (the pool tax starts then too)'
|
|
280
|
+
: !kind ? 'nothing set aside for a buy-back or liquidity chunk yet: it fills as the tax arrives'
|
|
281
|
+
: last > 0 && now < last + CHUNK_GAP_S ? `one chunk per 4 minutes (both kinds together): the next from ${iso(last + CHUNK_GAP_S)}`
|
|
282
|
+
: 'the price check: a 10-minute average of the pair\'s price (the next call records it, if none is running) and a price no more than 2% above it'
|
|
283
|
+
}
|
|
284
|
+
const nextChunk = ready
|
|
285
|
+
? burn
|
|
286
|
+
? { kind: 'buy-back', quoteIn: q18(amount), tokensBurned: formatUnits(tokensOut, 18) }
|
|
287
|
+
: { kind: 'liquidity', quoteChunk: q18(amount), buyHalf: q18(amount / 2n), tokensBought: formatUnits(tokensOut, 18) }
|
|
288
|
+
: { kind, ready: false }
|
|
289
|
+
|
|
290
|
+
const next = []
|
|
291
|
+
const assets = []
|
|
292
|
+
for (const a of raw.assets ?? []) {
|
|
293
|
+
const owedTotal = a.owedTotal ?? 0n
|
|
294
|
+
const undistributed = a.undistributed ?? 0n
|
|
295
|
+
if (!isQuote(a.asset) && undistributed === 0n && owedTotal === 0n) continue
|
|
296
|
+
const f = (x) => formatUnits(x, a.decimals ?? 18)
|
|
297
|
+
const owed = owedTotal > 0n && a.owed
|
|
298
|
+
? a.owed.map((x, index) => ({ index, payee: raw.payees[index], amount: f(x) })).filter((_, i) => a.owed[i] > 0n) : []
|
|
299
|
+
const byKeeper = isQuote(a.asset) && raw.keeperServesQuote
|
|
300
|
+
assets.push({
|
|
301
|
+
asset: a.asset, symbol: a.symbol ?? null, ...(isQuote(a.asset) && { boundQuote: true }),
|
|
302
|
+
undistributed: f(undistributed), owedTotal: f(owedTotal), ...(owed.length && { owed }),
|
|
303
|
+
splitBy: !token ? 'nobody until bound (distribute reverts NotBound)'
|
|
304
|
+
: byKeeper ? 'keeper (or anyone, gang combo distribute)'
|
|
305
|
+
: isQuote(a.asset) ? 'hand: gang combo distribute (anyone)'
|
|
306
|
+
: `hand: gang combo distribute (anyone): ${payees.length ? `${(bbBps + lpBps) / 100}% to 0xdead, the rest to the payees` : 'all of it to 0xdead'}`,
|
|
307
|
+
})
|
|
308
|
+
if (token && undistributed > 0n && !byKeeper) next.push(`gang combo distribute ${ref} --asset ${a.asset}`)
|
|
309
|
+
for (const o of owed) next.push(`gang combo release ${ref} --asset ${a.asset} --index ${o.index}`)
|
|
310
|
+
}
|
|
311
|
+
if (!token) next.unshift(String(ref ?? '').startsWith('--token ') ? `gang combo bind ${ref}` : 'gang combo bind --token <the token>')
|
|
312
|
+
if (ready) next.push(`gang combo chunk ${ref}`)
|
|
313
|
+
|
|
314
|
+
const sym = (assets.find((x) => x.boundQuote)?.symbol) || raw.quoteSymbol || quote
|
|
315
|
+
const distribution = !token ? 'unbound' : raw.keeperServesQuote ? 'keeper' : 'manual'
|
|
316
|
+
const keeperLine = distribution === 'unbound'
|
|
317
|
+
? 'Not bound to a token yet: nothing is split, bought back or added until gang combo bind --token <the token>'
|
|
318
|
+
: distribution === 'keeper'
|
|
319
|
+
? `The keeper serves this quote (${sym}): it runs the chunks and pays the payees (once their part reaches 0.05% of the pair's quote reserve, or after a day once it reaches 1/100 of that); anyone can do it sooner (gang combo chunk / gang combo distribute)`
|
|
320
|
+
: `The keeper does not serve this quote (${sym}): everything is manual — gang combo chunk and gang combo distribute (anyone)`
|
|
321
|
+
const [due, minOut] = raw.work ?? [false, 0n]
|
|
322
|
+
const parts = comboParts(bbBps, lpBps, payees.length)
|
|
323
|
+
return {
|
|
324
|
+
module: raw.module, moduleType: COMBO_TYPE, dev: raw.dev, token, quote, ...(quote && sym && { quoteSymbol: sym }),
|
|
325
|
+
buybackPct: bbBps / 100, lpPct: lpBps / 100, payeesPct: rest / 100, buybackBps: bbBps, lpBps, permanent: true,
|
|
326
|
+
payees,
|
|
327
|
+
buybackLeft: q18(raw.buybackLeft), lpLeft: q18(raw.lpLeft), unsplit: q18(unsplit),
|
|
328
|
+
nextChunk, ...(waiting && { nextChunkWaitsFor: waiting }),
|
|
329
|
+
lastChunkAt: iso(last), lastPaidAt: iso(raw.lastPaidAt ?? 0n),
|
|
330
|
+
distribution,
|
|
331
|
+
keeper: {
|
|
332
|
+
servesQuote: token ? !!raw.keeperServesQuote : null, due: !!due,
|
|
333
|
+
...(due && { plan: decodeWorkPlan(minOut) }),
|
|
334
|
+
},
|
|
335
|
+
assets,
|
|
336
|
+
...(next.length && { next }),
|
|
337
|
+
parts,
|
|
338
|
+
note: `${PERMANENT_NOTE}. ${keeperLine}. A failed payee push is owed to that slot and paid with its next push, or by gang combo release`,
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** Reads `asset`'s side of the module; null when it is not an ERC20 the module can read. */
|
|
343
|
+
async function assetRaw(read, module, asset, n) {
|
|
344
|
+
let undistributed, owedTotal
|
|
345
|
+
try {
|
|
346
|
+
[undistributed, owedTotal] = await Promise.all([
|
|
347
|
+
read(module, COMBO_ABI, 'undistributed', [asset]), read(module, COMBO_ABI, 'owedTotal', [asset]),
|
|
348
|
+
])
|
|
349
|
+
} catch { return null }
|
|
350
|
+
const [symbol, decimals, owed] = await Promise.all([
|
|
351
|
+
read(asset, ERC20_ABI, 'symbol').catch(() => null),
|
|
352
|
+
read(asset, ERC20_ABI, 'decimals').then(Number).catch(() => 18),
|
|
353
|
+
owedTotal > 0n ? Promise.all(Array.from({ length: n }, (_, i) => read(module, COMBO_ABI, 'owedOf', [asset, BigInt(i)]))) : null,
|
|
354
|
+
])
|
|
355
|
+
return { asset, symbol, decimals, undistributed, owedTotal, owed }
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* The module's state when `addr` is a GangComboSplitter (combo-v1); null when it is not. Assets read: the bound quote,
|
|
360
|
+
* WBNB, the module's GANG and `extraAssets` (e.g. the quote of a token paying it that is not the bound one). `pad`: to
|
|
361
|
+
* read graduation.
|
|
362
|
+
*/
|
|
363
|
+
export async function comboOf(read, addr, { wbnb, pad, extraAssets = [], ref } = {}) {
|
|
364
|
+
if (!addr || addr === zeroAddress) return null
|
|
365
|
+
let type
|
|
366
|
+
try { type = await read(addr, COMBO_ABI, 'moduleType') } catch { return null }
|
|
367
|
+
if (hexToString(type, { size: 32 }).replace(/\0+$/, '') !== COMBO_TYPE) return null
|
|
368
|
+
const [dev, token, quote, [payees, shares], buybackBps, lpBps, buybackLeft, lpLeft, unsplit, lastChunkAt, lastPaidAt, gangQuote] = await Promise.all([
|
|
369
|
+
...['dev', 'token', 'quote', 'payeesOf', 'buybackBps', 'lpBps', 'buybackLeft', 'lpLeft', 'unsplit', 'lastChunkAt', 'lastPaidAt'].map((f) => read(addr, COMBO_ABI, f)),
|
|
370
|
+
read(addr, COMBO_ABI, 'gangQuote').catch(() => zeroAddress),
|
|
371
|
+
])
|
|
372
|
+
const bound = token !== zeroAddress
|
|
373
|
+
const [preview, work, keeperServesQuote, graduated] = await Promise.all([
|
|
374
|
+
bound ? read(addr, COMBO_ABI, 'previewChunk').catch(() => null) : null,
|
|
375
|
+
bound ? read(addr, COMBO_ABI, 'previewWork').catch(() => null) : null,
|
|
376
|
+
bound ? read(addr, COMBO_ABI, 'keeperServes', [quote]).catch(() => false) : false,
|
|
377
|
+
bound && pad ? read(pad, PAD_ABI, 'curves', [token]).then((c) => c[6]).catch(() => null) : null,
|
|
378
|
+
])
|
|
379
|
+
const seen = new Set()
|
|
380
|
+
const list = [quote, wbnb, gangQuote, ...extraAssets].filter((a) => {
|
|
381
|
+
if (!a || a === zeroAddress || seen.has(a.toLowerCase())) return false
|
|
382
|
+
seen.add(a.toLowerCase())
|
|
383
|
+
return true
|
|
384
|
+
})
|
|
385
|
+
const assets = (await Promise.all(list.map((a) => assetRaw(read, addr, a, payees.length)))).filter(Boolean)
|
|
386
|
+
return formatCombo({
|
|
387
|
+
module: addr, dev, token, quote, buybackBps, lpBps, payees, shares, buybackLeft, lpLeft, unsplit, lastChunkAt, lastPaidAt,
|
|
388
|
+
keeperServesQuote, preview, work, graduated, assets,
|
|
389
|
+
}, ref ?? (bound ? `--token ${token}` : `--module ${addr}`))
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** When `token` pays its tax to the combo but the combo is bound to another token (a decoy bind): what to say. */
|
|
393
|
+
export function decoyWarning(s, token, tokenQuote, ref) {
|
|
394
|
+
if (!token || !s.token || s.token.toLowerCase() === token.toLowerCase()) return null
|
|
395
|
+
return `this token pays its tax to the combined recipient, but it is bound to another token (${s.token}): the buy-backs and liquidity go to that token's pair, and this token's tax (${tokenQuote ?? 'its quote'}) is not its bound quote — it is only distributed by hand (gang combo distribute ${ref} --asset ${tokenQuote ?? '<its quote>'}): its buy-back + LP share to 0xdead, the rest to the payees`
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function comboCtx(testnet) {
|
|
399
|
+
const net = padNets('v3')[testnet ? 'testnet' : 'mainnet']
|
|
400
|
+
if (!net.pad) throw new Error(NOT_ON_MAINNET)
|
|
401
|
+
const client = createPublicClient({ chain: net.chain, transport: rpcTransport(net.rpcs) })
|
|
402
|
+
return { ...net, client, read: (address, abi, functionName, args = []) => client.readContract({ address, abi, functionName, args }) }
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const SUBS = ['status', 'distribute', 'release', 'set-payee', 'bind', 'chunk']
|
|
406
|
+
const USAGE = 'usage: gang combo <status|distribute|release|set-payee|bind|chunk> --token <addr> (or --module <addr>) [--asset <addr>|wbnb] [--index <i>] [--to <addr>] [--max <amount>] [--slippage 1] [--testnet] — see gang help'
|
|
407
|
+
|
|
408
|
+
/** `gang combo <sub>`: the combined recipient of a V3 token (its tax recipient), found from --token (or named by --module). */
|
|
409
|
+
export async function runCombo(sub, { opt, flag, out, fail, summarize }) {
|
|
410
|
+
if (!SUBS.includes(sub)) return fail(USAGE, { got: sub ?? null })
|
|
411
|
+
const testnet = flag('testnet')
|
|
412
|
+
const rawOnly = flag('calldata')
|
|
413
|
+
let ctx
|
|
414
|
+
try { ctx = comboCtx(testnet) } catch (e) { return fail(e.message) }
|
|
415
|
+
const chainId = Number(ctx.chainId)
|
|
416
|
+
const tn = testnet ? ' --testnet' : ''
|
|
417
|
+
if (flag('token') && flag('module')) fail('give --token (its tax recipient is the combined recipient) or --module, not both')
|
|
418
|
+
let token = null, module, tokenQuote = null
|
|
419
|
+
if (flag('module')) {
|
|
420
|
+
if (sub === 'bind') fail('gang combo bind needs --token <the token> (it binds the token\'s own recipient)')
|
|
421
|
+
module = opt('module')
|
|
422
|
+
if (!isAddress(module ?? '')) fail('--module must be a combined recipient address (0x…)', { got: module ?? null })
|
|
423
|
+
} else {
|
|
424
|
+
token = opt('token')
|
|
425
|
+
if (!isAddress(token ?? '')) fail('--token must be a V3 token address (0x…), or name the module with --module <addr>', { got: token ?? null })
|
|
426
|
+
try {
|
|
427
|
+
const [creator, quote] = await ctx.read(ctx.pad, PAD_ABI, 'curves', [token])
|
|
428
|
+
if (creator === zeroAddress) throw new Error('not a curve')
|
|
429
|
+
tokenQuote = quote
|
|
430
|
+
module = (await ctx.read(ctx.pad, PAD_ABI, 'taxConfigOf', [token]))[3]
|
|
431
|
+
} catch {
|
|
432
|
+
return fail(`not a V3 token on this pad (${testnet ? 'BSC testnet' : 'BSC mainnet; add --testnet for a testnet token'})`, { token, chainId })
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
const ref = `${token ? `--token ${token}` : `--module ${module}`}${tn}`
|
|
436
|
+
// status --asset <addr>: read that asset too (a stray one the default list doesn't cover)
|
|
437
|
+
const extra = sub === 'status' && flag('asset') && isAddress(opt('asset') ?? '') ? [getAddress(opt('asset'))] : []
|
|
438
|
+
const s = await comboOf(ctx.read, module, {
|
|
439
|
+
wbnb: ctx.wbnb, pad: ctx.pad, extraAssets: [...(tokenQuote && tokenQuote !== zeroAddress ? [tokenQuote] : []), ...extra], ref,
|
|
440
|
+
})
|
|
441
|
+
if (!s) {
|
|
442
|
+
return fail(token ? 'this token\'s tax recipient is not a combined recipient (combo-v1)' : 'not a combined recipient (combo-v1)',
|
|
443
|
+
{ ...(token && { token }), recipient: module === zeroAddress ? null : module })
|
|
444
|
+
}
|
|
445
|
+
const warning = decoyWarning(s, token, tokenQuote, ref)
|
|
446
|
+
const me = () => walletFor(ctx, opt('from'))
|
|
447
|
+
const send = async (functionName, args, extra) => {
|
|
448
|
+
const sim = await simulateCombo(ctx.client, me(), s.module, COMBO_ABI, functionName, args)
|
|
449
|
+
if (sim.failed) return out({ success: false, step: extra.step, ...sim.failed, ...(warning && { warning }) })
|
|
450
|
+
const data = encodeFunctionData({ abi: COMBO_ABI, functionName, args })
|
|
451
|
+
// no gas field: the wallet / node estimates it (COMBO_GAS_NOTE)
|
|
452
|
+
return out(step(ctx, { from: me(), to: s.module, data }, { chainId, ...(token && { token }), module: s.module, ...extra, ...(warning && { warning }) }, rawOnly, summarize))
|
|
453
|
+
}
|
|
454
|
+
const assetArg = (def) => {
|
|
455
|
+
if (!flag('asset')) return def
|
|
456
|
+
const a = opt('asset')
|
|
457
|
+
if (/^wbnb$/i.test(a ?? '')) return ctx.wbnb
|
|
458
|
+
if (!isAddress(a ?? '') || a === zeroAddress) fail('--asset must be a token address (0x…, checksummed or all lowercase) or wbnb', { got: a ?? null })
|
|
459
|
+
return getAddress(a)
|
|
460
|
+
}
|
|
461
|
+
const assetState = async (asset) => {
|
|
462
|
+
const known = s.assets.find((x) => x.asset.toLowerCase() === asset.toLowerCase())
|
|
463
|
+
const r = await assetRaw(ctx.read, s.module, asset, s.payees.length)
|
|
464
|
+
if (!r) fail('the module cannot read that asset\'s balance (not an ERC20?)', { asset })
|
|
465
|
+
return { ...r, symbol: r.symbol ?? known?.symbol ?? null, f: (x) => formatUnits(x, r.decimals) }
|
|
466
|
+
}
|
|
467
|
+
const needBound = () => {
|
|
468
|
+
if (!s.token) fail(HINTS.NotBound, { module: s.module, ...(token && { next: `gang combo bind --token ${token}${tn}` }) })
|
|
469
|
+
}
|
|
470
|
+
/** `amount` split among the payees as the contract does: the others rounded down, the first the rest. */
|
|
471
|
+
const payeeParts = (amount, f) => {
|
|
472
|
+
if (!s.payees.length) return []
|
|
473
|
+
const amounts = s.payees.map((p) => (amount * BigInt(p.bps)) / BigInt(BPS))
|
|
474
|
+
amounts[0] = amount - amounts.slice(1).reduce((x, y) => x + y, 0n)
|
|
475
|
+
return s.payees.map((p, i) => ({ index: p.index, payee: p.payee, pctOfRest: p.pctOfRest, gets: f(amounts[i]) }))
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (sub === 'status') return out({ success: true, chainId, ...s, ...(s.token === null && { bound: false }), ...(warning && { warning }) })
|
|
479
|
+
|
|
480
|
+
if (sub === 'bind') {
|
|
481
|
+
if (s.token) return fail('already bound', { boundTo: s.token, ...(warning && { warning }) })
|
|
482
|
+
return send('bind', [token], { step: 'bind', note: 'anyone may bind (once); the token must be the dev\'s and pay its tax to this module. It decides which quote is split and which pair the buy-backs and liquidity go to' })
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (sub === 'distribute') {
|
|
486
|
+
needBound()
|
|
487
|
+
const asset = assetArg(s.quote)
|
|
488
|
+
const a = await assetState(asset)
|
|
489
|
+
if (a.undistributed === 0n) {
|
|
490
|
+
return fail('nothing of this asset is waiting to be split', {
|
|
491
|
+
asset, symbol: a.symbol, owedTotal: a.f(a.owedTotal),
|
|
492
|
+
...(a.owedTotal > 0n && { hint: `what is held is owed to payees after failed pushes: gang combo release ${ref} --asset ${asset} --index <i>` }),
|
|
493
|
+
})
|
|
494
|
+
}
|
|
495
|
+
const bb = BigInt(s.buybackBps), lpb = BigInt(s.lpBps)
|
|
496
|
+
if (asset.toLowerCase() === s.quote.toLowerCase()) {
|
|
497
|
+
const toBuyback = (a.undistributed * bb) / 10_000n, toLp = (a.undistributed * lpb) / 10_000n
|
|
498
|
+
const toPayees = s.payees.length ? a.undistributed - toBuyback - toLp : 0n
|
|
499
|
+
return send('distribute', [asset], {
|
|
500
|
+
step: 'distribute', asset, symbol: a.symbol, boundQuote: true, amount: a.f(a.undistributed),
|
|
501
|
+
toBuyback: a.f(toBuyback), toLp: a.f(toLp), toPayees: a.f(toPayees), parts: payeeParts(toPayees, a.f),
|
|
502
|
+
note: `anyone may: splits the bound quote that arrived (as split()): ${s.buybackPct}% set aside for buy-back, ${s.lpPct}% for liquidity, the rest pushed to the payees; a push that fails is owed to that slot. Gas: ${COMBO_GAS_NOTE}`,
|
|
503
|
+
})
|
|
504
|
+
}
|
|
505
|
+
const toDead = s.payees.length ? (a.undistributed * (bb + lpb)) / 10_000n : a.undistributed
|
|
506
|
+
const rest = a.undistributed - toDead
|
|
507
|
+
return send('distribute', [asset], {
|
|
508
|
+
step: 'distribute', asset, symbol: a.symbol, amount: a.f(a.undistributed), toDead: a.f(toDead), toPayees: a.f(rest),
|
|
509
|
+
parts: payeeParts(rest, a.f),
|
|
510
|
+
note: `anyone may: this is not the bound quote, so it cannot be bought back or added to the pool: ${s.payees.length ? `its buy-back + LP share (${(s.buybackBps + s.lpBps) / 100}%) goes to 0xdead, the rest to the payees at their shares` : 'all of it goes to 0xdead (no payees)'}; a push that fails is owed to that slot. Gas: ${COMBO_GAS_NOTE}`,
|
|
511
|
+
})
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if (sub === 'release') {
|
|
515
|
+
needBound()
|
|
516
|
+
if (!s.payees.length) return fail('this combined recipient has no payees (buy-back + LP = 100%): nothing is ever owed')
|
|
517
|
+
const asset = assetArg(s.quote)
|
|
518
|
+
const a = await assetState(asset)
|
|
519
|
+
let index
|
|
520
|
+
if (flag('index')) index = indexArg(opt('index'), s.payees.length, fail)
|
|
521
|
+
else {
|
|
522
|
+
const mine = s.payees.find((p) => p.payee.toLowerCase() === String(me()).toLowerCase())
|
|
523
|
+
const owedSlots = (a.owed ?? []).map((x, i) => (x > 0n ? i : -1)).filter((i) => i >= 0)
|
|
524
|
+
if (mine) index = mine.index
|
|
525
|
+
else if (owedSlots.length === 1) index = owedSlots[0]
|
|
526
|
+
else fail('--index <i> required: which payee slot to pay (gang combo status lists what each is owed)', { owedSlots })
|
|
527
|
+
}
|
|
528
|
+
const owed = a.owed ? a.owed[index] : 0n
|
|
529
|
+
if (owed === 0n) return fail(HINTS.NothingOwed, { asset, symbol: a.symbol, index, payee: s.payees[index].payee })
|
|
530
|
+
let max = maxUint256
|
|
531
|
+
if (flag('max')) max = parseUnits(parseAmount(fail, 'max', opt('max')), a.decimals)
|
|
532
|
+
const amount = owed < max ? owed : max
|
|
533
|
+
return send('release', [asset, BigInt(index), max], {
|
|
534
|
+
step: 'release', asset, symbol: a.symbol, index, payee: s.payees[index].payee, amount: a.f(amount), owed: a.f(owed),
|
|
535
|
+
note: `anyone may: splits what newly arrived of this asset first, then pushes ${max === maxUint256 ? 'all' : 'up to --max'} of what this slot is owed to its payee (reverts while it still cannot receive; nothing owed is lost). Gas: ${COMBO_GAS_NOTE}`,
|
|
536
|
+
})
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
if (sub === 'chunk') {
|
|
540
|
+
needBound()
|
|
541
|
+
const slippage = parseNum(fail, 'slippage', opt('slippage', '1'), 0, 50)
|
|
542
|
+
const [ready, burn, amount, tokensOut] = await ctx.read(s.module, COMBO_ABI, 'previewChunk')
|
|
543
|
+
if (ready) {
|
|
544
|
+
// previewChunk prices the buy (a liquidity chunk: its half) after the buy tax; the contract scales the minimum
|
|
545
|
+
// down when the pair got less
|
|
546
|
+
const minOut = (tokensOut * BigInt(Math.round((100 - slippage) * 100))) / 10_000n
|
|
547
|
+
return send('chunk', [minOut], burn
|
|
548
|
+
? {
|
|
549
|
+
step: 'chunk', kind: 'buy-back', quoteIn: q18(amount), expectTokensBurned: formatUnits(tokensOut, 18),
|
|
550
|
+
minTokens: formatUnits(minOut, 18), slippagePct: slippage, buybackLeft: s.buybackLeft, lpLeft: s.lpLeft,
|
|
551
|
+
note: `anyone may: splits what arrived, then one buy-back chunk (the larger set-aside part): buys the token in the pair and burns it at 0xdead (gang tx shows BoughtBack). The keeper does the same every few minutes. Gas: ${COMBO_GAS_NOTE}`,
|
|
552
|
+
}
|
|
553
|
+
: {
|
|
554
|
+
step: 'chunk', kind: 'liquidity', quoteChunk: q18(amount), buyHalf: q18(amount / 2n), expectTokensBought: formatUnits(tokensOut, 18),
|
|
555
|
+
minTokens: formatUnits(minOut, 18), slippagePct: slippage, buybackLeft: s.buybackLeft, lpLeft: s.lpLeft,
|
|
556
|
+
note: `anyone may: splits what arrived, then one liquidity chunk (the larger set-aside part): half buys the token, all of it goes back into the pair with the matching quote, the LP to 0xdead (gang tx shows LiquidityAdded). The keeper does the same every few minutes. Gas: ${COMBO_GAS_NOTE}`,
|
|
557
|
+
})
|
|
558
|
+
}
|
|
559
|
+
// not ready: only a call that records the price observation can pass; a minimum no chunk can meet makes it revert
|
|
560
|
+
// (Slippage) rather than trade unchecked if a chunk became possible before it lands
|
|
561
|
+
const sim = await simulateCombo(ctx.client, me(), s.module, COMBO_ABI, 'chunk', [maxUint128])
|
|
562
|
+
if (sim.failed) return out({ success: false, step: 'chunk', ...sim.failed, ...(s.nextChunkWaitsFor && { waitsFor: s.nextChunkWaitsFor }), buybackLeft: s.buybackLeft, lpLeft: s.lpLeft, ...(warning && { warning }) })
|
|
563
|
+
return send('chunk', [maxUint128], {
|
|
564
|
+
step: 'record-price', trades: false, waitsFor: s.nextChunkWaitsFor,
|
|
565
|
+
note: 'no chunk this time: the call splits what arrived and records the pair\'s price observation (or waits for the 10-minute average / a price no more than 2% above it). The keeper calls it too. If a chunk becomes possible before it lands, it reverts (Slippage) rather than trade without a minimum: run gang combo chunk again then, about 10 minutes after the first observation',
|
|
566
|
+
})
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// set-payee: only the slot's own payee; the index is the wallet's own slot unless given
|
|
570
|
+
if (!s.payees.length) return fail('this combined recipient has no payees (buy-back + LP = 100%)')
|
|
571
|
+
const wallet = String(me()).toLowerCase()
|
|
572
|
+
const mine = s.payees.find((p) => p.payee.toLowerCase() === wallet)
|
|
573
|
+
let index
|
|
574
|
+
if (flag('index')) index = indexArg(opt('index'), s.payees.length, fail)
|
|
575
|
+
else if (mine) index = mine.index
|
|
576
|
+
else return fail('this wallet is not a payee of this combined recipient: only a slot\'s own payee can move it', { wallet: me(), payees: s.payees.map((p) => p.payee) })
|
|
577
|
+
const slot = s.payees[index]
|
|
578
|
+
if (slot.payee.toLowerCase() !== wallet) return fail(HINTS.NotPayee, { index, payee: slot.payee, wallet: me() })
|
|
579
|
+
const to = opt('to')
|
|
580
|
+
if (!isAddress(to ?? '') || to === zeroAddress) fail('--to <0x…> required (checksummed or all lowercase): the address this slot is paid to from now on', { got: to ?? null })
|
|
581
|
+
if (to.toLowerCase() === s.module.toLowerCase()) return fail(HINTS.BadPayee, { to })
|
|
582
|
+
const taken = s.payees.find((p) => p.payee.toLowerCase() === to.toLowerCase())
|
|
583
|
+
if (taken) return fail(taken.index === index ? 'that is this slot\'s payee already' : HINTS.DuplicatePayee, { to, index: taken.index })
|
|
584
|
+
// the contract splits only the bound quote before the move: other assets that arrived would go to the new address,
|
|
585
|
+
// so split those first (each its own tx, then the same command again); needs the module bound (NotBound before)
|
|
586
|
+
const unsplit = s.token ? s.assets.filter((x) => !x.boundQuote && Number(x.undistributed) > 0) : []
|
|
587
|
+
if (unsplit.length) {
|
|
588
|
+
const first = unsplit[0]
|
|
589
|
+
return send('distribute', [first.asset], {
|
|
590
|
+
step: 'distribute-first', asset: first.asset, symbol: first.symbol, amount: first.undistributed,
|
|
591
|
+
...(unsplit.length > 1 && { thenAlso: unsplit.slice(1).map((x) => ({ asset: x.asset, symbol: x.symbol, amount: x.undistributed })) }),
|
|
592
|
+
note: `before the move: ${first.symbol || first.asset} that arrived earlier is distributed to the current payees (and its buy-back + LP share to 0xdead); the contract splits only the bound quote itself. After executing, re-run the same command. Gas: ${COMBO_GAS_NOTE}`,
|
|
593
|
+
})
|
|
594
|
+
}
|
|
595
|
+
return send('setPayee', [BigInt(index), getAddress(to)], {
|
|
596
|
+
step: 'set-payee', index, pctOfRest: slot.pctOfRest, fromPayee: slot.payee, toPayee: getAddress(to),
|
|
597
|
+
note: `applies at once; the share (${slot.pctOfRest}% of the rest) stays with the slot. The bound quote that arrived before is split first (to the current address); what this slot is owed (any asset) goes to the new one. The ratios and the other slots stay as they are (fixed for good). Gas: ${COMBO_GAS_NOTE}`,
|
|
598
|
+
})
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
function indexArg(raw, n, fail) {
|
|
602
|
+
const i = Number(raw)
|
|
603
|
+
if (!Number.isInteger(i) || i < 0 || i >= n) fail(`--index must be a payee slot: the contract's 0-based index, 0 to ${n - 1} (gang combo status lists them)`, { got: raw ?? null })
|
|
604
|
+
return i
|
|
605
|
+
}
|
package/src/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import { runBond } from './bond.js'
|
|
|
22
22
|
import { runBuyback } from './buyback.js'
|
|
23
23
|
import { runSplit, SPLIT_EVENT_ABIS } from './split.js'
|
|
24
24
|
import { runLp, LP_EVENT_ABIS } from './lp.js'
|
|
25
|
+
import { runCombo, COMBO_EVENT_ABIS } from './combo.js'
|
|
25
26
|
import { runFly, flyCtx, isFlyToken, FLY_EVENT_ABIS, FLY_CREATE_FLAGS } from './fly.js'
|
|
26
27
|
import { FAIR_DEV_BUY, isLaunch, LAUNCH_FLAGS, runLaunch } from './launch.js'
|
|
27
28
|
import { poolPayBnb, poolTrade } from './pool.js'
|
|
@@ -352,9 +353,10 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
352
353
|
nobody (not you, not the platform) can change the payees or shares later; a payee can
|
|
353
354
|
only move its own slot (gang split set-payee). Steps: clone your split module
|
|
354
355
|
(GangSplitModuleFactory; listed as a recipient in the same tx) → create with it as the
|
|
355
|
-
recipient → bind → the rest of the launch. --
|
|
356
|
-
|
|
357
|
-
only (the quotes the keeper splits; others are refused before the
|
|
356
|
+
recipient → bind → the rest of the launch. Not with --recipient; with --buyback / --lp
|
|
357
|
+
it makes a combined recipient (below). Quote: WBNB (default), GANG or one listed in the
|
|
358
|
+
pad's QuoteRegistry only (the quotes the keeper splits; others are refused before the
|
|
359
|
+
clone)
|
|
358
360
|
gang create … --buy-tax <1-5> --sell-tax <1-5> --lp <0-100> [--lp-to <addr>] [--dev-buy … [--bond …]]
|
|
359
361
|
V3, taxed, auto-liquidity: --lp % of the recipient's part of the tax is added to the
|
|
360
362
|
token's PancakeSwap pair as liquidity whose LP goes to 0xdead (locked for good), the
|
|
@@ -362,8 +364,23 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
362
364
|
graduation the keeper adds it in chunks (half buys the token, all of it goes back in
|
|
363
365
|
with the matching quote). Steps: clone your LP splitter (GangLiquiditySplitterFactory;
|
|
364
366
|
listed as a recipient in the same tx) → create with it as the recipient → bind → the
|
|
365
|
-
rest of the launch. Not with --buyback
|
|
366
|
-
(default), GANG or one listed in the pad's QuoteRegistry
|
|
367
|
+
rest of the launch. Not with --recipient; with --buyback / --split it makes a combined
|
|
368
|
+
recipient (below). Quote: WBNB (default), GANG or one listed in the pad's QuoteRegistry
|
|
369
|
+
only
|
|
370
|
+
gang create … --buy-tax <1-5> --sell-tax <1-5> --buyback <0-100> --lp <0-100> [--split <addr>:<pct>[,…]] [--dev-buy …]
|
|
371
|
+
V3, taxed, combined recipient (GangComboSplitter, combo-v1): two or three of --buyback,
|
|
372
|
+
--lp, --split together. --buyback % of the recipient's part is bought back and burned,
|
|
373
|
+
--lp % added to the pair as liquidity (LP to 0xdead), the rest (100 − both) pushed to
|
|
374
|
+
the --split payees, whose shares are of that rest and add up to 100 (e.g. --buyback 30
|
|
375
|
+
--lp 30 --split self:70,0xKol…:30: 28% / 12% of the recipient's part); without --split
|
|
376
|
+
the rest goes to you. --buyback + --lp = 100 takes no --split; above 100 is refused.
|
|
377
|
+
--buyback-to / --lp-to don't apply (name payees with --split). PERMANENT: the ratios,
|
|
378
|
+
payees and shares can never change (unlike a lone --buyback / --lp, whose ratio the
|
|
379
|
+
dev can change); a payee can only move its own slot (gang combo set-payee). Any other
|
|
380
|
+
asset sent to it: its buy-back + LP share goes to 0xdead, the rest to the payees.
|
|
381
|
+
Steps: clone your combined recipient (GangComboSplitterFactory; listed in the same tx)
|
|
382
|
+
→ create → bind → the rest of the launch. Quote: WBNB (default), GANG or one listed
|
|
383
|
+
in the pad's QuoteRegistry only
|
|
367
384
|
gang create --fair … [--shares <n>] --bond <quote> [--bond-hold …] --bond-days <7-90>
|
|
368
385
|
打新: create (the dev's --shares are bought in it) → bond. Progress is read from the
|
|
369
386
|
chain (a token this wallet created with this symbol since the plan); a run that finds
|
|
@@ -475,12 +492,39 @@ LP (a V3 token whose recipient is an LP splitter, lp-burn-v1; GANG_LP_FACTORY /
|
|
|
475
492
|
> 2% above it): minimum tokens = previewAdd less --slippage. Not ready: a call that
|
|
476
493
|
only records the price. Gas: a chunk takes ~0.53–0.75M; the CLI never sets a gas
|
|
477
494
|
limit, let the wallet estimate it. --testnet, --calldata, --from as in gang v3
|
|
495
|
+
COMBO (a V3 token whose recipient is a combined recipient, combo-v1; GANG_COMBO_FACTORY / GANG_TESTNET_COMBO_FACTORY):
|
|
496
|
+
gang combo status --token <addr> [--asset <addr>]
|
|
497
|
+
buy-back / LP / payees % (fixed for good), payees and shares, set aside for buy-back
|
|
498
|
+
(buybackLeft) and liquidity (lpLeft), not split yet (unsplit), what each slot is owed
|
|
499
|
+
(bound quote, WBNB, GANG, the token's quote, --asset), the next chunk (kind, ready or what it
|
|
500
|
+
waits for), the keeper (serves the quote or manual; due, and the planned action
|
|
501
|
+
decoded from previewWork: buy-back / liquidity / observe / split), next commands, and
|
|
502
|
+
a warning when the module is bound to another token than the one paying it
|
|
503
|
+
gang combo distribute --token <addr> [--asset <addr>|wbnb]
|
|
504
|
+
anyone, once bound: the bound quote (default) is split as the tax is; another asset's
|
|
505
|
+
buy-back + LP share goes to 0xdead, the rest to the payees
|
|
506
|
+
gang combo release --token <addr> [--asset <addr>] [--index <i>] [--max <amount>]
|
|
507
|
+
anyone: push a slot what a failed push left owed (--index = the contract's 0-based
|
|
508
|
+
slot, default your own slot or the only one owed)
|
|
509
|
+
gang combo set-payee --token <addr> --to <addr> [--index <i>]
|
|
510
|
+
only the slot's current payee (--index default: your wallet's slot): moves the slot
|
|
511
|
+
to --to at once, the share stays. Distributes other known assets waiting first (one
|
|
512
|
+
tx each, then re-run)
|
|
513
|
+
gang combo bind --token <addr> anyone: bind the module to its token (the launch does it)
|
|
514
|
+
gang combo chunk --token <addr> [--slippage 1]
|
|
515
|
+
anyone: one chunk now, as the keeper does (graduated tokens; one per 4 minutes for both
|
|
516
|
+
kinds; always the larger set-aside part): minimum tokens = previewChunk less --slippage
|
|
517
|
+
(default 1%). Not ready: a call that only records the price.
|
|
518
|
+
--module <addr> instead of --token names a module directly (not for bind). Gas: the
|
|
519
|
+
CLI never sets a gas limit; let the wallet estimate it (a chunk ~0.55–0.75M; each
|
|
520
|
+
payee push needs ~365k left before it, up to 10: a lower limit reverts PushStarved).
|
|
521
|
+
--testnet, --calldata, --from as in gang v3
|
|
478
522
|
gang execute --request-id <id> broadcast a previewed call
|
|
479
523
|
gang tx --pending a trade that waited for Binance App approval (execute: pendingConfirmation): find its tx
|
|
480
524
|
in the wallet's history by the exact call previewed, then as gang tx --hash below
|
|
481
525
|
gang tx --hash <0x..> [--testnet] wait for receipt and decode Gang events: V2 / Soft / U / S, GangLaunchpad (V3 /
|
|
482
|
-
打新, tax router, vaults), GangFlywheelPad (铸币飞轮 pad and tax handler), split modules
|
|
483
|
-
|
|
526
|
+
打新, tax router, vaults), GangFlywheelPad (铸币飞轮 pad and tax handler), split modules,
|
|
527
|
+
LP splitters and combined recipients (publishes a queued --note; mainnet). GangLaunchpad events
|
|
484
528
|
carry units: "raw" (amounts in wei, 18 decimals; bps / shares as is)
|
|
485
529
|
|
|
486
530
|
--note is PUBLIC: shown on gang.fun next to the trade. Its hash goes into the tx calldata, so it is provably written
|
|
@@ -1017,7 +1061,7 @@ const V3_CREATE_FLAGS = ['buy-tax', 'sell-tax', 'dividend', 'recipient']
|
|
|
1017
1061
|
const FAIR_CREATE_FLAGS = ['raise', 'cap', 'hold', 'mint-fee', 'exit-fee', 'shares']
|
|
1018
1062
|
// 铸币飞轮 settings beyond those it shares with 打新 (--raise / --hold / --mint-fee / --exit-fee) and V3 (--sell-tax)
|
|
1019
1063
|
const FLY_ONLY_FLAGS = FLY_CREATE_FLAGS.filter((f) => !['raise', 'hold', 'mint-fee', 'exit-fee', 'sell-tax'].includes(f))
|
|
1020
|
-
const FLY_NO_BOND = '铸币飞轮 tokens take no GangBond, buy-back splitter, split module, LP splitter or --dev-buy (phase 1): the creator mints its shares in the create with --dev-shares <n>'
|
|
1064
|
+
const FLY_NO_BOND = '铸币飞轮 tokens take no GangBond, buy-back splitter, split module, LP splitter, combined recipient or --dev-buy (phase 1): the creator mints its shares in the create with --dev-shares <n>'
|
|
1021
1065
|
/** The flags a 铸币飞轮 create refuses (gang create --fly and gang fly create alike). */
|
|
1022
1066
|
function checkFlyCreate() {
|
|
1023
1067
|
if (flag('fair')) fail('give --fly (铸币飞轮) or --fair (打新), not both')
|
|
@@ -1051,11 +1095,11 @@ function create() {
|
|
|
1051
1095
|
// commands whose JSON result carries `update`; `watch` streams NDJSON and help is plain text
|
|
1052
1096
|
const UPDATE_CHECKED = new Set(['version', '--version', '-v', 'preflight', 'list', 'hot', 'new', 'near-grad', 'notes', 'agents', 'token', 'info', 'status', 'portfolio', 'quote',
|
|
1053
1097
|
'buy', 'follow', 'sell', 'claim', 'mint', 'withdraw', 'release', 'upload-logo', 'create', 'execute', 'tx', 'fair', 'v3', 'bond',
|
|
1054
|
-
'buyback', 'split', 'lp', 'fly'])
|
|
1098
|
+
'buyback', 'split', 'lp', 'combo', 'fly'])
|
|
1055
1099
|
// gang tx decodes these beside the V2 / Soft / U / S pads' events (GangLaunchpad: both kinds; the tax router; the vaults)
|
|
1056
|
-
const GANG_EVENT_ABIS = [...V3_EVENT_ABIS, ...FAIR_EVENT_ABIS, ...FLY_EVENT_ABIS, ...SPLIT_EVENT_ABIS, ...LP_EVENT_ABIS]
|
|
1100
|
+
const GANG_EVENT_ABIS = [...V3_EVENT_ABIS, ...FAIR_EVENT_ABIS, ...FLY_EVENT_ABIS, ...SPLIT_EVENT_ABIS, ...LP_EVENT_ABIS, ...COMBO_EVENT_ABIS]
|
|
1057
1101
|
|
|
1058
|
-
/** gang bond / gang buyback / gang split / gang lp on a 铸币飞轮 token: those contracts refuse it, so say why before any step. */
|
|
1102
|
+
/** gang bond / gang buyback / gang split / gang lp / gang combo on a 铸币飞轮 token: those contracts refuse it, so say why before any step. */
|
|
1059
1103
|
async function refuseFly(what) {
|
|
1060
1104
|
const token = opt('token')
|
|
1061
1105
|
if (!isAddress(token ?? '')) return
|
|
@@ -1172,6 +1216,9 @@ async function main() {
|
|
|
1172
1216
|
case 'lp':
|
|
1173
1217
|
await refuseFly('an LP splitter')
|
|
1174
1218
|
return runLp(args[1], { opt, flag, out, fail, summarize: summarizePreview })
|
|
1219
|
+
case 'combo':
|
|
1220
|
+
await refuseFly('a combined recipient')
|
|
1221
|
+
return runCombo(args[1], { opt, flag, out, fail, summarize: summarizePreview })
|
|
1175
1222
|
case 'version':
|
|
1176
1223
|
case '--version':
|
|
1177
1224
|
case '-v':
|
package/src/launch.js
CHANGED
|
@@ -10,6 +10,7 @@ import { parseAmount, parseIntIn, step } from './steps.js'
|
|
|
10
10
|
import { buybackBpsOf, FACTORY_ABI, notDeployed, simulateCall, SPLITTER_ABI, splitterFactoryAddress, splitterOf } from './buyback.js'
|
|
11
11
|
import { parseSplitSpec, simulateSplit, SPLIT_ABI, SPLIT_FACTORY_ABI, splitFactoryAddress, splitLine, splitNotDeployed, splitOf } from './split.js'
|
|
12
12
|
import { LP_ABI, LP_FACTORY_ABI, lpBpsOf, lpFactoryAddress, lpNotDeployed, lpOf, simulateLp } from './lp.js'
|
|
13
|
+
import { COMBO_ABI, COMBO_FACTORY_ABI, comboFactoryAddress, comboLine, comboNotDeployed, comboOf, comboParts, parseComboSpec, PERMANENT_NOTE, simulateCombo } from './combo.js'
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* One command for a launch: `gang create … [--buyback <pct>] [--dev-buy <quote> [--bond <quote> [--bond-hold <tokens|N%|all>]
|
|
@@ -36,7 +37,12 @@ import { LP_ABI, LP_FACTORY_ABI, lpBpsOf, lpFactoryAddress, lpNotDeployed, lpOf,
|
|
|
36
37
|
* --lp <pct> [--lp-to <addr>] (V3, taxed): the same three steps with GangLiquiditySplitterFactory — the dev's LP splitter
|
|
37
38
|
* (lp-burn-v1: --lp % of the recipient's part added to the pair as liquidity, the LP to 0xdead) is cloned at
|
|
38
39
|
* predict(dev, salt), named as the recipient, then bound (`module: 'lp'` in the plan). A launch keeps the ratio and payee
|
|
39
|
-
* it began with. --
|
|
40
|
+
* it began with. --recipient goes with none of them (each sets the recipient).
|
|
41
|
+
* More than one of --buyback, --lp, --split (taxed V3): the same three steps with GangComboSplitterFactory — the dev's
|
|
42
|
+
* combined recipient (combo-v1: --buyback % of the recipient's part bought back and burned, --lp % added as liquidity, the
|
|
43
|
+
* rest pushed to the --split payees, or to the dev alone without --split) is cloned at predict(dev, salt), named as the
|
|
44
|
+
* recipient, then bound (`module: 'combo'`). Everything in it is fixed for good, so a re-run with other ratios or payees
|
|
45
|
+
* is refused rather than starting over. --buyback-to / --lp-to don't apply (the payees are --split's).
|
|
40
46
|
*/
|
|
41
47
|
|
|
42
48
|
const LAUNCH_DIR = process.env.GANG_LAUNCH_DIR || join(dirname(DIR), 'launch')
|
|
@@ -61,7 +67,7 @@ const REGISTRY_ABI = parseAbi(['function quoteRegistry() view returns (address)'
|
|
|
61
67
|
* --split takes the same quotes: a quote that calls the receiver back on transfer would let one payee make every split
|
|
62
68
|
* run out of gas, and the keeper splits only these quotes anyway (split spec §2.4).
|
|
63
69
|
* --lp takes the same quotes: the keeper adds liquidity only over these, and an unlisted quote may tax or block the
|
|
64
|
-
* transfers into the pair every chunk makes.
|
|
70
|
+
* transfers into the pair every chunk makes. A combined recipient (several of them) takes the same quotes for all reasons.
|
|
65
71
|
* null when trusted; otherwise the failure to report.
|
|
66
72
|
*/
|
|
67
73
|
const UNTRUSTED = {
|
|
@@ -77,6 +83,10 @@ const UNTRUSTED = {
|
|
|
77
83
|
why: '--lp needs WBNB, GANG or a quote listed in the pad\'s QuoteRegistry: the keeper adds liquidity only over those quotes, and an unlisted quote may tax or block the transfers into the pair every chunk makes',
|
|
78
84
|
hint: 'drop --quote (WBNB), use a listed quote, or launch without --lp',
|
|
79
85
|
},
|
|
86
|
+
combo: {
|
|
87
|
+
why: 'a combined recipient (more than one of --buyback / --lp / --split) needs WBNB, GANG or a quote listed in the pad\'s QuoteRegistry: its buy-backs and liquidity adds price on what the pair receives (a quote that taxes transfers into the pair fails every chunk), the keeper serves only those quotes, and an unlisted quote may call a payee back on transfer',
|
|
88
|
+
hint: 'drop --quote (WBNB), use a listed quote, or launch without --buyback / --lp / --split',
|
|
89
|
+
},
|
|
80
90
|
}
|
|
81
91
|
export async function untrustedBuybackQuote(read, net, quote, mode = 'buyback') {
|
|
82
92
|
if (!isAddress(quote ?? '')) return { error: '--quote must be a 0x address', got: quote ?? null }
|
|
@@ -102,8 +112,10 @@ export const FAIR_DEV_BUY = 'a 打新 dev buys its shares in the create itself:
|
|
|
102
112
|
|
|
103
113
|
/** The run asks for a chained launch (`kind` 'v3' | 'fair'). */
|
|
104
114
|
export const isLaunch = (kind, flag) => flag('bond') || flag('buyback') || flag('split') || flag('lp') || (kind === 'v3' && flag('dev-buy'))
|
|
105
|
-
/** The recipient modules a launch can clone (their flags),
|
|
115
|
+
/** The recipient modules a launch can clone (their flags): one alone clones its own module, several a combined one. */
|
|
106
116
|
const MODULE_FLAGS = ['buyback', 'split', 'lp']
|
|
117
|
+
/** How a module's flags read in a message. */
|
|
118
|
+
const MOD_FLAG = { buyback: '--buyback', split: '--split', lp: '--lp', combo: 'more than one of --buyback / --lp / --split' }
|
|
107
119
|
|
|
108
120
|
const planPath = (key) => join(LAUNCH_DIR, `${createHash('sha256').update(key).digest('hex').slice(0, 32)}.json`)
|
|
109
121
|
|
|
@@ -149,9 +161,9 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
149
161
|
if (kind === 'fair' && flag('buyback')) fail('--buyback is for V3 tokens: it makes the tax recipient a buy-back splitter, and a 打新 token has no recipient')
|
|
150
162
|
if (kind === 'fair' && flag('split')) fail('--split is for V3 tokens: it makes the tax recipient a split module, and a 打新 token has no recipient')
|
|
151
163
|
if (kind === 'fair' && flag('lp')) fail('--lp is for V3 tokens: it makes the tax recipient an LP splitter, and a 打新 token has no recipient')
|
|
152
|
-
if (flag('split') && flag('buyback')) fail('give --split or --buyback, not both: each makes the tax recipient its own module (a split with a buy-back is not supported)')
|
|
153
164
|
const mods = MODULE_FLAGS.filter((f) => flag(f))
|
|
154
|
-
|
|
165
|
+
// more than one: one combined recipient (GangComboSplitter) does them all
|
|
166
|
+
const combo = mods.length > 1
|
|
155
167
|
|
|
156
168
|
// everything checked before the create, so a launch never stops half way on a bad flag
|
|
157
169
|
const devBuy = kind === 'v3' && flag('dev-buy') ? parseAmount(fail, 'dev-buy', opt('dev-buy')) : null
|
|
@@ -169,10 +181,27 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
169
181
|
bond = { amount: parseAmount(fail, 'bond', opt('bond')), hold, days: parseIntIn(fail, 'bond-days', opt('bond-days'), 7, 90) }
|
|
170
182
|
}
|
|
171
183
|
|
|
184
|
+
// several of --buyback / --lp / --split: a taxed V3 token whose recipient is the dev's combined recipient
|
|
185
|
+
let comboFactory = null
|
|
186
|
+
if (combo) {
|
|
187
|
+
const names = mods.map((f) => `--${f}`).join(' + ')
|
|
188
|
+
comboFactory = comboFactoryAddress(testnet)
|
|
189
|
+
if (!comboFactory) fail(comboNotDeployed(testnet), { flags: mods.map((f) => `--${f}`) })
|
|
190
|
+
for (const to of ['buyback-to', 'lp-to']) {
|
|
191
|
+
if (flag(to)) fail(`--${to} does not apply to a combined recipient (${names}): the part not bought back or added goes to the payees — name them with --split self:<pct>,<addr>:<pct>,… (shares of that rest; without --split it all goes to you)`)
|
|
192
|
+
}
|
|
193
|
+
const zero = (f) => /^0+(\.0+)?$/.test(opt(f) ?? '')
|
|
194
|
+
if (!flag('buy-tax') || !flag('sell-tax') || (zero('buy-tax') && zero('sell-tax'))) {
|
|
195
|
+
fail(`${names} needs a taxed token: add --buy-tax and --sell-tax (each 1–5, in %); the combined recipient is paid from the tax`)
|
|
196
|
+
}
|
|
197
|
+
if (flag('recipient')) fail(`${names} makes the recipient your combined recipient: leave --recipient out`)
|
|
198
|
+
if (/^0*100(\.0+)?$/.test(opt('dividend', '0'))) fail(`--dividend 100 leaves nothing for the recipient: lower it or drop ${names}`)
|
|
199
|
+
}
|
|
200
|
+
|
|
172
201
|
// --buyback: a taxed V3 token whose recipient (the part left after holders) is the dev's splitter
|
|
173
202
|
let buyback = null
|
|
174
203
|
if (flag('buyback-to') && !flag('buyback')) fail('--buyback-to <addr> goes with --buyback <pct>: it names where the part not bought back goes')
|
|
175
|
-
if (flag('buyback')) {
|
|
204
|
+
if (flag('buyback') && !combo) {
|
|
176
205
|
const zero = (f) => /^0+(\.0+)?$/.test(opt(f) ?? '')
|
|
177
206
|
if (!flag('buy-tax') || !flag('sell-tax') || (zero('buy-tax') && zero('sell-tax'))) {
|
|
178
207
|
fail('--buyback needs a taxed token: add --buy-tax and --sell-tax (each 1–5, in %); the buy-back is paid from the tax')
|
|
@@ -191,9 +220,24 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
191
220
|
|
|
192
221
|
const me = walletFor({ chainId: net.chainId }, opt('from'))
|
|
193
222
|
|
|
223
|
+
// the combined recipient's ratios and payees (shares of the rest), checked as its initialize checks them
|
|
224
|
+
let comboSpec = null
|
|
225
|
+
if (combo) {
|
|
226
|
+
const spec = parseComboSpec({
|
|
227
|
+
buybackBps: flag('buyback') ? buybackBpsOf(fail, opt('buyback')) : 0,
|
|
228
|
+
lpBps: flag('lp') ? lpBpsOf(fail, opt('lp')) : 0,
|
|
229
|
+
split: flag('split') ? (opt('split') ?? '') : undefined,
|
|
230
|
+
}, me)
|
|
231
|
+
if (spec.error) {
|
|
232
|
+
const { error, ...extra } = spec
|
|
233
|
+
fail(error, extra)
|
|
234
|
+
}
|
|
235
|
+
comboSpec = { ...spec, factory: comboFactory }
|
|
236
|
+
}
|
|
237
|
+
|
|
194
238
|
// --split: a taxed V3 token whose recipient is the dev's split module (fixed payees and shares)
|
|
195
239
|
let split = null
|
|
196
|
-
if (flag('split')) {
|
|
240
|
+
if (flag('split') && !combo) {
|
|
197
241
|
const zero = (f) => /^0+(\.0+)?$/.test(opt(f) ?? '')
|
|
198
242
|
if (!flag('buy-tax') || !flag('sell-tax') || (zero('buy-tax') && zero('sell-tax'))) {
|
|
199
243
|
fail('--split needs a taxed token: add --buy-tax and --sell-tax (each 1–5, in %); the split is paid from the tax')
|
|
@@ -213,7 +257,7 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
213
257
|
// --lp: a taxed V3 token whose recipient is the dev's LP splitter (auto-liquidity, the LP to 0xdead)
|
|
214
258
|
let lp = null
|
|
215
259
|
if (flag('lp-to') && !flag('lp')) fail('--lp-to <addr> goes with --lp <pct>: it names where the part not added to the pool goes')
|
|
216
|
-
if (flag('lp')) {
|
|
260
|
+
if (flag('lp') && !combo) {
|
|
217
261
|
const zero = (f) => /^0+(\.0+)?$/.test(opt(f) ?? '')
|
|
218
262
|
if (!flag('buy-tax') || !flag('sell-tax') || (zero('buy-tax') && zero('sell-tax'))) {
|
|
219
263
|
fail('--lp needs a taxed token: add --buy-tax and --sell-tax (each 1–5, in %); the liquidity is paid from the tax')
|
|
@@ -229,12 +273,12 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
229
273
|
}
|
|
230
274
|
lp = { bps: lpBpsOf(fail, opt('lp')), factory, payee }
|
|
231
275
|
}
|
|
232
|
-
const mod = buyback ? 'buyback' : split ? 'split' : lp ? 'lp' : null
|
|
276
|
+
const mod = comboSpec ? 'combo' : buyback ? 'buyback' : split ? 'split' : lp ? 'lp' : null
|
|
233
277
|
|
|
234
278
|
const client = createPublicClient({ chain: net.chain, transport: rpcTransport(net.rpcs) })
|
|
235
279
|
const read = (address, abi, functionName, args = []) => client.readContract({ address, abi, functionName, args })
|
|
236
280
|
const key = [net.chainId, net.pad, me.toLowerCase(), kind, name, symbol].join('|')
|
|
237
|
-
const cloneStep = buyback
|
|
281
|
+
const cloneStep = { buyback: 'buyback-splitter', split: 'split-module', lp: 'lp-splitter', combo: 'combo-module' }[mod]
|
|
238
282
|
const steps = [...(mod ? [cloneStep] : []), kind === 'v3' ? 'create' : 'create (dev shares included)', ...(mod ? ['bind'] : []),
|
|
239
283
|
...(devBuy ? ['dev-buy'] : []), ...(bond ? ['bond'] : [])]
|
|
240
284
|
const rerun = 're-run this same command after executing it'
|
|
@@ -246,14 +290,15 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
246
290
|
|
|
247
291
|
// ---- a launch keeps the mode it began with (the create, once built, is never redone by a changed flag)
|
|
248
292
|
const created = plan?.startCount !== undefined
|
|
249
|
-
// the module this plan cloned: 'split' / 'lp' when it says so, else a --buyback splitter (plans from before --split)
|
|
250
|
-
const planMod = plan?.salt ? (
|
|
251
|
-
const modNoun = { buyback: 'splitter', split: 'split module', lp: 'LP splitter' }
|
|
293
|
+
// the module this plan cloned: 'split' / 'lp' / 'combo' when it says so, else a --buyback splitter (plans from before --split)
|
|
294
|
+
const planMod = plan?.salt ? (['split', 'lp', 'combo'].includes(plan.module) ? plan.module : 'buyback') : null
|
|
295
|
+
const modNoun = { buyback: 'splitter', split: 'split module', lp: 'LP splitter', combo: 'combined recipient' }
|
|
252
296
|
if (mod && created && !plan.splitter) {
|
|
253
|
-
return fail(`this launch was created without
|
|
297
|
+
return fail(`this launch was created without ${MOD_FLAG[mod]} (its recipient is fixed): run it again without ${mod === 'combo' ? '--buyback / --lp / --split' : MOD_FLAG[mod]}, or add --restart for a new token`)
|
|
254
298
|
}
|
|
255
299
|
if (planMod && mod !== planMod && (!created || mod)) {
|
|
256
|
-
|
|
300
|
+
const again = planMod === 'combo' ? 'the same --buyback / --lp / --split as before' : MOD_FLAG[planMod]
|
|
301
|
+
return fail(`this launch began with ${MOD_FLAG[planMod]} (its ${modNoun[planMod]} is cloned or on the way): run it again with ${again}${mod ? ` instead of ${MOD_FLAG[mod]}` : ''}, or add --restart${mod ? '' : ' without it'}`)
|
|
257
302
|
}
|
|
258
303
|
|
|
259
304
|
// ---- buy-back splitter: cloned for the dev before the create, at predict(dev, plan.salt)
|
|
@@ -389,6 +434,54 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
389
434
|
}
|
|
390
435
|
}
|
|
391
436
|
|
|
437
|
+
// ---- combined recipient: cloned for the dev before the create, at predict(dev, plan.salt)
|
|
438
|
+
if (comboSpec && !created) {
|
|
439
|
+
if (!plan?.salt) {
|
|
440
|
+
const refused = await untrustedBuybackQuote(read, net, flag('quote') ? opt('quote') : net.wbnb, 'combo')
|
|
441
|
+
if (refused) {
|
|
442
|
+
const { error, ...extra } = refused
|
|
443
|
+
return fail(error, extra)
|
|
444
|
+
}
|
|
445
|
+
if ((await client.getCode({ address: comboSpec.factory }) ?? '0x') === '0x') {
|
|
446
|
+
const env = testnet ? 'GANG_TESTNET_COMBO_FACTORY' : 'GANG_COMBO_FACTORY'
|
|
447
|
+
return fail(`GangComboSplitterFactory has no code at ${comboSpec.factory} on ${testnet ? 'the BSC testnet' : 'BSC mainnet'}: give one of --buyback / --lp / --split alone for now${process.env[env] ? ` (or fix ${env})` : ''}`, { factory: comboSpec.factory })
|
|
448
|
+
}
|
|
449
|
+
const salt = `0x${randomBytes(32).toString('hex')}`
|
|
450
|
+
const at = await read(comboSpec.factory, COMBO_FACTORY_ABI, 'predict', [me, salt])
|
|
451
|
+
if (comboSpec.payees.some((p) => p.toLowerCase() === at.toLowerCase())) return fail('--split: a payee cannot be the combined recipient itself', { module: at })
|
|
452
|
+
const args = [comboSpec.buybackBps, comboSpec.lpBps, comboSpec.payees, comboSpec.shares, salt]
|
|
453
|
+
const sim = await simulateCombo(client, me, comboSpec.factory, COMBO_FACTORY_ABI, 'create', args)
|
|
454
|
+
if (sim.failed) return out({ success: false, step: 'combo-module', factory: comboSpec.factory, ...tag('combo-module'), ...sim.failed })
|
|
455
|
+
writePlan(key, { ...base, salt, splitter: at, factory: comboSpec.factory, module: 'combo' })
|
|
456
|
+
const data = encodeFunctionData({ abi: COMBO_FACTORY_ABI, functionName: 'create', args })
|
|
457
|
+
const parts = comboParts(comboSpec.buybackBps, comboSpec.lpBps, comboSpec.payees.length)
|
|
458
|
+
return out({
|
|
459
|
+
...step({ chainId: net.chainId }, { from: me, to: comboSpec.factory, data }, {
|
|
460
|
+
step: 'combo-module', chainId: Number(net.chainId), factory: comboSpec.factory, module: at,
|
|
461
|
+
buybackPct: comboSpec.buybackBps / 100, lpPct: comboSpec.lpBps / 100, payeesPct: (10_000 - comboSpec.buybackBps - comboSpec.lpBps) / 100,
|
|
462
|
+
payees: comboSpec.list, permanent: true, parts,
|
|
463
|
+
note: `clones your combined recipient (combo-v1, listed as a tax recipient in the same tx). Of the recipient's part of the tax: ${comboLine(comboSpec.buybackBps, comboSpec.lpBps, comboSpec.payees, comboSpec.shares)}. ${PERMANENT_NOTE}. ${parts.otherAssets[0].toUpperCase()}${parts.otherAssets.slice(1)}`,
|
|
464
|
+
}, flag('calldata'), io.summarize),
|
|
465
|
+
...tag('combo-module', { module: at, next: `${rerun}: it then builds the create with the combined recipient as the recipient` }),
|
|
466
|
+
})
|
|
467
|
+
}
|
|
468
|
+
if ((await client.getCode({ address: plan.splitter }) ?? '0x') === '0x') {
|
|
469
|
+
return out({
|
|
470
|
+
success: false, ...tag('combo-module', { module: plan.splitter }), error: 'the combined recipient is not on chain yet',
|
|
471
|
+
hint: `if the clone was executed, wait for it to land and ${rerun.replace(' after executing it', '')}; if it was not, add --restart to build it again`,
|
|
472
|
+
})
|
|
473
|
+
}
|
|
474
|
+
const s = await comboOf(read, plan.splitter, { wbnb: net.wbnb })
|
|
475
|
+
if (!s || s.dev.toLowerCase() !== me.toLowerCase() || s.token) {
|
|
476
|
+
return fail('the module at this launch\'s address is not an unbound combined recipient of this wallet: add --restart', { module: plan.splitter })
|
|
477
|
+
}
|
|
478
|
+
const same = s.buybackBps === comboSpec.buybackBps && s.lpBps === comboSpec.lpBps && s.payees.length === comboSpec.payees.length
|
|
479
|
+
&& s.payees.every((p, i) => p.payee.toLowerCase() === comboSpec.payees[i].toLowerCase() && p.bps === comboSpec.shares[i])
|
|
480
|
+
if (!same) {
|
|
481
|
+
return fail(`this launch's combined recipient is ${comboLine(s.buybackBps, s.lpBps, s.payees.map((p) => p.payee), s.payees.map((p) => p.bps))}, not what --buyback / --lp / --split say: run it again with those, or add --restart for a new one (nothing in it can change after the clone)`, { module: plan.splitter })
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
392
485
|
// ---- create
|
|
393
486
|
if (!created) {
|
|
394
487
|
const startCount = (await read(net.pad, PAD_ABI, 'tokenCount')).toString()
|
|
@@ -439,7 +532,9 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
439
532
|
const bal = await read(token, ERC20_ABI, 'balanceOf', [me])
|
|
440
533
|
const isSplit = plan.module === 'split'
|
|
441
534
|
const isLp = plan.module === 'lp'
|
|
442
|
-
const
|
|
535
|
+
const isCombo = plan.module === 'combo'
|
|
536
|
+
const buybackState = () => (plan.splitter && !isSplit && !isLp && !isCombo ? splitterOf(read, plan.splitter) : null)
|
|
537
|
+
const comboState = () => (plan.splitter && isCombo ? comboOf(read, plan.splitter, { wbnb: net.wbnb, pad: net.pad, ref: `--token ${token}${testnet ? ' --testnet' : ''}` }) : null)
|
|
443
538
|
const lpState = () => (plan.splitter && isLp ? lpOf(read, plan.splitter, { pad: net.pad }) : null)
|
|
444
539
|
const splitState = () => (plan.splitter && isSplit ? splitOf(read, plan.splitter, { wbnb: net.wbnb, ref: `--token ${token}${testnet ? ' --testnet' : ''}` }) : null)
|
|
445
540
|
|
|
@@ -455,23 +550,27 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
455
550
|
if (sp) done.split = sp
|
|
456
551
|
const lps = await lpState()
|
|
457
552
|
if (lps) done.lp = lps
|
|
553
|
+
const cs = await comboState()
|
|
554
|
+
if (cs) done.combo = cs
|
|
458
555
|
if (!bond) return out({ ...done, note: `launched: gang ${kind} info --token ${token}${testnet ? ' --testnet' : ''}` })
|
|
459
556
|
return runBond('status', { ...stepIo({}), out: (o) => out({ ...done, bondStatus: o, note: `launched and bonded: gang bond status --token ${token}${testnet ? ' --testnet' : ''}` }) })
|
|
460
557
|
}
|
|
461
558
|
if (plan.done) return report()
|
|
462
559
|
|
|
463
|
-
// ---- bind the splitter / split module / LP splitter to the token (anyone may; the launch does it right after the create)
|
|
560
|
+
// ---- bind the splitter / split module / LP splitter / combined recipient to the token (anyone may; the launch does it right after the create)
|
|
464
561
|
if (plan.splitter) {
|
|
465
|
-
const abi = isSplit ? SPLIT_ABI : isLp ? LP_ABI : SPLITTER_ABI
|
|
562
|
+
const abi = isCombo ? COMBO_ABI : isSplit ? SPLIT_ABI : isLp ? LP_ABI : SPLITTER_ABI
|
|
466
563
|
const bound = await read(plan.splitter, abi, 'token')
|
|
467
564
|
if (bound === zeroAddress) {
|
|
468
|
-
const sim = await (isSplit ? simulateSplit : isLp ? simulateLp : simulateCall)(client, me, plan.splitter, abi, 'bind', [token])
|
|
565
|
+
const sim = await (isCombo ? simulateCombo : isSplit ? simulateSplit : isLp ? simulateLp : simulateCall)(client, me, plan.splitter, abi, 'bind', [token])
|
|
469
566
|
if (sim.failed) return out({ success: false, step: 'bind', ...tag('bind', { token }), ...sim.failed })
|
|
470
567
|
const data = encodeFunctionData({ abi, functionName: 'bind', args: [token] })
|
|
471
568
|
return out({
|
|
472
569
|
...step({ chainId: net.chainId }, { from: me, to: plan.splitter, data }, {
|
|
473
|
-
step: 'bind', chainId: Number(net.chainId), token, ...(isSplit ? { module: plan.splitter } : { splitter: plan.splitter }),
|
|
474
|
-
note:
|
|
570
|
+
step: 'bind', chainId: Number(net.chainId), token, ...(isSplit || isCombo ? { module: plan.splitter } : { splitter: plan.splitter }),
|
|
571
|
+
note: isCombo
|
|
572
|
+
? 'ties the combined recipient to this token for good: its quote is what gets split, and its pair is where the buy-backs and liquidity go (from graduation on). Nothing is split before this'
|
|
573
|
+
: isSplit
|
|
475
574
|
? 'ties the split module to this token for good: the keeper then splits its quote among the payees'
|
|
476
575
|
: isLp
|
|
477
576
|
? 'ties the LP splitter to this token for good: its pair is where the liquidity goes (from graduation on)'
|
|
@@ -481,7 +580,7 @@ export async function runLaunch(kind, { io, runV3, runFair, runBond, padNotes })
|
|
|
481
580
|
})
|
|
482
581
|
}
|
|
483
582
|
if (bound.toLowerCase() !== token.toLowerCase()) {
|
|
484
|
-
return out({ success: false, ...tag('bind', { token }), error: `the ${isSplit ? 'split module' : isLp ? 'LP splitter' : 'splitter'} is bound to another token`, [isSplit ? 'module' : 'splitter']: plan.splitter, boundTo: bound })
|
|
583
|
+
return out({ success: false, ...tag('bind', { token }), error: `the ${isCombo ? 'combined recipient' : isSplit ? 'split module' : isLp ? 'LP splitter' : 'splitter'} is bound to another token`, [isSplit || isCombo ? 'module' : 'splitter']: plan.splitter, boundTo: bound })
|
|
485
584
|
}
|
|
486
585
|
}
|
|
487
586
|
|
package/src/mcp.js
CHANGED
|
@@ -24,7 +24,7 @@ const WATCH_MAX_SEC = 30 * 60
|
|
|
24
24
|
|
|
25
25
|
// what the host shows the agent up front; some hosts cut server instructions near 2,000 characters, so the long form is in
|
|
26
26
|
// RULES (gang_help). Keep both in step with skill/SKILL.md "Hard rules"
|
|
27
|
-
const INSTRUCTIONS = `Gang (gang.fun): agent-only token launchpad on BNB Chain. Curve trades need a Binance Agentic Wallet with a .ai Agent ID: call gang_preflight first, relay each issues[].fix. Call gang_help for all flags and the full rules before any create, launch, bond, buyback, split, lp, mint or withdraw.
|
|
27
|
+
const INSTRUCTIONS = `Gang (gang.fun): agent-only token launchpad on BNB Chain. Curve trades need a Binance Agentic Wallet with a .ai Agent ID: call gang_preflight first, relay each issues[].fix. Call gang_help for all flags and the full rules before any create, launch, bond, buyback, split, lp, combo, mint or withdraw.
|
|
28
28
|
Hard rules:
|
|
29
29
|
- Preview -> show the user -> wait for a yes -> gang_execute. gang_buy / gang_sell / gang_follow and writes via gang_cli only preview; never gang_execute without the user's OK on that preview, unless they said to skip confirmation.
|
|
30
30
|
- step wrap-bnb | approve | approve-quote = setup: execute it, check gang_tx, run the same tool again. A launch in one command is re-run until launch.stage is done.
|
|
@@ -42,7 +42,7 @@ Hard rules:
|
|
|
42
42
|
export const RULES = [
|
|
43
43
|
'Start: gang_preflight; relay each issues[].fix. A result carrying update: { cmd, skill } means this CLI is older than the rules: tell the user to run cmd, and do not trade on it.',
|
|
44
44
|
'Preview -> show -> confirm -> execute. Every write first returns a preview with a requestId: show it, get the user\'s OK, then gang_execute. Chain steps without asking only when the user said to skip confirmation.',
|
|
45
|
-
'Setup steps: a preview with step wrap-bnb | approve-quote | approve is executed first; once gang_tx shows it landed, run the same tool again for the real step. A launch in one command (create with --dev-buy / --bond / --buyback / --split / --lp, or create --fair with --bond) is one tx per run: execute it, run the very same gang_cli args again until launch.stage is done.',
|
|
45
|
+
'Setup steps: a preview with step wrap-bnb | approve-quote | approve is executed first; once gang_tx shows it landed, run the same tool again for the real step. A launch in one command (create with --dev-buy / --bond / --buyback / --split / --lp, two or three of the last three together for one combined recipient whose ratios and payees are fixed for good, or create --fair with --bond) is one tx per run: execute it, run the very same gang_cli args again until launch.stage is done.',
|
|
46
46
|
'A gang_execute that timed out or was cancelled on your side keeps running here (the wallet may have sent it): never execute it again or build a new preview for the same trade before checking gang_status or gang_tx with pending: true; then gang_tx (hash, or pending: true) for the result and the note.',
|
|
47
47
|
'Notes (--note) are public and permanent: write one by default on every buy, sell, mint, withdraw (one line: what you saw, why now) and every create (the launch manifesto). Base it on data you checked, show its text with the preview, leave it out only when the user says so. No links. --conf is an honest 0-100.',
|
|
48
48
|
'Permanent token data: the logo, website, X link and description go on-chain at create and can never change. Use only links the user gave; ask once if they have not said. Never host a logo on a temporary file host. Local files (--logo, upload-logo --file) are read by this MCP server: pass an absolute path, or --logo-uri <image URL>.',
|
|
@@ -85,7 +85,7 @@ const tool = (name, title, description, properties, args, annotations, required
|
|
|
85
85
|
|
|
86
86
|
export const TOOLS = [
|
|
87
87
|
tool('gang_help', 'Commands and rules',
|
|
88
|
-
'Every gang command with all its flags (the CLI help) and the full rules. Read it before a create, launch, bond, buyback, split, lp, mint or withdraw, and whenever a flag is unclear; those commands then go through gang_cli.',
|
|
88
|
+
'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, mint or withdraw, and whenever a flag is unclear; those commands then go through gang_cli.',
|
|
89
89
|
{}, () => [], READ),
|
|
90
90
|
tool('gang_preflight', 'Check wallet setup', 'Signed in to baw, Developer Mode, Trade all tokens, Agent ID; each issue comes with a fix.',
|
|
91
91
|
{}, () => ['preflight'], READ),
|
|
@@ -175,7 +175,7 @@ export const TOOLS = [
|
|
|
175
175
|
{ hash: HASH, pending: { type: 'boolean', description: 'Find the txs of trades approved in the Binance App (no hash needed)' }, testnet: TESTNET },
|
|
176
176
|
(a) => (a.pending ? ['tx', '--pending'] : ['tx', '--hash', a.hash, ...bool('testnet', a.testnet)]), PREVIEW),
|
|
177
177
|
tool('gang_cli', 'Other gang commands',
|
|
178
|
-
'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), mint (--ref <inviter> on a Mint Flywheel token), withdraw, claim, release, fly open-early|launch|invite, quote, list, upload-logo, bond post|topup|raise-hold|extend|status|start|report|settle|refund|burn|tx, buyback status|set|set-payee|apply|bind|release, split status|distribute|release|set-payee|bind, lp status|set|set-payee|apply|bind|release|add, v3 income, version; the flags no other tool takes (--calldata, --from, …) too. E.g. ["create","--name","My Token","--symbol","MYT","--logo","/Users/me/avatar.png"], ["bond","status","--token","0x…"]. Local files are read by this server: absolute paths, or --logo-uri <image URL>. Writes only preview, as above. execute / watch / help have their own tools.',
|
|
178
|
+
'Every other gang command, its flags as separate items (gang_help lists them all): create (V3; create --fair = fair mint; create --fly = Mint Flywheel; launch in one command with --dev-buy / --bond / --buyback / --split / --lp, several of the last three = one combined recipient), mint (--ref <inviter> on a Mint Flywheel token), withdraw, claim, release, fly open-early|launch|invite, quote, list, upload-logo, bond post|topup|raise-hold|extend|status|start|report|settle|refund|burn|tx, buyback status|set|set-payee|apply|bind|release, split status|distribute|release|set-payee|bind, lp status|set|set-payee|apply|bind|release|add, combo status|distribute|release|set-payee|bind|chunk, v3 income, version; the flags no other tool takes (--calldata, --from, …) too. E.g. ["create","--name","My Token","--symbol","MYT","--logo","/Users/me/avatar.png"], ["bond","status","--token","0x…"]. Local files are read by this server: absolute paths, or --logo-uri <image URL>. Writes only preview, as above. execute / watch / help have their own tools.',
|
|
179
179
|
{ args: { type: 'array', items: { type: 'string' }, minItems: 1 } }, (a) => a.args, { readOnlyHint: false, destructiveHint: false, openWorldHint: true }, ['args']),
|
|
180
180
|
]
|
|
181
181
|
const BY_NAME = new Map(TOOLS.map((t) => [t.name, t]))
|
package/src/v3.js
CHANGED
|
@@ -9,6 +9,7 @@ import { bondGuard } from './bond.js'
|
|
|
9
9
|
import { splitterOf } from './buyback.js'
|
|
10
10
|
import { splitOf } from './split.js'
|
|
11
11
|
import { lpOf } from './lp.js'
|
|
12
|
+
import { comboOf, decoyWarning } from './combo.js'
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* `gang v3 …` — LaunchpadV3 (tax recipient): a token with its own buy / sell tax (1–5% each), a dividend share and a
|
|
@@ -285,6 +286,11 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
285
286
|
? await splitOf(ctx.read, c.recipient, { wbnb: ctx.wbnb, extraAssets: [c.quote], ref: `--token ${token}${net}` }) : null
|
|
286
287
|
// or the dev's LP splitter (lp-burn-v1): its ratio, what is set aside for the pool, the next chunk
|
|
287
288
|
const lp = c.recipient && !c.recipientIsCreator && !buyback && !split ? await lpOf(ctx.read, c.recipient, { pad: ctx.pad }) : null
|
|
289
|
+
// or the dev's combined recipient (combo-v1): fixed buy-back / LP ratios and payees, the set-aside parts, the next chunk
|
|
290
|
+
const comboRef = `--token ${token}${net}`
|
|
291
|
+
const combo = c.recipient && !c.recipientIsCreator && !buyback && !split && !lp
|
|
292
|
+
? await comboOf(ctx.read, c.recipient, { wbnb: ctx.wbnb, pad: ctx.pad, extraAssets: [c.quote], ref: comboRef }) : null
|
|
293
|
+
const comboWarning = combo ? decoyWarning(combo, token, c.quote, comboRef) : null
|
|
288
294
|
const lpWarn = lp && lp.token && lp.token.toLowerCase() !== token.toLowerCase()
|
|
289
295
|
? { warning: `this token pays its tax to the LP splitter, but it is bound to another token (${lp.token}): the liquidity goes to that token's pair` } : null
|
|
290
296
|
const splitWarn = split && split.token && split.token.toLowerCase() !== token.toLowerCase()
|
|
@@ -292,6 +298,7 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
292
298
|
return out({
|
|
293
299
|
success: true, chainId: Number(ctx.chainId), ...fees, ...pub, taxNote, ...(swapBack && { swapBack }), ...(buyback && { buyback }),
|
|
294
300
|
...(split && { split: { ...split, ...splitWarn } }), ...(lp && { lp: { ...lp, ...lpWarn } }),
|
|
301
|
+
...(combo && { combo: { ...combo, ...(comboWarning && { warning: comboWarning }) } }),
|
|
295
302
|
})
|
|
296
303
|
}
|
|
297
304
|
|