@agg-build/sdk 4.28.2 → 4.29.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/{agg-websocket-BA8wCwM5.d.mts → agg-websocket-BUI5Bx-n.d.mts} +399 -279
- package/dist/agg-websocket-BUI5Bx-n.d.mts.map +1 -0
- package/dist/{agg-websocket-BA8wCwM5.d.ts → agg-websocket-BUI5Bx-n.d.ts} +399 -279
- package/dist/agg-websocket-BUI5Bx-n.d.ts.map +1 -0
- package/dist/{agg-websocket-DTHMujEm.js → agg-websocket-CVZ7laJ4.js} +153 -13
- package/dist/{agg-websocket-BrkWNijv.mjs → agg-websocket-ClGhhROZ.mjs} +154 -14
- package/dist/agg-websocket-ClGhhROZ.mjs.map +1 -0
- package/dist/browser.d.mts +1 -1
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +2 -2
- package/dist/browser.mjs +2 -2
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +150 -26
- package/dist/index.mjs +141 -27
- package/dist/index.mjs.map +1 -1
- package/dist/market-data.d.mts +1 -1
- package/dist/market-data.d.ts +1 -1
- package/dist/market-data.js +6 -2
- package/dist/market-data.mjs +6 -2
- package/dist/market-data.mjs.map +1 -1
- package/package.json +4 -1
- package/dist/agg-websocket-BA8wCwM5.d.mts.map +0 -1
- package/dist/agg-websocket-BA8wCwM5.d.ts.map +0 -1
- package/dist/agg-websocket-BrkWNijv.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as loadImmutableHistory, c as orderbookCrc32, i as snapshotToOrderbook, l as projectedOrderbookChecksum, n as applyOrderbookDelta, r as computeChecksum, s as readChartHistoryText, t as AggWebSocket } from "./agg-websocket-
|
|
1
|
+
import { a as loadImmutableHistory, c as orderbookCrc32, i as snapshotToOrderbook, l as projectedOrderbookChecksum, n as applyOrderbookDelta, r as computeChecksum, s as readChartHistoryText, t as AggWebSocket } from "./agg-websocket-ClGhhROZ.mjs";
|
|
2
2
|
import { t as CandleBuilder } from "./candle-builder-BNewIe9K.mjs";
|
|
3
3
|
//#region ../common/src/enums/venue.ts
|
|
4
4
|
/** Use these constants instead of hardcoding "kalshi" or "polymarket". */
|
|
@@ -1057,6 +1057,71 @@ const RECURRENCE_CADENCES = [
|
|
|
1057
1057
|
"P1Y"
|
|
1058
1058
|
];
|
|
1059
1059
|
//#endregion
|
|
1060
|
+
//#region src/self-custody-signing.ts
|
|
1061
|
+
/**
|
|
1062
|
+
* Signing policy for a self-custody fill's `pendingSignatures`, shared by
|
|
1063
|
+
* `AggClient.fillSelfCustody` and `@agg-build/hooks`' `useSelfCustodySigning`
|
|
1064
|
+
* so both answer the same requests in the same order with the same bounds.
|
|
1065
|
+
*/
|
|
1066
|
+
/** EVM hex compares case-insensitively; Solana base58 is case-significant. */
|
|
1067
|
+
const isSameWalletAddress = (a, b) => a.startsWith("0x") && b.startsWith("0x") ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
1068
|
+
/** Step id prefix of a Polymarket order signature request (`poly-sign-<orderId>`). */
|
|
1069
|
+
const PM_ORDER_SIGNATURE_STEP_PREFIX = "poly-sign-";
|
|
1070
|
+
/** True for the trade-executor's Polymarket order signature step. */
|
|
1071
|
+
const isPolymarketOrderSignatureStep = (stepId) => stepId.startsWith(PM_ORDER_SIGNATURE_STEP_PREFIX);
|
|
1072
|
+
/** An optional fee pre-sign (`purpose: "app_fee"`), e.g. a Polymarket buy fee. */
|
|
1073
|
+
const isOptionalFeeRequest = (req) => !!req.optional && req.purpose === "app_fee";
|
|
1074
|
+
/**
|
|
1075
|
+
* A required fee request asked after every order filled: the post-fill sell
|
|
1076
|
+
* fee. Declining it leaves the fee uncollected; the trade itself is done.
|
|
1077
|
+
*/
|
|
1078
|
+
const isPostFillFeeRequest = (req, ordersFilled) => ordersFilled && !req.optional && req.purpose === "app_fee";
|
|
1079
|
+
/** Every order on the run reached a fill (full or partial). False with no orders yet. */
|
|
1080
|
+
const areOrdersFilled = (orders) => (orders?.length ?? 0) > 0 && orders.every((o) => o.event === "filled" || o.event === "partial_fill");
|
|
1081
|
+
/**
|
|
1082
|
+
* The requests to sign now, required first.
|
|
1083
|
+
*
|
|
1084
|
+
* An optional fee pre-sign is prepared independently of the order, so it can
|
|
1085
|
+
* be listed before the order prompt exists; it is held back until the
|
|
1086
|
+
* Polymarket ORDER signature has been submitted, and then signed in a round of
|
|
1087
|
+
* its own so a slow or declined fee prompt never holds anything else. Every
|
|
1088
|
+
* other request goes in one batch: the server reads an optional signature (a
|
|
1089
|
+
* referral code, a sponsor) right after the order finalises, so a second round
|
|
1090
|
+
* would arrive too late.
|
|
1091
|
+
*/
|
|
1092
|
+
const orderSignatureRound = (pending, { orderSubmitted }) => {
|
|
1093
|
+
const eligible = pending.filter((req) => orderSubmitted || !isOptionalFeeRequest(req));
|
|
1094
|
+
return [...eligible.some((req) => !isOptionalFeeRequest(req)) ? eligible.filter((req) => !isOptionalFeeRequest(req)) : eligible].sort((a, b) => Number(!!a.optional) - Number(!!b.optional));
|
|
1095
|
+
};
|
|
1096
|
+
/** The user's own wallets for this fill: its signing address plus every required request's signer. */
|
|
1097
|
+
const userSignerAddresses = (pending, signingAddress) => [signingAddress, ...pending.filter((req) => !req.optional).map((req) => req.signerAddress)].filter((address) => !!address);
|
|
1098
|
+
/**
|
|
1099
|
+
* How long to wait on the signer for `req`, or `undefined` to wait for the
|
|
1100
|
+
* human. An optional fee pre-sign is bounded by
|
|
1101
|
+
* `OPTIONAL_FEE_SIGNATURE_TIMEOUT_MS`; an optional request addressed to a
|
|
1102
|
+
* wallet other than the user's (a partner's sponsor) by
|
|
1103
|
+
* `OPTIONAL_SIGNATURE_TIMEOUT_MS`. Required requests and optional ones the
|
|
1104
|
+
* user signs (a referral code) are never bounded.
|
|
1105
|
+
*/
|
|
1106
|
+
const signatureTimeoutMs = (req, userSigners) => {
|
|
1107
|
+
if (isOptionalFeeRequest(req)) return OPTIONAL_FEE_SIGNATURE_TIMEOUT_MS;
|
|
1108
|
+
if (req.optional && !userSigners.some((a) => isSameWalletAddress(a, req.signerAddress))) return OPTIONAL_SIGNATURE_TIMEOUT_MS;
|
|
1109
|
+
};
|
|
1110
|
+
/** Rejects after `ms` (when given); a late settlement of `promise` is ignored. */
|
|
1111
|
+
function withTimeout(promise, ms) {
|
|
1112
|
+
if (ms === void 0) return promise;
|
|
1113
|
+
return new Promise((resolve, reject) => {
|
|
1114
|
+
const timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`timed out after ${ms}ms`)), ms);
|
|
1115
|
+
promise.then((value) => {
|
|
1116
|
+
clearTimeout(timer);
|
|
1117
|
+
resolve(value);
|
|
1118
|
+
}, (err) => {
|
|
1119
|
+
clearTimeout(timer);
|
|
1120
|
+
reject(err);
|
|
1121
|
+
});
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
//#endregion
|
|
1060
1125
|
//#region src/client.ts
|
|
1061
1126
|
const COOKIE_REFRESH_DELIVERY = "cookie-refresh";
|
|
1062
1127
|
const DEFAULT_MIDPOINT_IDS_PER_REQUEST = 75;
|
|
@@ -1077,8 +1142,6 @@ const MAX_SPORTS_EVENT_IDS_PER_REQUEST = 25;
|
|
|
1077
1142
|
*/
|
|
1078
1143
|
const MIN_POLL_INTERVAL_MS = 250;
|
|
1079
1144
|
const MAX_POLL_INTERVAL_MS = 3e4;
|
|
1080
|
-
/** Step id prefix of a Polymarket order signature request (`poly-sign-<orderId>`). */
|
|
1081
|
-
const PM_ORDER_SIGNATURE_STEP_PREFIX = "poly-sign-";
|
|
1082
1145
|
const isUserProfile = (user) => {
|
|
1083
1146
|
return "accounts" in user && "wallets" in user && "avatarUrl" in user;
|
|
1084
1147
|
};
|
|
@@ -1147,23 +1210,11 @@ const AUTH_PATHS = /* @__PURE__ */ new Set([
|
|
|
1147
1210
|
"/auth/token/exchange",
|
|
1148
1211
|
"/auth/sign-out"
|
|
1149
1212
|
]);
|
|
1150
|
-
/** Rejects after `ms`; a late settlement of `p` is ignored. */
|
|
1151
|
-
function withTimeout(p, ms) {
|
|
1152
|
-
return new Promise((resolve, reject) => {
|
|
1153
|
-
const timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`timed out after ${ms}ms`)), ms);
|
|
1154
|
-
p.then((v) => {
|
|
1155
|
-
clearTimeout(timer);
|
|
1156
|
-
resolve(v);
|
|
1157
|
-
}, (e) => {
|
|
1158
|
-
clearTimeout(timer);
|
|
1159
|
-
reject(e);
|
|
1160
|
-
});
|
|
1161
|
-
});
|
|
1162
|
-
}
|
|
1163
1213
|
var AggClient = class {
|
|
1164
1214
|
constructor(options) {
|
|
1165
1215
|
this.listeners = /* @__PURE__ */ new Set();
|
|
1166
1216
|
this.webSocketAuthCleanups = /* @__PURE__ */ new Set();
|
|
1217
|
+
this.tradeSockets = /* @__PURE__ */ new Set();
|
|
1167
1218
|
this._authStatus = "unauthenticated";
|
|
1168
1219
|
this.authChannel = null;
|
|
1169
1220
|
this.pendingRefresh = null;
|
|
@@ -1629,11 +1680,16 @@ var AggClient = class {
|
|
|
1629
1680
|
body: JSON.stringify({ contentType })
|
|
1630
1681
|
});
|
|
1631
1682
|
}
|
|
1632
|
-
/**
|
|
1633
|
-
|
|
1683
|
+
/**
|
|
1684
|
+
* Disconnect a linked auth provider from the current user. Pass
|
|
1685
|
+
* `providerAccountId` (the wallet address) when the user has more than one
|
|
1686
|
+
* account for the same provider, or the server rejects the call as ambiguous.
|
|
1687
|
+
*/
|
|
1688
|
+
async disconnectAccount(provider, options) {
|
|
1634
1689
|
return this.request(`/users/me/accounts/${provider}`, {
|
|
1635
1690
|
method: "DELETE",
|
|
1636
|
-
body: JSON.stringify({})
|
|
1691
|
+
body: JSON.stringify({}),
|
|
1692
|
+
...options?.providerAccountId ? { query: { providerAccountId: options.providerAccountId } } : {}
|
|
1637
1693
|
});
|
|
1638
1694
|
}
|
|
1639
1695
|
/** Sign out — revoke all tokens server-side and clear local session. */
|
|
@@ -2304,6 +2360,7 @@ var AggClient = class {
|
|
|
2304
2360
|
async getSmartRoute(params, options) {
|
|
2305
2361
|
const venueMarketOutcomeId = params.venueMarketOutcomeId ?? params.venueMarketId ?? params.outcomeId;
|
|
2306
2362
|
if (!venueMarketOutcomeId) throw new Error("getSmartRoute requires venueMarketOutcomeId");
|
|
2363
|
+
this.openTradeSockets();
|
|
2307
2364
|
const query = {};
|
|
2308
2365
|
if (params.maxSpend != null) query.maxSpend = String(params.maxSpend);
|
|
2309
2366
|
if (params.sellShares != null) query.sellShares = String(params.sellShares);
|
|
@@ -2321,6 +2378,8 @@ var AggClient = class {
|
|
|
2321
2378
|
if (params.referrerFeeBipsByVenue) query.referrerFeeBipsByVenue = JSON.stringify(params.referrerFeeBipsByVenue);
|
|
2322
2379
|
if (params.referralPayer) query.referralPayer = params.referralPayer;
|
|
2323
2380
|
if (params.referralPayerAddress) query.referralPayerAddress = params.referralPayerAddress;
|
|
2381
|
+
if (params.signingAddress) query.signingAddress = params.signingAddress;
|
|
2382
|
+
if (params.fundingAddresses?.length) query.fundingAddresses = params.fundingAddresses;
|
|
2324
2383
|
if (params.referralActivationSponsorAddress) query.referralActivationSponsorAddress = params.referralActivationSponsorAddress;
|
|
2325
2384
|
const response = await this.request(`/orderbook/${encodeURIComponent(venueMarketOutcomeId)}/route`, {
|
|
2326
2385
|
query,
|
|
@@ -2354,11 +2413,15 @@ var AggClient = class {
|
|
|
2354
2413
|
const watchdogHeaders = {};
|
|
2355
2414
|
if (this._appId) watchdogHeaders["x-app-id"] = this._appId;
|
|
2356
2415
|
if (this.apiKey) watchdogHeaders["x-app-api-key"] = this.apiKey;
|
|
2416
|
+
const isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
2417
|
+
const headers = this.apiKey && !isBrowser ? { "x-app-api-key": this.apiKey } : void 0;
|
|
2357
2418
|
const socket = createSocket({
|
|
2358
2419
|
url: url.toString(),
|
|
2359
2420
|
callbacks,
|
|
2360
2421
|
initialToken: this.accessToken,
|
|
2361
2422
|
enableLogs: options?.enableLogs ?? false,
|
|
2423
|
+
...headers ? { headers } : {},
|
|
2424
|
+
...options?.webSocketImpl ? { webSocketImpl: options.webSocketImpl } : {},
|
|
2362
2425
|
bookWatchdog: options?.bookWatchdog === false ? void 0 : {
|
|
2363
2426
|
baseUrl: this.baseUrl,
|
|
2364
2427
|
headers: watchdogHeaders,
|
|
@@ -2368,7 +2431,28 @@ var AggClient = class {
|
|
|
2368
2431
|
this.bindWebSocketAuth(socket, callbacks);
|
|
2369
2432
|
return socket;
|
|
2370
2433
|
}
|
|
2434
|
+
openTradeSockets() {
|
|
2435
|
+
for (const socket of this.tradeSockets) socket.connect();
|
|
2436
|
+
}
|
|
2437
|
+
/**
|
|
2438
|
+
* User events are registered by `{ action: "authenticate" }`, not a channel
|
|
2439
|
+
* subscribe. The confirmation is `{ type: "authenticated" }`. Send that
|
|
2440
|
+
* frame only when the socket is already open and it has not been sent for
|
|
2441
|
+
* this token. Opening a socket here would lose the fill to the handshake.
|
|
2442
|
+
*/
|
|
2443
|
+
confirmTradeSockets() {
|
|
2444
|
+
const token = this.accessToken;
|
|
2445
|
+
if (!token || this.tradeAuthSentForToken === token) return;
|
|
2446
|
+
const confirmedUserId = this.tradeSocketAuthenticatedUserId;
|
|
2447
|
+
if (confirmedUserId && (this.accessTokenUserId === void 0 || confirmedUserId === this.accessTokenUserId)) return;
|
|
2448
|
+
for (const socket of this.tradeSockets) {
|
|
2449
|
+
if (!socket.connected) continue;
|
|
2450
|
+
socket.authenticate(token);
|
|
2451
|
+
this.tradeAuthSentForToken = token;
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2371
2454
|
bindWebSocketAuth(socket, callbacks) {
|
|
2455
|
+
this.tradeSockets.add(socket);
|
|
2372
2456
|
let token = this.accessToken;
|
|
2373
2457
|
let userId = this.accessTokenUserId;
|
|
2374
2458
|
let authenticatedUserId;
|
|
@@ -2387,12 +2471,14 @@ var AggClient = class {
|
|
|
2387
2471
|
if (!connected) {
|
|
2388
2472
|
authenticatedUserId = void 0;
|
|
2389
2473
|
awaitingDisconnect = false;
|
|
2474
|
+
this.tradeSocketAuthenticatedUserId = void 0;
|
|
2390
2475
|
}
|
|
2391
2476
|
handlers.onConnectionStateChange?.(connected);
|
|
2392
2477
|
},
|
|
2393
2478
|
onAuthenticated: (message) => {
|
|
2394
2479
|
if (awaitingDisconnect || !this.accessToken || this.accessTokenUserId !== void 0 && this.accessTokenUserId !== message.userId) return;
|
|
2395
2480
|
authenticatedUserId = message.userId;
|
|
2481
|
+
this.tradeSocketAuthenticatedUserId = message.userId;
|
|
2396
2482
|
handlers.onAuthenticated?.(message);
|
|
2397
2483
|
},
|
|
2398
2484
|
onOrderEvent: (message) => {
|
|
@@ -2412,6 +2498,15 @@ var AggClient = class {
|
|
|
2412
2498
|
},
|
|
2413
2499
|
onWithdrawalLifecycle: (message) => {
|
|
2414
2500
|
if (canReceiveUserEvent(message.userId)) handlers.onWithdrawalLifecycle?.(message);
|
|
2501
|
+
},
|
|
2502
|
+
onAuthExpiring: (message) => {
|
|
2503
|
+
if (this.accessToken && message.userId === authenticatedUserId) this.refreshWithDedup().catch(() => {});
|
|
2504
|
+
handlers.onAuthExpiring?.(message);
|
|
2505
|
+
},
|
|
2506
|
+
onAuthExpired: (message) => {
|
|
2507
|
+
if (message.userId === authenticatedUserId) authenticatedUserId = void 0;
|
|
2508
|
+
if (this.accessToken && message.reason === "expired") this.refreshWithDedup().catch(() => {});
|
|
2509
|
+
handlers.onAuthExpired?.(message);
|
|
2415
2510
|
}
|
|
2416
2511
|
});
|
|
2417
2512
|
socket.setCallbacks = (handlers) => {
|
|
@@ -2422,7 +2517,9 @@ var AggClient = class {
|
|
|
2422
2517
|
socket.connect = () => {
|
|
2423
2518
|
connectRequested = true;
|
|
2424
2519
|
manuallyDisconnected = false;
|
|
2520
|
+
const willOpen = !socket.connected;
|
|
2425
2521
|
originalConnect.call(socket);
|
|
2522
|
+
if (willOpen && this.accessToken) this.tradeAuthSentForToken = this.accessToken;
|
|
2426
2523
|
};
|
|
2427
2524
|
socket.disconnect = () => {
|
|
2428
2525
|
connectRequested = false;
|
|
@@ -2441,12 +2538,18 @@ var AggClient = class {
|
|
|
2441
2538
|
const reconnect = connectRequested || socket.connected || !manuallyDisconnected && (diagnostics.orderbookOutcomeIds.length > 0 || diagnostics.tradeOutcomeIds.length > 0 || diagnostics.arbMarketIds.length > 0 || diagnostics.arbFeedSubscribers > 0);
|
|
2442
2539
|
authenticatedUserId = void 0;
|
|
2443
2540
|
awaitingDisconnect = true;
|
|
2541
|
+
this.tradeSocketAuthenticatedUserId = void 0;
|
|
2444
2542
|
originalDisconnect.call(socket);
|
|
2445
2543
|
socket.authenticate(nextToken ?? "");
|
|
2544
|
+
if (nextToken) this.tradeAuthSentForToken = nextToken;
|
|
2446
2545
|
if (reconnect) originalConnect.call(socket);
|
|
2447
|
-
} else if (nextToken)
|
|
2546
|
+
} else if (nextToken) {
|
|
2547
|
+
socket.authenticate(nextToken);
|
|
2548
|
+
this.tradeAuthSentForToken = nextToken;
|
|
2549
|
+
}
|
|
2448
2550
|
});
|
|
2449
2551
|
const cleanup = () => {
|
|
2552
|
+
this.tradeSockets.delete(socket);
|
|
2450
2553
|
unsubscribe();
|
|
2451
2554
|
this.webSocketAuthCleanups.delete(cleanup);
|
|
2452
2555
|
socket.setCallbacks = originalSetCallbacks;
|
|
@@ -2463,6 +2566,7 @@ var AggClient = class {
|
|
|
2463
2566
|
}
|
|
2464
2567
|
/** Execute a previously quoted managed trade. Returns pending order IDs. */
|
|
2465
2568
|
async executeManaged(params) {
|
|
2569
|
+
this.confirmTradeSockets();
|
|
2466
2570
|
return this.request("/execution/fill", {
|
|
2467
2571
|
method: "POST",
|
|
2468
2572
|
body: JSON.stringify(params)
|
|
@@ -2499,10 +2603,11 @@ var AggClient = class {
|
|
|
2499
2603
|
const deadline = Date.now() + SELF_CUSTODY_FILL_TIMEOUT_MS;
|
|
2500
2604
|
let nextPollMs = MIN_POLL_INTERVAL_MS;
|
|
2501
2605
|
const declinedOptional = /* @__PURE__ */ new Set();
|
|
2502
|
-
|
|
2606
|
+
let ordersFilled = false;
|
|
2607
|
+
const isPostFillFee = (req) => isPostFillFeeRequest(req, ordersFilled);
|
|
2503
2608
|
let orderSubmitted = false;
|
|
2504
2609
|
for (;;) {
|
|
2505
|
-
pending = pending.filter((p) => !declinedOptional.has(p.stepId) && (orderSubmitted || !
|
|
2610
|
+
pending = pending.filter((p) => !declinedOptional.has(p.stepId) && (orderSubmitted || !isOptionalFeeRequest(p)));
|
|
2506
2611
|
if (Date.now() > deadline) throw new Error(`Fill for quote ${quoteId} did not finish within the timeout.`);
|
|
2507
2612
|
if (pending.length === 0) {
|
|
2508
2613
|
await new Promise((r) => setTimeout(r, nextPollMs));
|
|
@@ -2515,6 +2620,7 @@ var AggClient = class {
|
|
|
2515
2620
|
pendingSignatures: []
|
|
2516
2621
|
};
|
|
2517
2622
|
}
|
|
2623
|
+
ordersFilled = areOrdersFilled(polled.orders);
|
|
2518
2624
|
pending = polled.pendingSignatures ?? [];
|
|
2519
2625
|
continue;
|
|
2520
2626
|
}
|
|
@@ -2522,20 +2628,28 @@ var AggClient = class {
|
|
|
2522
2628
|
if (key === lastKey) throw new Error(`Fill for quote ${quoteId} did not advance — still awaiting steps [${key}] after signing them.`);
|
|
2523
2629
|
lastKey = key;
|
|
2524
2630
|
const signatures = [];
|
|
2525
|
-
const ordered =
|
|
2526
|
-
const userSigners =
|
|
2631
|
+
const ordered = orderSignatureRound(pending, { orderSubmitted });
|
|
2632
|
+
const userSigners = userSignerAddresses(pending, params.signingAddress);
|
|
2527
2633
|
for (const req of ordered) {
|
|
2528
2634
|
if (Date.now() > new Date(req.expiresAt).getTime()) {
|
|
2529
2635
|
if (req.optional) {
|
|
2530
2636
|
declinedOptional.add(req.stepId);
|
|
2531
2637
|
continue;
|
|
2532
2638
|
}
|
|
2639
|
+
if (isPostFillFee(req)) return {
|
|
2640
|
+
...first,
|
|
2641
|
+
pendingSignatures: []
|
|
2642
|
+
};
|
|
2533
2643
|
throw new Error(`Signature request ${req.stepId} for quote ${quoteId} expired at ${req.expiresAt}; the fill must be re-quoted.`);
|
|
2534
2644
|
}
|
|
2535
2645
|
let signed;
|
|
2536
2646
|
try {
|
|
2537
|
-
signed =
|
|
2647
|
+
signed = await withTimeout(signer(req), signatureTimeoutMs(req, userSigners));
|
|
2538
2648
|
} catch (err) {
|
|
2649
|
+
if (isPostFillFee(req)) return {
|
|
2650
|
+
...first,
|
|
2651
|
+
pendingSignatures: []
|
|
2652
|
+
};
|
|
2539
2653
|
if (!req.optional) throw err;
|
|
2540
2654
|
declinedOptional.add(req.stepId);
|
|
2541
2655
|
continue;
|
|
@@ -2553,7 +2667,7 @@ var AggClient = class {
|
|
|
2553
2667
|
continue;
|
|
2554
2668
|
}
|
|
2555
2669
|
const next = await this.submitFillSignatures(quoteId, signatures);
|
|
2556
|
-
if (signatures.some((s) => s.stepId
|
|
2670
|
+
if (signatures.some((s) => isPolymarketOrderSignatureStep(s.stepId))) orderSubmitted = true;
|
|
2557
2671
|
pending = next.pendingSignatures ?? [];
|
|
2558
2672
|
}
|
|
2559
2673
|
}
|
|
@@ -2939,6 +3053,6 @@ function createAggClient(options) {
|
|
|
2939
3053
|
return new AggClient(options);
|
|
2940
3054
|
}
|
|
2941
3055
|
//#endregion
|
|
2942
|
-
export { ACTIVE_VENUES, AccountProvider, AccountType, AggApiError, AggClient, AggWebSocket, CONFIRMED_MATCH_STATUSES, CandleBuilder, Chain, DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW, DEFAULT_BALANCE_REFILL_MAX_FEE_RAW, IMAGE_SIZES, INACTIVE_VENUES, ImageSize, LIMIT_PRICE_RAW_SCALE, MarketStatus, MatchStatus, MatchType, OPTIONAL_SIGNATURE_TIMEOUT_MS, OrderStatus, OrderType, RECURRENCE_CADENCES, RETINA_IMAGE_SIZES, SELF_CUSTODY_FILL_TIMEOUT_MS, SELF_CUSTODY_POLL_INTERVAL_MS, TERMINAL_EXECUTION_STATES, TimeInForce, TradeSide, TurnstileChallengeError, VENUES, VENUE_CHAIN_IDS, Venue, adjustLimitPriceRawToTick, aggregateMidpoint, applyOrderbookDelta, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getBalanceRefillMaximumRaw, getEffectiveDisabledVenues, getWalletAddressFromUserProfile, hasShape, isAggApiError, isBalanceRefillWithinDailyCap, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, isVenueActive, isVenueDataVisible, isVenueInactive, loadImmutableHistory, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, orderbookCrc32, parse, parseEmail, parseEmailStrict, prepareHostedVenueFunding, prepareHostedVenueRoute, projectedOrderbookChecksum, retinaImageUrl, safeParse, snapshotToOrderbook, sortVenues, toChecksumAddress };
|
|
3056
|
+
export { ACTIVE_VENUES, AccountProvider, AccountType, AggApiError, AggClient, AggWebSocket, CONFIRMED_MATCH_STATUSES, CandleBuilder, Chain, DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW, DEFAULT_BALANCE_REFILL_MAX_FEE_RAW, IMAGE_SIZES, INACTIVE_VENUES, ImageSize, LIMIT_PRICE_RAW_SCALE, MarketStatus, MatchStatus, MatchType, OPTIONAL_FEE_SIGNATURE_TIMEOUT_MS, OPTIONAL_SIGNATURE_TIMEOUT_MS, OrderStatus, OrderType, RECURRENCE_CADENCES, RETINA_IMAGE_SIZES, SELF_CUSTODY_FILL_TIMEOUT_MS, SELF_CUSTODY_POLL_INTERVAL_MS, TERMINAL_EXECUTION_STATES, TimeInForce, TradeSide, TurnstileChallengeError, VENUES, VENUE_CHAIN_IDS, Venue, adjustLimitPriceRawToTick, aggregateMidpoint, applyOrderbookDelta, areOrdersFilled, buildVenueUrl, computeBestSplitsByAmount, computeChecksum, createAggClient, enumGuard, formatMarketQuestion, formatOutcomeLabel, formatOutcomeTitle, getBalanceRefillMaximumRaw, getEffectiveDisabledVenues, getWalletAddressFromUserProfile, hasShape, isAggApiError, isBalanceRefillWithinDailyCap, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, isOptionalFeeRequest, isPolymarketOrderSignatureStep, isPostFillFeeRequest, isSameWalletAddress, isVenueActive, isVenueDataVisible, isVenueInactive, loadImmutableHistory, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, orderSignatureRound, orderbookCrc32, parse, parseEmail, parseEmailStrict, prepareHostedVenueFunding, prepareHostedVenueRoute, projectedOrderbookChecksum, retinaImageUrl, safeParse, signatureTimeoutMs, snapshotToOrderbook, sortVenues, toChecksumAddress, userSignerAddresses, withTimeout };
|
|
2943
3057
|
|
|
2944
3058
|
//# sourceMappingURL=index.mjs.map
|