Skip to content

dProLabs/dpro-polymarket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

dpro-polymarket

An agent skill for Polymarket prediction market trading and data.

One skill surface covering market search, YES/NO price quotes, order books, account management, and trading β€” built for AI agent environments like Claude Code, OpenClaw, Codex, and OpenCode.


Get Started

Quick Install

# Claude Code
git clone https://github.com/dProLabs/dpro-polymarket.git .claude/skills/dpro-pm
cd .claude/skills/dpro-pm && npm install

Then add to your agent config:

Skills: .claude/skills/dpro-pm/SKILL.md

Local Development

git clone https://github.com/dProLabs/dpro-polymarket.git
cd dpro-polymarket
npm install

What It Can Do

  • Market search β€” find prediction markets by keyword, browse trending by volume
  • Price quotes β€” YES/NO prices, liquidity, volume, token IDs for any market
  • Order books β€” full depth for any outcome token
  • Account management β€” encrypted multi-account storage with AES-256
  • Portfolio β€” positions, open orders, USDC balance, trade history
  • Trading β€” buy/sell YES/NO shares with limit or market orders (GTC/GTD/FOK/FAK)
  • Flexible invocation β€” canonical commands, slash-style input, or natural language
  • Programmatic API β€” runPolymarketSkill(...) entry point for automation

Usage Examples

dpro-pm search bitcoin 2025
dpro-pm quote will-iran-strike-israel-on-march-6
dpro-pm book <token-id>
dpro-pm trending
dpro-pm event us-presidential-election-2024

dpro-pm account add 0xYourPrivateKey myaccount --password <pwd>
dpro-pm balance
dpro-pm positions
dpro-pm orders

dpro-pm buy will-trump-win yes 50 0.65
dpro-pm sell will-trump-win yes 20
dpro-pm cancel <orderId>
dpro-pm cancel-all

Programmatic

import { runPolymarketSkill } from './scripts/entry.mjs';

const result = await runPolymarketSkill('dpro-pm search bitcoin', {});
console.log(result);

// With password for trading
const trade = await runPolymarketSkill(
  'dpro-pm buy will-btc-hit-100k yes 10 0.65',
  { password: 'your-password' }
);
console.log(trade);

Account Setup

Polymarket uses a two-layer auth system:

  1. L1 β€” EIP-712 private key signing β†’ derives API credentials
  2. L2 β€” HMAC-SHA256 API key signing β†’ authenticates trading requests

The skill handles both automatically. You only need to provide your private key once:

# Export private key from polymarket.com/settings
dpro-pm account add 0xYourPrivateKey myaccount --password <password>

# Verify connection
dpro-pm balance

# Place a trade (API credentials derived automatically on first trade)
dpro-pm buy will-trump-tariffs-exceed-10-percent yes 10 0.55

Signature types:

  • Default: 2 (GNOSIS_SAFE) β€” for standard Polymarket.com accounts
  • Use --sig-type 0 (EOA) for raw MetaMask wallets

Reference Docs

Document Description
SKILL.md Routing, execution policy, and safety rules
references/markets.md Gamma API, market structure, token IDs
references/trading.md Order types, signing, tick sizes
references/auth.md L1/L2 auth, credential lifecycle, signature types
examples.md Task-oriented workflow cookbook

Safety

  • Trading commands always show a summary before submitting (handled by the skill's safety policy)
  • Private keys are AES-256-GCM encrypted at rest β€” never stored in plain text
  • API credentials are derived from private keys and cached separately
  • Password can be passed via --password, runtimeContext.password, or DPRO_PM_PASSWORD env var

Project Structure

references/               # API and auth reference docs
scripts/
β”œβ”€β”€ entry.mjs             # Single entry point: runPolymarketSkill()
β”œβ”€β”€ parser.mjs            # Input parsing (command + natural language)
β”œβ”€β”€ router.mjs            # AST β†’ command handler dispatch
β”œβ”€β”€ format.mjs            # Structured result β†’ text output
β”œβ”€β”€ config.mjs            # Config file management
β”œβ”€β”€ store.mjs             # Encrypted account + credential storage
β”œβ”€β”€ clients/
β”‚   β”œβ”€β”€ clob-client.mjs   # CLOB API (orderbook, trading) via @polymarket/clob-client
β”‚   └── gamma-client.mjs  # Gamma/Data API (markets, positions, history)
β”œβ”€β”€ commands/
β”‚   β”œβ”€β”€ market.mjs        # search, quote, book, trending, event
β”‚   β”œβ”€β”€ account.mjs       # account management, balance, positions, orders, history
β”‚   └── trade.mjs         # buy, sell, cancel, cancel-all
└── utils/
    β”œβ”€β”€ crypto.mjs        # AES-256-GCM encryption
    └── numbers.mjs       # Number formatting helpers

API Endpoints Used

API Base URL Purpose
CLOB https://clob.polymarket.com Orderbook + trading (L2 auth for trades)
Gamma https://gamma-api.polymarket.com Markets, events, search (no auth)
Data https://data-api.polymarket.com Positions, trade history (no auth)

Website

https://www.d.pro/

Contract Addresses (Polygon)

Contract Address
USDC.e 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174
CTF Exchange 0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E
Neg Risk CTF Exchange 0xC5d563A36AE78145C45a50134d48A1215220f80a

License

MIT

About

🧠 dPro + Polymarket operational toolkit for market/account reads, YES/NO trading, order book access, readiness checks, and secure credential-backed execution.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors