关于 stacks-market
Stacks Market skill 通过 stacksmarket.app 和链上合约交易预测市场,仅支持主网。适合需要发现市场、查看报价、买卖 YES/NO 份额并追踪或赎回持仓的 Stacks 用户。
主要功能
- 01按状态、类别筛选并搜索市场
- 02获取 YES/NO 份额实时报价
- 03带滑点保护买入或卖出份额
- 04市场结算后赎回获胜份额
- 05查询市场持仓余额
适用场景
- 01按主题寻找预测市场
- 02交易前核对成本或卖出收益
- 03市场结算后赎回获胜份额
- 04检查特定地址的市场持仓
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ aibtcdev/ skills --skill stacks-market安装后在 Claude Code 中输入/stacks-market确认已加载。
附带文件AGENT.mdstacks-market.ts
详细介绍
Stacks Market 技能
通过链上合约 SP3N5CN0PE7YRRP29X7K9XG22BT861BRS5BN8HFFA.market-factory-v18-bias,在 stacksmarket.app 上交易预测市场。
- 市场发现 — 通过 REST API 列出并搜索预测市场,可按状态、类别和精选标记筛选。
- 价格报价 — 在投入资金前,通过链上只读调用获取 YES/NO 份额的实时 LMSR 价格。
- 交易 — 使用滑点保护买入 YES 或 NO 份额(
buy-yes-auto、buy-no-auto)。卖出时设定最低收益保护(sell-yes-auto、sell-no-auto)。 - 赎回 — 市场结算后赎回获胜份额(获胜时,每份额 = 1 STX)。
- 持仓跟踪 — 查看你在任意市场中的 YES 和 NO 份额余额。
所有操作仅限主网。写入操作(buy-yes、buy-no、sell-yes、sell-no、redeem)需要已解锁的钱包(请先运行 bun run wallet/wallet.ts unlock)。
用法
bun run stacks-market/stacks-market.ts <subcommand> [options]
子命令
list-markets
列出 stacksmarket.app 上的预测市场。返回按最近活动时间排序的市场。
bun run stacks-market/stacks-market.ts list-markets [--limit <n>] [--status <status>] [--category <cat>] [--featured]
选项:
--limit(可选)— 返回的市场数量(默认值:20)--status(可选)— 按状态筛选:active|ended|resolved--category(可选)— 按类别筛选(例如,Crypto、Politics)--featured(可选)— 仅显示精选市场
输出:
{
"network": "mainnet",
"marketCount": 5,
"markets": [
{
"_id": "699c573ea7bb5ad25fee68a0",
"marketId": "1771853629839",
"title": "Will BTC close above $100k by end of Q1?",
"category": "Crypto",
"isActive": true,
"isResolved": false,
"endDate": "2026-03-31T23:59:00.000Z",
"totalVolume": 5000000000,
"totalTrades": 42
}
]
}
search-markets
按关键词搜索预测市场。搜索标题和描述。
bun run stacks-market/stacks-market.ts search-markets --query <keyword> [--limit <n>]
选项:
--query(必填)— 搜索关键词--limit(可选)— 最大结果数(默认值:10)
输出:
{
"network": "mainnet",
"query": "bitcoin",
"resultCount": 3,
"markets": [
{
"_id": "699c573ea7bb5ad25fee68a0",
"marketId": "1771853629839",
"title": "Will BTC close above $100k by end of Q1?",
"isActive": true,
"isResolved": false
}
]
}
get-market
获取单个预测市场的完整详情,包括交易历史和订单簿。
bun run stacks-market/stacks-market.ts get-market --market-id <mongoId>
选项:
--market-id(必填)— 市场的 MongoDB_id(例如,699c573ea7bb5ad25fee68a0)
输出:
{
"network": "mainnet",
"market": {
"_id": "699c573ea7bb5ad25fee68a0",
"marketId": "1771853629839",
"title": "Will BTC close above $100k by end of Q1?",
"description": "Resolution source: CoinGecko closing price...",
"category": "Crypto",
"options": [
{ "text": "Yes", "impliedProbability": 52, "totalVolume": 3000000000 },
{ "text": "No", "impliedProbability": 48, "totalVolume": 2000000000 }
],
"isActive": true,
"isResolved": false,
"winningOption": null,
"endDate": "2026-03-31T23:59:00.000Z",
"totalVolume": 5000000000,
"totalTrades": 42,
"tradeHistory": []
}
}
quote-buy
获取买入 YES 或 NO 份额的价格报价。买入前务必先询价,以确认成本和滑点。
bun run stacks-market/stacks-market.ts quote-buy --market-id <id> --side <yes|no> --amount <shares>
选项:
--market-id(必填)— 市场 ID(纪元毫秒时间戳,例如,1771853629839)--side(必填)—yes或no--amount(必填)— 要买入的份额数量(整数,例如,买入 5 份额时填写5)
输出:
{
"network": "mainnet",
"quote": {
"marketId": "1771853629839",
"side": "yes",
"shares": 5,
"totalCostUstx": 5250000,
"totalCostStx": "5.25",
"fees": {
"protocolUstx": 125000,
"lpUstx": 75000
}
}
}
quote-sell
获取卖出 YES 或 NO 份额的价格报价。卖出前务必先询价,以确认收益。
bun run stacks-market/stacks-market.ts quote-sell --market-id <id> --side <yes|no> --amount <shares>
选项:
--market-id(必填)— 市场 ID(纪元毫秒时间戳)--side(必填)—yes或no--amount(必填)— 要卖出的份额数量(整数)
输出:
{
"network": "mainnet",
"quote": {
"marketId": "1771853629839",
"side": "yes",
"shares": 5,
"totalProceedsUstx": 4750000,
"totalProceedsStx": "4.75",
"fees": {
"protocolUstx": 125000,
"lpUstx": 75000
}
}
}
buy-yes
在预测市场中买入 YES 份额。使用 buy-yes-auto 提供滑点保护。需要已解锁的钱包。
bun run stacks-market/stacks-market.ts buy-yes --market-id <id> --amount <shares> --max-cost <ustx>
选项:
--market-id(必填)— 市场 ID(纪元毫秒时间戳)--amount(必填)— 要买入的 YES 份额数量--max-cost(必填)— 总成本上限,单位为 uSTX(滑点保护)。请先通过quote-buy获取。
输出:
{
"success": true,
"txid": "abc123...",
"network": "mainnet",
"explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet",
"trade": {
"marketId": "1771853629839",
"side": "yes",
"shares": 5,
"maxCostUstx": 5500000
}
}
buy-no
在预测市场中买入 NO 份额。使用 buy-no-auto 提供滑点保护。需要已解锁的钱包。
bun run stacks-market/stacks-market.ts buy-no --market-id <id> --amount <shares> --max-cost <ustx>
选项:
--market-id(必填)— 市场 ID(纪元毫秒时间戳)--amount(必填)— 要买入的 NO 份额数量--max-cost(必填)— 总成本上限,单位为 uSTX(滑点保护)
输出:
{
"success": true,
"txid": "abc123...",
"network": "mainnet",
"explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet",
"trade": {
"marketId": "1771853629839",
"side": "no",
"shares": 5,
"maxCostUstx": 5500000
}
}
sell-yes
在市场结算前卖出 YES 份额。使用 sell-yes-auto 设置最低收益保护。需要已解锁的钱包。
bun run stacks-market/stacks-market.ts sell-yes --market-id <id> --amount <shares> --min-proceeds <ustx>
选项:
--market-id(必填)— 市场 ID(纪元毫秒时间戳)--amount(必填)— 要卖出的 YES 份额数量--min-proceeds(必填)— 可接受的最低收益,单位为 uSTX(滑点保护)。请先通过quote-sell获取。
输出:
{
"success": true,
"txid": "abc123...",
"network": "mainnet",
"explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet",
"trade": {
"marketId": "1771853629839",
"side": "yes",
"shares": 5,
"minProceedsUstx": 4500000
}
}
sell-no
在市场结算前卖出 NO 份额。使用 sell-no-auto 并设置最低收益保护。需要已解锁的钱包。
bun run stacks-market/stacks-market.ts sell-no --market-id <id> --amount <shares> --min-proceeds <ustx>
选项:
--market-id(必填)— 市场 ID(纪元毫秒时间戳)--amount(必填)— 要卖出的 NO 份额数量--min-proceeds(必填)— 可接受的最低收益,单位为 uSTX
输出:
{
"success": true,
"txid": "abc123...",
"network": "mainnet",
"explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet",
"trade": {
"marketId": "1771853629839",
"side": "no",
"shares": 5,
"minProceedsUstx": 4500000
}
}
redeem
在市场结算后赎回获胜份额。每份获胜份额可兑换 1 STX(1,000,000 uSTX)。需要已解锁的钱包。
bun run stacks-market/stacks-market.ts redeem --market-id <id>
选项:
--market-id(必填)— 市场 ID(纪元毫秒时间戳)
输出:
{
"success": true,
"txid": "abc123...",
"network": "mainnet",
"explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet",
"marketId": "1771853629839"
}
get-position
获取你在某个市场中的 YES 和 NO 份额余额。也可选择查询任意地址。
bun run stacks-market/stacks-market.ts get-position --market-id <id> [--address <stacksAddress>]
选项:
--market-id(必填)— 市场 ID(纪元毫秒时间戳)--address(可选)— 要查询的 Stacks 地址(若省略,则使用当前钱包)
输出:
{
"network": "mainnet",
"address": "SP2...",
"marketId": "1771853629839",
"position": {
"yesShares": 5,
"noShares": 0
}
}
注意事项
- 所有操作仅限 主网。在测试网上调用会返回错误。
- 写入操作需要已解锁的钱包(请先运行
bun run wallet/wallet.ts unlock)。 - 交易前务必运行
quote-buy或quote-sell,以确认成本并设置滑点范围。 - 市场 ID 是纪元毫秒时间戳(例如
1771853629839),不是 MongoDB_id。 get-market子命令使用 MongoDB_id(例如699c573ea7bb5ad25fee68a0),而不是marketId。- 写入操作必须使用
PostConditionMode.Allow— 合约会在内部转移 STX(发送方 → 池 → 手续费钱包),而默认后置条件会阻止此操作。 - 即使
endDate已过,isActive仍可能为true— 合约所有者必须手动结算。务必检查isResolved并对照时间。 - 赎回时,每份获胜份额可兑换 1 STX;失败份额不产生收益。所有份额都会被销毁。
- 除份额成本外,每笔交易的 Gas 费约为 0.05–0.1 STX。
- LMSR 定价:份额成本遵循对数曲线 — 在同一方向买入更多份额会推高价格。提交买入前,请立即获取最新报价。