dflow-kalshi-trading
Buy, sell, or redeem YES/NO outcome tokens on Kalshi prediction markets via DFlow. Use when the user wants to bet on an event, place a Kalshi order, take a…
от x402agent★ 26 звёзд на GitHub
Установить dflow-kalshi-trading в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
DFlow Kalshi Trading
Buy, sell, and redeem YES/NO outcome tokens on Kalshi prediction markets. PM trades are imperative and asynchronous — submit, then poll until terminal.
Prerequisites
- DFlow docs MCP (
https://pond.dflow.net/mcp) — install per the repo README. This skill is the recipe; the MCP is the reference. Look up endpoint shapes, parameter details, error codes, and anything else field-level viasearch_d_flow/query_docs_filesystem_d_flow— don't guess. dflowCLI (optional, for command-line/agent use) — install per the repo README.
Choose your surface
- CLI — command line, scripts, local agents. Manages keys, signs, submits, polls.
- API — web/mobile apps with a browser wallet (Phantom, Privy, Turnkey, etc.). Wallet handles signing + RPC; app must proxy HTTP through its backend (the Trading API serves no CORS).
If unclear, ask once: "From the command line, or wired into an app?"
Workflows
All three workflows assume the user already has a market ledger mint (CLI; the marketLedger field on the Metadata API market object) or an outcome mint (API; yesMint / noMint) in hand. If they only have a ticker / event name, defer to dflow-kalshi-market-scanner.
One market, two settlement rails. Every initialized Kalshi market on DFlow exposes both a USDC rail and a CASH rail in market.accounts — each with its own marketLedger, yesMint, and noMint. They share an orderbook (the top-level yesBid / yesAsk / volume24hFp are market-wide), but trades and holdings are rail-scoped: USDC-rail YES tokens are a different SPL mint from CASH-rail YES tokens and aren't fungible. Default to the USDC rail unless the user holds CASH, explicitly asks for CASH, or the active DFlow vault only has CASH. Don't write defensive "fall back to CASH if USDC rail missing" code — it never fires, and it hides the rail choice from the user. State the default at the top of the script instead.
Settlement mint constants (Solana, Token-2022 for CASH and the classic SPL token program for USDC):
- USDC:
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v - CASH:
CASHx9KJUStyftLFWGvEVf59SGeG9sh5FfcnZMVPCASH
Use these as the keys into market.accounts[mint] when picking a rail. There is no top-level market.settlementMint field on the /markets response (despite what some recipe snippets might suggest with market.accounts?.[market.settlementMint] — that pattern shows up in position-side code, where the rail is already known from the held outcome mint, not in market-discovery code). Key by the mint directly.
Buy (open or increase a YES/NO position)
- Confirm the buy gates (KYC + geo + maintenance window) are passable for this user — see Gotchas.
- Submit the order with the settlement mint as input (USDC or CASH) and the outcome mint as output.
- Poll status until terminal (
closed/expired/failed).
- CLI:
dflow trade <atomic-amount> USDC --market <marketLedger> --side yes|no— auto-polls for up to 120s.<FROM>accepts either the base58 mint or the shorthandUSDC/CASH(CLI resolves a small symbol set, same as spot).--markettakes themarketLedgerfor the settlement track matching the<from>arg — i.e.market.accounts[<USDC-or-CASH-mint>].marketLedgeron the Metadata API response. The CLI derives the YES/NO outcome mint from--side+<from>, so the samemarketLedgervalue is used for both--side yesand--side no. Don't pass ayesMint/noMinthere — those are inputs to the API surface, not the CLI. The docs' "market mint" and "market ledger mint" phrasing both refer to this one field.
"Buy N whole contracts" from a scan snapshot. Kalshi buys submit a USDC amount and get back as many whole contracts as it covers, refunding leftovers. When you're executing N contracts off a snapshotted yesAsk, compute Math.ceil(N * yesAsk * 1e6) atomic USDC and optionally add a small buffer (≤ ~1%, a few basis points is typically enough) so a tick-up in the ask between scan and submit doesn't leave you with N-1. Leftover stablecoin is refunded by the CLP, so over-funding slightly is cheap insurance. Don't over-fund by more than a percent or two — at some point it's no longer insurance, it's a different order size.
- API:
GET /order?userPublicKey=&inputMint=<settlement>&outputMint=<yesMint|noMint>&amount=<atomic>, then sign + submit + poll/order-status. The API takes the outcome mint directly (no--marketindirection). Field details via the docs MCP.
Sell (decrease or close)
Flip the mints — outcome in, settlement out. No KYC required. No --market / --side on the CLI; pass the outcome mint as the FROM positional and the CLI auto-resolves the settlement mint.
- CLI:
dflow trade <atomic-outcome> <outcome-mint> - API: same
/ordercall as buy, with input/output mi
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл dflow-kalshi-trading?
Buy, sell, or redeem YES/NO outcome tokens on Kalshi prediction markets via DFlow. Use when the user wants to bet on an event, place a Kalshi order, take a YES or NO position, exit a Kalshi position, redeem winning outcome tokens after a market resolves, tune priority fees on a PM trade, or build a gasless / sponsored PM flow where the app pays tx / ATA / market-init costs. Covers both the `dflow` CLI and the DFlow Trading API. Do NOT use to discover markets, view positions, stream prices, complete Proof KYC, or for non-Kalshi spot swaps.
Как установить скилл dflow-kalshi-trading?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл dflow-kalshi-trading запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…