stacks-market

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Stacks Market Skill

Stacks Market Skill

Trade prediction markets on stacksmarket.app via the on-chain contract
SP3N5CN0PE7YRRP29X7K9XG22BT861BRS5BN8HFFA.market-factory-v18-bias
.
  • Market Discovery — List and search prediction markets via REST API with filters for status, category, and featured flag.
  • Price Quoting — Get real-time LMSR prices for YES/NO shares via on-chain read-only calls before committing funds.
  • Trading — Buy YES or NO shares with slippage protection (
    buy-yes-auto
    ,
    buy-no-auto
    ). Sell with minimum proceeds guard (
    sell-yes-auto
    ,
    sell-no-auto
    ).
  • Redemption — Redeem winning shares after market resolution (1 share = 1 STX for winners).
  • Position Tracking — Check your YES and NO share balances in any market.
All operations are mainnet-only. Write operations (buy-yes, buy-no, sell-yes, sell-no, redeem) require an unlocked wallet (use
bun run wallet/wallet.ts unlock
first).
通过链上合约
SP3N5CN0PE7YRRP29X7K9XG22BT861BRS5BN8HFFA.market-factory-v18-bias
stacksmarket.app上交易预测市场。
  • 市场发现 — 通过REST API列出并搜索预测市场,支持按状态、分类和精选标记筛选。
  • 价格查询 — 在投入资金前,通过链上只读调用获取YES/NO份额的实时LMSR价格。
  • 交易 — 通过
    buy-yes-auto
    buy-no-auto
    实现滑点保护的YES/NO份额买入;通过
    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
)。

Usage

使用方法

bun run stacks-market/stacks-market.ts <subcommand> [options]
bun run stacks-market/stacks-market.ts <subcommand> [options]

Subcommands

子命令

list-markets

list-markets

List prediction markets from stacksmarket.app. Returns markets sorted by most recent activity.
bun run stacks-market/stacks-market.ts list-markets [--limit <n>] [--status <status>] [--category <cat>] [--featured]
Options:
  • --limit
    (optional) — Number of markets to return (default: 20)
  • --status
    (optional) — Filter by status:
    active
    |
    ended
    |
    resolved
  • --category
    (optional) — Filter by category (e.g.,
    Crypto
    ,
    Politics
    )
  • --featured
    (optional) — Show only featured markets
Output:
json
{
  "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
    }
  ]
}
列出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
    (可选)—— 仅显示精选市场
输出:
json
{
  "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

search-markets

Search prediction markets by keyword. Searches titles and descriptions.
bun run stacks-market/stacks-market.ts search-markets --query <keyword> [--limit <n>]
Options:
  • --query
    (required) — Search keyword
  • --limit
    (optional) — Maximum results (default: 10)
Output:
json
{
  "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
    }
  ]
}
通过关键词搜索预测市场,搜索范围包括标题和描述。
bun run stacks-market/stacks-market.ts search-markets --query <keyword> [--limit <n>]
选项:
  • --query
    (必填)—— 搜索关键词
  • --limit
    (可选)—— 最大结果数量(默认值:10)
