[new-plugin] polymarket v0.1.0#175
Conversation
📋 Phase 3: AI Code Review Report — Score: 78/100
1. Plugin Overview
Summary: This plugin enables trading on Polymarket prediction markets (Polygon chain) through the onchainos agent. It provides commands to browse markets, view positions, and execute buy/sell/cancel orders for YES/NO outcome tokens using USDC.e as collateral. The binary handles Polymarket CLOB API interactions, EIP-712 order signing, and triggers on-chain approvals via Target Users: Crypto traders interested in prediction markets who want to manage Polymarket positions through an AI agent interface. 2. Architecture AnalysisComponents:
Skill Structure: Data Flow:
Dependencies:
3. Auto-Detected Permissionsonchainos Commands Used
Wallet Operations
External APIs / URLs
Chains Operated On
Overall Permission SummaryThis plugin has significant financial operation capabilities. It can execute on-chain contract calls with 4. onchainos API ComplianceDoes this plugin use onchainos CLI for all on-chain write operations?✅ Yes — all on-chain write operations (token approvals) are performed via On-Chain Write Operations (MUST use onchainos)
Data Queries (allowed to use external sources)
External APIs / Libraries Detected
Verdict: ✅ Fully CompliantAll on-chain write operations (token approvals) correctly use 5. Security AssessmentStatic Rule Scan (C01-C09, H01-H09, M01-M08, L01-L02)
LLM Judge Analysis (L-PINJ, L-MALI, L-MEMA, L-IINJ, L-AEXE, L-FINA, L-FISO)
Toxic Flow Detection (TF001-TF006)
No toxic flows detected. Prompt Injection Scan
Result: ✅ Clean Dangerous Operations Check
Result: Data Exfiltration Risk
Result: Overall Security Rating: 🟡 Medium RiskKey risk factors:
6. Source Code Security (if source code is included)Language & Build Config
Dependency AnalysisSource code is not included in the submission. The binary is built from an external repository. Key concerns:
Code Safety Audit
Does SKILL.md accurately describe what the source code does?Cannot fully verify — source code is not included. SKILL.md is detailed and internally consistent, but the commit hash discrepancy between SKILL.md ( Verdict:
|
| Dimension | Score | Notes |
|---|---|---|
| Completeness (pre-flight, commands, error handling) | 21/25 | Thorough pre-flight checks, 6 well-documented commands. Missing: explicit error handling section for API failures, rate limits. Credential generation requires external Python tool. |
| Clarity (descriptions, no ambiguity) | 22/25 | Very clear command documentation with flags, examples, and output fields. Data trust boundary well articulated. Minor ambiguity: "signs via onchainos wallet sign-message" in buy/sell auth, but the "Known limitation" section acknowledges this doesn't actually work — contradictory. |
| Security Awareness (confirmations, slippage, limits) | 17/25 | Good: explicit data trust boundary, prompt injection warning, M08 field filtering. Concerning: --force flag bypasses confirmation, reliance on agent-level confirmation only. No slippage protection mentioned for market orders (FOK). No maximum amount limits. |
| Skill Routing (defers correctly, no overreach) | 13/15 | Good "Do NOT use for" section. Correctly defers to onchainos for wallet operations. Does not attempt to handle chains other than Polygon 137. |
| Formatting (markdown, tables, code blocks) | 5/10 | Well-structured markdown with tables and code blocks. However, the SKILL.md is very long and could benefit from a references directory for contract addresses and fee structures. Some sections (Credential Setup with Python code) add complexity. |
Strengths
- Excellent data trust boundary declaration: Explicitly addresses M07 and M08 requirements with concrete field enumeration and prompt injection warnings for market title content.
- Clear onchainos integration pattern: On-chain approvals correctly delegated to
onchainos wallet contract-call. Read-only operations appropriately use external APIs directly. - Comprehensive command documentation: Each command has clear flags, defaults, auth requirements, output fields, and examples.
Issues Found
-
🔴 Critical:
--forceflag on approval contract calls — The plugin automatically passes--forcetoonchainos wallet contract-callfor USDC.e and CTF token approvals, bypassing the backend's confirmation safety gate. While documented, this means a single agent misinterpretation could trigger unlimited token approvals. Recommendation: Remove--forceand handle the confirming response flow properly, or at minimum implement amount-limited approvals rather than unlimited. -
🔴 Critical: Commit hash mismatch — SKILL.md references source commit
6882d08dbut plugin.yaml specifiesdf1e7d0036ccb440358198aff226b093ecc58840. This makes it impossible to verify which version of the binary was actually built and whether the SKILL.md accurately describes its behavior. -
🟡 Important: Credential caching to plaintext file — API credentials are cached to
~/.config/polymarket/creds.jsonin plaintext. No warning about file permissions or.gitignore. The POLYMARKET_SECRET is derived from the user's private key, making this cache a high-value target. -
🟡 Important: No source code in submission — Binary is pre-built from external repo. Cannot verify: dependency safety, actual network endpoints contacted, credential handling, telemetry payload contents, absence of backdoors.
-
🟡 Important: Contradictory auth documentation — Buy/sell commands state "Auth required: Yes — active onchainos wallet (signs via
onchainos wallet sign-message)" but the "Known limitation" section states onchainos's sign-message format is incompatible with Polymarket. The actual signing appears to use credentials from env vars. This contradiction may confuse both agents and users. -
🔵 Minor: No maximum trade amount or position limits — No safeguards against accidentally large orders (e.g., typing
1000when meaning10). -
🔵 Minor: External Python dependency for credential setup — Requires
py-clob-clientand user's private key in a Python script for credential generation, which is a security-sensitive operation with no integrity verification guidance.
8. Recommendations
-
Remove
--forcefrom approval contract calls — Implement proper confirming response handling (display backend warning to user, wait for explicit confirmation, then retry with--force). This is the standard pattern used by official onchainos skills. -
Resolve commit hash mismatch — Align plugin.yaml's
source_commitwith the actual commit referenced in SKILL.md, or update both to the same verified commit. -
Include source code or provide verifiable build — Either include the Rust source in the submission, or provide reproducible build instructions so the binary can be verified against the source commit.
-
Encrypt or secure credential cache —
~/.config/polymarket/creds.jsonshould use file permissions (0600) at minimum. Consider using the system keychain via onchainos's keyring infrastructure instead. -
Fix contradictory auth documentation — Clarify that buy/sell signing uses Polymarket API credentials (env vars), not
onchainos wallet sign-message. Remove the misleading "signs via onchainos wallet sign-message" from the Auth Required fields. -
Add trade amount limits and confirmation for large orders — Implement a threshold (e.g., $500) above which the agent must display a prominent warning and require explicit user confirmation.
-
Add
.gitignorewarning — In the Credential Setup section, warn users to add~/.config/polymarket/creds.jsonto any version control ignore files and to never commit env files containing these credentials. -
Add error handling documentation — Include a section covering common API errors, rate limits, insufficient balance handling, and order rejection scenarios.
9. Reviewer Summary
One-line verdict: Well-documented Polymarket trading plugin with proper onchainos integration for on-chain operations, but critical concerns around --force flag usage on approvals, commit hash mismatch, and missing source code verification.
Merge recommendation: 🔍 Needs changes before merge
Required changes:
- Resolve commit hash mismatch between SKILL.md and plugin.yaml
- Remove or gate
--forceflag onwallet contract-callapprovals — implement proper confirming response flow - Fix contradictory auth documentation regarding
wallet sign-messagevs. env var credentials - Provide source code or reproducible build for binary verification
Recommended (non-blocking):
5. Secure credential cache file permissions
6. Add trade amount safety limits
7. Add error handling documentation
Generated by Claude AI via Anthropic API — review the full report before approving.
Phase 4: Summary + Pre-flight for
|
| Command | Description |
|---|---|
list-markets |
Browse active prediction markets with optional keyword filtering |
get-market |
Get detailed market information and order book data |
get-positions |
View current positions and PnL for a wallet address |
buy |
Buy YES or NO shares with specified amount and optional limit price |
sell |
Sell existing shares with specified quantity and optional limit price |
cancel |
Cancel orders by ID, market, or all open orders |
Triggers
Activate when users want to trade prediction markets, check Polymarket positions, browse available markets, or manage existing orders on the Polymarket platform. Use for any prediction market trading activity on Polygon.
Auto-injected Pre-flight
## Pre-flight Dependencies (auto-injected by Plugin Store CI)
> Run once per session before first use. These checks ensure required tools are installed.
### Install onchainos CLI + Skills (auto-injected)
```bash
# 1. Install onchainos CLI
onchainos --version 2>/dev/null || curl -fsSL https://raw.githubusercontent.com/okx/onchainos-skills/main/install.sh | sh
# 2. Install onchainos skills (enables AI agent to use onchainos commands)
npx skills add okx/onchainos-skills --yes --global
# 3. Install plugin-store skills (enables plugin discovery and management)
npx skills add MigOKG/plugin-store --skill plugin-store --yes --globalInstall polymarket binary (auto-injected)
if ! command -v polymarket >/dev/null 2>&1; then
OS=$(uname -s | tr A-Z a-z)
ARCH=$(uname -m)
case "${OS}_${ARCH}" in
darwin_arm64) TARGET="aarch64-apple-darwin" ;;
darwin_x86_64) TARGET="x86_64-apple-darwin" ;;
linux_x86_64) TARGET="x86_64-unknown-linux-gnu" ;;
linux_aarch64) TARGET="aarch64-unknown-linux-gnu" ;;
esac
curl -fsSL "https://github.com/MigOKG/plugin-store/releases/download/plugins/polymarket@0.1.0/polymarket-${TARGET}" -o ~/.local/bin/polymarket
chmod +x ~/.local/bin/polymarket
fiReport install (auto-injected, runs once)
REPORT_FLAG="$HOME/.plugin-store/reported/polymarket"
if [ ! -f "$REPORT_FLAG" ]; then
mkdir -p "$HOME/.plugin-store/reported"
# Device fingerprint → SHA256 → 32-char device ID
DEV_RAW="$(hostname):$(uname -s):$(uname -m):$HOME"
DEV_ID=$(echo -n "$DEV_RAW" | shasum -a 256 | head -c 32)
# HMAC signature (obfuscated key, same as CLI binary)
_K=$(echo 'OE9nNWFRUFdfSVJkektrMExOV2RNeTIzV2JibXo3ZWNTbExJUDFIWnVoZw==' | base64 -d 2>/dev/null || echo 'OE9nNWFRUFdfSVJkektrMExOV2RNeTIzV2JibXo3ZWNTbExJUDFIWnVoZw==' | openssl base64 -d)
HMAC_SIG=$(echo -n "${_K}${DEV_ID}" | shasum -a 256 | head -c 8)
DIV_ID="${DEV_ID}${HMAC_SIG}"
unset _K
# Report to Vercel stats
curl -s -X POST "https://plugin-store-dun.vercel.app/install" \
-H "Content-Type: application/json" \
-d '{"name":"polymarket","version":"0.1.0"}' >/dev/null 2>&1 || true
# Report to OKX API (with HMAC-signed device token)
curl -s -X POST "https://www.okx.com/priapi/v1/wallet/plugins/download/report" \
-H "Content-Type: application/json" \
-d '{"pluginName":"polymarket","divId":"'"$DIV_ID"'"}' >/dev/null 2>&1 || true
touch "$REPORT_FLAG"
fi
</details>
---
*Generated by Plugin Store CI after maintainer approval.*
🔨 Phase 2: Build Verification — ❌ FAILED
Build failed. Check the workflow logs. Source integrity: commit SHA |
New Plugin Submission: polymarket v0.1.0
Plugin: Trade prediction markets on Polymarket (Polygon)
Author: skylavis-sky
Category: defi-protocol
Source