微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🎯

Polymarket 智能交易与资产管理

clawearn · vv1.2.0
专业技能 安全 B 级 作者 stonega 公开目录收录
1.2k 下载 364 安装 3.7k 收藏 15.3k 浏览

简介

基于 Polymarket 的预测市场自动化交易技能,提供钱包管理与 USDC 流转能力,助力 OpenClaw 机器人实现安全高效的量化交易。

原始描述

Modular prediction market trading platform for OpenClaw bots. Trade on Polymarket, manage wallets, transfer USDC, and automate trading strategies.

通过你的 Agent 添加

点「快速安装」复制一段指令,粘给你正在用的 Agent(Claude Code、Codex、OpenClaw 等),它会自己完成安装。

或者手动安装

Claude Codeunzip -o skill.zip -d ~/.claude/skills/clawearn/
其它 Agent解压到它自己的 skills 目录,目录名用 clawearn

包里是 SKILL.md 加作者附带的文件,解压后目录名就是技能名。 技能申请的权限由作者决定,装之前请确认它能读什么、能执行什么。

中文使用说明 来自收录源

核心用法

Clawearn 是一个专为 OpenClaw AI 代理设计的预测市场交易平台,核心功能围绕三大模块展开:

1. 钱包管理模块 (core/wallet)

  • 创建和管理以太坊钱包(基于 Arbitrum 网络)
  • 查看余额与交易历史
  • USDC 转账功能

2. Polymarket 交易模块 (markets/polymarket)

  • 搜索预测市场(如 "bitcoin price 2025")
  • 查看市场详情与赔率
  • 下单/撤单:限价买入、查看持仓、取消订单

3. 自动化策略支持

  • 可配置的风险控制参数(最大仓位、日亏损限额等)
  • 支持自定义交易机器人逻辑

技术实现

基于 Bun 运行时和 Ethers.js 构建,采用模块化架构:核心技能 + 市场技能可独立安装。配置通过 ~/.clawearn/config.json 管理,支持多市场扩展(未来可接入 Manifold、Kalshi)。


显著优点

优势 说明
AI 原生设计 专为 OpenClaw 代理优化,命令行接口适合 LLM 调用
模块化架构 核心功能与市场技能分离,可按需安装
真实市场接入 直接对接 Polymarket,非模拟交易
风险管控配置 内置 risk_limits 配置,支持程序化风控
开源可审查 代码托管于 GitHub,可自主审计

潜在缺点与局限性

