create-polymarket-strategy 0.2.0 → 0.2.1

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/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  import { program } from "commander";
5
5
  import fs from "fs-extra";
6
6
  import path from "path";
7
- import { execSync } from "child_process";
7
+ import { execSync as execSync2 } from "child_process";
8
8
  import pc from "picocolors";
9
9
  import { fileURLToPath } from "url";
10
10
 
@@ -173,6 +173,124 @@ async function checkApprovals(address) {
173
173
  return { allApproved, details };
174
174
  }
175
175
 
176
+ // src/wallet/onepassword.ts
177
+ import { execSync } from "child_process";
178
+ var WALLET_ITEM_PREFIX = "Polymarket Wallet";
179
+ function check1PasswordCli() {
180
+ try {
181
+ execSync("which op", { encoding: "utf8", stdio: "pipe" });
182
+ } catch {
183
+ return {
184
+ available: false,
185
+ authenticated: false,
186
+ error: "1Password CLI not installed. Install with: brew install --cask 1password-cli"
187
+ };
188
+ }
189
+ try {
190
+ execSync("op account list", { encoding: "utf8", stdio: "pipe" });
191
+ return { available: true, authenticated: true };
192
+ } catch {
193
+ return {
194
+ available: true,
195
+ authenticated: false,
196
+ error: "1Password CLI not authenticated. Enable app integration: Settings \u2192 Developer \u2192 Integrate with 1Password CLI"
197
+ };
198
+ }
199
+ }
200
+ async function storeIn1Password(name, credentials, vault = "Private") {
201
+ const itemName = `${WALLET_ITEM_PREFIX} - ${name}`;
202
+ try {
203
+ const fields = [
204
+ `address[text]=${credentials.address}`,
205
+ `private_key[password]=${credentials.privateKey}`,
206
+ `api_key[text]=${credentials.apiKey}`,
207
+ `api_secret[password]=${credentials.apiSecret}`,
208
+ `api_passphrase[password]=${credentials.apiPassphrase}`,
209
+ `created_at[text]=${(/* @__PURE__ */ new Date()).toISOString()}`
210
+ ];
211
+ const cmd = [
212
+ "op",
213
+ "item",
214
+ "create",
215
+ "--category=Login",
216
+ `--title=${itemName}`,
217
+ `--vault=${vault}`,
218
+ ...fields.map((f) => `"${f}"`)
219
+ ].join(" ");
220
+ execSync(cmd, { encoding: "utf8", stdio: "pipe" });
221
+ return { itemName, success: true };
222
+ } catch (error) {
223
+ const msg = error instanceof Error ? error.message : String(error);
224
+ return { itemName, success: false, error: msg };
225
+ }
226
+ }
227
+ async function getFrom1Password(name) {
228
+ const itemName = `${WALLET_ITEM_PREFIX} - ${name}`;
229
+ try {
230
+ const output = execSync(
231
+ `op item get "${itemName}" --format json`,
232
+ { encoding: "utf8", stdio: "pipe" }
233
+ );
234
+ const item = JSON.parse(output);
235
+ const fields = {};
236
+ for (const field of item.fields || []) {
237
+ if (field.label && field.value) {
238
+ fields[field.label] = field.value;
239
+ }
240
+ }
241
+ if (!fields.address || !fields.private_key) {
242
+ return { error: `Wallet "${itemName}" is missing required fields` };
243
+ }
244
+ return {
245
+ credentials: {
246
+ address: fields.address,
247
+ privateKey: fields.private_key,
248
+ apiKey: fields.api_key || "",
249
+ apiSecret: fields.api_secret || "",
250
+ apiPassphrase: fields.api_passphrase || ""
251
+ }
252
+ };
253
+ } catch (error) {
254
+ const msg = error instanceof Error ? error.message : String(error);
255
+ if (msg.includes("isn't an item")) {
256
+ return { error: `Wallet "${itemName}" not found in 1Password` };
257
+ }
258
+ return { error: msg };
259
+ }
260
+ }
261
+ function listWallets(vault) {
262
+ try {
263
+ const vaultArg = vault ? `--vault="${vault}"` : "";
264
+ const output = execSync(
265
+ `op item list --format json ${vaultArg}`,
266
+ { encoding: "utf8", stdio: "pipe" }
267
+ );
268
+ const items = JSON.parse(output);
269
+ const wallets = [];
270
+ for (const item of items) {
271
+ if (item.title?.startsWith(WALLET_ITEM_PREFIX)) {
272
+ const name = item.title.replace(`${WALLET_ITEM_PREFIX} - `, "");
273
+ wallets.push(name);
274
+ }
275
+ }
276
+ return wallets;
277
+ } catch {
278
+ return [];
279
+ }
280
+ }
281
+ function getWalletAddress(name) {
282
+ const itemName = `${WALLET_ITEM_PREFIX} - ${name}`;
283
+ try {
284
+ const output = execSync(
285
+ `op item get "${itemName}" --fields address --reveal`,
286
+ { encoding: "utf8", stdio: "pipe" }
287
+ );
288
+ return output.trim();
289
+ } catch {
290
+ return null;
291
+ }
292
+ }
293
+
176
294
  // src/index.ts
177
295
  var __dirname = path.dirname(fileURLToPath(import.meta.url));
178
296
  var TEMPLATE_DIR = path.resolve(__dirname, "..", "templates", "worker");