输出:
json
{
  "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

get-market

Get full details for a single prediction market including trade history and order book.
bun run stacks-market/stacks-market.ts get-market --market-id <mongoId>
Options:
  • --market-id
    (required) — MongoDB
    _id
    of the market (e.g.,
    699c573ea7bb5ad25fee68a0
    )
Output:
json
{
  "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": []
  }
}
获取单个预测市场的完整详情,包括交易历史和订单簿。
bun run stacks-market/stacks-market.ts get-market --market-id <mongoId>
选项:
  • --market-id
    (必填)—— 市场的MongoDB
    _id
    (例如:
    699c573ea7bb5ad25fee68a0
输出:
json
{
  "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

quote-buy

Get a price quote for buying YES or NO shares. Always quote before buying to verify cost and slippage.
bun run stacks-market/stacks-market.ts quote-buy --market-id <id> --side <yes|no> --amount <shares>
Options:
  • --market-id
    (required) — Market ID (epoch millisecond timestamp, e.g.,
    1771853629839
    )
  • --side
    (required) —
    yes
    or
    no
  • --amount
    (required) — Number of shares to buy (integer, e.g.,
    5
    for 5 shares)
Output:
json
{
  "network": "mainnet",
  "quote": {
    "marketId": "1771853629839",
    "side": "yes",
    "shares": 5,
    "totalCostUstx": 5250000,
    "totalCostStx": "5.25",
    "fees": {
      "protocolUstx": 125000,
      "lpUstx": 75000
    }
  }
}
获取买入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份)
输出:
json
{
  "network": "mainnet",
  "quote": {
    "marketId": "1771853629839",
    "side": "yes",
    "shares": 5,
    "totalCostUstx": 5250000,
    "totalCostStx": "5.25",
    "fees": {
      "protocolUstx": 125000,
      "lpUstx": 75000
    }
  }
}

quote-sell

quote-sell

Get a price quote for selling YES or NO shares. Always quote before selling to verify proceeds.
bun run stacks-market/stacks-market.ts quote-sell --market-id <id> --side <yes|no> --amount <shares>
Options:
  • --market-id
    (required) — Market ID (epoch millisecond timestamp)
  • --side
    (required) —
    yes
    or
    no
  • --amount
    (required) — Number of shares to sell (integer)
Output:
json
{
  "network": "mainnet",
  "quote": {
    "marketId": "1771853629839",
    "side": "yes",
    "shares": 5,
    "totalProceedsUstx": 4750000,
    "totalProceedsStx": "4.75",
    "fees": {
      "protocolUstx": 125000,
      "lpUstx": 75000
    }
  }
}
获取卖出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
    (必填)—— 卖出的份额数量(整数)
输出:
json
{
  "network": "mainnet",
  "quote": {
    "marketId": "1771853629839",
    "side": "yes",
    "shares": 5,
    "totalProceedsUstx": 4750000,
    "totalProceedsStx": "4.75",
    "fees": {
      "protocolUstx": 125000,
      "lpUstx": 75000
    }
  }
}

buy-yes

buy-yes

Buy YES shares in a prediction market. Uses
buy-yes-auto
for slippage protection. Requires an unlocked wallet.
bun run stacks-market/stacks-market.ts buy-yes --market-id <id> --amount <shares> --max-cost <ustx>
Options:
  • --market-id
    (required) — Market ID (epoch millisecond timestamp)
  • --amount
    (required) — Number of YES shares to buy
  • --max-cost
    (required) — Maximum total cost in uSTX (slippage protection). Get from
    quote-buy
    first.
Output:
json
{
  "success": true,
  "txid": "abc123...",
  "network": "mainnet",
  "explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet",
  "trade": {
    "marketId": "1771853629839",
    "side": "yes",
    "shares": 5,
    "maxCostUstx": 5500000
  }
}
在预测市场中买入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
    获取
输出:
json
{
  "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

buy-no

Buy NO shares in a prediction market. Uses
buy-no-auto
for slippage protection. Requires an unlocked wallet.
bun run stacks-market/stacks-market.ts buy-no --market-id <id> --amount <shares> --max-cost <ustx>
Options:
  • --market-id
    (required) — Market ID (epoch millisecond timestamp)
  • --amount
    (required) — Number of NO shares to buy
  • --max-cost
    (required) — Maximum total cost in uSTX (slippage protection)
Output:
json
{
  "success": true,
  "txid": "abc123...",
  "network": "mainnet",
  "explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet",
  "trade": {
    "marketId": "1771853629839",
    "side": "no",
    "shares": 5,
    "maxCostUstx": 5500000
  }
}
在预测市场中买入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为单位,滑点保护用)
输出:
json
{
  "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

sell-yes

Sell YES shares before market resolution. Uses
sell-yes-auto
with minimum proceeds guard. Requires an unlocked wallet.
bun run stacks-market/stacks-market.ts sell-yes --market-id <id> --amount <shares> --min-proceeds <ustx>
Options:
  • --market-id
    (required) — Market ID (epoch millisecond timestamp)
  • --amount
    (required) — Number of YES shares to sell
  • --min-proceeds
    (required) — Minimum acceptable proceeds in uSTX (slippage protection). Get from
    quote-sell
    first.
Output:
json
{
  "success": true,
  "txid": "abc123...",
  "network": "mainnet",
  "explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet",
  "trade": {
    "marketId": "1771853629839",
    "side": "yes",
    "shares": 5,
    "minProceedsUstx": 4500000
  }
}
在市场结算前卖出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
    获取
输出:
json
{
  "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

sell-no

Sell NO shares before market resolution. Uses
sell-no-auto
with minimum proceeds guard. Requires an unlocked wallet.
bun run stacks-market/stacks-market.ts sell-no --market-id <id> --amount <shares> --min-proceeds <ustx>
Options:
  • --market-id
    (required) — Market ID (epoch millisecond timestamp)
  • --amount
    (required) — Number of NO shares to sell
  • --min-proceeds
    (required) — Minimum acceptable proceeds in uSTX
Output:
json
{
  "success": true,
  "txid": "abc123...",
  "network": "mainnet",
  "explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet",
  "trade": {
    "marketId": "1771853629839",
    "side": "no",
    "shares": 5,
    "minProceedsUstx": 4500000
  }
}
在市场结算前卖出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为单位)
输出:
json
{
  "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

redeem

Redeem winning shares after market resolution. Winning shares pay 1 STX (1,000,000 uSTX) each. Requires an unlocked wallet.
bun run stacks-market/stacks-market.ts redeem --market-id <id>
Options:
  • --market-id
    (required) — Market ID (epoch millisecond timestamp)
Output:
json
{
  "success": true,
  "txid": "abc123...",
  "network": "mainnet",
  "explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet",
  "marketId": "1771853629839"
}
市场结算后兑换获胜份额,获胜份额每份可兑换1 STX(1,000,000 uSTX),需要解锁的钱包。
bun run stacks-market/stacks-market.ts redeem --market-id <id>
选项:
  • --market-id
    (必填)—— 市场ID(毫秒级时间戳)
输出:
json
{
  "success": true,
  "txid": "abc123...",
  "network": "mainnet",
  "explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet",
  "marketId": "1771853629839"
}

get-position

get-position

Get your YES and NO share balances in a market. Optionally check any address.
bun run stacks-market/stacks-market.ts get-position --market-id <id> [--address <stacksAddress>]
Options:
  • --market-id
    (required) — Market ID (epoch millisecond timestamp)
  • --address
    (optional) — Stacks address to check (uses active wallet if omitted)
Output:
json
{
  "network": "mainnet",
  "address": "SP2...",
  "marketId": "1771853629839",
  "position": {
    "yesShares": 5,
    "noShares": 0
  }
}
查询你在某个市场中的YES和NO份额余额,也可查询指定地址的仓位。
bun run stacks-market/stacks-market.ts get-position --market-id <id> [--address <stacksAddress>]
选项:
  • --market-id
    (必填)—— 市场ID(毫秒级时间戳)
  • --address
    (可选)—— 要查询的Stacks地址(未指定则使用当前活跃钱包)
输出:
json
{
  "network": "mainnet",
  "address": "SP2...",
  "marketId": "1771853629839",
  "position": {
    "yesShares": 5,
    "noShares": 0
  }
}

Notes

注意事项

  • All operations are mainnet-only. Calls on testnet will return an error.
  • Write operations require an unlocked wallet (use
    bun run wallet/wallet.ts unlock
    first).
  • Always run
    quote-buy
    or
    quote-sell
    before trading to verify costs and set slippage bounds.
  • Market IDs are epoch millisecond timestamps (e.g.,
    1771853629839
    ), not MongoDB
    _id
    .
  • The
    get-market
    subcommand takes MongoDB
    _id
    (e.g.,
    699c573ea7bb5ad25fee68a0
    ), not
    marketId
    .
  • Write operations MUST use
    PostConditionMode.Allow
    — the contract moves STX internally (sender → pool → fee wallets) and default post-conditions block this.
  • isActive
    can be
    true
    even after
    endDate
    passes — the contract owner must manually resolve. Always check
    isResolved
    and compare time.
  • Winning shares pay 1 STX each on redemption; losing shares pay nothing. Burns all shares.
  • Gas fees are approximately 0.05–0.1 STX per transaction, in addition to the share cost.
  • LMSR pricing: cost of shares follows a logarithmic curve — buying more shares in one direction increases price. Get a fresh quote immediately before submitting a buy.
  • 所有操作仅支持主网,测试网调用会返回错误。
  • 写入操作需要解锁的钱包(请先执行
    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定价:份额成本遵循对数曲线——单向买入更多份额会推高价格,因此提交买入前请获取最新报价。