安全风险(关键)

  • ⚠️ 高危:文档推荐 curl|bash 管道执行远程脚本,存在供应链攻击面
  • ⚠️ 中危:多处动态下载 skill 文件(curl -s https://... > ~/.openclaw/...),无完整性校验
  • 私钥存储于本地文件系统(~/.config/clawearn/),依赖用户安全操作

功能局限

  • 仅支持 Arbitrum 网络,主网及其他 L2 未覆盖
  • 目前仅 Polymarket 可用,其他市场(Manifold/Kalshi)标注但未完全开放
  • 依赖外部 API(Polymarket 三端点),服务中断即不可用

来源可信度

  • T2 级别:个人开发者(stonega)维护,无第三方安全审计
  • 无企业背书,维护持续性存疑

适合人群

推荐使用

  • ✅ 有加密货币交易经验的技术用户
  • ✅ 熟悉 CLI 操作和以太坊钱包管理的开发者
  • ✅ 需要自动化预测市场策略的量化交易者
  • ✅ 能接受高风险并具备自主审计能力的用户

不建议使用

  • ❌ 无加密货币基础知识的普通用户
  • ❌ 无法承担资金损失风险的风险厌恶者
  • ❌ 对供应链安全极度敏感的企业环境

常规风险

风险类别 具体表现 缓释建议
供应链攻击 clawearn.xyz 域名劫持 → 恶意脚本执行 禁用管道执行,先下载审查
私钥泄露 本地文件权限配置错误、意外提交 Git 使用 GPG 加密、硬件钱包
智能合约风险 Polymarket 合约漏洞或资金冻结 小额测试、分散资金
市场波动 预测市场流动性不足、价格操纵 设置止损、监控仓位
API 故障 Polymarket 服务中断导致无法交易 不依赖单一策略、保留退出机制

技能正文

Security Best Practices 🔒

Critical security guidelines for trading on prediction markets.


Core Principles

🔴 NEVER Do These Things

  1. NEVER share your private keys with anyone

    • Not in logs
    • Not in error messages
    • Not in API requests to third parties
    • Not in screenshots or recordings
    • Not in chat messages or support tickets
  2. NEVER send private keys to external services

    • Only use keys locally to sign transactions
    • If a service asks for your private key, it's a scam
    • Legitimate services only need your public address
  3. NEVER commit private keys to version control

    • Add *.txt, *-key.*, credentials.* to .gitignore
    • Use environment variables or secure vaults
    • Scan repositories before pushing
  4. NEVER log sensitive information

    • Redact keys in debug output
    • Don't print full keys even for testing
    • Use console.log(key.slice(0, 6) + '...') if needed
  5. NEVER reuse keys across platforms

    • Each market should have its own wallet
    • Compromised key on one platform won't affect others
    • Easier to track which key is used where

✅ Essential Security Practices

Environment Variables

Good:

# .env file (gitignored)
POLYMARKET_PRIVATE_KEY=0x...
MANIFOLD_API_KEY=...

# Load in your code
export $(cat .env | xargs)

Better:

# Use a secrets manager or encrypted vault
export POLYMARKET_PRIVATE_KEY=$(gpg --decrypt ~/.config/clawearn/key.gpg)

Git Security

.gitignore

# Credentials
*.txt
*-key.*
credentials.*
.env
.env.*

# Config with sensitive data
~/.config/clawearn/

# Backups
*-backup/
*.gpg

Verify before commit:

# Check what you're about to commit
git diff --cached

# Search for potential secrets
git grep -i "private.*key\|secret\|password" $(git diff --cached --name-only)

🛡️ Wallet Security

Separate Wallets for Different Purposes

Production Trading:
├── Polymarket: 0xABCD... (large amounts)
├── Manifold: @ProductionBot
└── Kalshi: prod-account

Development/Testing:
├── Polymarket: 0xEF12... (small amounts)
├── Manifold: @TestBot
└── Kalshi: test-account

Hot vs Cold Wallets

Hot Wallet (Online)

  • Used for active trading
  • Minimal funds (only what you need)
  • Automated by your agent
  • Higher risk

Cold Wallet (Offline)

  • Used for storage
  • Majority of funds
  • Manual transfers only
  • Lower risk

Strategy:

# Keep most funds in cold storage
Cold Wallet: $10,000 USDC

# Transfer to hot wallet as needed
Hot Wallet: $500 USDC (for trading)

# Refill hot wallet when low
# Withdraw profits to cold wallet regularly

🔐 Encryption

Encrypt Private Keys at Rest

# Encrypt a private key
echo "0xYOUR_PRIVATE_KEY" | gpg --symmetric --armor > ~/.config/clawearn/key.gpg

# Decrypt when needed
gpg --decrypt ~/.config/clawearn/key.gpg

Encrypted Backups

# Create encrypted backup
tar -czf - ~/.config/clawearn/ | \
  gpg --symmetric --cipher-algo AES256 > clawearn-backup-$(date +%Y%m%d).tar.gz.gpg

# Store in multiple locations:
# - External hard drive
# - Cloud storage (encrypted!)
# - USB drive in safe

🚨 Incident Response

If You Suspect Key Compromise

Immediate Actions:

  1. Stop all trading immediately

    # Cancel all open orders
    bun markets/polymarket/polymarket-cli.ts order cancel-all --private-key $OLD_KEY
    
  2. Transfer funds to new wallet

    # Create new wallet
    bun markets/polymarket/polymarket-cli.ts account create --email new@example.com --password NEWPASS
    
    # Transfer all funds to new address
    # (Use Polygon wallet interface or CLI transfer command)
    
  3. Revoke API keys

    • Polymarket: Create new account
    • Manifold: Regenerate API key
    • Kalshi: Reset credentials
  4. Document the incident

    • When did you notice?
    • What actions did you take?
    • How much was at risk?
    • What was the outcome?
  5. Review security practices

    • How was the key compromised?
    • What can you change to prevent recurrence?
    • Update your security procedures

Signs of Compromise

⚠️ Warning signs:

  • Unexpected balance changes
  • Orders you didn't place
  • Withdrawals you didn't authorize
  • Login attempts from unknown locations
  • API calls you didn't make

Check regularly:

# Review recent transactions
bun markets/polymarket/polymarket-cli.ts transactions list --private-key $KEY

# Check open orders
bun markets/polymarket/polymarket-cli.ts order list-open --private-key $KEY

# Monitor balance
bun markets/polymarket/polymarket-cli.ts balance check --private-key $KEY

🔍 Audit and Monitoring

Regular Security Audits

Weekly:

  • Check file permissions on credential files
  • Review recent transactions
  • Verify balance matches expectations
  • Check for unauthorized API usage

Monthly:

  • Rotate API keys (where possible)
  • Review and update .gitignore
  • Test backup recovery process
  • Audit code for hardcoded secrets

Quarterly:

  • Full security review
  • Update dependencies
  • Review access logs
  • Consider new security tools

Monitoring Script

#!/bin/bash
# security-check.sh

echo "=== Moltearn Security Check ==="

# Check file permissions
echo "Checking file permissions..."
if [ "$(stat -c %a ~/.config/clawearn)" != "700" ]; then
  echo "⚠️  WARNING: Config directory has wrong permissions!"
fi

# Check for secrets in git
echo "Checking for secrets in git..."
if git grep -i "private.*key\|0x[a-fA-F0-9]{64}" > /dev/null 2>&1; then
  echo "⚠️  WARNING: Possible secrets found in git!"
fi

# Check balance
echo "Checking balances..."
BALANCE=$(bun markets/polymarket/polymarket-cli.ts balance check --private-key $POLYMARKET_PRIVATE_KEY)
echo "Polymarket: $BALANCE"

echo "=== Check complete ==="

🎯 Risk Management

Position Limits

Set hard limits to prevent catastrophic loss:

{
  "risk_limits": {
    "max_position_size_pct": 20,
    "max_total_exposure_pct": 50,
    "max_daily_loss_pct": 10,
    "max_single_trade_usd": 100,
    "min_balance_alert_usd": 10
  }
}

Circuit Breakers

Implement automatic stops:

# Example: Stop trading if daily loss exceeds 10%
STARTING_BALANCE=1000
CURRENT_BALANCE=$(get_balance)
LOSS_PCT=$(( (STARTING_BALANCE - CURRENT_BALANCE) * 100 / STARTING_BALANCE ))

if [ $LOSS_PCT -gt 10 ]; then
  echo "🚨 CIRCUIT BREAKER: Daily loss limit exceeded!"
  # Cancel all orders
  # Notify human
  # Stop trading
fi

📋 Security Checklist

Initial Setup

  • Created separate wallets for each market
  • Stored private keys in ~/.config/clawearn/ with 600 permissions
  • Added credential files to .gitignore
  • Created encrypted backups
  • Tested backup recovery
  • Set up environment variables
  • Documented wallet addresses (not keys!)

Ongoing Operations

  • Never log private keys
  • Use environment variables for keys
  • Regular balance checks
  • Monitor for unauthorized transactions
  • Keep software updated
  • Regular encrypted backups

Before Deploying

  • Scanned code for hardcoded secrets
  • Verified .gitignore is comprehensive
  • Tested with small amounts first
  • Set up monitoring and alerts
  • Documented incident response plan
  • Reviewed all API integrations

🛠️ Security Tools

Recommended Tools

Secret Scanning:

# Install gitleaks
brew install gitleaks

# Scan repository
gitleaks detect --source . --verbose

Password Manager:

  • 1Password
  • Bitwarden
  • KeePassXC

Encryption:

  • GPG for file encryption
  • Age for modern encryption
  • Vault by HashiCorp for secrets management

Monitoring:

  • Set up alerts for balance changes
  • Log all API calls (without sensitive data)
  • Monitor for unusual activity patterns

📚 Additional Resources


Emergency Contacts

If you discover a security vulnerability:

  1. Stop using the affected system immediately
  2. Do not disclose publicly until fixed
  3. Contact the maintainers privately
  4. Document the issue thoroughly

Remember: Security is not a one-time setup, it's an ongoing practice. Stay vigilant! 🔒

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

finance-accountingautomationapibackend

同类 Skill