Skip to content

feat(polymarket): Polymarket prediction market trading#59

Draft
AkshatGada wants to merge 2 commits intomainfrom
feat/polymarket-ts
Draft

feat(polymarket): Polymarket prediction market trading#59
AkshatGada wants to merge 2 commits intomainfrom
feat/polymarket-ts

Conversation

@AkshatGada
Copy link
Collaborator

Summary

Adds full Polymarket prediction market trading support to the Polygon Agent CLI. Agents can browse markets, place limit and market orders on the Polymarket CLOB, manage positions, and handle the on-chain approval flow — all through the existing CLI and smart wallet infrastructure.

Architecture

Uses a 3-address system: the Sequence ecosystem wallet funds a Polymarket proxy wallet (derived via CREATE2 from the builder EOA), which holds USDC.e and outcome tokens. CLOB orders are signed by the EOA with signatureType=POLY_PROXY. The proxy wallet factory routes all on-chain calls.

Commands

Command Purpose
polymarket markets Browse active prediction markets
polymarket market <conditionId> Get details + odds for a specific market
polymarket set-key <privateKey> Import EOA private key for CLOB signing
polymarket proxy-wallet Show derived proxy wallet address
polymarket approve One-time on-chain approvals (USDC.e, CTF, exchanges)
polymarket clob-buy <conditionId> <outcome> <amount> Place a buy order (limit or market)
polymarket sell <conditionId> <outcome> <shares> Sell outcome token shares
polymarket positions View current holdings
polymarket orders View open orders
polymarket cancel <orderId> Cancel an open order

Key Features

  • Supports both regular and neg-risk markets
  • CLOB limit orders and market orders
  • Funds proxy wallet from Sequence smart wallet via dapp-client transactions
  • On-chain approval management (USDC.e, CTF tokens, exchange contracts)
  • Skill files (POLYMARKET.md, polymarket-skill.md) for LLM agent guidance

AkshatGada and others added 2 commits March 5, 2026 06:17
Add polymarket trading commands (approve, clob-buy, sell, markets,
proxy-wallet, set-key, orders, cancel, positions) as a yargs
CommandModule following the new src/commands/*.ts structure.

- src/commands/polymarket.ts: all 10 subcommands
- src/lib/polymarket.ts: Gamma API, CLOB client, proxy wallet helpers
- src/lib/storage.ts: add savePolymarketKey + loadPolymarketKey
- src/index.ts: register polymarketCommand
- package.json: add @polymarket/clob-client, @polymarket/sdk, ethers5
- skills/POLYMARKET.md: full reference doc

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
data = JSON.parse(fs.readFileSync(configPath, 'utf8'));
}
data.polymarketPrivateKey = encrypt(privateKey);
fs.writeFileSync(configPath, JSON.stringify(data, null, 2), { mode: 0o600 });

Check failure

Code scanning / CodeQL

Potential file system race condition High

The file may have changed since it
was checked
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant