polytown 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -0
- package/dist/index.js +2056 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Polytown
|
|
2
|
+
|
|
3
|
+
Best Polymarket CLI for humans and AI agents.
|
|
4
|
+
|
|
5
|
+
Fast, lightweight, and scriptable — built with [Bun](https://bun.sh) and TypeScript. Query markets, manage wallets, place trades, and pipe structured output to your agent or workflow.
|
|
6
|
+
|
|
7
|
+
## Why Polytown
|
|
8
|
+
|
|
9
|
+
- **Gnosis Safe only** — Uses the same Safe wallet infrastructure as polymarket.com. Your CLI wallet and web wallet share the same account, balances, and positions. Implements Polymarket's custom Safe Factory with CREATE2 derivation — not standard Gnosis Safe.
|
|
10
|
+
- **Built-in CLOB proxy** — Access Polymarket's CLOB API from anywhere, no VPN needed. `proxy.polytown.app` is preconfigured out of the box.
|
|
11
|
+
- **100% gas-free** — All on-chain operations (Safe deployment, token approvals, splits, merges, redemptions, withdrawals) go through the relayer. You never need MATIC.
|
|
12
|
+
- **Complete CLOB coverage** — Built on the official [`@polymarket/clob-client`](https://www.npmjs.com/package/@polymarket/clob-client). 50+ subcommands: real-time pricing, order book depth, limit/market orders, batch operations, rewards tracking, API key management.
|
|
13
|
+
- **URL resolver** — Paste any Polymarket URL or `@username` and get back structured IDs (event, market, condition, tokens, wallet address). Useful for piping into other commands.
|
|
14
|
+
- **Interactive setup wizard** — Four-step guided setup: wallet create/import → Safe deployment → token approvals → balance check. Zero-to-trading in one command.
|
|
15
|
+
- **Agent-friendly** — Every command outputs structured, parseable text. Pipe it into your AI agent, chain commands, or call from any script.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bun install
|
|
21
|
+
bun link
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Setup
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
polytown setup
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Interactive wizard that walks you through wallet creation/import, Safe deployment, token approvals, and balance verification.
|
|
31
|
+
|
|
32
|
+
Or copy `.env.example` to `.env` and fill in your values manually:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
cp .env.example .env
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
polytown <command> [options]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Commands
|
|
45
|
+
|
|
46
|
+
| Command | Description |
|
|
47
|
+
| --------------------- | -------------------------------------------------------------- |
|
|
48
|
+
| `setup` | Interactive setup wizard (wallet → Safe → approvals → balance) |
|
|
49
|
+
| `status` | API health checks (CLOB, Gamma, Data, RPC) |
|
|
50
|
+
| `resolve <url>` | Resolve any Polymarket URL or @username to structured IDs |
|
|
51
|
+
| `markets` | Search and browse markets with 20+ filters |
|
|
52
|
+
| `events` | Search and browse events |
|
|
53
|
+
| `movers` | Biggest price movers by category |
|
|
54
|
+
| `clob` | Full CLOB trading suite (pricing, orders, trades, rewards) |
|
|
55
|
+
| `wallet` | Create, import, show balance, withdraw USDC |
|
|
56
|
+
| `approve` | Check and set token approvals (gas-free) |
|
|
57
|
+
| `ctf` | Conditional token operations: split, merge, redeem (gas-free) |
|
|
58
|
+
| `data` | Portfolio analytics: positions, trades, leaderboard |
|
|
59
|
+
| `profile [address]` | User profile and stats lookup |
|
|
60
|
+
| `comments <event_id>` | Event discussion feed |
|
|
61
|
+
| `tags` | Browse market tags and related items |
|
|
62
|
+
| `series` | Browse event series |
|
|
63
|
+
| `sports` | Sports markets, leagues, and teams |
|
|
64
|
+
|
|
65
|
+
Run `polytown <command> --help` for details on any command.
|
|
66
|
+
|
|
67
|
+
### Examples
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Zero-to-trading setup
|
|
71
|
+
polytown setup
|
|
72
|
+
|
|
73
|
+
# Check API status
|
|
74
|
+
polytown status
|
|
75
|
+
|
|
76
|
+
# Resolve a URL to tradeable IDs
|
|
77
|
+
polytown resolve https://polymarket.com/event/<slug>
|
|
78
|
+
polytown resolve https://polymarket.com/event/<slug>/<market-slug>
|
|
79
|
+
polytown resolve @username
|
|
80
|
+
|
|
81
|
+
# Search markets
|
|
82
|
+
polytown markets search "bitcoin"
|
|
83
|
+
|
|
84
|
+
# Get biggest movers
|
|
85
|
+
polytown movers --limit 10
|
|
86
|
+
|
|
87
|
+
# Check order book
|
|
88
|
+
polytown clob book <condition_id>
|
|
89
|
+
|
|
90
|
+
# Place a limit order
|
|
91
|
+
polytown clob create-order <token_id> --price 0.5 --size 100 --side BUY
|
|
92
|
+
|
|
93
|
+
# Check your positions
|
|
94
|
+
polytown data positions
|
|
95
|
+
|
|
96
|
+
# Withdraw USDC (gas-free)
|
|
97
|
+
polytown wallet withdraw 100 0x1234...
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### For AI Agents
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Pipe market data to your agent
|
|
104
|
+
polytown markets search "election" | your-agent-script
|
|
105
|
+
|
|
106
|
+
# Resolve URL → get token IDs → check price → place order
|
|
107
|
+
polytown resolve https://polymarket.com/event/<slug>/<market-slug>
|
|
108
|
+
polytown clob price <token_id>
|
|
109
|
+
polytown clob create-order <token_id> --price 0.45 --size 50 --side BUY
|
|
110
|
+
|
|
111
|
+
# Call from any runtime
|
|
112
|
+
const result = Bun.spawnSync(["polytown", "markets", "search", "bitcoin"]);
|
|
113
|
+
```
|