@gangfun/cli 0.28.0 → 0.29.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 +2 -1
- package/README.zh-CN.md +2 -1
- package/package.json +1 -1
- package/src/bond.js +64 -8
- package/src/index.js +3 -2
package/README.md
CHANGED
|
@@ -106,7 +106,8 @@ gang v3 income --recipient 0x… # a recipient's income per token
|
|
|
106
106
|
gang bond post --token <addr> --hold <tokens|N%> --days <7-90> (--amount <quote> | --cover 100) [--use-wbnb] # creator, from create on (--cover once on the pair); WBNB quote: paid in BNB unless --use-wbnb
|
|
107
107
|
gang bond topup --token <addr> (--amount <quote> | --cover <%>) | gang bond raise-hold --token <addr> --hold <tokens|N%>
|
|
108
108
|
gang bond extend --token <addr> --days <n> # creator: bond only grows, X only rises, the commitment only gets longer
|
|
109
|
-
gang bond status --token <addr> # state, pending / running, X vs the creator's balance, coverage + tier, time left
|
|
109
|
+
gang bond status --token <addr> # state, pending / running, X vs the creator's balance, live coverage + tier, time left
|
|
110
|
+
# (0.29.0+: the tier is gang.fun's anchored one, so a price rise never lowers it; tierBasis anchor | live)
|
|
110
111
|
gang bond start --token <addr> # anyone, once graduated / launched: start the --days clock
|
|
111
112
|
gang bond report --token <addr> # anyone, below X: 1% to you, the rest buys back and burns
|
|
112
113
|
gang bond settle --token <addr> # anyone, after T while X is held: the bond goes back to the creator
|
package/README.zh-CN.md
CHANGED
|
@@ -85,7 +85,8 @@ gang v3 income --recipient 0x… # 接收地址按币统计的到
|
|
|
85
85
|
gang bond post --token <addr> --hold <枚数|N%> --days <7-90> (--amount <报价币数量> | --cover 100) [--use-wbnb] # 创建者,发币后随时可押(--cover 要等开盘);WBNB 报价默认付 BNB,--use-wbnb 付 WBNB
|
|
86
86
|
gang bond topup --token <addr> (--amount <数量> | --cover <%>) | gang bond raise-hold --token <addr> --hold <枚数|N%>
|
|
87
87
|
gang bond extend --token <addr> --days <天数> # 创建者:押金只能加、X 只能提高、承诺期只能变长
|
|
88
|
-
gang bond status --token <addr> # 状态(待开始 / 计时中)、X
|
|
88
|
+
gang bond status --token <addr> # 状态(待开始 / 计时中)、X 和创建者余额、现价覆盖率和档位、剩余时间
|
|
89
|
+
# (0.29.0 起档位按 gang.fun 的锚定价计算,币价上涨不降档;tierBasis anchor | live)
|
|
89
90
|
gang bond start --token <addr> # 任何人,毕业 / 开盘后开始计时
|
|
90
91
|
gang bond report --token <addr> # 任何人,余额低于 X 时举报:拿押金 1%,其余回购销毁
|
|
91
92
|
gang bond settle --token <addr> # 任何人,T 之后余额仍达标:押金退回创建者
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gangfun/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"mcpName": "io.github.gangfun/gang",
|
|
5
5
|
"description": "Gang launchpad CLI for Binance Agentic Wallet agents: create on GangLaunchpad (untaxed or tax tokens), 打新 fair mint, PancakeSwap pool trades, LaunchpadV2 and legacy Soft/U/S trade.",
|
|
6
6
|
"type": "module",
|
package/src/bond.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createPublicClient, parseAbi, encodeFunctionData, decodeEventLog, forma
|
|
|
2
2
|
import { decimalsOf, fundingStep as fund, parseAmount, parseIntIn, parseNum, revertOf as revertIn, step, units, GAS_RESERVE } from './steps.js'
|
|
3
3
|
import { atTokenPad, GANG_GENS, gangGens, KIND_UNREAD, MERGED_ERRORS_ABI, MERGED_HINTS, NOT_ON_MAINNET, padNets, rpcTransport } from './gangpad.js'
|
|
4
4
|
import { bawAddress } from './baw.js'
|
|
5
|
+
import { get as apiGet } from './discover.js'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* `gang bond …` — GangBond (Agent 押金承诺, gang-launchpad src/gang/GangBond.sol): a creator of a GangLaunchpad token
|
|
@@ -159,12 +160,44 @@ const ceilDiv = (a, b) => (a + b - 1n) / b
|
|
|
159
160
|
const tierOf = (bps) => (bps >= BPS ? 'full' : bps >= 5_000n ? 'bond' : 'none')
|
|
160
161
|
const TIER_NOTE = { full: '押金全覆盖: dumping X now loses money (bond ≥ what the sale fetches)', bond: '押金: bond covers 50–100% of what dumping X fetches', none: 'below 50% coverage: a plain gray 押金 badge on gang.fun (bond and coverage still shown)' }
|
|
161
162
|
|
|
163
|
+
/**
|
|
164
|
+
* The tier's coverage (bps): the bond over the lower of the dump value now and the anchor. gang.fun anchors the badge to
|
|
165
|
+
* the dump value when X was set on the pair (post on it / clock start / hold raise; raised to any higher live read in the
|
|
166
|
+
* hour after, so a one-block dip can't set it), so a price rise never lowers the tier and an honest creator need not keep
|
|
167
|
+
* adding to stay 押金全覆盖; the live coverage is still shown next to it. No anchor: the live coverage. MAX_UINT when X
|
|
168
|
+
* fetches nothing (as GangBond.coverageBps).
|
|
169
|
+
*/
|
|
170
|
+
export const tierBps = (amount, dump, anchor) => {
|
|
171
|
+
const d = anchor != null && anchor < dump ? anchor : dump
|
|
172
|
+
return d ? (amount * BPS) / d : MAX_UINT
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** How long a bond command waits for gang.fun's anchor before going on with the live tier. */
|
|
176
|
+
const ANCHOR_WAIT_MS = 3_000
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* gang.fun's anchor for this round (wei of the quote), or null: not mainnet (gang.fun indexes mainnet only), no anchor
|
|
180
|
+
* indexed yet, another round, an X gang.fun has not caught up with (a hold raise not indexed yet: its anchor is for the
|
|
181
|
+
* old X), or gang.fun unreachable / slower than ANCHOR_WAIT_MS — the tier is then the live one. Never fails the command.
|
|
182
|
+
*/
|
|
183
|
+
export async function anchorOf(ctx, token, round, hold) {
|
|
184
|
+
if (String(ctx.chainId) !== '56') return null
|
|
185
|
+
try {
|
|
186
|
+
const r = await apiGet(`/bonds/${token.toLowerCase()}`, AbortSignal.timeout(ANCHOR_WAIT_MS), '')
|
|
187
|
+
if (!r || Number(r.round) !== round || !same(r.bond ?? ctx.bond, ctx.bond) || !/^\d+$/.test(r.anchorDumpValue ?? '')) return null
|
|
188
|
+
if (r.holdAmount != null && String(r.holdAmount) !== String(hold)) return null
|
|
189
|
+
const a = BigInt(r.anchorDumpValue)
|
|
190
|
+
return a > 0n ? a : null
|
|
191
|
+
} catch { return null }
|
|
192
|
+
}
|
|
193
|
+
|
|
162
194
|
async function nowOf(ctx) {
|
|
163
195
|
return Number((await ctx.client.getBlock()).timestamp)
|
|
164
196
|
}
|
|
165
197
|
|
|
166
|
-
/** The bond and everything around it, formatted; raw fields kept under `_raw` for the commands.
|
|
167
|
-
|
|
198
|
+
/** The bond and everything around it, formatted; raw fields kept under `_raw` for the commands. withAnchor: ask gang.fun
|
|
199
|
+
* for the tier's anchor (status and the previews that show a tier; report / settle don't wait on it). */
|
|
200
|
+
async function bondView(ctx, token, m, withAnchor = false) {
|
|
168
201
|
const b = await ctx.read(ctx.bond, BOND_ABI, 'bondOf', [token])
|
|
169
202
|
const state = STATES[Number(b.state)] ?? String(b.state)
|
|
170
203
|
const quote = b.quote === zeroAddress ? m.quote : b.quote
|
|
@@ -210,14 +243,25 @@ async function bondView(ctx, token, m) {
|
|
|
210
243
|
})
|
|
211
244
|
return { ...v, _raw: raw }
|
|
212
245
|
}
|
|
213
|
-
const [dump, cov] = await Promise.all([
|
|
246
|
+
const [dump, cov, anchor] = await Promise.all([
|
|
214
247
|
ctx.read(ctx.bond, BOND_ABI, 'dumpValue', [token]),
|
|
215
248
|
ctx.read(ctx.bond, BOND_ABI, 'coverageBps', [token]),
|
|
249
|
+
withAnchor ? anchorOf(ctx, token, Number(b.round), b.holdAmount) : null,
|
|
216
250
|
])
|
|
217
251
|
const left = Number(b.deadline) - now
|
|
218
252
|
const settleAt = Number(b.requestAt)
|
|
253
|
+
const tcov = tierBps(b.amount, dump, anchor)
|
|
254
|
+
const anchored = anchor != null && dump > anchor
|
|
219
255
|
Object.assign(v, {
|
|
220
|
-
phase: 'running', violated, dumpValue: q(dump), coveragePct: cov === MAX_UINT ? null : pctOfBps(cov),
|
|
256
|
+
phase: 'running', violated, dumpValue: q(dump), coveragePct: cov === MAX_UINT ? null : pctOfBps(cov),
|
|
257
|
+
// the badge: anchored on gang.fun (a price rise never lowers it); coveragePct / toFullCover stay live
|
|
258
|
+
// tierBasis anchor: at the dump value when X was set (or now, if lower); live: no anchor from gang.fun
|
|
259
|
+
tier: tierOf(tcov), tierCoveragePct: tcov === MAX_UINT ? null : pctOfBps(tcov), tierBasis: anchor == null ? 'live' : 'anchor',
|
|
260
|
+
anchorDumpValue: anchor == null ? null : q(anchor),
|
|
261
|
+
...(anchored && { dumpChangePct: pctOfBps(((dump - anchor) * BPS) / anchor) }),
|
|
262
|
+
tierNote: anchored
|
|
263
|
+
? `dumping X now fetches more than at the anchor: the badge stays at the anchor's tier (${tierOf(tcov)}); live coverage ${cov === MAX_UINT ? '-' : pctOfBps(cov)}%`
|
|
264
|
+
: TIER_NOTE[tierOf(tcov)],
|
|
221
265
|
toFullCover: dump > b.amount ? q(dump - b.amount) : '0',
|
|
222
266
|
...(left > 0 ? { secondsLeft: left, daysLeft: Math.round((left / DAY) * 10) / 10 } : { pastDeadline: true }),
|
|
223
267
|
...violatedNote,
|
|
@@ -230,7 +274,7 @@ async function bondView(ctx, token, m) {
|
|
|
230
274
|
: `settle is due: gang bond settle --token ${token} returns the bond to the creator (X must still be held)`,
|
|
231
275
|
}),
|
|
232
276
|
})
|
|
233
|
-
Object.assign(raw, { dump, cov })
|
|
277
|
+
Object.assign(raw, { dump, cov, anchor })
|
|
234
278
|
}
|
|
235
279
|
if (state === 'slashed') {
|
|
236
280
|
const [ready, quoteIn, tokensOut] = await ctx.read(ctx.bond, BOND_ABI, 'previewBurn', [token])
|
|
@@ -320,7 +364,7 @@ export async function runBond(sub, { opt, flag, out, fail, summarize }) {
|
|
|
320
364
|
if (!ctx.bond) return fail('this token\'s GangLaunchpad generation has no GangBond in this CLI version', { token, chainId, padGen: ctx.gen })
|
|
321
365
|
const m = await marketOf(ctx, token)
|
|
322
366
|
if (!m) return fail('not a GangLaunchpad token (V3 or 打新) on this network: bonds cover only those', { token, chainId })
|
|
323
|
-
const view = await bondView(ctx, token, m)
|
|
367
|
+
const view = await bondView(ctx, token, m, ['status', 'topup', 'raise-hold'].includes(sub))
|
|
324
368
|
const { _raw: raw, ...pub } = view
|
|
325
369
|
const b = raw.bond
|
|
326
370
|
const qf = (x) => formatUnits(x, raw.dec)
|
|
@@ -499,9 +543,11 @@ export async function runBond(sub, { opt, flag, out, fail, summarize }) {
|
|
|
499
543
|
if (sim.failed) return out({ success: false, step: 'topup', ...sim.failed })
|
|
500
544
|
const total = b.amount + amount
|
|
501
545
|
const cov = !raw.dump ? null : (total * BPS) / raw.dump
|
|
546
|
+
const tcov = raw.dump == null ? null : tierBps(total, raw.dump, raw.anchor)
|
|
502
547
|
return out(send('topUp', [token, amount], {
|
|
503
548
|
step: 'topup', add: qf(amount), bondAfter: qf(total), quote: view.quote, payWith: pay.value ? 'BNB' : view.quote,
|
|
504
|
-
dumpValue: view.dumpValue, coveragePct: cov == null ? null : pctOfBps(cov),
|
|
549
|
+
dumpValue: view.dumpValue, coveragePct: cov == null ? null : pctOfBps(cov),
|
|
550
|
+
tier: tcov == null || tcov === MAX_UINT ? 'full' : tierOf(tcov), ...(view.tierBasis && { tierBasis: view.tierBasis }), deadline: view.deadline,
|
|
505
551
|
note: 'a bond can only grow: nothing comes back before settle',
|
|
506
552
|
}, pay.value))
|
|
507
553
|
}
|
|
@@ -515,9 +561,19 @@ export async function runBond(sub, { opt, flag, out, fail, summarize }) {
|
|
|
515
561
|
if (sim.failed) return out({ success: false, step: 'raise-hold', ...sim.failed })
|
|
516
562
|
const dump = m.live ? await ctx.read(ctx.bond, BOND_ABI, 'quoteDump', [token, hold]) : null
|
|
517
563
|
const cov = !dump ? null : (b.amount * BPS) / dump
|
|
564
|
+
// gang.fun's new anchor: the dump of the new X now, or the old anchor scaled to it if lower (a raise after a rise),
|
|
565
|
+
// never below the old anchor (a raise in a dip must not lock in a low one)
|
|
566
|
+
const scaled = raw.anchor == null || !b.holdAmount ? null : (raw.anchor * hold) / b.holdAmount
|
|
567
|
+
const lower = scaled == null || dump == null ? null : dump < scaled ? dump : scaled
|
|
568
|
+
const anchor = lower == null ? null : lower > raw.anchor ? lower : raw.anchor
|
|
569
|
+
const tcov = dump == null ? null : tierBps(b.amount, dump, anchor)
|
|
518
570
|
return out(send('raiseHold', [token, hold], {
|
|
519
571
|
step: 'raise-hold', holdBefore: view.holdTokens, holdAfter: tokens(hold), creatorBalance: view.creatorBalance,
|
|
520
|
-
...(dump != null && {
|
|
572
|
+
...(dump != null && {
|
|
573
|
+
dumpValueAfter: qf(dump), coveragePctAfter: cov == null ? null : pctOfBps(cov),
|
|
574
|
+
tierAfter: tcov === MAX_UINT ? 'full' : tierOf(tcov), ...(view.tierBasis && { tierBasis: view.tierBasis }),
|
|
575
|
+
}),
|
|
576
|
+
deadline: view.deadline,
|
|
521
577
|
note: 'X can only go up; a higher X means dumping it fetches more, so the same bond covers less',
|
|
522
578
|
}))
|
|
523
579
|
}
|
package/src/index.js
CHANGED
|
@@ -492,8 +492,9 @@ BOND (押金承诺, GangBond; any GangLaunchpad token, from create on; GANG_BOND
|
|
|
492
492
|
creator only: the bond only grows, X only rises, the commitment only gets longer (90
|
|
493
493
|
days in all before the pair; a deadline ≤ 90 days from now after it)
|
|
494
494
|
gang bond status --token <addr> state, phase (pending: waiting for the pair / running), X and the creator's balance /
|
|
495
|
-
headroom, coverage + tier once on the pair (≥100% full cover, 50–100% bond, <50% plain
|
|
496
|
-
gray badge), toFullCover, time left,
|
|
495
|
+
headroom, live coverage + tier once on the pair (≥100% full cover, 50–100% bond, <50% plain
|
|
496
|
+
gray badge; anchored on gang.fun, a price rise never lowers it), toFullCover, time left,
|
|
497
|
+
buy-back progress, the creator's record
|
|
497
498
|
gang bond start --token <addr> anyone, once the token graduated / launched: start the clock (deadline = now + days)
|
|
498
499
|
gang bond report --token <addr> anyone, when the creator holds less than X: 1% of the bond to you, the rest buys
|
|
499
500
|
back and burns the token (simulated first; nothing is sent when not violated)
|