@gangfun/cli 0.43.1 → 0.44.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/DEVELOPERS.md +10 -0
- package/DEVELOPERS.zh-CN.md +9 -0
- package/README.md +6 -1
- package/README.zh-CN.md +15 -2
- package/package.json +1 -1
- package/src/capabilities.js +7 -0
- package/src/countdown.js +762 -0
- package/src/flags.js +1 -1
- package/src/floor.js +4 -3
- package/src/gangpad.js +13 -2
- package/src/gradreward.js +38 -11
- package/src/index.js +75 -9
- package/src/launch.js +287 -28
- package/src/mcp.js +5 -3
- package/src/pool.js +15 -0
- package/src/promote.js +1 -1
- package/src/telemetry.js +1 -1
- package/src/v3.js +74 -17
package/src/v3.js
CHANGED
|
@@ -15,9 +15,10 @@ import { lpOf } from './lp.js'
|
|
|
15
15
|
import { comboOf, decoyWarning } from './combo.js'
|
|
16
16
|
import { cappedOf, decoyWarning as cappedDecoyWarning } from './capped.js'
|
|
17
17
|
import { floorFactoryAddress, floorOf, floorShown, treasuryShare, typedFloorModule } from './floor.js'
|
|
18
|
+
import { COUNTDOWN_TYPE, countdownBuy, countdownFactoryAddress, countdownForToken, countdownSellLine, formatCountdown } from './countdown.js'
|
|
18
19
|
import { VANITY_ABI, vanityCreate, vanityDeployer } from './vanity.js'
|
|
19
20
|
import { BASE_LOST, BASE_NO_BOND, BASE_PAD_ABI, baseOf as baseVaultView, basePayoff, baseSupport, baseTaxLine, HINTS as BASE_HINTS, parseBase, scheduleLine } from './base.js'
|
|
20
|
-
import { bnbInQuote, DEFAULT_MIN_BUY_BNB, GRAD_FLAGS, GRAD_PAD_ABI, gradBuyLine, gradCreateView, gradOf, gradSellLine, gradSupport, HINTS as GRAD_HINTS, MIN_SEED_BNB, parseGradReward } from './gradreward.js'
|
|
21
|
+
import { bnbInQuote, carryClosed, DEFAULT_MIN_BUY_BNB, DEFAULTS as GRAD_DEFAULTS, GRAD_FLAGS, GRAD_PAD_ABI, gradBuyLine, gradCreateView, gradOf, gradSellLine, gradSupport, HINTS as GRAD_HINTS, MIN_SEED_BNB, parseGradReward } from './gradreward.js'
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* `gang v3 …` — LaunchpadV3 (tax recipient): a token with its own buy / sell tax (1–5% each), a dividend share and a
|
|
@@ -393,6 +394,13 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
393
394
|
...floorRaw,
|
|
394
395
|
treasuryGets: treasuryShare({ buyTaxPct: c.buyTaxPct, sellTaxPct: c.sellTaxPct, platformTaxPct: fees.platformTaxPct, dividendPct: c.dividendPct, payBps: floorRaw.cap?.reached ? 0 : floorRaw.payBps }),
|
|
395
396
|
})
|
|
397
|
+
// or its countdown reward module (countdown-v1): the dev's tax share as buyers' rewards; only one the factory made,
|
|
398
|
+
// cloned for this very token, is shown with its numbers
|
|
399
|
+
const cdSeen = c.recipient && !c.recipientIsCreator && !buyback && !split && !lp && !combo && !capped && !floorRaw
|
|
400
|
+
? await countdownForToken(ctx, token, c.recipient) : null
|
|
401
|
+
const countdown = !cdSeen ? null : cdSeen.unread ? { error: 'could not read the token\'s countdown reward module (RPC error)', detail: cdSeen.unread, retry: `gang countdown status --token ${token}${net}` }
|
|
402
|
+
: cdSeen.warning ? { module: cdSeen.module, isThisTokensCountdown: false, warning: cdSeen.warning }
|
|
403
|
+
: { ...formatCountdown(cdSeen.raw, { symbol: c.quoteSymbol, decimals: await decimalsOf(ctx, c.quote) }, `--token ${token}${net}`), more: `gang countdown status --token ${token}${net}` }
|
|
396
404
|
const lpWarn = lp && lp.token && lp.token.toLowerCase() !== token.toLowerCase()
|
|
397
405
|
? { 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
|
|
398
406
|
const splitWarn = split && split.token && split.token.toLowerCase() !== token.toLowerCase()
|
|
@@ -417,7 +425,7 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
417
425
|
...(split && { split: { ...split, ...splitWarn } }), ...(lp && { lp: { ...lp, ...lpWarn } }),
|
|
418
426
|
...(combo && { combo: { ...combo, ...(comboWarning && { warning: comboWarning }) } }),
|
|
419
427
|
...(capped && { capped: { ...capped, ...(cappedWarning && { warning: cappedWarning }) } }),
|
|
420
|
-
...(floor && { floor }),
|
|
428
|
+
...(floor && { floor }), ...(countdown && { countdown }),
|
|
421
429
|
})
|
|
422
430
|
}
|
|
423
431
|
|
|
@@ -533,8 +541,12 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
533
541
|
if (gr) {
|
|
534
542
|
if (vault) fail('--grad-reward and --vault can\'t go together: a vault-bound token takes no graduation reward (its locks move balances outside the curve)')
|
|
535
543
|
if (base) fail('--grad-reward and --base can\'t go together (one create entry each)')
|
|
536
|
-
|
|
544
|
+
// the one launch it goes with: --countdown-reward (the module cloned for this token takes the tax; the carry goes there)
|
|
545
|
+
if ((launchFloor && launchFloor.noun !== 'countdown reward module') || launchPoolModule) fail('--grad-reward goes on a plain create, or a --countdown-reward launch only')
|
|
537
546
|
}
|
|
547
|
+
const cdLaunch = launchFloor?.noun === 'countdown reward module'
|
|
548
|
+
const carryBps = gr ? (gr.carryBps ?? (cdLaunch ? GRAD_DEFAULTS.carryPct * 100 : 0)) : 0
|
|
549
|
+
if (gr && carryBps > 0 && !cdLaunch) fail('--gr-carry carries part of the pool into the token\'s countdown reward: add --countdown-reward (the launch clones the module), or leave --gr-carry out')
|
|
538
550
|
if (grad !== null && !(grad > 0)) fail('--grad must be the graduation target in BNB raised: 6, 9, 12 or 15', { got: opt('grad') ?? null })
|
|
539
551
|
const buyTax = taxed ? taxOf('buy-tax') : 0
|
|
540
552
|
const sellTax = taxed ? taxOf('sell-tax') : 0
|
|
@@ -591,10 +603,16 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
591
603
|
if (support.unread) fail('could not check the pad for the opening base (RPC error)', { pad: ctx.pad, detail: support.unread, retry: 'same command again' })
|
|
592
604
|
if (!support.open) fail(`${support.why}: drop --base${testnet ? '' : ' (it is on the BSC testnet: --testnet)'}`, { pad: ctx.pad })
|
|
593
605
|
}
|
|
606
|
+
// with --countdown-reward, the pad knows the module (the carry's and the sweep's destination) only once gang opened
|
|
607
|
+
// the carry with this CLI's countdown factory
|
|
608
|
+
let grToModule = false
|
|
594
609
|
if (gr) {
|
|
595
610
|
const support = await gradSupport(ctx)
|
|
596
611
|
if (support.unread) fail('could not check the pad for the graduation reward (RPC error)', { pad: ctx.pad, detail: support.unread, retry: 'same command again' })
|
|
597
612
|
if (!support.open) fail(`${support.why}: drop --grad-reward${testnet ? '' : ' (it is on the BSC testnet: --testnet)'}`, { pad: ctx.pad })
|
|
613
|
+
const cf = countdownFactoryAddress(testnet)
|
|
614
|
+
grToModule = cdLaunch && !!cf && String(support.countdownFactory ?? '').toLowerCase() === cf.toLowerCase()
|
|
615
|
+
if (carryBps > 0 && !grToModule) fail(carryClosed(support.countdownFactory, cf), { pad: ctx.pad })
|
|
598
616
|
}
|
|
599
617
|
// the recipient may be the creator itself: checkTaxConfigFor knows who creates (a pad without it: checkTaxConfig)
|
|
600
618
|
const [ok, reason] = await ctx.read(ctx.pad, PAD_ABI, 'checkTaxConfigFor', [me, tax]).catch((e) => {
|
|
@@ -612,6 +630,15 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
612
630
|
if (typed.floor) {
|
|
613
631
|
fail('--recipient is a floor module: a token can\'t name one by hand. A floor module serves only the token address it was cloned for, so this token\'s tax would go into a module that can never bind it, and the token would have no floor. Leave --recipient out and add --floor: the launch clones a module for this token', { recipient, seenBy: typed.by })
|
|
614
632
|
}
|
|
633
|
+
// a countdown reward module likewise serves the one token address it was cloned for: this token's tax would feed
|
|
634
|
+
// another token's reward pool
|
|
635
|
+
if (!typed.unlisted && !typed.unread) {
|
|
636
|
+
const cd = await typedFloorModule({ client: ctx.client, pad: ctx.pad }, recipient, countdownFactoryAddress(testnet), COUNTDOWN_TYPE)
|
|
637
|
+
if (cd.floor) {
|
|
638
|
+
fail('--recipient is a countdown reward module: a token can\'t name one by hand. It serves only the token address it was cloned for, so this token\'s tax would feed another token\'s reward pool, and this token would have no countdown. Leave --recipient out and add --countdown-reward: the launch clones a module for this token', { recipient, seenBy: cd.by })
|
|
639
|
+
}
|
|
640
|
+
if (cd.unread) fail('could not check --recipient (RPC error)', { detail: cd.unread, retry: 'same command again' })
|
|
641
|
+
}
|
|
615
642
|
// the pad just took this recipient, so it is listed: a node that says otherwise is behind (or the two answers are
|
|
616
643
|
// of different blocks). Not sure → nothing is built
|
|
617
644
|
if (typed.unlisted) fail('could not check --recipient: the pad accepts it, but the tax handler did not show it as listed at the block it was checked on (a node may be behind)', { recipient, retry: 'same command again' })
|
|
@@ -658,12 +685,12 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
658
685
|
if (seedRaw < seedFloor) fail(`--grad-reward: the seed must be at least ${await units(ctx, quote, seedFloor)} ${sym} (${MIN_SEED_BNB} BNB at this token's rate): a smaller pool is not worth a list`, { got: gr.seed })
|
|
659
686
|
if (seedRaw >= 2n ** 128n || minBuyRaw >= 2n ** 96n || minBuyRaw === 0n) fail('--grad-reward / --gr-min-buy: amount out of range', { seed: gr.seed, minBuy: gr.minBuy })
|
|
660
687
|
grCfg = {
|
|
661
|
-
seed: seedRaw, minBuy: minBuyRaw, entries: gr.entries, lastBps: gr.lastBps, carryBps
|
|
688
|
+
seed: seedRaw, minBuy: minBuyRaw, entries: gr.entries, lastBps: gr.lastBps, carryBps, refundAfter: gr.refundDays * 86_400,
|
|
662
689
|
promoteBps: promote?.shareBps ?? 0, promoteWindow: promote?.window ?? 0,
|
|
663
690
|
}
|
|
664
691
|
grView = gradCreateView({
|
|
665
692
|
seed: await units(ctx, quote, seedRaw), minBuy: await units(ctx, quote, minBuyRaw), sym, entries: gr.entries, lastBps: gr.lastBps,
|
|
666
|
-
refundDays: gr.refundDays, targetBnb, gateOn: await ctx.read(ctx.pad, GRAD_PAD_ABI, 'agentGateEnabled'),
|
|
693
|
+
refundDays: gr.refundDays, targetBnb, gateOn: await ctx.read(ctx.pad, GRAD_PAD_ABI, 'agentGateEnabled'), carryBps, toModule: grToModule,
|
|
667
694
|
...(!gr.minBuy && { seedFloorNote: `--gr-min-buy left out: ${DEFAULT_MIN_BUY_BNB} BNB at this token's rate` }),
|
|
668
695
|
})
|
|
669
696
|
const pre = await fundingStep(ctx, me, quote, seedRaw, sym, 'approve-quote', rawOnly, summarize)
|
|
@@ -683,21 +710,25 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
683
710
|
const prepareCreate = (logoURI, metaURI, fixed = null) => vanityCreate(ctx, me, createData(logoURI, metaURI), {
|
|
684
711
|
args: [name, symbol, metaURI, handler, tax.buyTaxBps, tax.sellTaxBps, false], fixed,
|
|
685
712
|
})
|
|
686
|
-
// the logo / metadata strings never decide a revert: dry-run without them, so a create that would fail uploads nothing
|
|
687
|
-
|
|
713
|
+
// the logo / metadata strings never decide a revert: dry-run without them, so a create that would fail uploads nothing.
|
|
714
|
+
// A pinned launch (floor / countdown module cloned for one address) has them fixed already: its dry run uses them and
|
|
715
|
+
// the pinned salt, since a carry checks that the module was made for this very token address
|
|
716
|
+
const pinned = launchFloor ? [launchFloor.logoURI, launchFloor.metaURI] : ['', '']
|
|
717
|
+
const probe = await prepareCreate(...pinned, launchFloor ? { salt: launchFloor.salt, token: launchFloor.token } : null)
|
|
688
718
|
// createWithSalt (abcd) or the entry itself; a base create sends exactly its cost either way
|
|
689
|
-
const dry = await simulate(ctx, me, ctx.pad, probe.salt ? VANITY_ABI : createAbi,
|
|
690
|
-
probe.salt ? 'createWithSalt' : fn, probe.salt ? [probe.salt, createData(
|
|
691
|
-
if (dry
|
|
719
|
+
const dry = probe.mismatch ? null : await simulate(ctx, me, ctx.pad, probe.salt ? VANITY_ABI : createAbi,
|
|
720
|
+
probe.salt ? 'createWithSalt' : fn, probe.salt ? [probe.salt, createData(...pinned)] : argsOf(...pinned), baseCost)
|
|
721
|
+
if (dry?.failed) return out({ success: false, step: 'create', ...dry.failed })
|
|
692
722
|
// a floor launch: the module was cloned for one token address, so the create reuses the metadata and the salt that
|
|
693
723
|
// give it, and is refused when anything that decides the address (name, symbol, tax rates) changed since
|
|
694
724
|
const logo = launchFloor ? { logoURI: launchFloor.logoURI, uploaded: !!launchFloor.uploaded } : await resolveLogo()
|
|
695
725
|
const meta = launchFloor ? { metaURI: launchFloor.metaURI, metadata: launchFloor.metadata } : await resolveMeta({ name, symbol, logoURI: logo.logoURI })
|
|
696
726
|
const launch = await prepareCreate(logo.logoURI, meta.metaURI, launchFloor ? { salt: launchFloor.salt, token: launchFloor.token } : null)
|
|
727
|
+
const pinnedNoun = launchFloor?.noun ?? 'floor module'
|
|
697
728
|
if (launch.mismatch) {
|
|
698
729
|
return fail(launch.mismatch.got
|
|
699
|
-
?
|
|
700
|
-
:
|
|
730
|
+
? `this create would put the token at another address than the one its ${pinnedNoun} was cloned for: the name, the symbol or a tax rate changed since the module was cloned. Run the launch again with what it began with, or add --restart for a new module and token`
|
|
731
|
+
: `the pad's token deployer could not be read: a ${pinnedNoun} launch creates its token at the address its module was cloned for, so nothing is built without it`, {
|
|
701
732
|
floorToken: launch.mismatch.expected, ...(launch.mismatch.got && { wouldBe: launch.mismatch.got }), retry: launch.mismatch.got ? undefined : 'same command again',
|
|
702
733
|
})
|
|
703
734
|
}
|
|
@@ -706,7 +737,7 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
706
737
|
const sure = await simulate(ctx, me, ctx.pad, VANITY_ABI, 'createWithSalt', [launch.salt, createData(logo.logoURI, meta.metaURI)])
|
|
707
738
|
if (sure.failed) return out({ success: false, step: 'create', ...sure.failed })
|
|
708
739
|
if (String(sure.result).toLowerCase() !== String(launchFloor.token).toLowerCase()) {
|
|
709
|
-
return fail(
|
|
740
|
+
return fail(`the pad would create this token at another address than the one its ${pinnedNoun} was cloned for: nothing is built. Add --restart for a new module and token`, { floorToken: launchFloor.token, padSays: sure.result })
|
|
710
741
|
}
|
|
711
742
|
}
|
|
712
743
|
let label = null
|
|
@@ -739,7 +770,7 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
739
770
|
buyTaxPct: buyTax, sellTaxPct: sellTax, dividendPct: dividend,
|
|
740
771
|
recipient: recipient === zeroAddress ? null : recipient, recipientLabel: selfRecipient ? 'you (the creator)' : label, tokenIfNext: launch.token ?? dry.result,
|
|
741
772
|
...(launch.token && { addressSuffix: 'abcd' }),
|
|
742
|
-
...(launchFloor && { floorToken: launchFloor.token, metadataFixed:
|
|
773
|
+
...(launchFloor && { [launchFloor.noun === 'countdown reward module' ? 'countdownToken' : 'floorToken']: launchFloor.token, metadataFixed: `the metadata is the one fixed when the ${pinnedNoun} was cloned (its URL is part of the token's address); --logo / --description / --website / --twitter given now are not read again` }),
|
|
743
774
|
split: taxed
|
|
744
775
|
? `of each ${buyTax}% buy / ${sellTax}% sell tax in the PancakeSwap pool (after graduation; the curve charges no tax): ${fees.platformTaxPct}% of volume to the platform, then ${dividend}% of the rest to holders, ${rest}% to the recipient in the quote`
|
|
745
776
|
+ (dividend > 0 ? '; if no holder has 10,000+ tokens when a tax is paid, the holders\' part goes to the recipient too' : '')
|
|
@@ -774,13 +805,27 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
774
805
|
if (flag('promoter')) fail('--promoter binds on the curve only, and this token has graduated: on a token with a pool share, a wallet bound on the curve keeps counting for its promoter here, inside its window', { token })
|
|
775
806
|
if (!flag('amount') && !flag('bnb')) fail('--amount <quote (or BNB) to spend> required')
|
|
776
807
|
const raw = parseAmount(fail, flag('amount') ? 'amount' : 'bnb', opt('amount') ?? opt('bnb'))
|
|
808
|
+
// the token's countdown reward (countdown-v1): only a buy through its module counts, so gang buy goes there
|
|
809
|
+
const me = walletFor(ctx, opt('from'))
|
|
810
|
+
const cd = await countdownForToken(ctx, token, c.recipientIsCreator ? null : c.recipient, me)
|
|
811
|
+
if (cd?.unread) fail('could not check whether this token\'s tax recipient is its countdown reward module (RPC error): nothing is built, since a buy that should count must go through the module', { token, detail: cd.unread, retry: 'same command again' })
|
|
812
|
+
if (cd?.live) {
|
|
813
|
+
// the module's buy carries no invite tag: gang.fun credits an invite on curve trades and mints
|
|
814
|
+
if (flag('ref')) fail('--ref does not apply to a buy through the countdown reward module: that buy carries no invite tag. Leave --ref out (the invite credit is for a first curve trade or mint)', { token, module: cd.raw.module })
|
|
815
|
+
return out(await countdownBuy(ctx, {
|
|
816
|
+
token, c, cd, me, amount: raw, slippage: parseSlippage(fail, opt('slippage', '1')), payBnb: poolPayBnb(ctx, c.quote, flag),
|
|
817
|
+
mustCount: !flag('cd-uncounted'), rawOnly, summarize, base: { kind: 'v3', ...notes.pool },
|
|
818
|
+
}))
|
|
819
|
+
}
|
|
820
|
+
if (flag('cd-uncounted')) fail('--cd-uncounted applies to a token whose tax recipient is its countdown reward module (countdown-v1): this one has none', { token })
|
|
777
821
|
return out(await poolTrade(ctx, {
|
|
778
822
|
side: 'buy', token, quote: c.quote, me: walletFor(ctx, opt('from')), amount: raw,
|
|
779
823
|
slippage: parseSlippage(fail, opt('slippage', '1')), buyTaxBps: Math.round(c.buyTaxPct * 100),
|
|
780
824
|
sellTaxBps: Math.round(c.sellTaxPct * 100), handler: c.taxHandler, payBnb: poolPayBnb(ctx, c.quote, flag),
|
|
781
|
-
base: { kind: 'v3', pair: c.pair, ...notes.pool },
|
|
825
|
+
base: { kind: 'v3', pair: c.pair, ...notes.pool, ...(cd?.warning && { rewards: { countdown: { counts: false, warning: cd.warning } } }) },
|
|
782
826
|
}, { rawOnly, summarize, revertOf }))
|
|
783
827
|
}
|
|
828
|
+
if (flag('cd-uncounted')) fail('--cd-uncounted applies to pool buys after graduation: curve buys never count for the countdown reward', { token })
|
|
784
829
|
const me = walletFor(ctx, opt('from'))
|
|
785
830
|
if (!(await ctx.read(ctx.pad, PAD_ABI, 'isAgent', [me]))) fail('this wallet holds no Agent ID; curve trades are Agent-only', { wallet: me })
|
|
786
831
|
const room = await ctx.read(ctx.pad, PAD_ABI, 'walletRoom', [token, me])
|
|
@@ -802,6 +847,14 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
802
847
|
: `the 1% wallet cap leaves this wallet room for ${formatUnits(tokensOut, 18)} more tokens only`
|
|
803
848
|
return { spent: s, refund: r, cutBy: cut, cutNote: `${why}: the buy spends ${s} ${c.quoteSymbol} (fee included) and refunds ${r} ${refundAs}` }
|
|
804
849
|
}
|
|
850
|
+
// a countdown reward counts pool buys through its module only: a curve buy never does (read once per command)
|
|
851
|
+
let cdCurve
|
|
852
|
+
const cdCurveLine = async () => {
|
|
853
|
+
cdCurve ??= countdownForToken(ctx, token, c.recipientIsCreator ? null : c.recipient).then((cd) => (cd?.live
|
|
854
|
+
? { counts: false, why: 'curve buys never count: the countdown starts after graduation, for buys through the token\'s countdown module in its PancakeSwap pool (gang buy does that by default)' }
|
|
855
|
+
: cd?.unread ? { error: 'could not read the token\'s countdown reward (RPC error)', detail: cd.unread } : null))
|
|
856
|
+
return cdCurve
|
|
857
|
+
}
|
|
805
858
|
// the token's buy-time rewards (3.0): what this buy means for each, one key per kind
|
|
806
859
|
const rewardsOf = async (tokensOut) => {
|
|
807
860
|
const { spent, cut } = await spentFor(ctx, c, quoteIn, tokensOut, room)
|
|
@@ -810,7 +863,8 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
810
863
|
const feeBps = BigInt(Math.round((await feesOf(ctx)).curveFeePct * 100))
|
|
811
864
|
const graduates = cut === 'graduation' || spent - (spent * feeBps) / 10_000n >= c.curveRaw.remaining
|
|
812
865
|
const gradReward = await gradBuyLine(ctx, token, c.quote, c.quoteSymbol, me, spent, graduates)
|
|
813
|
-
|
|
866
|
+
const countdown = await cdCurveLine()
|
|
867
|
+
return gradReward || countdown ? { rewards: { ...(gradReward && { gradReward }), ...(countdown && { countdown }) } } : {}
|
|
814
868
|
}
|
|
815
869
|
const extra = async (tokensOut, minOut, refundAs = c.quoteSymbol) => ({
|
|
816
870
|
step: 'buy', chainId: Number(ctx.chainId), token, spend: raw, quote: c.quoteSymbol, expectTokens: formatUnits(tokensOut, 18),
|
|
@@ -899,10 +953,13 @@ export async function runV3(sub, { opt, flag, out, fail, summarize, resolveLogo,
|
|
|
899
953
|
let me = null
|
|
900
954
|
try { me = walletFor(ctx, opt('from')) } catch { /* no wallet configured */ }
|
|
901
955
|
if (me) {
|
|
956
|
+
const cd = await countdownForToken(ctx, token, c.recipientIsCreator ? null : c.recipient)
|
|
957
|
+
const cdLine = cd?.live ? countdownSellLine(cd.raw, { symbol: c.quoteSymbol, decimals: await decimalsOf(ctx, c.quote) })
|
|
958
|
+
: cd?.unread ? { error: 'could not read the token\'s countdown reward (RPC error): a sell never touches its slots anyway', detail: cd.unread } : null
|
|
902
959
|
return out(await poolTrade(ctx, {
|
|
903
960
|
side: 'sell', token, quote: c.quote, me, amount: flag('all') ? null : parseAmount(fail, 'amount', opt('amount')), all: flag('all'),
|
|
904
961
|
slippage, buyTaxBps: Math.round(c.buyTaxPct * 100), sellTaxBps: Math.round(c.sellTaxPct * 100), handler: c.taxHandler,
|
|
905
|
-
swapBackGas: c.sellTaxPct > 0, toBnb: flag('to-bnb'), base: { kind: 'v3', pair: c.pair, ...notes.pool },
|
|
962
|
+
swapBackGas: c.sellTaxPct > 0, toBnb: flag('to-bnb'), base: { kind: 'v3', pair: c.pair, ...notes.pool, ...(cdLine && { rewards: { countdown: cdLine } }) },
|
|
906
963
|
bond: { testnet, breakBond: flag('break-bond'), settleFirst: flag('settle-first'), breakCallBond: flag('break-call-bond') },
|
|
907
964
|
}, { rawOnly, summarize, revertOf }))
|
|
908
965
|
}
|