pandora-cli-skills 1.1.11 → 1.1.13

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.
@@ -431,6 +431,7 @@ async function browseMirrorMarkets(options = {}) {
431
431
  schemaVersion: MIRROR_BROWSE_SCHEMA_VERSION,
432
432
  generatedAt: new Date().toISOString(),
433
433
  source: polymarket.source,
434
+ gammaApiError: polymarket.gammaApiError || null,
434
435
  filters: polymarket.filters,
435
436
  count: items.length,
436
437
  items,
@@ -227,7 +227,13 @@ async function runMirrorSync(options, deps = {}) {
227
227
  const diagnostics = [];
228
228
 
229
229
  const maxIterations = options.mode === 'once' ? 1 : options.iterations || Number.POSITIVE_INFINITY;
230
- const minimumTimeToCloseSec = Math.max(Math.ceil((options.intervalMs || 5_000) / 1000) * 2, 1800);
230
+ const configuredMinTimeToCloseSec = Number.isInteger(Number(options.minTimeToCloseSec))
231
+ ? Math.max(60, Math.trunc(Number(options.minTimeToCloseSec)))
232
+ : 1800;
233
+ const minimumTimeToCloseSec = Math.max(
234
+ Math.ceil((options.intervalMs || 5_000) / 1000) * 2,
235
+ configuredMinTimeToCloseSec,
236
+ );
231
237
  let iteration = 0;
232
238
  let shouldStop = false;
233
239
  let stoppedReason = null;
@@ -8,6 +8,7 @@ const {
8
8
  parseUnits,
9
9
  } = require('viem');
10
10
  const { privateKeyToAccount } = require('viem/accounts');
11
+ const { decodeContractError, formatDecodedContractError } = require('./contract_error_decoder.cjs');
11
12
 
12
13
  const DEFAULT_ORACLE = '0x259308E7d8557e4Ba192De1aB8Cf7e0E21896442';
13
14
  const DEFAULT_FACTORY = '0xaB120F1FD31FB1EC39893B75d80a3822b1Cd8d0c';
@@ -115,6 +116,16 @@ function createDeployError(code, message, details = undefined) {
115
116
  return err;
116
117
  }
117
118
 
119
+ async function wrapDeployExecutionError(err, code, fallbackMessage, details = undefined) {
120
+ const decoded = await decodeContractError(err);
121
+ const decodedMessage = formatDecodedContractError(decoded);
122
+ return createDeployError(code, decodedMessage || (err && err.message ? err.message : fallbackMessage), {
123
+ decodedError: decoded,
124
+ cause: err && err.message ? err.message : String(err),
125
+ ...((details && typeof details === 'object') ? details : {}),
126
+ });
127
+ }
128
+
118
129
  function resolveChain(chainId, rpcUrl) {
119
130
  const id = Number(chainId || process.env.CHAIN_ID || 1);
120
131
  if (![1, 146].includes(id)) {
@@ -209,7 +220,7 @@ function buildDeploymentArgs(options = {}) {
209
220
  distributionNo,
210
221
  feeTier,
211
222
  maxImbalance,
212
- arbiter: String(options.arbiter || '0x818457C9e2b18D87981CCB09b75AE183D107b257').toLowerCase(),
223
+ arbiter: String(options.arbiter || '0x0D7B957C47Da86c2968dc52111D633D42cb7a5F7').toLowerCase(),
213
224
  category,
214
225
  };
215
226
  }
@@ -318,17 +329,30 @@ async function deployPandoraAmmMarket(options = {}) {
318
329
  );
319
330
  }
320
331
 
321
- const pollSimulation = await publicClient.simulateContract({
322
- account,
323
- address: oracle,
324
- abi: ORACLE_ABI,
325
- functionName: 'createPoll',
326
- args: [args.question, args.rules, args.sources, BigInt(args.targetTimestamp), args.arbiter, args.category],
327
- value: pollFee,
328
- });
332
+ let pollSimulation;
333
+ try {
334
+ pollSimulation = await publicClient.simulateContract({
335
+ account,
336
+ address: oracle,
337
+ abi: ORACLE_ABI,
338
+ functionName: 'createPoll',
339
+ args: [args.question, args.rules, args.sources, BigInt(args.targetTimestamp), args.arbiter, args.category],
340
+ value: pollFee,
341
+ });
342
+ } catch (err) {
343
+ throw await wrapDeployExecutionError(err, 'POLL_SIMULATION_FAILED', 'createPoll simulation failed.');
344
+ }
329
345
 
330
- const pollTxHash = await walletClient.writeContract(pollSimulation.request);
331
- const pollReceipt = await publicClient.waitForTransactionReceipt({ hash: pollTxHash });
346
+ let pollTxHash;
347
+ let pollReceipt;
348
+ try {
349
+ pollTxHash = await walletClient.writeContract(pollSimulation.request);
350
+ pollReceipt = await publicClient.waitForTransactionReceipt({ hash: pollTxHash });
351
+ } catch (err) {
352
+ throw await wrapDeployExecutionError(err, 'POLL_EXECUTION_FAILED', 'createPoll transaction failed.', {
353
+ pollTxHash: pollTxHash || null,
354
+ });
355
+ }
332
356
 
333
357
  let pollAddress = pollSimulation.result || null;
334
358
  for (const log of pollReceipt.logs || []) {
@@ -354,27 +378,45 @@ async function deployPandoraAmmMarket(options = {}) {
354
378
 
355
379
  let approveTxHash = null;
356
380
  if (currentAllowance < liquidityRaw) {
357
- approveTxHash = await walletClient.writeContract({
358
- address: usdc,
359
- abi: ERC20_ABI,
360
- functionName: 'approve',
361
- args: [factory, liquidityRaw],
362
- });
363
- await publicClient.waitForTransactionReceipt({ hash: approveTxHash });
381
+ try {
382
+ approveTxHash = await walletClient.writeContract({
383
+ address: usdc,
384
+ abi: ERC20_ABI,
385
+ functionName: 'approve',
386
+ args: [factory, liquidityRaw],
387
+ });
388
+ await publicClient.waitForTransactionReceipt({ hash: approveTxHash });
389
+ } catch (err) {
390
+ throw await wrapDeployExecutionError(err, 'APPROVE_EXECUTION_FAILED', 'USDC approve failed.', {
391
+ approveTxHash: approveTxHash || null,
392
+ });
393
+ }
364
394
  }
365
395
 
366
396
  const distributionHint = [BigInt(args.distributionYes), BigInt(args.distributionNo)];
367
397
 
368
- const marketSimulation = await publicClient.simulateContract({
369
- account,
370
- address: factory,
371
- abi: FACTORY_ABI,
372
- functionName: 'createMarket',
373
- args: [pollAddress, usdc, liquidityRaw, distributionHint, args.feeTier, args.maxImbalance],
374
- });
398
+ let marketSimulation;
399
+ try {
400
+ marketSimulation = await publicClient.simulateContract({
401
+ account,
402
+ address: factory,
403
+ abi: FACTORY_ABI,
404
+ functionName: 'createMarket',
405
+ args: [pollAddress, usdc, liquidityRaw, distributionHint, args.feeTier, args.maxImbalance],
406
+ });
407
+ } catch (err) {
408
+ throw await wrapDeployExecutionError(err, 'MARKET_SIMULATION_FAILED', 'createMarket simulation failed.');
409
+ }
375
410
 
376
- const marketTxHash = await walletClient.writeContract(marketSimulation.request);
377
- await publicClient.waitForTransactionReceipt({ hash: marketTxHash });
411
+ let marketTxHash;
412
+ try {
413
+ marketTxHash = await walletClient.writeContract(marketSimulation.request);
414
+ await publicClient.waitForTransactionReceipt({ hash: marketTxHash });
415
+ } catch (err) {
416
+ throw await wrapDeployExecutionError(err, 'MARKET_EXECUTION_FAILED', 'createMarket transaction failed.', {
417
+ marketTxHash: marketTxHash || null,
418
+ });
419
+ }
378
420
 
379
421
  payload.tx = {
380
422
  pollTxHash,
@@ -1,6 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const os = require('os');
3
3
  const path = require('path');
4
+ const crypto = require('crypto');
4
5
  const { ClobClient, Chain, Side, OrderType, AssetType } = require('@polymarket/clob-client');
5
6
 
6
7
  const DEFAULT_POLYMARKET_HOST = 'https://clob.polymarket.com';
@@ -177,7 +178,7 @@ function writeCacheFile(cacheFile, payload) {
177
178
 
178
179
  const dir = path.dirname(cacheFile);
179
180
  fs.mkdirSync(dir, { recursive: true });
180
- const tmpPath = `${cacheFile}.${process.pid}.${Date.now()}.tmp`;
181
+ const tmpPath = `${cacheFile}.${process.pid}.${Date.now()}.${crypto.randomBytes(4).toString('hex')}.tmp`;
181
182
  fs.writeFileSync(tmpPath, JSON.stringify(payload, null, 2));
182
183
  fs.renameSync(tmpPath, cacheFile);
183
184
  }
@@ -948,6 +949,9 @@ async function browsePolymarketMarkets(options = {}) {
948
949
  sourceType: item.source || (options.mockUrl ? 'polymarket:mock' : 'polymarket:gamma'),
949
950
  }));
950
951
 
952
+ const gammaApiError =
953
+ diagnostics.find((line) => /^Gamma request failed/i.test(String(line || ''))) || null;
954
+
951
955
  return {
952
956
  schemaVersion: '1.0.0',
953
957
  generatedAt: new Date().toISOString(),
@@ -963,6 +967,7 @@ async function browsePolymarketMarkets(options = {}) {
963
967
  },
964
968
  count: items.length,
965
969
  items,
970
+ gammaApiError,
966
971
  diagnostics,
967
972
  };
968
973
  }