pandora-cli-skills 1.1.21 → 1.1.22
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.
|
@@ -1413,6 +1413,8 @@ async function buildTradingClient(options = {}) {
|
|
|
1413
1413
|
const signatureType = resolveSignatureType(options);
|
|
1414
1414
|
const cacheKey = buildTradingCacheKey(host, chain, options);
|
|
1415
1415
|
const allowCache = options.disableCache !== true;
|
|
1416
|
+
const timeoutMs = Number.isInteger(options.timeoutMs) && options.timeoutMs > 0 ? options.timeoutMs : 12_000;
|
|
1417
|
+
const ClobCtor = options.clobClientClass || ClobClient;
|
|
1416
1418
|
|
|
1417
1419
|
if (allowCache && tradingClientCache.has(cacheKey)) {
|
|
1418
1420
|
return tradingClientCache.get(cacheKey);
|
|
@@ -1443,7 +1445,7 @@ async function buildTradingClient(options = {}) {
|
|
|
1443
1445
|
if (allowCache && derivedCredsCache.has(cacheKey)) {
|
|
1444
1446
|
creds = derivedCredsCache.get(cacheKey);
|
|
1445
1447
|
} else {
|
|
1446
|
-
const bootstrap = new
|
|
1448
|
+
const bootstrap = new ClobCtor(
|
|
1447
1449
|
host,
|
|
1448
1450
|
chain,
|
|
1449
1451
|
signer,
|
|
@@ -1459,12 +1461,27 @@ async function buildTradingClient(options = {}) {
|
|
|
1459
1461
|
if (typeof bootstrap.deriveApiKey === 'function') {
|
|
1460
1462
|
try {
|
|
1461
1463
|
// deriveApiKey expects nonce, not signature type; default to nonce 0.
|
|
1462
|
-
creds = await
|
|
1463
|
-
|
|
1464
|
-
|
|
1464
|
+
creds = await callWithTimeout(
|
|
1465
|
+
() => bootstrap.deriveApiKey(0),
|
|
1466
|
+
timeoutMs,
|
|
1467
|
+
'Polymarket deriveApiKey(0)',
|
|
1468
|
+
);
|
|
1469
|
+
} catch (err) {
|
|
1470
|
+
if (err && typeof err.message === 'string' && err.message.includes('timed out')) {
|
|
1471
|
+
throw err;
|
|
1472
|
+
}
|
|
1473
|
+
creds = await callWithTimeout(
|
|
1474
|
+
() => bootstrap.deriveApiKey(),
|
|
1475
|
+
timeoutMs,
|
|
1476
|
+
'Polymarket deriveApiKey()',
|
|
1477
|
+
);
|
|
1465
1478
|
}
|
|
1466
1479
|
} else if (typeof bootstrap.createOrDeriveApiKey === 'function') {
|
|
1467
|
-
creds = await
|
|
1480
|
+
creds = await callWithTimeout(
|
|
1481
|
+
() => bootstrap.createOrDeriveApiKey(),
|
|
1482
|
+
timeoutMs,
|
|
1483
|
+
'Polymarket createOrDeriveApiKey()',
|
|
1484
|
+
);
|
|
1468
1485
|
} else {
|
|
1469
1486
|
throw new Error('CLOB client does not support API key derivation.');
|
|
1470
1487
|
}
|
|
@@ -1474,7 +1491,7 @@ async function buildTradingClient(options = {}) {
|
|
|
1474
1491
|
}
|
|
1475
1492
|
}
|
|
1476
1493
|
|
|
1477
|
-
const client = new
|
|
1494
|
+
const client = new ClobCtor(
|
|
1478
1495
|
host,
|
|
1479
1496
|
chain,
|
|
1480
1497
|
signer,
|
|
@@ -1528,25 +1545,44 @@ async function placeHedgeOrder(options = {}) {
|
|
|
1528
1545
|
const host = options.host || DEFAULT_POLYMARKET_HOST;
|
|
1529
1546
|
const chain = options.chain || DEFAULT_POLYMARKET_CHAIN;
|
|
1530
1547
|
const cacheKey = buildTradingCacheKey(host, chain, options);
|
|
1548
|
+
const timeoutMs = Number.isInteger(options.timeoutMs) && options.timeoutMs > 0 ? options.timeoutMs : 12_000;
|
|
1531
1549
|
const client = options.client || (await buildTradingClient(options));
|
|
1532
1550
|
const side = resolveOrderSide(options.side || 'buy');
|
|
1533
1551
|
try {
|
|
1534
|
-
const tickSize =
|
|
1535
|
-
|
|
1552
|
+
const tickSize =
|
|
1553
|
+
options.tickSize ||
|
|
1554
|
+
(await callWithTimeout(
|
|
1555
|
+
() => client.getTickSize(tokenId),
|
|
1556
|
+
timeoutMs,
|
|
1557
|
+
`Polymarket getTickSize(${tokenId})`,
|
|
1558
|
+
));
|
|
1559
|
+
const negRisk =
|
|
1560
|
+
typeof options.negRisk === 'boolean'
|
|
1561
|
+
? options.negRisk
|
|
1562
|
+
: await callWithTimeout(
|
|
1563
|
+
() => client.getNegRisk(tokenId),
|
|
1564
|
+
timeoutMs,
|
|
1565
|
+
`Polymarket getNegRisk(${tokenId})`,
|
|
1566
|
+
);
|
|
1536
1567
|
|
|
1537
|
-
const response = await
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1568
|
+
const response = await callWithTimeout(
|
|
1569
|
+
() =>
|
|
1570
|
+
client.createAndPostMarketOrder(
|
|
1571
|
+
{
|
|
1572
|
+
tokenID: tokenId,
|
|
1573
|
+
amount: amountUsd,
|
|
1574
|
+
side,
|
|
1575
|
+
orderType: OrderType.FAK,
|
|
1576
|
+
},
|
|
1577
|
+
{
|
|
1578
|
+
tickSize,
|
|
1579
|
+
negRisk,
|
|
1580
|
+
},
|
|
1581
|
+
OrderType.FAK,
|
|
1582
|
+
false,
|
|
1583
|
+
),
|
|
1584
|
+
timeoutMs,
|
|
1585
|
+
`Polymarket createAndPostMarketOrder(${tokenId})`,
|
|
1550
1586
|
);
|
|
1551
1587
|
const ok = responseIndicatesSuccess(response);
|
|
1552
1588
|
if (!ok && classifyAuthFailure(response)) {
|