liberfi-predict
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLiberFi Prediction Market
LiberFi 预测市场
Browse prediction market events, manage positions, and place orders on Kalshi and Polymarket using the LiberFi CLI.
使用LiberFi CLI浏览预测市场事件、管理持仓,并在Kalshi和Polymarket上下单。
Pre-flight Checks
预检查
See bootstrap.md for CLI installation and connectivity verification.
This skill's auth requirements:
| Command | Requires Auth |
|---|---|
| No |
| No |
| No |
| No |
| No |
| No (Polymarket needs POLY_* headers) |
| No (Polymarket needs POLY_* headers) |
| No |
| No |
| No (uses TEE wallet if logged in) |
| No |
| Yes (LiberFi JWT) |
| Yes (LiberFi JWT — server signs via TEE) |
| Yes (LiberFi JWT — server signs via TEE) |
| Yes (LiberFi JWT — auto L2 auth for polymarket) |
| No |
| No |
| No (requires POLY_* headers) |
Recommended flow (TEE auto): → /
/ . The server holds the user's TEE wallet via Privy
and signs every transaction internally — no POLY_* HMAC, no Solana signing,
no EIP-712 work for the caller.
polymarket-setuppolymarket-placekalshi-placecancelLegacy flow: Polymarket order operations via require
CLOB HMAC authentication via five flags. These are NOT LiberFi
JWT credentials — they are the user's own Polymarket CLOB API credentials.
polymarket-order--poly-*CLI安装和连通性验证请查看bootstrap.md。
本技能的认证要求:
| 命令 | 是否需要认证 |
|---|---|
| 否 |
| 否 |
| 否 |
| 否 |
| 否 |
| 否(Polymarket需要POLY_*头信息) |
| 否(Polymarket需要POLY_*头信息) |
| 否 |
| 否 |
| 否(已认证时使用TEE钱包) |
| 否 |
| 是(需要LiberFi JWT) |
| 是(需要LiberFi JWT — 服务器通过TEE签名) |
| 是(需要LiberFi JWT — 服务器通过TEE签名) |
| 是(需要LiberFi JWT — Polymarket自动完成L2认证) |
| 否 |
| 否 |
| 否(需要POLY_*头信息) |
推荐流程(TEE自动): → / / 。服务器通过Privy托管用户的TEE钱包,并在内部完成所有交易签名——调用者无需处理POLY_* HMAC、Solana签名或EIP-712相关操作。
polymarket-setuppolymarket-placekalshi-placecancel旧版流程:通过进行Polymarket订单操作需要通过五个参数完成CLOB HMAC认证。这些并非LiberFi JWT凭证——它们是用户自己的Polymarket CLOB API凭证。
polymarket-order--poly-*TEE Auto Order Flow (CRITICAL)
TEE自动订单流程(关键)
For the canonical end-to-end order placement flow — including pre-flight
status checks, deposit handling, market vs limit order branching, and post-
order verification — see reference/order-flow.md.
The CLI/skill expects this exact ordering for Polymarket:
- — confirm authenticated; if not, run
lfi statuslfi login key - — check Safe deployment + token approvals
lfi predict polymarket-setup-status --json - If or any approval missing:
safe_deployed=false(one-shot; gasless via Builder Relayer)lfi predict polymarket-setup --json - Check Safe USDC balance — pass the TEE EOA, NOT the Safe:
(server derives Safe from EOA internally). If
lfi predict balance --source polymarket --user <tee-eoa> --json, fetch BRIDGE deposit addresses using the Safe address from step 2/3:balance < 2→ returnslfi predict polymarket-deposit-addresses --safe-address <safe> --json. Pick the field matching the user's chain (default{ evm, svm, btc, tron }for ETH/Polygon/Base/Arb/Op/BNB). Tell user to send ≥ $2 USDC to that bridge address (NEVER to the Safe address — the Safe is Polymarket's internal custody contract, not a user-facing deposit target). The Polymarket Bridge service auto-credits the Safe.evm - Ask the user: market or limit? For limit, also ask price + size + GTC vs GTD (with expiration if GTD). For market, ask USDC spend (BUY) or share count (SELL)
- Show the final order summary, wait for explicit confirmation
lfi predict polymarket-place --token-id <id> --side <s> --order-type <t> [--price <p>] [--size <sz>] [--expiration <epoch>] --json- — verify open orders
lfi predict orders --source polymarket --json - — cancel if user asks
lfi predict cancel <id> --source polymarket --json
For Kalshi the flow is shorter: — quote, sign
(SignSOL), and submit are all done server-side.
lfi predict kalshi-place --input-mint <inMint> --output-mint <outMint> --amount <amt> --json关于完整的端到端下单流程——包括预检查状态、充值处理、市价/限价单分支以及下单后验证——请查看reference/order-flow.md。
CLI/技能要求Polymarket操作严格遵循以下步骤:
- — 确认已认证;若未认证,执行
lfi statuslfi login key - — 检查Safe部署情况和代币授权状态
lfi predict polymarket-setup-status --json - 若或存在未授权项:执行
safe_deployed=false(一键完成;通过Builder Relayer实现无gas费用)lfi predict polymarket-setup --json - 检查Safe的USDC余额——传入TEE EOA,而非Safe地址:(服务器会从EOA内部推导Safe地址)。若
lfi predict balance --source polymarket --user <tee-eoa> --json,使用步骤2/3中获取的Safe地址获取BRIDGE充值地址:balance < 2→ 返回lfi predict polymarket-deposit-addresses --safe-address <safe> --json。选择与用户链匹配的字段(默认{ evm, svm, btc, tron }适用于ETH/Polygon/Base/Arb/Op/BNB)。告知用户向该桥接地址转入≥2美元的USDC(绝不要转入Safe地址——Safe是Polymarket的内部托管合约,并非面向用户的充值目标)。Polymarket Bridge服务会自动将资金转入Safe。evm - 询问用户:市价单还是限价单?若为限价单,还需询问价格、数量以及GTC(取消前有效)或GTD(到期前有效,需提供到期时间)。若为市价单,询问USDC投入金额(买入)或份额数量(卖出)
- 展示最终订单摘要,等待用户明确确认
lfi predict polymarket-place --token-id <id> --side <s> --order-type <t> [--price <p>] [--size <sz>] [--expiration <epoch>] --json- — 验证未成交订单
lfi predict orders --source polymarket --json - — 若用户要求则取消订单
lfi predict cancel <id> --source polymarket --json
Kalshi的流程更简短: — 报价、签名(SignSOL)和提交均在服务器端完成。
lfi predict kalshi-place --input-mint <inMint> --output-mint <outMint> --amount <amt> --jsonSkill Routing
技能路由规则
| If user asks about... | Route to |
|---|---|
| Token search, price, details, security | liberfi-token |
| Token K-line, candlestick chart | liberfi-token |
| Trending tokens, market rankings | liberfi-market |
| Newly listed tokens | liberfi-market |
| Wallet holdings, balance (non-prediction), PnL | liberfi-portfolio |
| Wallet activity, transaction history | liberfi-portfolio |
| Token swap, trade execution | liberfi-swap |
| Login, logout, session management | liberfi-auth |
| 用户询问内容 | 路由至 |
|---|---|
| 代币搜索、价格、详情、安全 | liberfi-token |
| 代币K线图、蜡烛图 | liberfi-token |
| 热门代币、市场排行 | liberfi-market |
| 新上线代币 | liberfi-market |
| 钱包资产、余额(非预测市场)、盈亏 | liberfi-portfolio |
| 钱包活动、交易历史 | liberfi-portfolio |
| 代币兑换、交易执行 | liberfi-swap |
| 登录、登出、会话管理 | liberfi-auth |
CLI Command Index
CLI命令索引
Query Commands (read-only)
查询命令(只读)
| Command | Description | Auth |
|---|---|---|
| List prediction events with filtering | No |
| Get event details by slug | No |
| Get USDC balance | No |
| Get portfolio positions | No |
| List trade history | No |
| List orders | No (POLY_* for Polymarket) |
| Get order details | No (POLY_* for Polymarket) |
| 命令 | 描述 | 是否需要认证 |
|---|---|---|
| 通过筛选列出预测事件 | 否 |
| 通过slug获取事件详情 | 否 |
| 获取USDC余额 | 否 |
| 获取投资组合持仓 | 否 |
| 列出交易历史 | 否 |
| 列出订单 | 否(Polymarket需要POLY_*头信息) |
| 获取订单详情 | 否(Polymarket需要POLY_*头信息) |
TEE Auto Flow Commands (recommended)
TEE自动流程命令(推荐)
| Command | Description | Auth |
|---|---|---|
| Min tick size for a token | No |
| Base fee rate (bps) | No |
| Safe deployment + approval status | No (uses TEE wallet if logged in) |
| Deploy Safe + approve all tokens (gasless) | JWT |
| Multi-chain deposit addresses for Safe | No |
| Prepare → TEE sign → execute Polymarket order | JWT |
| Quote → SignSOL → submit Kalshi order | JWT |
| Cancel order (auto L2 auth for poly) | JWT |
| 命令 | 描述 | 是否需要认证 |
|---|---|---|
| 获取代币最小变动价位 | 否 |
| 获取基础费率(基点) | 否 |
| Safe部署状态和授权状态 | 否(已认证时使用TEE钱包) |
| 部署Safe并授权所有代币(无gas费用) | JWT |
| Safe的多链充值地址 | 否 |
| 准备→TEE签名→执行Polymarket订单 | JWT |
| 报价→SignSOL→提交Kalshi订单 | JWT |
| 取消订单(Polymarket自动完成L2认证) | JWT |
Legacy / Deprecated Commands
旧版/已弃用命令
| Command | Description | Auth |
|---|---|---|
| DEPRECATED — use | No |
| DEPRECATED — use | No |
| DEPRECATED — use | POLY_* headers |
| 命令 | 描述 | 是否需要认证 |
|---|---|---|
| 已弃用 — 请使用 | 否 |
| 已弃用 — 请使用 | 否 |
| 已弃用 — 请使用 | POLY_*头信息 |
Parameter Reference
参数参考
Events list ():
lfi predict events- — Max results per page
--limit <n> - — Pagination cursor
--cursor <cursor> - — Event status filter (e.g.
--status <status>,active)resolved - — Provider source:
--source <source>orkalshipolymarket - — Filter by tag
--tag-slug <slug> - — Free-text search
--search <query> - — Sort field
--sort-by <field> - — Sort ascending:
--sort-asc <bool>ortruefalse - — Include embedded markets:
--with-markets <bool>ortruefalse
Event detail ():
lfi predict event <slug>- — Required. Event slug identifier
<slug> - — Required. Provider source:
--source <source>orkalshipolymarket
Balance ():
lfi predict balance- — Required. Provider source:
--source <source>orkalshipolymarket - — Required. For
--user <address>: pass the user's TEE EOA (e.g.polymarketfromevmAddress); the server auto-derives the Safe via CREATE2. NEVER pass a Safe address here. Forlfi whoami: pass the Solana public key (kalshi).solAddress
Positions ():
lfi predict positions- — Required. Same rule as
--user <address>: TEE EOA for polymarket (server derives Safe), Solana public key for kalshi.balance - — Optional provider source filter
--source <source>
Trades ():
lfi predict trades- — Required. Same rule as
--wallet <address>: TEE EOA for polymarket (server derives Safe), Solana public key for kalshi.balance - — Optional provider source filter
--source <source> - — Max results per page
--limit <n> - — Pagination cursor
--cursor <cursor> - — Comma-separated trade types
--type <types> - — Trade side filter
--side <side>
Orders ():
lfi predict orders- — Provider source
--source <source> - — Wallet address (required for kalshi)
--wallet-address <address> - — Market ID filter
--market-id <id> - — Asset ID filter
--asset-id <id> - — Pagination cursor
--next-cursor <cursor> - ,
--poly-api-key,--poly-address,--poly-signature,--poly-passphrase— Polymarket CLOB auth (required when source is polymarket)--poly-timestamp
Order detail ():
lfi predict order <id>- — Required. Order ID
<id> - — Required. Provider source
--source <source> - Same flags as orders list
--poly-*
Polymarket tick size ():
lfi predict polymarket-tick-size- — Required. Polymarket CLOB token ID
--token-id <id>
Polymarket fee rate ():
lfi predict polymarket-fee-rate- — Required. Polymarket CLOB token ID
--token-id <id>
Polymarket setup status ():
lfi predict polymarket-setup-status- — Optional EVM address. Defaults to caller's TEE wallet when authenticated.
--wallet-address <addr>
Polymarket setup (run) ():
lfi predict polymarket-setup- No flags. Requires authentication. Idempotent — safe to call repeatedly.
Polymarket deposit addresses ():
lfi predict polymarket-deposit-addresses- — Required. Safe wallet address (from
--safe-address <addr>)polymarket-setup-status
Polymarket place (TEE auto) ():
lfi predict polymarket-place- — Required. Polymarket CLOB token ID
--token-id <id> - — Required.
--side BUY|SELL - — Required.
--order-type GTC|GTD|FOK|FAK|MARKET - — Limit price (limit orders only, e.g.
--price <p>). Required for GTC/GTD/FOK/FAK.0.55 - — Limit: shares; market BUY: USDC; market SELL: shares. Required for limit and market.
--size <sz> - — Required for
--expiration <epochSec>.GTD - — Force NegRisk exchange. Auto-detected when omitted.
--neg-risk true|false - — Override fee rate (PS auto-resolves when omitted).
--fee-rate-bps <n> - — Override tick size (PS auto-resolves when omitted).
--tick-size <n> - — Restrict the taker (advanced).
--taker-address <addr>
Kalshi place (TEE auto) ():
lfi predict kalshi-place- — Required. Input token mint
--input-mint <addr> - — Required. Output token mint
--output-mint <addr> - — Required. Amount in smallest unit
--amount <amt> - — Slippage tolerance in basis points
--slippage-bps <bps>
Cancel order ():
lfi predict cancel <id>- — Required. Order ID
<id> - — Required. For polymarket the L2 HMAC headers are derived from the caller's TEE wallet automatically.
--source polymarket|kalshi
Kalshi quote ():
lfi predict kalshi-quote- — Required. Input token mint address
--input-mint <address> - — Required. Output token mint address
--output-mint <address> - — Required. Swap amount
--amount <amount> - — Required. User's Solana public key
--user-public-key <key> - — Slippage tolerance in basis points
--slippage-bps <bps>
Kalshi submit ():
lfi predict kalshi-submit- — Required. Signed transaction data
--signed-transaction <tx> - — Required. Order context as JSON string (contains
--order-context <json>,user_public_key,market_slug,side, mints,outcome,amount,price)slippage_bps
Polymarket order ():
lfi predict polymarket-order- — Required. Raw order JSON string
--body <json> - — Required. Polymarket API key
--poly-api-key <key> - — Required. Polymarket address
--poly-address <address> - — Required. Polymarket HMAC signature
--poly-signature <sig> - — Required. Polymarket passphrase
--poly-passphrase <pass> - — Required. Polymarket timestamp
--poly-timestamp <ts>
事件列表 ():
lfi predict events- — 每页最大结果数
--limit <n> - — 分页游标
--cursor <cursor> - — 事件状态筛选(例如
--status <status>、active)resolved - — 服务商来源:
--source <source>或kalshipolymarket - — 按标签筛选
--tag-slug <slug> - — 自由文本搜索
--search <query> - — 排序字段
--sort-by <field> - — 是否升序排序:
--sort-asc <bool>或truefalse - — 是否包含内嵌市场:
--with-markets <bool>或truefalse
事件详情 ():
lfi predict event <slug>- — 必填。事件slug标识符
<slug> - — 必填。服务商来源:
--source <source>或kalshipolymarket
余额查询 ():
lfi predict balance- — 必填。服务商来源:
--source <source>或kalshipolymarket - — 必填。对于
--user <address>:传入用户的TEE EOA(例如polymarket返回的lfi whoami);服务器会通过CREATE2自动推导Safe地址。绝不要传入Safe地址。对于evmAddress:传入Solana公钥(kalshi)。solAddress
持仓查询 ():
lfi predict positions- — 必填。规则与
--user <address>相同:Polymarket使用TEE EOA(服务器推导Safe),Kalshi使用Solana公钥。balance - — 可选的服务商来源筛选
--source <source>
交易历史查询 ():
lfi predict trades- — 必填。规则与
--wallet <address>相同:Polymarket使用TEE EOA(服务器推导Safe),Kalshi使用Solana公钥。balance - — 可选的服务商来源筛选
--source <source> - — 每页最大结果数
--limit <n> - — 分页游标
--cursor <cursor> - — 逗号分隔的交易类型
--type <types> - — 交易方向筛选
--side <side>
订单列表 ():
lfi predict orders- — 服务商来源
--source <source> - — 钱包地址(Kalshi必填)
--wallet-address <address> - — 市场ID筛选
--market-id <id> - — 资产ID筛选
--asset-id <id> - — 分页游标
--next-cursor <cursor> - ,
--poly-api-key,--poly-address,--poly-signature,--poly-passphrase— Polymarket CLOB认证参数(来源为polymarket时必填)--poly-timestamp
订单详情 ():
lfi predict order <id>- — 必填。订单ID
<id> - — 必填。服务商来源
--source <source> - 与订单列表相同的参数
--poly-*
Polymarket最小变动价位 ():
lfi predict polymarket-tick-size- — 必填。Polymarket CLOB代币ID
--token-id <id>
Polymarket费率 ():
lfi predict polymarket-fee-rate- — 必填。Polymarket CLOB代币ID
--token-id <id>
Polymarket部署状态 ():
lfi predict polymarket-setup-status- — 可选的EVM地址。已认证时默认使用调用者的TEE钱包。
--wallet-address <addr>
Polymarket部署执行 ():
lfi predict polymarket-setup- 无参数。需要认证。幂等操作——可重复调用。
Polymarket充值地址 ():
lfi predict polymarket-deposit-addresses- — 必填。Safe钱包地址(来自
--safe-address <addr>)polymarket-setup-status
Polymarket下单(TEE自动) ():
lfi predict polymarket-place- — 必填。Polymarket CLOB代币ID
--token-id <id> - — 必填。
--side BUY|SELL - — 必填。
--order-type GTC|GTD|FOK|FAK|MARKET - — 限价(仅限价单需要,例如
--price <p>)。GTC/GTD/FOK/FAK订单必填。0.55 - — 限价单:份额数;市价买入:USDC金额;市价卖出:份额数。限价单和市价单均必填。
--size <sz> - —
--expiration <epochSec>订单必填。GTD - — 强制使用NegRisk交易所。省略时自动检测。
--neg-risk true|false - — 覆盖费率(省略时PS自动解析)。
--fee-rate-bps <n> - — 覆盖最小变动价位(省略时PS自动解析)。
--tick-size <n> - — 限制对手方地址(高级功能)。
--taker-address <addr>
Kalshi下单(TEE自动) ():
lfi predict kalshi-place- — 必填。输入代币mint地址
--input-mint <addr> - — 必填。输出代币mint地址
--output-mint <addr> - — 必填。最小单位金额
--amount <amt> - — 滑点容忍度(基点)
--slippage-bps <bps>
取消订单 ():
lfi predict cancel <id>- — 必填。订单ID
<id> - — 必填。对于Polymarket,L2 HMAC头信息会从调用者的TEE钱包自动推导。
--source polymarket|kalshi
Kalshi报价 ():
lfi predict kalshi-quote- — 必填。输入代币mint地址
--input-mint <address> - — 必填。输出代币mint地址
--output-mint <address> - — 必填。兑换金额
--amount <amount> - — 必填。用户的Solana公钥
--user-public-key <key> - — 滑点容忍度(基点)
--slippage-bps <bps>
Kalshi提交 ():
lfi predict kalshi-submit- — 必填。已签名的交易数据
--signed-transaction <tx> - — 必填。订单上下文JSON字符串(包含
--order-context <json>、user_public_key、market_slug、side、mints、outcome、amount、price)slippage_bps
Polymarket订单 ():
lfi predict polymarket-order- — 必填。原始订单JSON字符串
--body <json> - — 必填。Polymarket API密钥
--poly-api-key <key> - — 必填。Polymarket地址
--poly-address <address> - — 必填。Polymarket HMAC签名
--poly-signature <sig> - — 必填。Polymarket密码短语
--poly-passphrase <pass> - — 必填。Polymarket时间戳
--poly-timestamp <ts>
Operation Flow
操作流程
Browse Prediction Events
浏览预测事件
- Fetch events:
lfi predict events --with-markets true --limit 20 --json - Present results: Show event title, status, number of markets, volume
- Suggest next step: "Want to see details for a specific event?" / "需要查看某个事件的详情?"
- 获取事件:
lfi predict events --with-markets true --limit 20 --json - 展示结果:显示事件标题、状态、市场数量、交易量
- 建议下一步:"需要查看某个事件的详情?"
Browse Events by Source
按来源浏览事件
- Determine source: Ask user for or
kalshipolymarket - Fetch:
lfi predict events --source kalshi --with-markets true --limit 20 --json - Present: Events filtered by provider
- Suggest next step: "Pick an event to view its markets and outcomes"
- 确定来源:询问用户选择或
kalshipolymarket - 获取事件:
lfi predict events --source kalshi --with-markets true --limit 20 --json - 展示结果:按服务商筛选后的事件
- 建议下一步:"选择一个事件查看其市场和结果"
View Event Details
查看事件详情
- Determine slug: From user selection or input
- Fetch event:
lfi predict event <slug> --source <source> --json - Present: Event title, description, status, resolution sources, markets with outcomes and prices
- Suggest next step: "Want to check your balance or place an order?"
- 确定slug:从用户选择或输入中获取
- 获取事件:
lfi predict event <slug> --source <source> --json - 展示结果:事件标题、描述、状态、结果来源、包含结果和价格的市场信息
- 建议下一步:"需要查看余额或下单?"
Check USDC Balance
查询USDC余额
If the user says "我的余额", "my balance", "我在 Polymarket/Kalshi 有多少钱"
or any first-person variant — DO NOT ask for a wallet address. Use the
"My ..." auto-flow below.
Generic flow (when the user explicitly provides someone else's address):
- Collect inputs: Source (kalshi/polymarket) and wallet address
- Fetch:
lfi predict balance --source <source> --user <address> --json - Present: Available USDC balance
- Suggest next step: "Ready to place a prediction?" / "准备下注了吗?"
如果用户说“我的余额”、“my balance”、“我在 Polymarket/Kalshi 有多少钱”或任何第一人称表述——不要向用户索要钱包地址。请使用下方的“我的...”自动流程。
通用流程(用户明确提供他人地址时):
- 收集输入:来源(kalshi/polymarket)和钱包地址
- 获取余额:
lfi predict balance --source <source> --user <address> --json - 展示结果:可用USDC余额
- 建议下一步:"准备下注了吗?"
Kalshi Order Flow (Quote → Sign → Submit)
Kalshi订单流程(报价→签名→提交)
- Browse events:
lfi predict events --source kalshi --with-markets true --json - View event: — identify market, outcomes, and mints
lfi predict event <slug> --source kalshi --json - Check balance:
lfi predict balance --source kalshi --user <publicKey> --json - Get quote:
lfi predict kalshi-quote --input-mint <inMint> --output-mint <outMint> --amount <amt> --user-public-key <key> --json - Present quote: Show expected output amount, price, slippage
- (mandatory) Wait for explicit user confirmation
- User signs the transaction (externally, e.g. via wallet)
- Submit:
lfi predict kalshi-submit --signed-transaction <signedTx> --order-context '<contextJson>' --json - Present result: Show signature, status
- 浏览事件:
lfi predict events --source kalshi --with-markets true --json - 查看事件:— 确定市场、结果和mints
lfi predict event <slug> --source kalshi --json - 检查余额:
lfi predict balance --source kalshi --user <publicKey> --json - 获取报价:
lfi predict kalshi-quote --input-mint <inMint> --output-mint <outMint> --amount <amt> --user-public-key <key> --json - 展示报价:显示预期输出金额、价格、滑点
- (必填) 等待用户明确确认
- 用户签名交易(外部操作,例如通过钱包)
- 提交交易:
lfi predict kalshi-submit --signed-transaction <signedTx> --order-context '<contextJson>' --json - 展示结果:显示签名、状态
Polymarket Order Flow
Polymarket订单流程
- Browse events:
lfi predict events --source polymarket --with-markets true --json - View event:
lfi predict event <slug> --source polymarket --json - Check balance:
lfi predict balance --source polymarket --user <address> --json - Prepare order body: Construct the Polymarket order JSON
- (mandatory) Show order summary and wait for explicit user confirmation
- Create order:
lfi predict polymarket-order --body '<orderJson>' --poly-api-key <key> --poly-address <addr> --poly-signature <sig> --poly-passphrase <pass> --poly-timestamp <ts> --json - Present result: Show order response
- 浏览事件:
lfi predict events --source polymarket --with-markets true --json - 查看事件:
lfi predict event <slug> --source polymarket --json - 检查余额:
lfi predict balance --source polymarket --user <address> --json - 准备订单体:构造Polymarket订单JSON
- (必填) 展示订单摘要并等待用户明确确认
- 创建订单:
lfi predict polymarket-order --body '<orderJson>' --poly-api-key <key> --poly-address <addr> --poly-signature <sig> --poly-passphrase <pass> --poly-timestamp <ts> --json - 展示结果:显示订单响应
View Positions
查看持仓
If the user says "我的持仓", "我现在押了哪些", "my positions", "我赌了什么"
or any first-person variant — DO NOT ask for a wallet address. Use the
"My ..." auto-flow below.
Generic flow (when the user explicitly provides someone else's address):
- Determine user: Get wallet address from user
- Fetch:
lfi predict positions --user <address> --json - Present: Show event/market, outcome, size, entry price, current value
- Suggest next step: "Want to see your trade history?" / "需要查看交易历史?"
如果用户说“我的持仓”、“我现在押了哪些”、“my positions”、“我赌了什么”或任何第一人称表述——不要向用户索要钱包地址。请使用下方的“我的...”自动流程。
通用流程(用户明确提供他人地址时):
- 确定用户:从用户处获取钱包地址
- 获取持仓:
lfi predict positions --user <address> --json - 展示结果:显示事件/市场、结果、数量、入场价格、当前价值
- 建议下一步:"需要查看交易历史?"
View Trade History
查看交易历史
If the user says "我的交易", "我赚了多少", "我亏了多少", "my trades",
"我的盈亏" or any first-person variant — DO NOT ask for a wallet address.
Use the "My ..." auto-flow below.
Generic flow (when the user explicitly provides someone else's address):
- Determine wallet: Get wallet address from user
- Fetch:
lfi predict trades --wallet <address> --limit 20 --json - Present: Show trade timestamp, event/market, side, price, size
- Suggest next step: "Want to check your current positions?" / "需要查看当前持仓?"
如果用户说“我的交易”、“我赚了多少”、“我亏了多少”、“my trades”、“我的盈亏”或任何第一人称表述——不要向用户索要钱包地址。请使用下方的“我的...”自动流程。
通用流程(用户明确提供他人地址时):
- 确定钱包:从用户处获取钱包地址
- 获取交易历史:
lfi predict trades --wallet <address> --limit 20 --json - 展示结果:显示交易时间戳、事件/市场、方向、价格、数量
- 建议下一步:"需要查看当前持仓?"
"My ..." auto-flow (CRITICAL — covers "我的", "my", "我自己")
“我的...”自动流程(关键——覆盖“我的”、“my”、“我自己”)
Whenever the user asks about THEIR OWN prediction-market data — positions,
trades, balance, PnL, "我现在押了哪些", "我在预测市场赚了多少",
"我在 Polymarket 上的钱", etc. — run this exact sequence. NEVER ask the
user to type their wallet address.
- Check session:
lfi status --json - If not authenticated (or ):
expired: truelfi login key --role AGENT --name "OpenClawAgent" --json - Fetch TEE wallet addresses: → returns
lfi whoami --json(use for Polymarket) andevmAddress(use for Kalshi).solAddress - Determine source(s):
- If the user named "Polymarket" → use only.
evmAddress - If the user named "Kalshi" → use only.
solAddress - If neither was named (e.g. "我在预测市场赚了多少") → query BOTH and merge.
- If the user named "Polymarket" → use
- Run the matching query for each source — pass the TEE EOA / SOL pubkey
from step 3 DIRECTLY. NEVER convert to a Safe address first; the server
does that internally for Polymarket.
- Positions:
lfi predict positions --user <evmAddress|solAddress> [--source <s>] --json - Trades:
lfi predict trades --wallet <evmAddress|solAddress> [--source <s>] --limit 50 --json - Balance:
lfi predict balance --source <s> --user <evmAddress|solAddress> --json
- Positions:
- Present a single consolidated answer that names the source(s) used and, for the "我赚了多少" / PnL question, sums realized + unrealized PnL across the returned trades/positions.
Why this is mandatory: prediction queries always require an address parameter
in the CLI, but a normal user does NOT know their TEE wallet address — the
LiberFi server holds it. The skill must resolve "我" → TEE wallet via
, transparently. The user should never have to type or even see the
hex/Base58 address unless they ask.
whoamiEOA vs Safe — critical distinction for Polymarket: The address from
is the user's TEE EOA. For / /
queries, ALWAYS pass the EOA — the prediction-server derives the
Polymarket Safe via CREATE2 internally. The Safe address (returned by
) is ONLY for (Polymarket Bridge requires the actual Safe as bridge key).
Mixing these up → balance / positions / trades return EMPTY because the
server tries to derive a Safe from an already-Safe address.
whoami.evmAddressbalancepositionstradespolymarket-setup-statuspolymarket-deposit-addresses --safe-address每当用户询问他们自己的预测市场数据——持仓、交易、余额、盈亏、“我现在押了哪些”、“我在预测市场赚了多少”、“我在 Polymarket 上的钱”等——请严格执行以下步骤。绝不要让用户输入钱包地址。
- 检查会话:
lfi status --json - 若未认证(或):执行
expired: truelfi login key --role AGENT --name "OpenClawAgent" --json - 获取TEE钱包地址:→ 返回
lfi whoami --json(用于Polymarket)和evmAddress(用于Kalshi)。solAddress - 确定来源:
- 如果用户提到“Polymarket” → 仅使用。
evmAddress - 如果用户提到“Kalshi” → 仅使用。
solAddress - 如果两者都未提及(例如“我在预测市场赚了多少”) → 查询两者并合并结果。
- 如果用户提到“Polymarket” → 仅使用
- 对每个来源执行匹配查询——直接传入步骤3中的TEE EOA/SOL公钥。绝不要先转换为Safe地址;服务器会为Polymarket内部完成转换。
- 持仓:
lfi predict positions --user <evmAddress|solAddress> [--source <s>] --json - 交易:
lfi predict trades --wallet <evmAddress|solAddress> [--source <s>] --limit 50 --json - 余额:
lfi predict balance --source <s> --user <evmAddress|solAddress> --json
- 持仓:
- 展示合并后的结果,注明使用的来源;对于“我赚了多少”/盈亏查询,需汇总返回的交易/持仓中的已实现+未实现盈亏。
为何这是必填项:预测查询在CLI中始终需要地址参数,但普通用户不知道他们的TEE钱包地址——该地址由LiberFi服务器托管。技能需通过自动将“我”解析为TEE钱包地址,全程透明。除非用户主动询问,否则用户无需输入甚至查看十六进制/Base58格式的地址。
whoamiEOA与Safe的关键区别(针对Polymarket):是用户的TEE EOA。对于//查询,必须传入EOA——预测服务器会通过CREATE2从EOA自动推导Polymarket Safe地址。Safe地址(由返回)仅用于(Polymarket Bridge需要真实的Safe地址作为桥接密钥)。混淆两者会导致余额/持仓/交易查询返回空值,因为服务器会尝试从已有的Safe地址再推导一个Safe地址。
whoami.evmAddressbalancepositionstradespolymarket-setup-statuspolymarket-deposit-addresses --safe-addressCheck Order Status
查看订单状态
- List orders:
lfi predict orders --source <source> --wallet-address <address> --json - Or get specific order:
lfi predict order <id> --source <source> --json - Present: Show order status, side, price, filled amount
- 列出订单:
lfi predict orders --source <source> --wallet-address <address> --json - 或查看特定订单:
lfi predict order <id> --source <source> --json - 展示结果:显示订单状态、方向、价格、成交金额
Cross-Skill Workflows
跨技能工作流
"Research an event and place a bet"
“研究事件并下注”
Full flow: predict → predict → predict → predict → predict
- predict →
lfi predict events --search "bitcoin" --with-markets true --json - predict → — view markets and outcomes
lfi predict event <slug> --source kalshi --json - predict → — check funds
lfi predict balance --source kalshi --user <publicKey> --json - predict → — get quote
lfi predict kalshi-quote --input-mint <in> --output-mint <out> --amount <amt> --user-public-key <key> --json - Present quote, wait for confirmation, user signs transaction
- predict →
lfi predict kalshi-submit --signed-transaction <tx> --order-context '<ctx>' --json
完整流程:predict → predict → predict → predict → predict
- predict →
lfi predict events --search "bitcoin" --with-markets true --json - predict → — 查看市场和结果
lfi predict event <slug> --source kalshi --json - predict → — 检查资金
lfi predict balance --source kalshi --user <publicKey> --json - predict → — 获取报价
lfi predict kalshi-quote --input-mint <in> --output-mint <out> --amount <amt> --user-public-key <key> --json - 展示报价,等待用户确认,用户签名交易
- predict →
lfi predict kalshi-submit --signed-transaction <tx> --order-context '<ctx>' --json
"Check my prediction portfolio and trade history"
“查看我的预测投资组合和交易历史”
Full flow: predict → predict
- predict → — current positions
lfi predict positions --user <address> --json - predict → — trade history
lfi predict trades --wallet <address> --limit 50 --json - Present consolidated portfolio view
完整流程:predict → predict
- predict → — 当前持仓
lfi predict positions --user <address> --json - predict → — 交易历史
lfi predict trades --wallet <address> --limit 50 --json - 展示合并后的投资组合视图
"Browse events, then research the underlying token"
“浏览事件,然后研究相关代币”
Full flow: predict → token → token
- predict →
lfi predict events --with-markets true --limit 10 --json - User selects an event related to a specific token
- token → — token details
lfi token info sol <tokenAddress> --json - token → — security audit
lfi token security sol <tokenAddress> --json
完整流程:predict → token → token
- predict →
lfi predict events --with-markets true --limit 10 --json - 用户选择与特定代币相关的事件
- token → — 代币详情
lfi token info sol <tokenAddress> --json - token → — 安全审计
lfi token security sol <tokenAddress> --json
Suggest Next Steps
建议下一步操作
| Just completed | Suggest to user |
|---|---|
| Events list | "Want to view a specific event?" / "需要查看某个事件的详情?" |
| Event detail | "Want to check your balance or place an order?" / "需要查看余额或下单?" |
| Balance check | "Ready to place a prediction?" / "准备下注了吗?" |
| Kalshi quote | "Want to proceed with this trade?" / "要继续这笔交易吗?" |
| Kalshi submit | "Order submitted! Check your positions to verify." / "订单已提交!查看持仓确认。" |
| Polymarket order | "Order created! Check order status to confirm." / "订单已创建!查看订单状态确认。" |
| Positions view | "Want to see trade history?" / "需要查看交易历史?" |
| Trade history | "Want to check current positions?" / "需要查看当前持仓?" |
| Orders list | "Want to see details for a specific order?" / "需要查看某个订单的详情?" |
| 刚完成的操作 | 向用户建议 |
|---|---|
| 事件列表浏览 | "需要查看某个事件的详情?" |
| 事件详情查看 | "需要查看余额或下单?" |
| 余额查询 | "准备下注了吗?" |
| Kalshi报价获取 | "要继续这笔交易吗?" |
| Kalshi订单提交 | "订单已提交!查看持仓确认。" |
| Polymarket订单创建 | "订单已创建!查看订单状态确认。" |
| 持仓查看 | "需要查看交易历史?" |
| 交易历史查看 | "需要查看当前持仓?" |
| 订单列表浏览 | "需要查看某个订单的详情?" |
Edge Cases
边缘情况
- Invalid source: If the API returns an error about source, list valid sources (,
kalshi) and ask the user to choosepolymarket - No events found: Inform user: "No prediction events found matching your criteria. Try different filters or search terms."
- Empty positions: Inform user: "No open positions found for this wallet. You can browse events to find prediction opportunities."
- Insufficient balance: If balance is too low for a trade, inform the user and suggest depositing funds
- Invalid slug: If event not found, suggest searching events first via
lfi predict events --search <keyword> - Polymarket auth missing: If POLY_* flags are missing for Polymarket operations, list all required flags and ask the user to provide them
- Invalid JSON in --body or --order-context: If JSON parsing fails, show the parse error and ask the user to correct the JSON
- Quote expired: Kalshi quotes have limited validity; if too much time passes, get a new quote
- Network timeout: Retry once after 3 seconds; if still fails, suggest checking connectivity via
lfi ping --json
- 无效来源:如果API返回来源错误,列出有效来源(、
kalshi)并请用户选择polymarket - 未找到事件:告知用户:"未找到符合条件的预测事件。请尝试不同的筛选条件或搜索词。"
- 无持仓:告知用户:"该钱包无未平仓持仓。你可以浏览事件寻找预测机会。"
- 余额不足:如果余额不足以交易,告知用户并建议充值
- 无效slug:如果未找到事件,建议用户先通过搜索事件
lfi predict events --search <keyword> - Polymarket认证缺失:如果Polymarket操作缺少POLY_*参数,列出所有必填参数并请用户提供
- --body或--order-context中的JSON无效:如果JSON解析失败,显示解析错误并请用户修正JSON
- 报价过期:Kalshi报价有效期有限;如果时间过长,获取新报价
- 网络超时:3秒后重试一次;若仍失败,建议用户通过检查连通性
lfi ping --json
Common Pitfalls
常见陷阱
| Pitfall | Correct Approach |
|---|---|
Forgetting | Always specify |
| Missing POLY_* flags for Polymarket | All five |
| Modifying the quote response before submitting | Pass quote data through as-is in |
| Submitting without user confirmation | ALWAYS show order/quote summary and wait for explicit "yes" |
| Fabricating a signed transaction | The |
| Using wrong mint addresses | Verify mints from the event detail response before quoting |
| 陷阱 | 正确做法 |
|---|---|
查看事件详情时忘记 | 始终指定 |
| Polymarket操作缺少POLY_*参数 | Polymarket订单和订单查询需要所有五个 |
| 提交前修改报价响应 | 直接将报价数据传入 |
| 未获得用户确认就提交 | 始终展示订单/报价摘要并等待用户明确回复“是” |
| 伪造签名交易 | |
| 使用错误的mint地址 | 在报价前从事件详情响应中验证mint地址 |
Security Notes
安全说明
See security-policy.md for global security rules.
Skill-specific rules:
- Polymarket CLOB credentials are sensitive — never log, display, or store POLY_* values beyond the immediate command execution
- Kalshi transactions involve real funds — never fabricate or guess signed transaction data
- NEVER place orders without explicit user confirmation — always show the order summary first
- The and
--order-contextfields are opaque — pass them through as-is; do not interpret, modify, or display raw content beyond summarizing key fields (amount, side, market)--body - After order submission, provide the result so the user can independently verify
全局安全规则请查看security-policy.md。
本技能专属规则:
- Polymarket CLOB凭证敏感——绝不要记录、显示或存储POLY_*值,仅在执行命令时临时使用
- Kalshi交易涉及真实资金——绝不要伪造或猜测签名交易数据
- 绝不要在未获得用户明确确认的情况下下单——始终先展示订单摘要
- 和
--order-context字段为透明字段——直接传递,不要解析、修改或显示原始内容,仅汇总关键字段(金额、方向、市场)--body - 订单提交后,向用户展示结果以便用户独立验证