torch-prediction-market-bot
Autonomous vault-based prediction market bot for Torch Market on Solana. Creates binary prediction markets as Torch tokens — the bonding curve provides price discovery, the treasury accumulates value from trading fees, and the vault manages positions. Each market has an oracle (price feed or manual) and resolves at a deadline. The agent keypair is generated in-process -- disposable, holds nothing of value. All SOL routes through the vault. The human principal creates the vault, funds it, links the agent, and retains full control. Built on torchsdk v3.7.23 and the Torch Market protocol.
What this skill does
# Torch Prediction Market Kit
You're here because you want to run prediction markets on Torch Market -- and you want to do it safely.
Every prediction market is a Torch token. The bonding curve is the AMM -- no LP setup, deterministic pricing, instant liquidity. The 10% treasury accumulates fees from every buy. Users buy the token to bet YES (price goes up), sell to bet NO (price goes down). At the deadline, the oracle checks the outcome and the bot records it.
**Settlement model: token-as-signal.** No payout mechanism. The token price IS the prediction. The bonding curve and treasury do the work.
That's where this bot comes in.
It reads your `markets.json` file, creates Torch tokens for pending markets, seeds them with initial liquidity from your vault, monitors price and volume, and resolves them at the deadline using an oracle (CoinGecko price feed or manual). All value routes through your vault. The agent wallet that signs transactions holds nothing.
**This is not a read-only scanner.** This is a fully operational market maker that generates its own keypair, verifies vault linkage, creates tokens, seeds liquidity, and resolves markets autonomously in a continuous loop.
---
## How It Works
```
┌─────────────────────────────────────────────────────────┐
│ MARKET CYCLE LOOP │
│ │
│ 1. Load market definitions from markets.json │
│ 2. For each pending market: │
│ → buildCreateTokenTransaction(name, symbol, uri) │
│ → sign + submit + confirm │
│ → buildBuyTransaction(vault, mint, seed SOL) │
│ → sign + submit + confirm │
│ → update status to 'active', save mint address │
│ 3. For each active market: │
│ → getToken(mint) — snapshot price, volume, holders │
│ → if deadline passed: │
│ → checkOracle(oracle) — price feed or manual │
│ → update status to 'resolved', record outcome │
│ 4. Save updated markets.json │
│ 5. Sleep SCAN_INTERVAL_MS, repeat │
│ │
│ All SOL comes from vault. Agent wallet holds nothing. │
│ Vault is the boundary. │
└─────────────────────────────────────────────────────────┘
```
### The Agent Keypair
The bot generates a fresh `Keypair` in-process on every startup. No private key file. No environment variable (unless you want to provide one). The keypair is disposable -- it signs transactions but holds nothing of value.
On first run, the bot checks if this keypair is linked to your vault. If not, it prints the exact SDK call you need to link it:
```
--- ACTION REQUIRED ---
agent wallet is NOT linked to the vault.
link it by running (from your authority wallet):
buildLinkWalletTransaction(connection, {
authority: "<your-authority-pubkey>",
vault_creator: "<your-vault-creator>",
wallet_to_link: "<agent-pubkey>"
})
then restart the bot.
-----------------------
```
Link it from your authority wallet (hardware wallet, multisig, whatever you use). The agent never needs the authority's key. The authority never needs the agent's key. They share a vault, not keys.
### The Vault
This is the same Torch Vault from the full Torch Market protocol. It holds all assets -- SOL and tokens. The agent is a disposable controller.
When the bot creates and seeds a market:
- **Token creation** — agent signs as creator, no SOL cost beyond gas
- **Seed liquidity** — SOL comes from the vault via `buildBuyTransaction(vault=creator)`
- **Tokens purchased** — go to the vault's associated token account (ATA)
The human principal retains full control:
- `withdrawVault()` — pull SOL at any time
- `withdrawTokens(mint)` — pull market tokens at any time
- `unlinkWallet(agent)` — revoke agent access instantly
If the agent keypair is compromised, the attacker gets dust and vault access that you revoke in one transaction.
---
## Getting Started
### 1. Install
```bash
npm install [email protected]
```
Or use the bundled source from ClawHub — the Torch SDK is included in `lib/torchsdk/` and the bot source is in `lib/kit/`.
### 2. Create and Fund a Vault (Human Principal)
From your authority wallet:
```typescript
import { Connection } from "@solana/web3.js";
import {
buildCreateVaultTransaction,
buildDepositVaultTransaction,
} from "./lib/torchsdk/index.js";
const connection = new Connection(process.env.SOLANA_RPC_URL);
// Create vault
const { transaction: createTx } = await buildCreateVaultTransaction(connection, {
creator: authorityPubkey,
});
// sign and submit with authority wallet...
// Fund vault with SOL for market creation + seed liquidity
const { transaction: depositTx } = await buildDepositVaultTransaction(connection, {
depositor: authorityPubkey,
vault_creator: authorityPubkey,
amount_sol: 5_000_000_000, // 5 SOL
});
// sign and submit with authority wallet...
```
### 3. Define Markets
Create `markets.json`:
```json
[
{
"id": "sol-200-mar",
"question": "Will SOL be above $200 by March 1, 2026?",
"symbol": "SOL200M",
"name": "SOL Above 200 March",
"oracle": {
"type": "price_feed",
"asset": "solana",
"condition": "above",
"target": 200
},
"deadline": 1740787200,
"initialLiquidityLamports": 100000000,
"metadataUri": "https://arweave.net/placeholder"
}
]
```
### 4. Run the Bot
```bash
VAULT_CREATOR=<your-vault-creator-pubkey> SOLANA_RPC_URL=<rpc-url> npx torch-prediction-market-bot
```
On first run, the bot prints the agent keypair and instructions to link it. Link it from your authority wallet, then restart.
### 5. Configuration
| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `SOLANA_RPC_URL` | **Yes** | -- | Solana RPC endpoint (HTTPS). Fallback: `RPC_URL` |
| `VAULT_CREATOR` | **Yes** | -- | Vault creator pubkey |
| `SOLANA_PRIVATE_KEY` | No | -- | Disposable controller keypair (base58 or JSON byte array). If omitted, generates fresh keypair on startup (recommended) |
| `SCAN_INTERVAL_MS` | No | `60000` | Milliseconds between market cycles (min 5000) |
| `LOG_LEVEL` | No | `info` | `debug`, `info`, `warn`, `error` |
| `MARKETS_PATH` | No | `./markets.json` | Path to market definitions file |
---
## Architecture
```
packages/kit/src/
├── index.ts — entry point: keypair generation, vault verification, market cycle loop
├── config.ts — loadConfig(): validates SOLANA_RPC_URL, VAULT_CREATOR, MARKETS_PATH, etc.
├── types.ts — Market, Oracle, MarketSnapshot, BotConfig interfaces
├── markets.ts — loadMarkets(), saveMarkets(), createMarket(), snapshotMarket(), resolveMarket()
├── oracle.ts — checkPriceFeed(), checkOracle() — CoinGecko price resolution
└── utils.ts — sol(), createLogger(), decodeBase58(), withTimeout()
```
The bot is ~280 lines of TypeScript across 6 modules. It does three things: create markets, monitor them, and resolve them through the vault.
### Dependencies
| Package | Version | Purpose |
|---------|---------|---------|
| `@solana/web3.js` | 1.98.4 | Solana RPC, keypair, transaction |
| `torchsdk` | 3.7.23 | Token queries, token creation, buy builder, vault queries |
Two runtime dependencies. Both pinned to exact versions. No `^` or `~` ranges.
---
## Market Lifecycle
```
pending ──→ active ──→ resolved
│
└──→ cancelled
```
| Status | Description |
|--------|-------------|
| **pending** | Market defined in `markets.json`, no token created yet |
| **active** | Torch token created on bonding curve, users can trade |
| **resolved** | Deadline passed, oracle checked, outcome recorded (yes/no) |
| **cancelled** | Market removed before resRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.