@@ -262,10 +380,10 @@ async function createStrategy(name, options) {
262
380
  if (options.install) {
263
381
  console.log(` ${pc.green("\u2713")} Installing dependencies...`);
264
382
  try {
265
- execSync("pnpm install", { cwd: targetDir, stdio: "pipe" });
383
+ execSync2("pnpm install", { cwd: targetDir, stdio: "pipe" });
266
384
  } catch {
267
385
  try {
268
- execSync("npm install", { cwd: targetDir, stdio: "pipe" });
386
+ execSync2("npm install", { cwd: targetDir, stdio: "pipe" });
269
387
  } catch {
270
388
  console.log(
271
389
  pc.yellow(" Could not install dependencies automatically.")
@@ -279,8 +397,8 @@ async function createStrategy(name, options) {
279
397
  if (options.git) {
280
398
  console.log(` ${pc.green("\u2713")} Initializing git repository...`);
281
399
  try {
282
- execSync("git init", { cwd: targetDir, stdio: "pipe" });
283
- execSync("git add -A", { cwd: targetDir, stdio: "pipe" });
400
+ execSync2("git init", { cwd: targetDir, stdio: "pipe" });
401
+ execSync2("git add -A", { cwd: targetDir, stdio: "pipe" });
284
402
  } catch {
285
403
  console.log(pc.yellow(" Could not initialize git repository."));
286
404
  }
@@ -296,10 +414,18 @@ async function createStrategy(name, options) {
296
414
  console.log(pc.cyan(" wrangler deploy"));
297
415
  console.log();
298
416
  }
299
- async function walletCreate() {
417
+ async function walletCreate(options) {
300
418
  console.log();
301
419
  console.log(pc.cyan("Creating new Polymarket wallet..."));
302
420
  console.log();
421
+ if (options.store1password) {
422
+ const opStatus = check1PasswordCli();
423
+ if (!opStatus.available || !opStatus.authenticated) {
424
+ console.error(pc.red(`Error: ${opStatus.error}`));
425
+ process.exit(1);
426
+ }
427
+ console.log(` ${pc.green("\u2713")} 1Password CLI authenticated`);
428
+ }
303
429
  console.log(` ${pc.yellow("\u2192")} Generating Ethereum wallet...`);
304
430
  const wallet = generateWallet();
305
431
  console.log(` ${pc.green("\u2713")} Address: ${pc.bold(wallet.address)}`);
@@ -307,16 +433,38 @@ async function walletCreate() {
307
433
  try {
308
434
  const apiCreds = await deriveApiCredentials(wallet.privateKey);
309
435
  console.log(` ${pc.green("\u2713")} API credentials derived`);
436
+ const fullCreds = { ...wallet, ...apiCreds };
437
+ if (options.store1password && options.name) {
438
+ console.log(` ${pc.yellow("\u2192")} Storing in 1Password...`);
439
+ const result = await storeIn1Password(
440
+ options.name,
441
+ fullCreds,
442
+ options.vault || "Private"
443
+ );
444
+ if (result.success) {
445
+ console.log(` ${pc.green("\u2713")} Stored as "${result.itemName}"`);
446
+ } else {
447
+ console.error(pc.red(` \u2717 Failed to store: ${result.error}`));
448
+ }
449
+ }
310
450
  console.log();
311
451
  console.log(pc.cyan("\u2550".repeat(60)));
312
- console.log(pc.bold("SAVE THESE CREDENTIALS SECURELY"));
452
+ if (options.store1password && options.name) {
453
+ console.log(pc.bold("WALLET CREATED & STORED IN 1PASSWORD"));
454
+ } else {
455
+ console.log(pc.bold("SAVE THESE CREDENTIALS SECURELY"));
456
+ }
313
457
  console.log(pc.cyan("\u2550".repeat(60)));
314
458
  console.log();
315
459
  console.log(`${pc.bold("Address:")} ${wallet.address}`);
316
- console.log(`${pc.bold("Private Key:")} ${wallet.privateKey}`);
317
- console.log(`${pc.bold("API Key:")} ${apiCreds.apiKey}`);
318
- console.log(`${pc.bold("API Secret:")} ${apiCreds.apiSecret}`);
319
- console.log(`${pc.bold("API Passphrase:")} ${apiCreds.apiPassphrase}`);
460
+ if (!options.store1password) {
461
+ console.log(`${pc.bold("Private Key:")} ${wallet.privateKey}`);
462
+ console.log(`${pc.bold("API Key:")} ${apiCreds.apiKey}`);
463
+ console.log(`${pc.bold("API Secret:")} ${apiCreds.apiSecret}`);
464
+ console.log(`${pc.bold("API Passphrase:")} ${apiCreds.apiPassphrase}`);
465
+ } else {
466
+ console.log(pc.dim(" (credentials stored securely in 1Password)"));
467
+ }
320
468
  console.log();
321
469
  console.log(pc.cyan("\u2550".repeat(60)));
322
470
  console.log();
@@ -329,13 +477,24 @@ async function walletCreate() {
329
477
  console.log(` - Send ~1 POL for gas fees`);
330
478
  console.log();
331
479
  console.log(` 2. ${pc.yellow("Run on-chain setup:")}`);
332
- console.log(
333
- ` npx create-polymarket-strategy wallet setup --private-key ${wallet.privateKey}`
334
- );
480
+ if (options.store1password && options.name) {
481
+ console.log(
482
+ ` npx create-polymarket-strategy wallet setup --from-1password ${options.name}`
483
+ );
484
+ } else {
485
+ console.log(
486
+ ` npx create-polymarket-strategy wallet setup --private-key <key>`
487
+ );
488
+ }
335
489
  console.log();
336
490
  console.log(` 3. ${pc.yellow("Add secrets to your worker:")}`);
337
- console.log(` wrangler secret put EXECUTOR_API_KEY`);
491
+ console.log(` wrangler secret put WALLET_PRIVATE_KEY`);
338
492
  console.log();
493
+ if (options.store1password && options.name) {
494
+ console.log(pc.dim(`To retrieve later:`));
495
+ console.log(pc.dim(` npx create-polymarket-strategy wallet get ${options.name}`));
496
+ console.log();
497
+ }
339
498
  } catch (error) {
340
499
  console.log(` ${pc.red("\u2717")} Failed to derive API credentials`);
341
500
  console.log(
@@ -402,7 +561,80 @@ async function walletBalance(address) {
402
561
  process.exit(1);
403
562
  }
404
563
  }
405
- async function walletSetup(privateKey) {
564
+ async function walletGet(name) {
565
+ console.log();
566
+ console.log(pc.cyan(`Retrieving wallet "${name}" from 1Password...`));
567
+ console.log();
568
+ const opStatus = check1PasswordCli();
569
+ if (!opStatus.available || !opStatus.authenticated) {
570
+ console.error(pc.red(`Error: ${opStatus.error}`));
571
+ process.exit(1);
572
+ }
573
+ const result = await getFrom1Password(name);
574
+ if (result.error) {
575
+ console.error(pc.red(`Error: ${result.error}`));
576
+ process.exit(1);
577
+ }
578
+ const creds = result.credentials;
579
+ console.log(pc.cyan("\u2550".repeat(60)));
580
+ console.log(pc.bold(`${WALLET_ITEM_PREFIX} - ${name}`));
581
+ console.log(pc.cyan("\u2550".repeat(60)));
582
+ console.log();
583
+ console.log(`${pc.bold("Address:")} ${creds.address}`);
584
+ console.log(`${pc.bold("Private Key:")} ${creds.privateKey}`);
585
+ if (creds.apiKey) {
586
+ console.log(`${pc.bold("API Key:")} ${creds.apiKey}`);
587
+ console.log(`${pc.bold("API Secret:")} ${creds.apiSecret}`);
588
+ console.log(`${pc.bold("API Passphrase:")} ${creds.apiPassphrase}`);
589
+ }
590
+ console.log();
591
+ }
592
+ async function walletList() {
593
+ console.log();
594
+ console.log(pc.cyan("Listing Polymarket wallets in 1Password..."));
595
+ console.log();
596
+ const opStatus = check1PasswordCli();
597
+ if (!opStatus.available || !opStatus.authenticated) {
598
+ console.error(pc.red(`Error: ${opStatus.error}`));
599
+ process.exit(1);
600
+ }
601
+ const wallets = listWallets();
602
+ if (wallets.length === 0) {
603
+ console.log(pc.yellow("No Polymarket wallets found in 1Password."));
604
+ console.log();
605
+ console.log(pc.dim("Create one with:"));
606
+ console.log(pc.dim(" npx create-polymarket-strategy wallet create --name my-trader --store-1password"));
607
+ console.log();
608
+ return;
609
+ }
610
+ console.log(pc.bold(`Found ${wallets.length} wallet(s):`));
611
+ console.log();
612
+ for (const name of wallets) {
613
+ const address = getWalletAddress(name);
614
+ console.log(` ${pc.cyan(name)}`);
615
+ console.log(` ${pc.dim(address || "address unavailable")}`);
616
+ }
617
+ console.log();
618
+ }
619
+ async function walletSetup(options) {
620
+ let privateKey = options.privateKey;
621
+ if (options.from1password) {
622
+ const opStatus = check1PasswordCli();
623
+ if (!opStatus.available || !opStatus.authenticated) {
624
+ console.error(pc.red(`Error: ${opStatus.error}`));
625
+ process.exit(1);
626
+ }
627
+ const result = await getFrom1Password(options.from1password);
628
+ if (result.error) {
629
+ console.error(pc.red(`Error: ${result.error}`));
630
+ process.exit(1);
631
+ }
632
+ privateKey = result.credentials.privateKey;
633
+ }
634
+ if (!privateKey) {
635
+ console.error(pc.red("Error: Either --private-key or --from-1password is required"));
636
+ process.exit(1);
637
+ }
406
638
  console.log();
407
639
  console.log(pc.cyan("Setting up wallet for Polymarket trading..."));
408
640
  console.log();
@@ -473,8 +705,10 @@ program.argument("[name]", "Project name").option("--no-git", "Skip git initiali
473
705
  }
474
706
  });
475
707
  var walletCmd = program.command("wallet").description("Wallet management commands");
476
- walletCmd.command("create").description("Create a new wallet and derive API credentials").action(walletCreate);
708
+ walletCmd.command("create").description("Create a new wallet and derive API credentials").option("--name <name>", "Trader/strategy name (required for 1Password storage)").option("--store-1password", "Store credentials in 1Password").option("--vault <vault>", "1Password vault name", "Private").action((options) => walletCreate(options));
477
709
  walletCmd.command("balance").description("Check wallet balances").argument("<address>", "Wallet address").action(walletBalance);
478
- walletCmd.command("setup").description("Approve exchange contracts for trading").requiredOption("--private-key <key>", "Wallet private key").action((options) => walletSetup(options.privateKey));
710
+ walletCmd.command("setup").description("Approve exchange contracts for trading").option("--private-key <key>", "Wallet private key").option("--from-1password <name>", "Get private key from 1Password wallet").action((options) => walletSetup(options));
711
+ walletCmd.command("get").description("Retrieve wallet credentials from 1Password").argument("<name>", "Trader/strategy name").action(walletGet);
712
+ walletCmd.command("list").description("List all Polymarket wallets in 1Password").action(walletList);
479
713
  program.parse();
480
714
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/wallet/index.ts","../src/wallet/constants.ts"],"sourcesContent":["import { program } from \"commander\";\nimport fs from \"fs-extra\";\nimport path from \"path\";\nimport { execSync } from \"child_process\";\nimport pc from \"picocolors\";\nimport { fileURLToPath } from \"url\";\nimport {\n generateWallet,\n deriveApiCredentials,\n getBalances,\n approveExchangeContracts,\n checkApprovals,\n} from \"./wallet/index.js\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\n// Template directory is at the package root, not in dist\nconst TEMPLATE_DIR = path.resolve(__dirname, \"..\", \"templates\", \"worker\");\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\nfunction toKebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/[\\s_]+/g, \"-\")\n .toLowerCase();\n}\n\nfunction toPascalCase(str: string): string {\n return str\n .split(/[-_\\s]+/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\"\");\n}\n\nfunction toCamelCase(str: string): string {\n const pascal = toPascalCase(str);\n return pascal.charAt(0).toLowerCase() + pascal.slice(1);\n}\n\nasync function replaceInFile(\n filePath: string,\n replacements: Record<string, string>\n): Promise<void> {\n let content = await fs.readFile(filePath, \"utf-8\");\n for (const [key, value] of Object.entries(replacements)) {\n content = content.replace(\n new RegExp(key.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"), \"g\"),\n value\n );\n }\n await fs.writeFile(filePath, content);\n}\n\nasync function replaceInFiles(\n dir: string,\n replacements: Record<string, string>\n): Promise<void> {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n\n if (entry.isDirectory()) {\n await replaceInFiles(fullPath, replacements);\n } else if (entry.isFile()) {\n const ext = path.extname(entry.name);\n if ([\".ts\", \".js\", \".json\", \".jsonc\", \".md\", \".txt\", \"\"].includes(ext)) {\n await replaceInFile(fullPath, replacements);\n }\n }\n }\n}\n\nasync function renameFiles(\n dir: string,\n replacements: Record<string, string>\n): Promise<void> {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n\n if (entry.isDirectory()) {\n await renameFiles(fullPath, replacements);\n }\n\n let newName = entry.name;\n for (const [key, value] of Object.entries(replacements)) {\n if (newName.includes(key)) {\n newName = newName.replace(key, value);\n }\n }\n\n if (newName !== entry.name) {\n const newPath = path.join(dir, newName);\n await fs.rename(fullPath, newPath);\n }\n }\n}\n\n// =============================================================================\n// Create Command\n// =============================================================================\n\ninterface CreateOptions {\n git: boolean;\n install: boolean;\n}\n\nasync function createStrategy(\n name: string,\n options: CreateOptions\n): Promise<void> {\n const targetDir = path.resolve(process.cwd(), name);\n const strategyName = toKebabCase(name);\n const strategyClassName = toPascalCase(name);\n const strategyVarName = toCamelCase(name);\n\n if (await fs.pathExists(targetDir)) {\n console.error(pc.red(`Error: Directory \"${name}\" already exists.`));\n process.exit(1);\n }\n\n if (!(await fs.pathExists(TEMPLATE_DIR))) {\n console.error(pc.red(`Error: Template not found at ${TEMPLATE_DIR}`));\n console.error(pc.yellow(\"This may be a development installation issue.\"));\n process.exit(1);\n }\n\n console.log();\n console.log(pc.cyan(`Creating Polymarket strategy: ${pc.bold(name)}`));\n console.log();\n\n console.log(` ${pc.green(\"✓\")} Copying template...`);\n await fs.copy(TEMPLATE_DIR, targetDir);\n\n console.log(` ${pc.green(\"✓\")} Configuring project...`);\n const replacements = {\n \"{{name}}\": name,\n \"{{strategy-name}}\": strategyName,\n \"{{StrategyName}}\": strategyClassName,\n \"{{strategyName}}\": strategyVarName,\n };\n await replaceInFiles(targetDir, replacements);\n await renameFiles(targetDir, {\n \"{{strategy-name}}\": strategyName,\n });\n\n if (options.install) {\n console.log(` ${pc.green(\"✓\")} Installing dependencies...`);\n try {\n execSync(\"pnpm install\", { cwd: targetDir, stdio: \"pipe\" });\n } catch {\n try {\n execSync(\"npm install\", { cwd: targetDir, stdio: \"pipe\" });\n } catch {\n console.log(\n pc.yellow(\" Could not install dependencies automatically.\")\n );\n console.log(\n pc.yellow(\" Run 'npm install' or 'pnpm install' manually.\")\n );\n }\n }\n }\n\n if (options.git) {\n console.log(` ${pc.green(\"✓\")} Initializing git repository...`);\n try {\n execSync(\"git init\", { cwd: targetDir, stdio: \"pipe\" });\n execSync(\"git add -A\", { cwd: targetDir, stdio: \"pipe\" });\n } catch {\n console.log(pc.yellow(\" Could not initialize git repository.\"));\n }\n }\n\n console.log();\n console.log(pc.green(\"Done! \") + pc.bold(`Created ${name}`));\n console.log();\n console.log(\"Next steps:\");\n console.log();\n console.log(pc.cyan(` cd ${name}`));\n console.log(pc.cyan(` # Edit src/strategies/${strategyName}.ts`));\n console.log(pc.cyan(\" # Configure wrangler.jsonc\"));\n console.log(pc.cyan(\" wrangler deploy\"));\n console.log();\n}\n\n// =============================================================================\n// Wallet Commands\n// =============================================================================\n\nasync function walletCreate(): Promise<void> {\n console.log();\n console.log(pc.cyan(\"Creating new Polymarket wallet...\"));\n console.log();\n\n // Generate wallet\n console.log(` ${pc.yellow(\"→\")} Generating Ethereum wallet...`);\n const wallet = generateWallet();\n console.log(` ${pc.green(\"✓\")} Address: ${pc.bold(wallet.address)}`);\n\n // Derive API credentials\n console.log(` ${pc.yellow(\"→\")} Deriving Polymarket API credentials...`);\n try {\n const apiCreds = await deriveApiCredentials(wallet.privateKey);\n console.log(` ${pc.green(\"✓\")} API credentials derived`);\n\n // Output credentials\n console.log();\n console.log(pc.cyan(\"═\".repeat(60)));\n console.log(pc.bold(\"SAVE THESE CREDENTIALS SECURELY\"));\n console.log(pc.cyan(\"═\".repeat(60)));\n console.log();\n console.log(`${pc.bold(\"Address:\")} ${wallet.address}`);\n console.log(`${pc.bold(\"Private Key:\")} ${wallet.privateKey}`);\n console.log(`${pc.bold(\"API Key:\")} ${apiCreds.apiKey}`);\n console.log(`${pc.bold(\"API Secret:\")} ${apiCreds.apiSecret}`);\n console.log(`${pc.bold(\"API Passphrase:\")} ${apiCreds.apiPassphrase}`);\n console.log();\n console.log(pc.cyan(\"═\".repeat(60)));\n console.log();\n console.log(pc.bold(\"Next steps:\"));\n console.log();\n console.log(\n ` 1. ${pc.yellow(\"Fund this wallet on Polygon network:\")}`\n );\n console.log(` - Send USDC to: ${wallet.address}`);\n console.log(` - Send ~1 POL for gas fees`);\n console.log();\n console.log(` 2. ${pc.yellow(\"Run on-chain setup:\")}`);\n console.log(\n ` npx create-polymarket-strategy wallet setup --private-key ${wallet.privateKey}`\n );\n console.log();\n console.log(` 3. ${pc.yellow(\"Add secrets to your worker:\")}`);\n console.log(` wrangler secret put EXECUTOR_API_KEY`);\n console.log();\n } catch (error) {\n console.log(` ${pc.red(\"✗\")} Failed to derive API credentials`);\n console.log(\n pc.yellow(\n \" This may be a network issue. You can derive credentials later.\"\n )\n );\n console.log();\n console.log(pc.cyan(\"═\".repeat(60)));\n console.log(pc.bold(\"WALLET CREATED (API credentials pending)\"));\n console.log(pc.cyan(\"═\".repeat(60)));\n console.log();\n console.log(`${pc.bold(\"Address:\")} ${wallet.address}`);\n console.log(`${pc.bold(\"Private Key:\")} ${wallet.privateKey}`);\n console.log();\n console.log(\n pc.yellow(\n \"Fund the wallet and re-run to derive API credentials.\"\n )\n );\n console.log();\n }\n}\n\nasync function walletBalance(address: string): Promise<void> {\n console.log();\n console.log(pc.cyan(`Checking balances for ${address}...`));\n console.log();\n\n try {\n const balances = await getBalances(address);\n\n console.log(pc.cyan(\"═\".repeat(50)));\n console.log(pc.bold(\"Polymarket Wallet Balance\"));\n console.log(pc.cyan(\"═\".repeat(50)));\n console.log();\n console.log(\n ` ${pc.bold(\"POL:\")} ${balances.pol.toFixed(4)} (~$${(balances.pol * 0.4).toFixed(2)})`\n );\n console.log(` ${pc.bold(\"USDC:\")} $${balances.usdcNative.toFixed(2)}`);\n console.log(\n ` ${pc.bold(\"USDC.e:\")} $${balances.usdcE.toFixed(2)} ${pc.dim(\"(Polymarket uses this)\")}`\n );\n console.log();\n console.log(` ${pc.bold(\"Total USDC:\")} $${balances.totalUsdc.toFixed(2)}`);\n console.log();\n console.log(pc.cyan(\"═\".repeat(50)));\n console.log(`View: https://polygonscan.com/address/${address}`);\n console.log();\n\n // Check approvals\n const approvals = await checkApprovals(address);\n if (approvals.allApproved) {\n console.log(pc.green(\"✓ All exchange contracts approved\"));\n } else {\n console.log(pc.yellow(\"⚠ Some contracts not approved:\"));\n for (const detail of approvals.details) {\n const status =\n detail.usdcApproved && detail.ctfApproved\n ? pc.green(\"✓\")\n : pc.red(\"✗\");\n console.log(` ${status} ${detail.contract}`);\n }\n console.log();\n console.log(\n pc.dim(\"Run 'npx create-polymarket-strategy wallet setup' to approve\")\n );\n }\n console.log();\n } catch (error) {\n console.error(pc.red(`Error: ${error}`));\n process.exit(1);\n }\n}\n\nasync function walletSetup(privateKey: string): Promise<void> {\n console.log();\n console.log(pc.cyan(\"Setting up wallet for Polymarket trading...\"));\n console.log();\n\n try {\n // Get wallet address from private key\n const { ethers } = await import(\"ethers\");\n const wallet = new ethers.Wallet(privateKey);\n const address = wallet.address;\n\n console.log(` ${pc.bold(\"Address:\")} ${address}`);\n console.log();\n\n // Check balances first\n console.log(pc.yellow(\"Checking balances...\"));\n const balances = await getBalances(address);\n\n console.log(` POL: ${balances.pol.toFixed(4)}`);\n console.log(` USDC: $${balances.usdcNative.toFixed(2)}`);\n console.log(` USDC.e: $${balances.usdcE.toFixed(2)}`);\n console.log();\n\n if (balances.pol < 0.01) {\n console.error(pc.red(\"Error: Need at least 0.01 POL for gas fees\"));\n console.log(`Send POL to: ${address}`);\n process.exit(1);\n }\n\n if (balances.usdcNative > 1 && balances.usdcE < 1) {\n console.log(\n pc.yellow(\n \"Note: You have native USDC but Polymarket requires USDC.e\"\n )\n );\n console.log(\n pc.yellow(\"Use a DEX like Uniswap to swap USDC → USDC.e first\")\n );\n console.log();\n }\n\n // Approve contracts\n console.log(pc.yellow(\"Approving Polymarket exchange contracts...\"));\n console.log(\n pc.dim(\"(3 contracts x 2 approvals each = up to 6 transactions)\")\n );\n console.log();\n\n const results = await approveExchangeContracts(privateKey, (msg) => {\n console.log(` ${pc.yellow(\"→\")} ${msg}`);\n });\n\n console.log();\n\n // Summary\n let txCount = 0;\n for (const result of results) {\n if (result.usdcTxHash) txCount++;\n if (result.ctfTxHash) txCount++;\n }\n\n console.log(pc.cyan(\"═\".repeat(50)));\n console.log(pc.bold(\"Setup Complete\"));\n console.log(pc.cyan(\"═\".repeat(50)));\n console.log();\n console.log(` ${pc.green(\"✓\")} All contracts approved`);\n console.log(` ${pc.dim(`${txCount} transaction(s) submitted`)}`);\n console.log();\n console.log(` USDC.e balance: $${balances.usdcE.toFixed(2)}`);\n console.log();\n console.log(pc.bold(\"Your wallet is ready for live trading!\"));\n console.log();\n } catch (error) {\n console.error(pc.red(`Error: ${error}`));\n process.exit(1);\n }\n}\n\n// =============================================================================\n// CLI Setup\n// =============================================================================\n\nprogram\n .name(\"create-polymarket-strategy\")\n .description(\"Create and manage Polymarket trading strategies\")\n .version(\"0.2.0\");\n\n// Default command: create a new strategy\nprogram\n .argument(\"[name]\", \"Project name\")\n .option(\"--no-git\", \"Skip git initialization\")\n .option(\"--no-install\", \"Skip dependency installation\")\n .action(async (name, options) => {\n if (name) {\n await createStrategy(name, options);\n } else {\n program.help();\n }\n });\n\n// Wallet subcommands\nconst walletCmd = program\n .command(\"wallet\")\n .description(\"Wallet management commands\");\n\nwalletCmd\n .command(\"create\")\n .description(\"Create a new wallet and derive API credentials\")\n .action(walletCreate);\n\nwalletCmd\n .command(\"balance\")\n .description(\"Check wallet balances\")\n .argument(\"<address>\", \"Wallet address\")\n .action(walletBalance);\n\nwalletCmd\n .command(\"setup\")\n .description(\"Approve exchange contracts for trading\")\n .requiredOption(\"--private-key <key>\", \"Wallet private key\")\n .action((options) => walletSetup(options.privateKey));\n\nprogram.parse();\n","import { ethers } from \"ethers\";\nimport {\n CHAIN_ID,\n RPC_URL,\n CLOB_API,\n USDC_NATIVE,\n USDC_E,\n CTF_ADDRESS,\n EXCHANGE_CONTRACTS,\n CLOB_AUTH_DOMAIN,\n CLOB_AUTH_MESSAGE,\n ERC20_ABI,\n ERC1155_ABI,\n} from \"./constants.js\";\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport interface WalletCredentials {\n address: string;\n privateKey: string;\n}\n\nexport interface ApiCredentials {\n apiKey: string;\n apiSecret: string;\n apiPassphrase: string;\n}\n\nexport interface FullCredentials extends WalletCredentials, ApiCredentials {}\n\nexport interface WalletBalances {\n address: string;\n pol: number;\n usdcNative: number;\n usdcE: number;\n totalUsdc: number;\n}\n\n// =============================================================================\n// Wallet Creation\n// =============================================================================\n\n/**\n * Generate a new Ethereum wallet.\n */\nexport function generateWallet(): WalletCredentials {\n const wallet = ethers.Wallet.createRandom();\n return {\n address: wallet.address,\n privateKey: wallet.privateKey,\n };\n}\n\n// =============================================================================\n// API Credential Derivation\n// =============================================================================\n\n/**\n * Sign the CLOB auth message (EIP-712).\n */\nasync function signClobAuthMessage(\n wallet: ethers.Wallet,\n timestamp: number,\n nonce: number\n): Promise<string> {\n const types = {\n ClobAuth: [\n { name: \"address\", type: \"address\" },\n { name: \"timestamp\", type: \"string\" },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"message\", type: \"string\" },\n ],\n };\n\n const value = {\n address: wallet.address,\n timestamp: timestamp.toString(),\n nonce: nonce,\n message: CLOB_AUTH_MESSAGE,\n };\n\n return wallet.signTypedData(CLOB_AUTH_DOMAIN, types, value);\n}\n\n/**\n * Derive API credentials from wallet.\n * First tries to create new credentials, then falls back to deriving existing ones.\n */\nexport async function deriveApiCredentials(\n privateKey: string,\n nonce: number = 0\n): Promise<ApiCredentials> {\n const wallet = new ethers.Wallet(privateKey);\n const timestamp = Math.floor(Date.now() / 1000);\n const signature = await signClobAuthMessage(wallet, timestamp, nonce);\n\n const headers = {\n \"POLY_ADDRESS\": wallet.address,\n \"POLY_SIGNATURE\": signature,\n \"POLY_TIMESTAMP\": timestamp.toString(),\n \"POLY_NONCE\": nonce.toString(),\n };\n\n // Try to derive existing credentials first\n let response = await fetch(`${CLOB_API}/auth/derive-api-key`, {\n method: \"GET\",\n headers,\n });\n\n if (!response.ok) {\n // Try to create new credentials\n response = await fetch(`${CLOB_API}/auth/api-key`, {\n method: \"POST\",\n headers,\n });\n }\n\n if (!response.ok) {\n const text = await response.text();\n throw new Error(`Failed to derive API credentials: ${response.status} ${text}`);\n }\n\n const data = await response.json();\n\n return {\n apiKey: data.apiKey,\n apiSecret: data.secret,\n apiPassphrase: data.passphrase,\n };\n}\n\n/**\n * Generate wallet and derive API credentials.\n */\nexport async function createWalletWithCredentials(): Promise<FullCredentials> {\n const wallet = generateWallet();\n const apiCreds = await deriveApiCredentials(wallet.privateKey);\n\n return {\n ...wallet,\n ...apiCreds,\n };\n}\n\n// =============================================================================\n// Balance Checking\n// =============================================================================\n\n/**\n * Get provider for Polygon.\n */\nfunction getProvider(): ethers.JsonRpcProvider {\n return new ethers.JsonRpcProvider(RPC_URL, CHAIN_ID);\n}\n\n/**\n * Check wallet balances (POL, USDC, USDC.e).\n */\nexport async function getBalances(address: string): Promise<WalletBalances> {\n const provider = getProvider();\n\n // POL balance\n const polBalance = await provider.getBalance(address);\n const pol = Number(ethers.formatEther(polBalance));\n\n // USDC Native balance\n const usdcNativeContract = new ethers.Contract(USDC_NATIVE, ERC20_ABI, provider);\n const usdcNativeBalance = await usdcNativeContract.balanceOf(address);\n const usdcNative = Number(ethers.formatUnits(usdcNativeBalance, 6));\n\n // USDC.e balance\n const usdcEContract = new ethers.Contract(USDC_E, ERC20_ABI, provider);\n const usdcEBalance = await usdcEContract.balanceOf(address);\n const usdcE = Number(ethers.formatUnits(usdcEBalance, 6));\n\n return {\n address,\n pol,\n usdcNative,\n usdcE,\n totalUsdc: usdcNative + usdcE,\n };\n}\n\n// =============================================================================\n// Contract Approvals\n// =============================================================================\n\ninterface ApprovalResult {\n contract: string;\n usdcApproved: boolean;\n usdcTxHash?: string;\n ctfApproved: boolean;\n ctfTxHash?: string;\n}\n\n/**\n * Approve Polymarket exchange contracts for trading.\n */\nexport async function approveExchangeContracts(\n privateKey: string,\n onProgress?: (message: string) => void\n): Promise<ApprovalResult[]> {\n const provider = getProvider();\n const wallet = new ethers.Wallet(privateKey, provider);\n const results: ApprovalResult[] = [];\n\n const usdcE = new ethers.Contract(USDC_E, ERC20_ABI, wallet);\n const ctf = new ethers.Contract(CTF_ADDRESS, ERC1155_ABI, wallet);\n\n const maxApproval = ethers.MaxUint256;\n\n for (const exchange of EXCHANGE_CONTRACTS) {\n const result: ApprovalResult = {\n contract: exchange.name,\n usdcApproved: false,\n ctfApproved: false,\n };\n\n // Check and approve USDC.e\n const currentAllowance = await usdcE.allowance(wallet.address, exchange.address);\n if (currentAllowance < ethers.parseUnits(\"1000000000\", 6)) {\n onProgress?.(`Approving USDC.e for ${exchange.name}...`);\n const tx = await usdcE.approve(exchange.address, maxApproval);\n const receipt = await tx.wait();\n result.usdcTxHash = receipt.hash;\n result.usdcApproved = true;\n } else {\n onProgress?.(`USDC.e already approved for ${exchange.name}`);\n result.usdcApproved = true;\n }\n\n // Check and approve CTF\n const isApproved = await ctf.isApprovedForAll(wallet.address, exchange.address);\n if (!isApproved) {\n onProgress?.(`Approving CTF for ${exchange.name}...`);\n const tx = await ctf.setApprovalForAll(exchange.address, true);\n const receipt = await tx.wait();\n result.ctfTxHash = receipt.hash;\n result.ctfApproved = true;\n } else {\n onProgress?.(`CTF already approved for ${exchange.name}`);\n result.ctfApproved = true;\n }\n\n results.push(result);\n }\n\n return results;\n}\n\n/**\n * Check if wallet has sufficient approvals for trading.\n */\nexport async function checkApprovals(address: string): Promise<{\n allApproved: boolean;\n details: { contract: string; usdcApproved: boolean; ctfApproved: boolean }[];\n}> {\n const provider = getProvider();\n const usdcE = new ethers.Contract(USDC_E, ERC20_ABI, provider);\n const ctf = new ethers.Contract(CTF_ADDRESS, ERC1155_ABI, provider);\n\n const details = [];\n\n for (const exchange of EXCHANGE_CONTRACTS) {\n const allowance = await usdcE.allowance(address, exchange.address);\n const isCtfApproved = await ctf.isApprovedForAll(address, exchange.address);\n\n details.push({\n contract: exchange.name,\n usdcApproved: allowance > 0n,\n ctfApproved: isCtfApproved,\n });\n }\n\n const allApproved = details.every((d) => d.usdcApproved && d.ctfApproved);\n\n return { allApproved, details };\n}\n","// Polygon Mainnet\nexport const CHAIN_ID = 137;\nexport const RPC_URL = \"https://1rpc.io/matic\";\n\n// Polymarket CLOB API\nexport const CLOB_API = \"https://clob.polymarket.com\";\n\n// Token addresses on Polygon\nexport const USDC_NATIVE = \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\";\nexport const USDC_E = \"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\"; // Polymarket uses this\nexport const CTF_ADDRESS = \"0x4D97DCd97eC945f40cF65F87097ACe5EA0476045\";\n\n// Polymarket exchange contracts that need approval\nexport const EXCHANGE_CONTRACTS = [\n { address: \"0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E\", name: \"CTF Exchange\" },\n { address: \"0xC5d563A36AE78145C45a50134d48A1215220f80a\", name: \"Neg Risk CTF Exchange\" },\n { address: \"0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296\", name: \"Neg Risk Adapter\" },\n];\n\n// Uniswap V3 Router on Polygon (for USDC → USDC.e swap)\nexport const UNISWAP_ROUTER = \"0xE592427A0AEce92De3Edee1F18E0157C05861564\";\n\n// EIP-712 domain for CLOB auth\nexport const CLOB_AUTH_DOMAIN = {\n name: \"ClobAuthDomain\",\n version: \"1\",\n chainId: CHAIN_ID,\n};\n\n// Message to sign for CLOB auth\nexport const CLOB_AUTH_MESSAGE = \"This message attests that I control the given wallet\";\n\n// ABIs\nexport const ERC20_ABI = [\n \"function balanceOf(address owner) view returns (uint256)\",\n \"function approve(address spender, uint256 amount) returns (bool)\",\n \"function allowance(address owner, address spender) view returns (uint256)\",\n];\n\nexport const ERC1155_ABI = [\n \"function setApprovalForAll(address operator, bool approved)\",\n \"function isApprovedForAll(address account, address operator) view returns (bool)\",\n];\n\nexport const UNISWAP_ROUTER_ABI = [\n \"function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 deadline, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountOut)\",\n];\n"],"mappings":";;;AAAA,SAAS,eAAe;AACxB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,gBAAgB;AACzB,OAAO,QAAQ;AACf,SAAS,qBAAqB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AAK,GAAG,MAAM,QAAG,CAAC,yBAAyB;AACvD,YAAQ,IAAI,KAAK,GAAG,IAAI,GAAG,OAAO,2BAA2B,CAAC,EAAE;AAChE,YAAQ,IAAI;AACZ,YAAQ,IAAI,sBAAsB,SAAS,MAAM,QAAQ,CAAC,CAAC,EAAE;AAC7D,YAAQ,IAAI;AACZ,YAAQ,IAAI,GAAG,KAAK,wCAAwC,CAAC;AAC7D,YAAQ,IAAI;AAAA,EACd,SAAS,OAAO;AACd,YAAQ,MAAM,GAAG,IAAI,UAAU,KAAK,EAAE,CAAC;AACvC,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAMA,QACG,KAAK,4BAA4B,EACjC,YAAY,iDAAiD,EAC7D,QAAQ,OAAO;AAGlB,QACG,SAAS,UAAU,cAAc,EACjC,OAAO,YAAY,yBAAyB,EAC5C,OAAO,gBAAgB,8BAA8B,EACrD,OAAO,OAAO,MAAM,YAAY;AAC/B,MAAI,MAAM;AACR,UAAM,eAAe,MAAM,OAAO;AAAA,EACpC,OAAO;AACL,YAAQ,KAAK;AAAA,EACf;AACF,CAAC;AAGH,IAAM,YAAY,QACf,QAAQ,QAAQ,EAChB,YAAY,4BAA4B;AAE3C,UACG,QAAQ,QAAQ,EAChB,YAAY,gDAAgD,EAC5D,OAAO,YAAY;AAEtB,UACG,QAAQ,SAAS,EACjB,YAAY,uBAAuB,EACnC,SAAS,aAAa,gBAAgB,EACtC,OAAO,aAAa;AAEvB,UACG,QAAQ,OAAO,EACf,YAAY,wCAAwC,EACpD,eAAe,uBAAuB,oBAAoB,EAC1D,OAAO,CAAC,YAAY,YAAY,QAAQ,UAAU,CAAC;AAEtD,QAAQ,MAAM;","names":["ethers"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/wallet/index.ts","../src/wallet/constants.ts","../src/wallet/onepassword.ts"],"sourcesContent":["import { program } from \"commander\";\nimport fs from \"fs-extra\";\nimport path from \"path\";\nimport { execSync } from \"child_process\";\nimport pc from \"picocolors\";\nimport { fileURLToPath } from \"url\";\nimport {\n generateWallet,\n deriveApiCredentials,\n getBalances,\n approveExchangeContracts,\n checkApprovals,\n} from \"./wallet/index.js\";\nimport {\n check1PasswordCli,\n storeIn1Password,\n getFrom1Password,\n listWallets,\n getWalletAddress,\n WALLET_ITEM_PREFIX,\n} from \"./wallet/onepassword.js\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\n// Template directory is at the package root, not in dist\nconst TEMPLATE_DIR = path.resolve(__dirname, \"..\", \"templates\", \"worker\");\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\nfunction toKebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/[\\s_]+/g, \"-\")\n .toLowerCase();\n}\n\nfunction toPascalCase(str: string): string {\n return str\n .split(/[-_\\s]+/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\"\");\n}\n\nfunction toCamelCase(str: string): string {\n const pascal = toPascalCase(str);\n return pascal.charAt(0).toLowerCase() + pascal.slice(1);\n}\n\nasync function replaceInFile(\n filePath: string,\n replacements: Record<string, string>\n): Promise<void> {\n let content = await fs.readFile(filePath, \"utf-8\");\n for (const [key, value] of Object.entries(replacements)) {\n content = content.replace(\n new RegExp(key.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"), \"g\"),\n value\n );\n }\n await fs.writeFile(filePath, content);\n}\n\nasync function replaceInFiles(\n dir: string,\n replacements: Record<string, string>\n): Promise<void> {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n\n if (entry.isDirectory()) {\n await replaceInFiles(fullPath, replacements);\n } else if (entry.isFile()) {\n const ext = path.extname(entry.name);\n if ([\".ts\", \".js\", \".json\", \".jsonc\", \".md\", \".txt\", \"\"].includes(ext)) {\n await replaceInFile(fullPath, replacements);\n }\n }\n }\n}\n\nasync function renameFiles(\n dir: string,\n replacements: Record<string, string>\n): Promise<void> {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n\n if (entry.isDirectory()) {\n await renameFiles(fullPath, replacements);\n }\n\n let newName = entry.name;\n for (const [key, value] of Object.entries(replacements)) {\n if (newName.includes(key)) {\n newName = newName.replace(key, value);\n }\n }\n\n if (newName !== entry.name) {\n const newPath = path.join(dir, newName);\n await fs.rename(fullPath, newPath);\n }\n }\n}\n\n// =============================================================================\n// Create Command\n// =============================================================================\n\ninterface CreateOptions {\n git: boolean;\n install: boolean;\n}\n\nasync function createStrategy(\n name: string,\n options: CreateOptions\n): Promise<void> {\n const targetDir = path.resolve(process.cwd(), name);\n const strategyName = toKebabCase(name);\n const strategyClassName = toPascalCase(name);\n const strategyVarName = toCamelCase(name);\n\n if (await fs.pathExists(targetDir)) {\n console.error(pc.red(`Error: Directory \"${name}\" already exists.`));\n process.exit(1);\n }\n\n if (!(await fs.pathExists(TEMPLATE_DIR))) {\n console.error(pc.red(`Error: Template not found at ${TEMPLATE_DIR}`));\n console.error(pc.yellow(\"This may be a development installation issue.\"));\n process.exit(1);\n }\n\n console.log();\n console.log(pc.cyan(`Creating Polymarket strategy: ${pc.bold(name)}`));\n console.log();\n\n console.log(` ${pc.green(\"✓\")} Copying template...`);\n await fs.copy(TEMPLATE_DIR, targetDir);\n\n console.log(` ${pc.green(\"✓\")} Configuring project...`);\n const replacements = {\n \"{{name}}\": name,\n \"{{strategy-name}}\": strategyName,\n \"{{StrategyName}}\": strategyClassName,\n \"{{strategyName}}\": strategyVarName,\n };\n await replaceInFiles(targetDir, replacements);\n await renameFiles(targetDir, {\n \"{{strategy-name}}\": strategyName,\n });\n\n if (options.install) {\n console.log(` ${pc.green(\"✓\")} Installing dependencies...`);\n try {\n execSync(\"pnpm install\", { cwd: targetDir, stdio: \"pipe\" });\n } catch {\n try {\n execSync(\"npm install\", { cwd: targetDir, stdio: \"pipe\" });\n } catch {\n console.log(\n pc.yellow(\" Could not install dependencies automatically.\")\n );\n console.log(\n pc.yellow(\" Run 'npm install' or 'pnpm install' manually.\")\n );\n }\n }\n }\n\n if (options.git) {\n console.log(` ${pc.green(\"✓\")} Initializing git repository...`);\n try {\n execSync(\"git init\", { cwd: targetDir, stdio: \"pipe\" });\n execSync(\"git add -A\", { cwd: targetDir, stdio: \"pipe\" });\n } catch {\n console.log(pc.yellow(\" Could not initialize git repository.\"));\n }\n }\n\n console.log();\n console.log(pc.green(\"Done! \") + pc.bold(`Created ${name}`));\n console.log();\n console.log(\"Next steps:\");\n console.log();\n console.log(pc.cyan(` cd ${name}`));\n console.log(pc.cyan(` # Edit src/strategies/${strategyName}.ts`));\n console.log(pc.cyan(\" # Configure wrangler.jsonc\"));\n console.log(pc.cyan(\" wrangler deploy\"));\n console.log();\n}\n\n// =============================================================================\n// Wallet Commands\n// =============================================================================\n\ninterface WalletCreateOptions {\n name?: string;\n store1password?: boolean;\n vault?: string;\n}\n\nasync function walletCreate(options: WalletCreateOptions): Promise<void> {\n console.log();\n console.log(pc.cyan(\"Creating new Polymarket wallet...\"));\n console.log();\n\n // Check 1Password if storing\n if (options.store1password) {\n const opStatus = check1PasswordCli();\n if (!opStatus.available || !opStatus.authenticated) {\n console.error(pc.red(`Error: ${opStatus.error}`));\n process.exit(1);\n }\n console.log(` ${pc.green(\"✓\")} 1Password CLI authenticated`);\n }\n\n // Generate wallet\n console.log(` ${pc.yellow(\"→\")} Generating Ethereum wallet...`);\n const wallet = generateWallet();\n console.log(` ${pc.green(\"✓\")} Address: ${pc.bold(wallet.address)}`);\n\n // Derive API credentials\n console.log(` ${pc.yellow(\"→\")} Deriving Polymarket API credentials...`);\n try {\n const apiCreds = await deriveApiCredentials(wallet.privateKey);\n console.log(` ${pc.green(\"✓\")} API credentials derived`);\n\n const fullCreds = { ...wallet, ...apiCreds };\n\n // Store in 1Password if requested\n if (options.store1password && options.name) {\n console.log(` ${pc.yellow(\"→\")} Storing in 1Password...`);\n const result = await storeIn1Password(\n options.name,\n fullCreds,\n options.vault || \"Private\"\n );\n if (result.success) {\n console.log(` ${pc.green(\"✓\")} Stored as \"${result.itemName}\"`);\n } else {\n console.error(pc.red(` ✗ Failed to store: ${result.error}`));\n // Fall through to print credentials\n }\n }\n\n // Output credentials\n console.log();\n console.log(pc.cyan(\"═\".repeat(60)));\n if (options.store1password && options.name) {\n console.log(pc.bold(\"WALLET CREATED & STORED IN 1PASSWORD\"));\n } else {\n console.log(pc.bold(\"SAVE THESE CREDENTIALS SECURELY\"));\n }\n console.log(pc.cyan(\"═\".repeat(60)));\n console.log();\n console.log(`${pc.bold(\"Address:\")} ${wallet.address}`);\n if (!options.store1password) {\n console.log(`${pc.bold(\"Private Key:\")} ${wallet.privateKey}`);\n console.log(`${pc.bold(\"API Key:\")} ${apiCreds.apiKey}`);\n console.log(`${pc.bold(\"API Secret:\")} ${apiCreds.apiSecret}`);\n console.log(`${pc.bold(\"API Passphrase:\")} ${apiCreds.apiPassphrase}`);\n } else {\n console.log(pc.dim(\" (credentials stored securely in 1Password)\"));\n }\n console.log();\n console.log(pc.cyan(\"═\".repeat(60)));\n console.log();\n console.log(pc.bold(\"Next steps:\"));\n console.log();\n console.log(\n ` 1. ${pc.yellow(\"Fund this wallet on Polygon network:\")}`\n );\n console.log(` - Send USDC to: ${wallet.address}`);\n console.log(` - Send ~1 POL for gas fees`);\n console.log();\n console.log(` 2. ${pc.yellow(\"Run on-chain setup:\")}`);\n if (options.store1password && options.name) {\n console.log(\n ` npx create-polymarket-strategy wallet setup --from-1password ${options.name}`\n );\n } else {\n console.log(\n ` npx create-polymarket-strategy wallet setup --private-key <key>`\n );\n }\n console.log();\n console.log(` 3. ${pc.yellow(\"Add secrets to your worker:\")}`);\n console.log(` wrangler secret put WALLET_PRIVATE_KEY`);\n console.log();\n if (options.store1password && options.name) {\n console.log(pc.dim(`To retrieve later:`));\n console.log(pc.dim(` npx create-polymarket-strategy wallet get ${options.name}`));\n console.log();\n }\n } catch (error) {\n console.log(` ${pc.red(\"✗\")} Failed to derive API credentials`);\n console.log(\n pc.yellow(\n \" This may be a network issue. You can derive credentials later.\"\n )\n );\n console.log();\n console.log(pc.cyan(\"═\".repeat(60)));\n console.log(pc.bold(\"WALLET CREATED (API credentials pending)\"));\n console.log(pc.cyan(\"═\".repeat(60)));\n console.log();\n console.log(`${pc.bold(\"Address:\")} ${wallet.address}`);\n console.log(`${pc.bold(\"Private Key:\")} ${wallet.privateKey}`);\n console.log();\n console.log(\n pc.yellow(\n \"Fund the wallet and re-run to derive API credentials.\"\n )\n );\n console.log();\n }\n}\n\nasync function walletBalance(address: string): Promise<void> {\n console.log();\n console.log(pc.cyan(`Checking balances for ${address}...`));\n console.log();\n\n try {\n const balances = await getBalances(address);\n\n console.log(pc.cyan(\"═\".repeat(50)));\n console.log(pc.bold(\"Polymarket Wallet Balance\"));\n console.log(pc.cyan(\"═\".repeat(50)));\n console.log();\n console.log(\n ` ${pc.bold(\"POL:\")} ${balances.pol.toFixed(4)} (~$${(balances.pol * 0.4).toFixed(2)})`\n );\n console.log(` ${pc.bold(\"USDC:\")} $${balances.usdcNative.toFixed(2)}`);\n console.log(\n ` ${pc.bold(\"USDC.e:\")} $${balances.usdcE.toFixed(2)} ${pc.dim(\"(Polymarket uses this)\")}`\n );\n console.log();\n console.log(` ${pc.bold(\"Total USDC:\")} $${balances.totalUsdc.toFixed(2)}`);\n console.log();\n console.log(pc.cyan(\"═\".repeat(50)));\n console.log(`View: https://polygonscan.com/address/${address}`);\n console.log();\n\n // Check approvals\n const approvals = await checkApprovals(address);\n if (approvals.allApproved) {\n console.log(pc.green(\"✓ All exchange contracts approved\"));\n } else {\n console.log(pc.yellow(\"⚠ Some contracts not approved:\"));\n for (const detail of approvals.details) {\n const status =\n detail.usdcApproved && detail.ctfApproved\n ? pc.green(\"✓\")\n : pc.red(\"✗\");\n console.log(` ${status} ${detail.contract}`);\n }\n console.log();\n console.log(\n pc.dim(\"Run 'npx create-polymarket-strategy wallet setup' to approve\")\n );\n }\n console.log();\n } catch (error) {\n console.error(pc.red(`Error: ${error}`));\n process.exit(1);\n }\n}\n\nasync function walletGet(name: string): Promise<void> {\n console.log();\n console.log(pc.cyan(`Retrieving wallet \"${name}\" from 1Password...`));\n console.log();\n\n const opStatus = check1PasswordCli();\n if (!opStatus.available || !opStatus.authenticated) {\n console.error(pc.red(`Error: ${opStatus.error}`));\n process.exit(1);\n }\n\n const result = await getFrom1Password(name);\n if (result.error) {\n console.error(pc.red(`Error: ${result.error}`));\n process.exit(1);\n }\n\n const creds = result.credentials!;\n console.log(pc.cyan(\"═\".repeat(60)));\n console.log(pc.bold(`${WALLET_ITEM_PREFIX} - ${name}`));\n console.log(pc.cyan(\"═\".repeat(60)));\n console.log();\n console.log(`${pc.bold(\"Address:\")} ${creds.address}`);\n console.log(`${pc.bold(\"Private Key:\")} ${creds.privateKey}`);\n if (creds.apiKey) {\n console.log(`${pc.bold(\"API Key:\")} ${creds.apiKey}`);\n console.log(`${pc.bold(\"API Secret:\")} ${creds.apiSecret}`);\n console.log(`${pc.bold(\"API Passphrase:\")} ${creds.apiPassphrase}`);\n }\n console.log();\n}\n\nasync function walletList(): Promise<void> {\n console.log();\n console.log(pc.cyan(\"Listing Polymarket wallets in 1Password...\"));\n console.log();\n\n const opStatus = check1PasswordCli();\n if (!opStatus.available || !opStatus.authenticated) {\n console.error(pc.red(`Error: ${opStatus.error}`));\n process.exit(1);\n }\n\n const wallets = listWallets();\n\n if (wallets.length === 0) {\n console.log(pc.yellow(\"No Polymarket wallets found in 1Password.\"));\n console.log();\n console.log(pc.dim(\"Create one with:\"));\n console.log(pc.dim(\" npx create-polymarket-strategy wallet create --name my-trader --store-1password\"));\n console.log();\n return;\n }\n\n console.log(pc.bold(`Found ${wallets.length} wallet(s):`));\n console.log();\n for (const name of wallets) {\n const address = getWalletAddress(name);\n console.log(` ${pc.cyan(name)}`);\n console.log(` ${pc.dim(address || \"address unavailable\")}`);\n }\n console.log();\n}\n\ninterface WalletSetupOptions {\n privateKey?: string;\n from1password?: string;\n}\n\nasync function walletSetup(options: WalletSetupOptions): Promise<void> {\n let privateKey = options.privateKey;\n\n // Get from 1Password if specified\n if (options.from1password) {\n const opStatus = check1PasswordCli();\n if (!opStatus.available || !opStatus.authenticated) {\n console.error(pc.red(`Error: ${opStatus.error}`));\n process.exit(1);\n }\n\n const result = await getFrom1Password(options.from1password);\n if (result.error) {\n console.error(pc.red(`Error: ${result.error}`));\n process.exit(1);\n }\n privateKey = result.credentials!.privateKey;\n }\n\n if (!privateKey) {\n console.error(pc.red(\"Error: Either --private-key or --from-1password is required\"));\n process.exit(1);\n }\n console.log();\n console.log(pc.cyan(\"Setting up wallet for Polymarket trading...\"));\n console.log();\n\n try {\n // Get wallet address from private key\n const { ethers } = await import(\"ethers\");\n const wallet = new ethers.Wallet(privateKey);\n const address = wallet.address;\n\n console.log(` ${pc.bold(\"Address:\")} ${address}`);\n console.log();\n\n // Check balances first\n console.log(pc.yellow(\"Checking balances...\"));\n const balances = await getBalances(address);\n\n console.log(` POL: ${balances.pol.toFixed(4)}`);\n console.log(` USDC: $${balances.usdcNative.toFixed(2)}`);\n console.log(` USDC.e: $${balances.usdcE.toFixed(2)}`);\n console.log();\n\n if (balances.pol < 0.01) {\n console.error(pc.red(\"Error: Need at least 0.01 POL for gas fees\"));\n console.log(`Send POL to: ${address}`);\n process.exit(1);\n }\n\n if (balances.usdcNative > 1 && balances.usdcE < 1) {\n console.log(\n pc.yellow(\n \"Note: You have native USDC but Polymarket requires USDC.e\"\n )\n );\n console.log(\n pc.yellow(\"Use a DEX like Uniswap to swap USDC → USDC.e first\")\n );\n console.log();\n }\n\n // Approve contracts\n console.log(pc.yellow(\"Approving Polymarket exchange contracts...\"));\n console.log(\n pc.dim(\"(3 contracts x 2 approvals each = up to 6 transactions)\")\n );\n console.log();\n\n const results = await approveExchangeContracts(privateKey, (msg) => {\n console.log(` ${pc.yellow(\"→\")} ${msg}`);\n });\n\n console.log();\n\n // Summary\n let txCount = 0;\n for (const result of results) {\n if (result.usdcTxHash) txCount++;\n if (result.ctfTxHash) txCount++;\n }\n\n console.log(pc.cyan(\"═\".repeat(50)));\n console.log(pc.bold(\"Setup Complete\"));\n console.log(pc.cyan(\"═\".repeat(50)));\n console.log();\n console.log(` ${pc.green(\"✓\")} All contracts approved`);\n console.log(` ${pc.dim(`${txCount} transaction(s) submitted`)}`);\n console.log();\n console.log(` USDC.e balance: $${balances.usdcE.toFixed(2)}`);\n console.log();\n console.log(pc.bold(\"Your wallet is ready for live trading!\"));\n console.log();\n } catch (error) {\n console.error(pc.red(`Error: ${error}`));\n process.exit(1);\n }\n}\n\n// =============================================================================\n// CLI Setup\n// =============================================================================\n\nprogram\n .name(\"create-polymarket-strategy\")\n .description(\"Create and manage Polymarket trading strategies\")\n .version(\"0.2.0\");\n\n// Default command: create a new strategy\nprogram\n .argument(\"[name]\", \"Project name\")\n .option(\"--no-git\", \"Skip git initialization\")\n .option(\"--no-install\", \"Skip dependency installation\")\n .action(async (name, options) => {\n if (name) {\n await createStrategy(name, options);\n } else {\n program.help();\n }\n });\n\n// Wallet subcommands\nconst walletCmd = program\n .command(\"wallet\")\n .description(\"Wallet management commands\");\n\nwalletCmd\n .command(\"create\")\n .description(\"Create a new wallet and derive API credentials\")\n .option(\"--name <name>\", \"Trader/strategy name (required for 1Password storage)\")\n .option(\"--store-1password\", \"Store credentials in 1Password\")\n .option(\"--vault <vault>\", \"1Password vault name\", \"Private\")\n .action((options) => walletCreate(options));\n\nwalletCmd\n .command(\"balance\")\n .description(\"Check wallet balances\")\n .argument(\"<address>\", \"Wallet address\")\n .action(walletBalance);\n\nwalletCmd\n .command(\"setup\")\n .description(\"Approve exchange contracts for trading\")\n .option(\"--private-key <key>\", \"Wallet private key\")\n .option(\"--from-1password <name>\", \"Get private key from 1Password wallet\")\n .action((options) => walletSetup(options));\n\nwalletCmd\n .command(\"get\")\n .description(\"Retrieve wallet credentials from 1Password\")\n .argument(\"<name>\", \"Trader/strategy name\")\n .action(walletGet);\n\nwalletCmd\n .command(\"list\")\n .description(\"List all Polymarket wallets in 1Password\")\n .action(walletList);\n\nprogram.parse();\n","import { ethers } from \"ethers\";\nimport {\n CHAIN_ID,\n RPC_URL,\n CLOB_API,\n USDC_NATIVE,\n USDC_E,\n CTF_ADDRESS,\n EXCHANGE_CONTRACTS,\n CLOB_AUTH_DOMAIN,\n CLOB_AUTH_MESSAGE,\n ERC20_ABI,\n ERC1155_ABI,\n} from \"./constants.js\";\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport interface WalletCredentials {\n address: string;\n privateKey: string;\n}\n\nexport interface ApiCredentials {\n apiKey: string;\n apiSecret: string;\n apiPassphrase: string;\n}\n\nexport interface FullCredentials extends WalletCredentials, ApiCredentials {}\n\nexport interface WalletBalances {\n address: string;\n pol: number;\n usdcNative: number;\n usdcE: number;\n totalUsdc: number;\n}\n\n// =============================================================================\n// Wallet Creation\n// =============================================================================\n\n/**\n * Generate a new Ethereum wallet.\n */\nexport function generateWallet(): WalletCredentials {\n const wallet = ethers.Wallet.createRandom();\n return {\n address: wallet.address,\n privateKey: wallet.privateKey,\n };\n}\n\n// =============================================================================\n// API Credential Derivation\n// =============================================================================\n\n/**\n * Sign the CLOB auth message (EIP-712).\n */\nasync function signClobAuthMessage(\n wallet: ethers.Wallet,\n timestamp: number,\n nonce: number\n): Promise<string> {\n const types = {\n ClobAuth: [\n { name: \"address\", type: \"address\" },\n { name: \"timestamp\", type: \"string\" },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"message\", type: \"string\" },\n ],\n };\n\n const value = {\n address: wallet.address,\n timestamp: timestamp.toString(),\n nonce: nonce,\n message: CLOB_AUTH_MESSAGE,\n };\n\n return wallet.signTypedData(CLOB_AUTH_DOMAIN, types, value);\n}\n\n/**\n * Derive API credentials from wallet.\n * First tries to create new credentials, then falls back to deriving existing ones.\n */\nexport async function deriveApiCredentials(\n privateKey: string,\n nonce: number = 0\n): Promise<ApiCredentials> {\n const wallet = new ethers.Wallet(privateKey);\n const timestamp = Math.floor(Date.now() / 1000);\n const signature = await signClobAuthMessage(wallet, timestamp, nonce);\n\n const headers = {\n \"POLY_ADDRESS\": wallet.address,\n \"POLY_SIGNATURE\": signature,\n \"POLY_TIMESTAMP\": timestamp.toString(),\n \"POLY_NONCE\": nonce.toString(),\n };\n\n // Try to derive existing credentials first\n let response = await fetch(`${CLOB_API}/auth/derive-api-key`, {\n method: \"GET\",\n headers,\n });\n\n if (!response.ok) {\n // Try to create new credentials\n response = await fetch(`${CLOB_API}/auth/api-key`, {\n method: \"POST\",\n headers,\n });\n }\n\n if (!response.ok) {\n const text = await response.text();\n throw new Error(`Failed to derive API credentials: ${response.status} ${text}`);\n }\n\n const data = await response.json();\n\n return {\n apiKey: data.apiKey,\n apiSecret: data.secret,\n apiPassphrase: data.passphrase,\n };\n}\n\n/**\n * Generate wallet and derive API credentials.\n */\nexport async function createWalletWithCredentials(): Promise<FullCredentials> {\n const wallet = generateWallet();\n const apiCreds = await deriveApiCredentials(wallet.privateKey);\n\n return {\n ...wallet,\n ...apiCreds,\n };\n}\n\n// =============================================================================\n// Balance Checking\n// =============================================================================\n\n/**\n * Get provider for Polygon.\n */\nfunction getProvider(): ethers.JsonRpcProvider {\n return new ethers.JsonRpcProvider(RPC_URL, CHAIN_ID);\n}\n\n/**\n * Check wallet balances (POL, USDC, USDC.e).\n */\nexport async function getBalances(address: string): Promise<WalletBalances> {\n const provider = getProvider();\n\n // POL balance\n const polBalance = await provider.getBalance(address);\n const pol = Number(ethers.formatEther(polBalance));\n\n // USDC Native balance\n const usdcNativeContract = new ethers.Contract(USDC_NATIVE, ERC20_ABI, provider);\n const usdcNativeBalance = await usdcNativeContract.balanceOf(address);\n const usdcNative = Number(ethers.formatUnits(usdcNativeBalance, 6));\n\n // USDC.e balance\n const usdcEContract = new ethers.Contract(USDC_E, ERC20_ABI, provider);\n const usdcEBalance = await usdcEContract.balanceOf(address);\n const usdcE = Number(ethers.formatUnits(usdcEBalance, 6));\n\n return {\n address,\n pol,\n usdcNative,\n usdcE,\n totalUsdc: usdcNative + usdcE,\n };\n}\n\n// =============================================================================\n// Contract Approvals\n// =============================================================================\n\ninterface ApprovalResult {\n contract: string;\n usdcApproved: boolean;\n usdcTxHash?: string;\n ctfApproved: boolean;\n ctfTxHash?: string;\n}\n\n/**\n * Approve Polymarket exchange contracts for trading.\n */\nexport async function approveExchangeContracts(\n privateKey: string,\n onProgress?: (message: string) => void\n): Promise<ApprovalResult[]> {\n const provider = getProvider();\n const wallet = new ethers.Wallet(privateKey, provider);\n const results: ApprovalResult[] = [];\n\n const usdcE = new ethers.Contract(USDC_E, ERC20_ABI, wallet);\n const ctf = new ethers.Contract(CTF_ADDRESS, ERC1155_ABI, wallet);\n\n const maxApproval = ethers.MaxUint256;\n\n for (const exchange of EXCHANGE_CONTRACTS) {\n const result: ApprovalResult = {\n contract: exchange.name,\n usdcApproved: false,\n ctfApproved: false,\n };\n\n // Check and approve USDC.e\n const currentAllowance = await usdcE.allowance(wallet.address, exchange.address);\n if (currentAllowance < ethers.parseUnits(\"1000000000\", 6)) {\n onProgress?.(`Approving USDC.e for ${exchange.name}...`);\n const tx = await usdcE.approve(exchange.address, maxApproval);\n const receipt = await tx.wait();\n result.usdcTxHash = receipt.hash;\n result.usdcApproved = true;\n } else {\n onProgress?.(`USDC.e already approved for ${exchange.name}`);\n result.usdcApproved = true;\n }\n\n // Check and approve CTF\n const isApproved = await ctf.isApprovedForAll(wallet.address, exchange.address);\n if (!isApproved) {\n onProgress?.(`Approving CTF for ${exchange.name}...`);\n const tx = await ctf.setApprovalForAll(exchange.address, true);\n const receipt = await tx.wait();\n result.ctfTxHash = receipt.hash;\n result.ctfApproved = true;\n } else {\n onProgress?.(`CTF already approved for ${exchange.name}`);\n result.ctfApproved = true;\n }\n\n results.push(result);\n }\n\n return results;\n}\n\n/**\n * Check if wallet has sufficient approvals for trading.\n */\nexport async function checkApprovals(address: string): Promise<{\n allApproved: boolean;\n details: { contract: string; usdcApproved: boolean; ctfApproved: boolean }[];\n}> {\n const provider = getProvider();\n const usdcE = new ethers.Contract(USDC_E, ERC20_ABI, provider);\n const ctf = new ethers.Contract(CTF_ADDRESS, ERC1155_ABI, provider);\n\n const details = [];\n\n for (const exchange of EXCHANGE_CONTRACTS) {\n const allowance = await usdcE.allowance(address, exchange.address);\n const isCtfApproved = await ctf.isApprovedForAll(address, exchange.address);\n\n details.push({\n contract: exchange.name,\n usdcApproved: allowance > 0n,\n ctfApproved: isCtfApproved,\n });\n }\n\n const allApproved = details.every((d) => d.usdcApproved && d.ctfApproved);\n\n return { allApproved, details };\n}\n","// Polygon Mainnet\nexport const CHAIN_ID = 137;\nexport const RPC_URL = \"https://1rpc.io/matic\";\n\n// Polymarket CLOB API\nexport const CLOB_API = \"https://clob.polymarket.com\";\n\n// Token addresses on Polygon\nexport const USDC_NATIVE = \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\";\nexport const USDC_E = \"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\"; // Polymarket uses this\nexport const CTF_ADDRESS = \"0x4D97DCd97eC945f40cF65F87097ACe5EA0476045\";\n\n// Polymarket exchange contracts that need approval\nexport const EXCHANGE_CONTRACTS = [\n { address: \"0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E\", name: \"CTF Exchange\" },\n { address: \"0xC5d563A36AE78145C45a50134d48A1215220f80a\", name: \"Neg Risk CTF Exchange\" },\n { address: \"0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296\", name: \"Neg Risk Adapter\" },\n];\n\n// Uniswap V3 Router on Polygon (for USDC → USDC.e swap)\nexport const UNISWAP_ROUTER = \"0xE592427A0AEce92De3Edee1F18E0157C05861564\";\n\n// EIP-712 domain for CLOB auth\nexport const CLOB_AUTH_DOMAIN = {\n name: \"ClobAuthDomain\",\n version: \"1\",\n chainId: CHAIN_ID,\n};\n\n// Message to sign for CLOB auth\nexport const CLOB_AUTH_MESSAGE = \"This message attests that I control the given wallet\";\n\n// ABIs\nexport const ERC20_ABI = [\n \"function balanceOf(address owner) view returns (uint256)\",\n \"function approve(address spender, uint256 amount) returns (bool)\",\n \"function allowance(address owner, address spender) view returns (uint256)\",\n];\n\nexport const ERC1155_ABI = [\n \"function setApprovalForAll(address operator, bool approved)\",\n \"function isApprovedForAll(address account, address operator) view returns (bool)\",\n];\n\nexport const UNISWAP_ROUTER_ABI = [\n \"function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 deadline, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountOut)\",\n];\n","/**\n * 1Password CLI Integration\n *\n * Provides secure storage for wallet credentials.\n */\n\nimport { execSync } from \"child_process\";\nimport type { FullCredentials } from \"./index.js\";\n\n// Standard naming convention for Polymarket wallets\nexport const WALLET_ITEM_PREFIX = \"Polymarket Wallet\";\n\n/**\n * Check if 1Password CLI is available and authenticated.\n */\nexport function check1PasswordCli(): { available: boolean; authenticated: boolean; error?: string } {\n try {\n execSync(\"which op\", { encoding: \"utf8\", stdio: \"pipe\" });\n } catch {\n return {\n available: false,\n authenticated: false,\n error: \"1Password CLI not installed. Install with: brew install --cask 1password-cli\",\n };\n }\n\n try {\n execSync(\"op account list\", { encoding: \"utf8\", stdio: \"pipe\" });\n return { available: true, authenticated: true };\n } catch {\n return {\n available: true,\n authenticated: false,\n error: \"1Password CLI not authenticated. Enable app integration: Settings → Developer → Integrate with 1Password CLI\",\n };\n }\n}\n\n/**\n * Store wallet credentials in 1Password.\n *\n * @param name - Trader/strategy name (e.g., \"temperature\")\n * @param credentials - Full wallet and API credentials\n * @param vault - 1Password vault name (default: \"Private\")\n */\nexport async function storeIn1Password(\n name: string,\n credentials: FullCredentials,\n vault: string = \"Private\"\n): Promise<{ itemName: string; success: boolean; error?: string }> {\n const itemName = `${WALLET_ITEM_PREFIX} - ${name}`;\n\n try {\n // Build op item create command\n const fields = [\n `address[text]=${credentials.address}`,\n `private_key[password]=${credentials.privateKey}`,\n `api_key[text]=${credentials.apiKey}`,\n `api_secret[password]=${credentials.apiSecret}`,\n `api_passphrase[password]=${credentials.apiPassphrase}`,\n `created_at[text]=${new Date().toISOString()}`,\n ];\n\n const cmd = [\n \"op\",\n \"item\",\n \"create\",\n \"--category=Login\",\n `--title=${itemName}`,\n `--vault=${vault}`,\n ...fields.map((f) => `\"${f}\"`),\n ].join(\" \");\n\n execSync(cmd, { encoding: \"utf8\", stdio: \"pipe\" });\n\n return { itemName, success: true };\n } catch (error) {\n const msg = error instanceof Error ? error.message : String(error);\n return { itemName, success: false, error: msg };\n }\n}\n\n/**\n * Retrieve wallet credentials from 1Password.\n *\n * @param name - Trader/strategy name (e.g., \"temperature\")\n */\nexport async function getFrom1Password(\n name: string\n): Promise<{ credentials?: FullCredentials; error?: string }> {\n const itemName = `${WALLET_ITEM_PREFIX} - ${name}`;\n\n try {\n // Get all fields at once\n const output = execSync(\n `op item get \"${itemName}\" --format json`,\n { encoding: \"utf8\", stdio: \"pipe\" }\n );\n\n const item = JSON.parse(output);\n const fields: Record<string, string> = {};\n\n for (const field of item.fields || []) {\n if (field.label && field.value) {\n fields[field.label] = field.value;\n }\n }\n\n if (!fields.address || !fields.private_key) {\n return { error: `Wallet \"${itemName}\" is missing required fields` };\n }\n\n return {\n credentials: {\n address: fields.address,\n privateKey: fields.private_key,\n apiKey: fields.api_key || \"\",\n apiSecret: fields.api_secret || \"\",\n apiPassphrase: fields.api_passphrase || \"\",\n },\n };\n } catch (error) {\n const msg = error instanceof Error ? error.message : String(error);\n if (msg.includes(\"isn't an item\")) {\n return { error: `Wallet \"${itemName}\" not found in 1Password` };\n }\n return { error: msg };\n }\n}\n\n/**\n * List all Polymarket wallets in 1Password.\n */\nexport function listWallets(vault?: string): string[] {\n try {\n const vaultArg = vault ? `--vault=\"${vault}\"` : \"\";\n const output = execSync(\n `op item list --format json ${vaultArg}`,\n { encoding: \"utf8\", stdio: \"pipe\" }\n );\n\n const items = JSON.parse(output);\n const wallets: string[] = [];\n\n for (const item of items) {\n if (item.title?.startsWith(WALLET_ITEM_PREFIX)) {\n const name = item.title.replace(`${WALLET_ITEM_PREFIX} - `, \"\");\n wallets.push(name);\n }\n }\n\n return wallets;\n } catch {\n return [];\n }\n}\n\n/**\n * Get just the wallet address from 1Password (quick lookup).\n */\nexport function getWalletAddress(name: string): string | null {\n const itemName = `${WALLET_ITEM_PREFIX} - ${name}`;\n\n try {\n const output = execSync(\n `op item get \"${itemName}\" --fields address --reveal`,\n { encoding: \"utf8\", stdio: \"pipe\" }\n );\n return output.trim();\n } catch {\n return null;\n }\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;AACxB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,YAAAA,iBAAgB;AACzB,OAAO,QAAQ;AACf,SAAS,qBAAqB;;;ACL9B,SAAS,cAAc;;;ACChB,IAAM,WAAW;AACjB,IAAM,UAAU;AAGhB,IAAM,WAAW;AAGjB,IAAM,cAAc;AACpB,IAAM,SAAS;AACf,IAAM,cAAc;AAGpB,IAAM,qBAAqB;AAAA,EAChC,EAAE,SAAS,8CAA8C,MAAM,eAAe;AAAA,EAC9E,EAAE,SAAS,8CAA8C,MAAM,wBAAwB;AAAA,EACvF,EAAE,SAAS,8CAA8C,MAAM,mBAAmB;AACpF;AAMO,IAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AACX;AAGO,IAAM,oBAAoB;AAG1B,IAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,cAAc;AAAA,EACzB;AAAA,EACA;AACF;;;ADKO,SAAS,iBAAoC;AAClD,QAAM,SAAS,OAAO,OAAO,aAAa;AAC1C,SAAO;AAAA,IACL,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,EACrB;AACF;AASA,eAAe,oBACb,QACA,WACA,OACiB;AACjB,QAAM,QAAQ;AAAA,IACZ,UAAU;AAAA,MACR,EAAE,MAAM,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wCAAwC,CAAC;AAC7D,YAAQ,IAAI;AAAA,EACd,SAAS,OAAO;AACd,YAAQ,MAAM,GAAG,IAAI,UAAU,KAAK,EAAE,CAAC;AACvC,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAMA,QACG,KAAK,4BAA4B,EACjC,YAAY,iDAAiD,EAC7D,QAAQ,OAAO;AAGlB,QACG,SAAS,UAAU,cAAc,EACjC,OAAO,YAAY,yBAAyB,EAC5C,OAAO,gBAAgB,8BAA8B,EACrD,OAAO,OAAO,MAAM,YAAY;AAC/B,MAAI,MAAM;AACR,UAAM,eAAe,MAAM,OAAO;AAAA,EACpC,OAAO;AACL,YAAQ,KAAK;AAAA,EACf;AACF,CAAC;AAGH,IAAM,YAAY,QACf,QAAQ,QAAQ,EAChB,YAAY,4BAA4B;AAE3C,UACG,QAAQ,QAAQ,EAChB,YAAY,gDAAgD,EAC5D,OAAO,iBAAiB,uDAAuD,EAC/E,OAAO,qBAAqB,gCAAgC,EAC5D,OAAO,mBAAmB,wBAAwB,SAAS,EAC3D,OAAO,CAAC,YAAY,aAAa,OAAO,CAAC;AAE5C,UACG,QAAQ,SAAS,EACjB,YAAY,uBAAuB,EACnC,SAAS,aAAa,gBAAgB,EACtC,OAAO,aAAa;AAEvB,UACG,QAAQ,OAAO,EACf,YAAY,wCAAwC,EACpD,OAAO,uBAAuB,oBAAoB,EAClD,OAAO,2BAA2B,uCAAuC,EACzE,OAAO,CAAC,YAAY,YAAY,OAAO,CAAC;AAE3C,UACG,QAAQ,KAAK,EACb,YAAY,4CAA4C,EACxD,SAAS,UAAU,sBAAsB,EACzC,OAAO,SAAS;AAEnB,UACG,QAAQ,MAAM,EACd,YAAY,0CAA0C,EACtD,OAAO,UAAU;AAEpB,QAAQ,MAAM;","names":["execSync","execSync","ethers"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-polymarket-strategy",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Create a new Polymarket trading strategy project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,7 +10,7 @@
10
10
  "typecheck": "tsc --noEmit"
11
11
  },
12
12
  "dependencies": {
13
- "polymarket-trading-sdk": "^0.1.0"
13
+ "polymarket-trading-sdk": "^0.2.1"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@cloudflare/workers-types": "^4.20240620.0",