feat(launkr): add restricted SIP-010 token launcher + XYK AMM skill#413
feat(launkr): add restricted SIP-010 token launcher + XYK AMM skill#413julianariel wants to merge 3 commits into
Conversation
Adds the `launkr` skill (SKILL.md, AGENT.md, launkr.ts) for launching and
trading restricted SIP-010 tokens on the Launkr protected AMM, plus the
README and skills.json manifest entries.
Verified against the Launkr source (lp-singleton-v6 contract + /api/{launch,
protocol}): contract addresses, function/arg order, get-pool tuple fields,
fee schedule (bonding 1% / direct 5%), floors, and error codes.
Notable review fixes folded in:
- Network is single-sourced from the shared NETWORK env var (matching every
other skill and the wallet the tx is signed with). Removed the per-command
--network flag, which diverged from the broadcast network and from the fee
and explorer-URL network.
- swap-sell now broadcasts in Deny mode with a scoped fungible post-condition
on the token sold (asset name is the constant `strategy-token`, since every
token is a byte-identical copy of the template) instead of Allow mode.
- Dropped dead temp-file I/O in launch; reconciled SKILL.md / AGENT.md docs.
Follow-up (not in this PR): the /api/launch intent specifies clarityVersion 4
and the token template uses `contract-hash?` (Clarity 4), but the shared
deployContract helper cannot yet pass a clarity version.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
arc0btc
left a comment
There was a problem hiding this comment.
Adds the launkr skill for launching restricted SIP-010 tokens and trading them through Launkr's protected XYK AMM singleton. Solid piece of work — clearly cross-checked against the live contract (lp-singleton-v6), not just the API docs.
What works well:
- Post-condition discipline is correct and matches the docs:
swap-buyscopes an exact STX post-condition (eq --stx-in),swap-sellscopes an exact fungible post-condition onstrategy-token(eq --tokens-in), both broadcast inDenymode. SinceDenymode rejects any unlisted asset movement, the direct-modelaunchpath (emptypostConditionswhen--stx-seedis absent) fails closed rather than silently draining STX — good instinct, not an oversight. - Sequencing between deploy and pool-create is right:
waitForConfirmationpollstx_statusand only proceeds on"success", with an explicit abort-status list (coversdropped_replace_by_feeetc. — the same transient status our own nonce-gap incident hit, per our memory notes). No premature step 2. - Network handling is single-sourced from the shared
NETWORKenv var (typed"mainnet" | "testnet"insrc/lib/config/networks.ts), matching how the wallet itself resolves network — no risk of a--networkflag diverging from the signing key/broadcast target. AGENT.mdis a genuinely useful "how to behave" doc, not boilerplate — the hash-gate warning, thenonevsSome("")optional-encoding gotcha, and the "don't retry blind" error-handling guidance are the kind of thing that prevents real mistakes.
[question] Clarity 4 deploy target not yet wired through
The PR description flags that /api/launch specifies clarityVersion: 4 (needed for contract-hash? in the token template) but deployContract in src/lib/transactions/builder.ts has no way to pass a clarity version yet, so the deploy falls back to the Stacks.js default. AGENT.md separately says the contract "has passed a live end-to-end test" — can you confirm that live test went through this exact launch deploy path (not just a manual deploy), and if so, what clarity version stacks.js actually negotiated? If the default happens to resolve to 4 on the current epoch this is moot, but if not, create-pool would fail after the deploy is already confirmed on-chain, which is a wasted (though recoverable) transaction rather than a fund-loss risk.
[suggestion] No client-side validation of mode-conditional required args (launkr.ts launch command)
--virtual-stx/--graduation-threshold (bonding) and --stx-seed (direct) are all .option(), not .requiredOption(), and nothing checks that the right ones are present for the chosen --mode before hitting the API. Today a missing arg just surfaces as a Launkr API 400, which handleError reports — not a silent failure — so this isn't blocking, just a rougher error message than a local check would give (e.g. "--stx-seed is required for --mode direct").
[nit] A handful of .requiredOption(...) .action(...) and .option(...) .action(...) calls are missing the newline between chained calls (e.g. get-pool line ~904, quote-buy ~988, quote-sell ~1058, swap-buy ~1140, swap-sell ~1203) — cosmetic, doesn't affect behavior.
Code quality notes:
NET_CONFIG.mainnet.hiroApiis hardcoded to"https://api.hiro.so"while the existing shared helpergetApiBaseUrl(network)insrc/lib/config/networks.tsalready returns"https://api.mainnet.hiro.so"/"https://api.testnet.hiro.so"for the same purpose. Both are valid Hiro endpoints, but this is a second, slightly different source of truth for the same mapping — worth reusing the existing helper instead of re-declaring it, so a future endpoint change doesn't need to be made in two places.- The repeated read-only-call boilerplate (
get-pool/quote-buy/quote-sellall do the same try/catch-fallback-to-burn-addressgetWalletAddress()dance, then the samedecodeCV→ unwrap-value→ stringify pattern) could be a shared helper, but it's not large enough to be a real maintenance risk at 3 call sites.
Operational context: We already run several DeFi skills (defi, bitflow, zest-yield-manager) through this same builder.ts/post-conditions.ts infrastructure, and the nonce-handling pattern here (no explicit nonce, confirm-before-next-step) matches what we rely on operationally — no new nonce-serialization risk introduced.
None of the above is blocking. Approving.
makeContractDeploy is called without a clarity version, so deploys use the Stacks.js default. Add an optional `clarityVersion` to ContractDeployOptions and pass it through, so callers deploying a contract that needs a specific Clarity version (e.g. one using `contract-hash?`, a Clarity 4 primitive) can request it. Additive and backward-compatible — omitting it keeps the previous behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Pass the /api/launch intent's clarityVersion (4) through to the token deploy so the restricted-token template (which uses contract-hash?, a Clarity 4 primitive) deploys under the right version. - Validate mode-specific required args client-side before the API call (bonding needs --virtual-stx/--graduation-threshold; direct needs --stx-seed), so a bad invocation fails fast with a clear message. - Source the Hiro API host from the shared getApiBaseUrl(network) helper instead of a second hardcoded copy in NET_CONFIG. - Add author-agent frontmatter and inline launkr.io / ratherlabs.com links in SKILL.md; fix the skills.json author (rather-labs) to match the frontmatter and add authorAgent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Reopening to finish here — the earlier close was a process mixup, apologies for the churn. Pushed follow-ups addressing the review: |
|
Superseded by #414 — reopened as a fresh PR with the verified version (read path fixed; no shared-library changes). |
launkr— launch & trade restricted SIP-010 tokens on LaunkrLaunkr is a protected token launcher and XYK AMM on Stacks, built by Rather Labs. Each pool trades STX against a restricted SIP-010 token whose transfers are locked to the authorized singleton, so every swap routes through the protocol and captures fees. Tokens launch in one of two pool modes — bonding (virtual reserves, 1% fee, auto-graduates once it crosses its threshold) or direct (real STX seed, 5% fee). Works on mainnet and testnet.
This skill lets an agent (or a user via any LLM client) drive the full lifecycle:
launch— deploy a restricted token (byte-identical to the on-chain template) and open its bonding or direct pool.get-pool— read a pool's mode, reserves, graduation progress, and fee receiver.quote-buy/quote-sell— simulate a trade and get expected output net of fees (no wallet needed).swap-buy/swap-sell— trade STX for tokens and back through the singleton, with slippage guards.SKILL.mddocuments the subcommands, arguments, protocol floors, and error codes;AGENT.mdcovers autonomous-operation rules. Files:launkr/{SKILL.md,AGENT.md,launkr.ts}, plus aREADME.mdrow and theskills.jsonmanifest entry.