polytown 0.1.0 → 0.1.2
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 +17 -17
- package/dist/index.js +28 -6
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -17,22 +17,33 @@ Fast, lightweight, and scriptable — built with [Bun](https://bun.sh) and TypeS
|
|
|
17
17
|
## Install
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
|
|
21
|
-
bun link
|
|
20
|
+
npm install -g polytown
|
|
22
21
|
```
|
|
23
22
|
|
|
24
23
|
## Setup
|
|
25
24
|
|
|
26
25
|
```bash
|
|
26
|
+
# Interactive (humans)
|
|
27
27
|
polytown setup
|
|
28
|
+
|
|
29
|
+
# Non-interactive (agents / scripts)
|
|
30
|
+
polytown setup -y # generate new wallet + deploy + approve
|
|
31
|
+
polytown setup -y --key 0xYourKey # import existing key + deploy + approve
|
|
28
32
|
```
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
The setup wizard handles: wallet creation/import → Gnosis Safe deployment → token approvals → balance check. All on-chain operations are gas-free via relayer.
|
|
35
|
+
|
|
36
|
+
Configuration is saved to `~/.polytown/.env`. You can override with a local `.env` in your working directory or via environment variables.
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
For agent integration, see [`skill.md`](./skill.md).
|
|
39
|
+
|
|
40
|
+
### Development
|
|
33
41
|
|
|
34
42
|
```bash
|
|
35
|
-
|
|
43
|
+
git clone https://github.com/kale5195/polymarket-cli.git
|
|
44
|
+
cd polymarket-cli
|
|
45
|
+
bun install
|
|
46
|
+
bun run dev
|
|
36
47
|
```
|
|
37
48
|
|
|
38
49
|
## Usage
|
|
@@ -99,15 +110,4 @@ polytown wallet withdraw 100 0x1234...
|
|
|
99
110
|
|
|
100
111
|
### For AI Agents
|
|
101
112
|
|
|
102
|
-
|
|
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
|
-
```
|
|
113
|
+
See [`SKILL.md`](./SKILL.md) for the full agent skill reference.
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { program } from "commander";
|
|
@@ -1856,7 +1856,8 @@ ${key}=${value}
|
|
|
1856
1856
|
}
|
|
1857
1857
|
writeFileSync(CONFIG_ENV_PATH, content, { mode: 384 });
|
|
1858
1858
|
}
|
|
1859
|
-
var setupCommand = new Command15("setup").description("Interactive setup wizard for Polymarket trading").action(async () => {
|
|
1859
|
+
var setupCommand = new Command15("setup").description("Interactive setup wizard for Polymarket trading").option("-y, --yes", "Skip all confirmations (auto-approve everything)").option("--key <private_key>", "Provide private key non-interactively").action(async (opts) => {
|
|
1860
|
+
const autoYes = opts.yes ?? false;
|
|
1860
1861
|
console.log(bold("\nPolymarket CLI Setup\n"));
|
|
1861
1862
|
let privateKey;
|
|
1862
1863
|
let eoaAddress;
|
|
@@ -1868,6 +1869,23 @@ var setupCommand = new Command15("setup").description("Interactive setup wizard
|
|
|
1868
1869
|
step(1, 4, "Wallet");
|
|
1869
1870
|
console.log(` ${green("Found existing key in environment")}`);
|
|
1870
1871
|
console.log(` EOA: ${cyan(eoaAddress)}`);
|
|
1872
|
+
} else if (opts.key) {
|
|
1873
|
+
step(1, 4, "Wallet");
|
|
1874
|
+
privateKey = resolvePrivateKey(opts.key);
|
|
1875
|
+
const account = privateKeyToAccount8(privateKey);
|
|
1876
|
+
eoaAddress = account.address;
|
|
1877
|
+
updateEnvFile({ POLYMARKET_PRIVATE_KEY: privateKey });
|
|
1878
|
+
console.log(` EOA: ${cyan(eoaAddress)}`);
|
|
1879
|
+
console.log(` ${green("Saved to ~/.polytown/.env")}`);
|
|
1880
|
+
} else if (autoYes) {
|
|
1881
|
+
step(1, 4, "Wallet");
|
|
1882
|
+
const wallet = createRandomWallet();
|
|
1883
|
+
privateKey = wallet.privateKey;
|
|
1884
|
+
eoaAddress = wallet.address;
|
|
1885
|
+
updateEnvFile({ POLYMARKET_PRIVATE_KEY: privateKey });
|
|
1886
|
+
console.log(` EOA: ${cyan(eoaAddress)}`);
|
|
1887
|
+
console.log(` Private Key: ${yellow(wallet.privateKey)}`);
|
|
1888
|
+
console.log(` ${green("Saved to ~/.polytown/.env")}`);
|
|
1871
1889
|
} else {
|
|
1872
1890
|
step(1, 4, "Wallet");
|
|
1873
1891
|
const walletChoice = await select({
|
|
@@ -1907,7 +1925,7 @@ var setupCommand = new Command15("setup").description("Interactive setup wizard
|
|
|
1907
1925
|
console.log(` Status: ${green("deployed")}`);
|
|
1908
1926
|
} else {
|
|
1909
1927
|
console.log(` Status: ${yellow("not deployed")}`);
|
|
1910
|
-
const doDeploy = await confirm({
|
|
1928
|
+
const doDeploy = autoYes || await confirm({
|
|
1911
1929
|
message: "Deploy your Gnosis Safe now? (gas-free via relayer)",
|
|
1912
1930
|
default: true
|
|
1913
1931
|
});
|
|
@@ -1961,7 +1979,7 @@ var setupCommand = new Command15("setup").description("Interactive setup wizard
|
|
|
1961
1979
|
console.log(` CTF -> CTF Exchange: ${tag(ctfCtf)}`);
|
|
1962
1980
|
console.log(` CTF -> Neg Risk Exchange: ${tag(ctfNeg)}`);
|
|
1963
1981
|
if (!allApproved) {
|
|
1964
|
-
const doApprove = await confirm({
|
|
1982
|
+
const doApprove = autoYes || await confirm({
|
|
1965
1983
|
message: "Set all approvals now? (gas-free via relayer)",
|
|
1966
1984
|
default: true
|
|
1967
1985
|
});
|
|
@@ -2014,7 +2032,7 @@ var CATEGORIES = [
|
|
|
2014
2032
|
var moversCommand = new Command16("movers").description("Get biggest movers (highest price change markets)").option(
|
|
2015
2033
|
"--category <category>",
|
|
2016
2034
|
`Filter by category (${CATEGORIES.join(", ")})`
|
|
2017
|
-
).action(async (opts) => {
|
|
2035
|
+
).option("--limit <n>", "Limit number of results", parseInt).action(async (opts) => {
|
|
2018
2036
|
const params = {};
|
|
2019
2037
|
if (opts.category && opts.category !== "all") {
|
|
2020
2038
|
params.category = opts.category;
|
|
@@ -2028,7 +2046,11 @@ var moversCommand = new Command16("movers").description("Get biggest movers (hig
|
|
|
2028
2046
|
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
2029
2047
|
}
|
|
2030
2048
|
const data = await res.json();
|
|
2031
|
-
|
|
2049
|
+
let markets = data.markets || [];
|
|
2050
|
+
if (opts.limit) {
|
|
2051
|
+
markets = markets.slice(0, opts.limit);
|
|
2052
|
+
}
|
|
2053
|
+
console.log(JSON.stringify(markets, null, 2));
|
|
2032
2054
|
});
|
|
2033
2055
|
|
|
2034
2056
|
// src/index.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polytown",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"polytown": "./dist/index.js"
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"build": "tsup",
|
|
16
16
|
"prepublishOnly": "npm run build",
|
|
17
17
|
"test": "bun test",
|
|
18
|
-
"typecheck": "tsc --noEmit"
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"release": "npm version patch && npm publish"
|
|
19
20
|
},
|
|
20
21
|
"dependencies": {
|
|
21
22
|
"@inquirer/prompts": "^8.3.0",
|
|
@@ -28,4 +29,4 @@
|
|
|
28
29
|
"tsup": "^8.5.1",
|
|
29
30
|
"typescript": "^5.9.3"
|
|
30
31
|
}
|
|
31
|
-
}
|
|
32
|
+
}
|