@agg-build/sdk 1.2.0 → 1.2.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.
- package/README.md +9 -0
- package/dist/index.d.mts +482 -17
- package/dist/index.d.ts +482 -17
- package/dist/index.js +159 -3
- package/dist/index.mjs +157 -3
- package/dist/server.d.mts +62 -6
- package/dist/server.d.ts +62 -6
- package/dist/server.js +61 -2
- package/dist/server.mjs +58 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -76,12 +76,14 @@ __export(index_exports, {
|
|
|
76
76
|
Venue: () => Venue,
|
|
77
77
|
aggregateMidpoint: () => aggregateMidpoint,
|
|
78
78
|
applyOrderbookDelta: () => applyOrderbookDelta,
|
|
79
|
+
buildVenueUrl: () => buildVenueUrl,
|
|
79
80
|
computeBestSplitsByAmount: () => computeBestSplitsByAmount2,
|
|
80
81
|
computeChecksum: () => computeChecksum,
|
|
81
82
|
createAggClient: () => createAggClient,
|
|
82
83
|
enumGuard: () => enumGuard,
|
|
83
84
|
formatMarketQuestion: () => formatMarketQuestion,
|
|
84
85
|
formatOutcomeLabel: () => formatOutcomeLabel,
|
|
86
|
+
formatOutcomeTitle: () => formatOutcomeTitle,
|
|
85
87
|
getWalletAddressFromUserProfile: () => getWalletAddressFromUserProfile,
|
|
86
88
|
hasShape: () => hasShape,
|
|
87
89
|
isEmail: () => isEmail,
|
|
@@ -214,6 +216,29 @@ function formatMarketQuestion(venue, market) {
|
|
|
214
216
|
}
|
|
215
217
|
return market.question.trim();
|
|
216
218
|
}
|
|
219
|
+
function formatOutcomeTitle(_venue, outcome, market) {
|
|
220
|
+
var _a, _b;
|
|
221
|
+
const outcomes = (_a = market.venueMarketOutcomes) != null ? _a : [];
|
|
222
|
+
if (outcomes.length >= 2) {
|
|
223
|
+
const normalized = outcomes.map((o) => {
|
|
224
|
+
var _a2, _b2;
|
|
225
|
+
return (_b2 = (_a2 = o.title) == null ? void 0 : _a2.trim()) != null ? _b2 : "";
|
|
226
|
+
});
|
|
227
|
+
const hasAnyTitle = normalized.some((t) => t.length > 0);
|
|
228
|
+
if (hasAnyTitle && normalized.every((t) => t === normalized[0])) return null;
|
|
229
|
+
}
|
|
230
|
+
const title = (_b = outcome.title) == null ? void 0 : _b.trim();
|
|
231
|
+
if (title) return title;
|
|
232
|
+
return deriveOverUnderTitle(outcome.label, market.question);
|
|
233
|
+
}
|
|
234
|
+
var OVER_UNDER_QUESTION = /\bO\/U\s+\d/i;
|
|
235
|
+
function deriveOverUnderTitle(label, question) {
|
|
236
|
+
if (!question || !OVER_UNDER_QUESTION.test(question)) return null;
|
|
237
|
+
const normalized = label.trim().toLowerCase();
|
|
238
|
+
if (normalized === "yes") return "Over";
|
|
239
|
+
if (normalized === "no") return "Under";
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
217
242
|
|
|
218
243
|
// ../common/src/utils/auth.ts
|
|
219
244
|
function getWalletAddressFromUserProfile(user) {
|
|
@@ -560,6 +585,51 @@ var getVenueOrder = (venue) => {
|
|
|
560
585
|
};
|
|
561
586
|
var sortVenues = (venues) => [...venues].sort((a, b) => getVenueOrder(a) - getVenueOrder(b));
|
|
562
587
|
|
|
588
|
+
// ../common/src/utils/venue-url.ts
|
|
589
|
+
function buildVenueUrl(venue, opts) {
|
|
590
|
+
switch (venue) {
|
|
591
|
+
case "kalshi": {
|
|
592
|
+
const series = opts.seriesExternalId;
|
|
593
|
+
const event = opts.eventExternalId;
|
|
594
|
+
if (series && event) {
|
|
595
|
+
return `https://kalshi.com/markets/${series.toLowerCase()}/${event.toLowerCase()}`;
|
|
596
|
+
}
|
|
597
|
+
return null;
|
|
598
|
+
}
|
|
599
|
+
case "polymarket": {
|
|
600
|
+
if (opts.eventSlug) return `https://polymarket.com/event/${opts.eventSlug}`;
|
|
601
|
+
if (opts.conditionId) return `https://polymarket.com/market/${opts.conditionId}`;
|
|
602
|
+
return null;
|
|
603
|
+
}
|
|
604
|
+
case "predict": {
|
|
605
|
+
if (opts.eventSlug) return `https://predict.fun/market/${opts.eventSlug}`;
|
|
606
|
+
return null;
|
|
607
|
+
}
|
|
608
|
+
case "limitless": {
|
|
609
|
+
if (opts.eventSlug) return `https://limitless.exchange/markets/${opts.eventSlug}`;
|
|
610
|
+
return null;
|
|
611
|
+
}
|
|
612
|
+
case "opinion": {
|
|
613
|
+
if (opts.eventSlug) return `https://www.opinion.trade/market/${opts.eventSlug}`;
|
|
614
|
+
return null;
|
|
615
|
+
}
|
|
616
|
+
case "myriad": {
|
|
617
|
+
if (opts.eventSlug) return `https://myriad.markets/markets/${opts.eventSlug}`;
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
case "hyperliquid": {
|
|
621
|
+
if (opts.eventSlug) return `https://app.hyperliquid.xyz/trade/${opts.eventSlug}`;
|
|
622
|
+
return null;
|
|
623
|
+
}
|
|
624
|
+
case "probable": {
|
|
625
|
+
if (opts.eventSlug) return `https://probable.markets/event/${opts.eventSlug}`;
|
|
626
|
+
return null;
|
|
627
|
+
}
|
|
628
|
+
default:
|
|
629
|
+
return null;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
563
633
|
// src/orderbook-utils.ts
|
|
564
634
|
var PRICE_KEY_SCALE = 1e9;
|
|
565
635
|
function crc32(str) {
|
|
@@ -1592,6 +1662,7 @@ var AggClient = class {
|
|
|
1592
1662
|
let message = response.status === 404 ? "Market not found" : `AGG API error: ${response.status} ${response.statusText}`;
|
|
1593
1663
|
let code;
|
|
1594
1664
|
let retryable;
|
|
1665
|
+
let errors;
|
|
1595
1666
|
try {
|
|
1596
1667
|
const body = yield response.json();
|
|
1597
1668
|
if (typeof body.message === "string" && body.message.length > 0) {
|
|
@@ -1603,12 +1674,20 @@ var AggClient = class {
|
|
|
1603
1674
|
if (typeof body.retryable === "boolean") {
|
|
1604
1675
|
retryable = body.retryable;
|
|
1605
1676
|
}
|
|
1677
|
+
if (Array.isArray(body.errors)) {
|
|
1678
|
+
const parsed = body.errors.map((e) => ({
|
|
1679
|
+
field: typeof (e == null ? void 0 : e.field) === "string" ? e.field : "",
|
|
1680
|
+
message: typeof (e == null ? void 0 : e.message) === "string" ? e.message : ""
|
|
1681
|
+
})).filter((e) => e.message.length > 0);
|
|
1682
|
+
if (parsed.length > 0) errors = parsed;
|
|
1683
|
+
}
|
|
1606
1684
|
} catch (e) {
|
|
1607
1685
|
}
|
|
1608
1686
|
const error = new Error(message);
|
|
1609
1687
|
error.status = response.status;
|
|
1610
1688
|
if (code) error.code = code;
|
|
1611
1689
|
if (retryable !== void 0) error.retryable = retryable;
|
|
1690
|
+
if (errors) error.errors = errors;
|
|
1612
1691
|
throw error;
|
|
1613
1692
|
});
|
|
1614
1693
|
}
|
|
@@ -1999,11 +2078,18 @@ Issued At: ${issuedAt}`;
|
|
|
1999
2078
|
});
|
|
2000
2079
|
});
|
|
2001
2080
|
}
|
|
2002
|
-
/**
|
|
2081
|
+
/**
|
|
2082
|
+
* List execution orders for the authenticated user (cursor pagination).
|
|
2083
|
+
*
|
|
2084
|
+
* Pass `quoteId` to fetch every leg of a multi-venue split route in
|
|
2085
|
+
* one call — `useQuoteSummary(quoteId)` reduces the list into a
|
|
2086
|
+
* rollup (total cost, share-weighted avg price, to-win).
|
|
2087
|
+
*/
|
|
2003
2088
|
getExecutionOrders() {
|
|
2004
2089
|
return __async(this, arguments, function* (params = {}) {
|
|
2005
2090
|
const query = {};
|
|
2006
2091
|
if (params.orderId) query.orderId = params.orderId;
|
|
2092
|
+
if (params.quoteId) query.quoteId = params.quoteId;
|
|
2007
2093
|
if (params.status) query.status = params.status;
|
|
2008
2094
|
if (params.cursor) query.cursor = params.cursor;
|
|
2009
2095
|
if (params.limit != null) query.limit = String(params.limit);
|
|
@@ -2070,6 +2156,7 @@ Issued At: ${issuedAt}`;
|
|
|
2070
2156
|
if ((options == null ? void 0 : options.status) && options.status.length > 0) query.status = options.status;
|
|
2071
2157
|
if (options == null ? void 0 : options.sortBy) query.sortBy = options.sortBy;
|
|
2072
2158
|
if (options == null ? void 0 : options.sortDir) query.sortDir = options.sortDir;
|
|
2159
|
+
if (options == null ? void 0 : options.recurrence) query.recurrence = options.recurrence;
|
|
2073
2160
|
if ((options == null ? void 0 : options.limit) != null) query.limit = String(options.limit);
|
|
2074
2161
|
if (options == null ? void 0 : options.cursor) query.cursor = options.cursor;
|
|
2075
2162
|
if ((options == null ? void 0 : options.minYesPrice) != null) query.minYesPrice = String(options.minYesPrice);
|
|
@@ -2115,6 +2202,7 @@ Issued At: ${issuedAt}`;
|
|
|
2115
2202
|
const query = {};
|
|
2116
2203
|
if ((options == null ? void 0 : options.limit) != null) query.limit = String(options.limit);
|
|
2117
2204
|
if (options == null ? void 0 : options.cursor) query.cursor = options.cursor;
|
|
2205
|
+
if (options == null ? void 0 : options.parentId) query.parentId = options.parentId;
|
|
2118
2206
|
return this.request("/categories", {
|
|
2119
2207
|
query: Object.keys(query).length > 0 ? query : void 0
|
|
2120
2208
|
});
|
|
@@ -2126,7 +2214,14 @@ Issued At: ${issuedAt}`;
|
|
|
2126
2214
|
return this.request("/app/config", init);
|
|
2127
2215
|
});
|
|
2128
2216
|
}
|
|
2129
|
-
/**
|
|
2217
|
+
/**
|
|
2218
|
+
* Search events or markets by query string. Supports cursor-based pagination.
|
|
2219
|
+
*
|
|
2220
|
+
* Pass `deep: true` on submit (Enter / Search button) to opt in to the
|
|
2221
|
+
* server-side reranker. Leave it off for debounced typeahead — the wire
|
|
2222
|
+
* format intentionally omits the param so the server hits the cheaper
|
|
2223
|
+
* (and longer-TTL) light cache slot.
|
|
2224
|
+
*/
|
|
2130
2225
|
search(params) {
|
|
2131
2226
|
return __async(this, null, function* () {
|
|
2132
2227
|
const query = {
|
|
@@ -2136,11 +2231,66 @@ Issued At: ${issuedAt}`;
|
|
|
2136
2231
|
if (params.categoryIds && params.categoryIds.length > 0) query.categoryIds = params.categoryIds;
|
|
2137
2232
|
if (params.limit != null) query.limit = String(params.limit);
|
|
2138
2233
|
if (params.cursor) query.cursor = params.cursor;
|
|
2234
|
+
if (params.deep) query.deepSearch = "true";
|
|
2139
2235
|
return this.request("/search", {
|
|
2140
2236
|
query
|
|
2141
2237
|
});
|
|
2142
2238
|
});
|
|
2143
2239
|
}
|
|
2240
|
+
/** Get Correlated Markets processing and embedding coverage. */
|
|
2241
|
+
getCorrelatedMarketsStatus(options) {
|
|
2242
|
+
return __async(this, null, function* () {
|
|
2243
|
+
return this.request("/correlated-markets/status", {
|
|
2244
|
+
signal: options == null ? void 0 : options.signal
|
|
2245
|
+
});
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
/** Get the generated correlated market signals for a market. */
|
|
2249
|
+
getMarketCorrelatedSignals(venueMarketId, options) {
|
|
2250
|
+
return __async(this, null, function* () {
|
|
2251
|
+
const query = {};
|
|
2252
|
+
if ((options == null ? void 0 : options.includeResolved) != null) query.includeResolved = String(options.includeResolved);
|
|
2253
|
+
return this.request(
|
|
2254
|
+
`/correlated-markets/${encodeURIComponent(venueMarketId)}`,
|
|
2255
|
+
{ query, signal: options == null ? void 0 : options.signal }
|
|
2256
|
+
);
|
|
2257
|
+
});
|
|
2258
|
+
}
|
|
2259
|
+
/** Search markets by Correlated Markets signal similarity. */
|
|
2260
|
+
queryCorrelatedMarkets(params, options) {
|
|
2261
|
+
return __async(this, null, function* () {
|
|
2262
|
+
return this.request("/correlated-markets/query", {
|
|
2263
|
+
method: "POST",
|
|
2264
|
+
body: JSON.stringify(params),
|
|
2265
|
+
signal: options == null ? void 0 : options.signal
|
|
2266
|
+
});
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
/** Get expansion and hedge candidates for an already-processed market. */
|
|
2270
|
+
getCorrelatedMarketCascade(params, options) {
|
|
2271
|
+
return __async(this, null, function* () {
|
|
2272
|
+
const query = {};
|
|
2273
|
+
if (params.side) query.side = params.side;
|
|
2274
|
+
if (params.mode) query.mode = params.mode;
|
|
2275
|
+
if (params.limit != null) query.limit = String(params.limit);
|
|
2276
|
+
if (params.cursor) query.cursor = params.cursor;
|
|
2277
|
+
if (params.includeResolved != null) query.includeResolved = String(params.includeResolved);
|
|
2278
|
+
return this.request(
|
|
2279
|
+
`/correlated-markets/cascade/${encodeURIComponent(params.venueMarketId)}`,
|
|
2280
|
+
{ query, signal: options == null ? void 0 : options.signal }
|
|
2281
|
+
);
|
|
2282
|
+
});
|
|
2283
|
+
}
|
|
2284
|
+
/** Resolve a market by ID, venue identifier, slug, conditionId, or text, then return candidates. */
|
|
2285
|
+
resolveCorrelatedMarkets(params, options) {
|
|
2286
|
+
return __async(this, null, function* () {
|
|
2287
|
+
return this.request("/correlated-markets/resolve", {
|
|
2288
|
+
method: "POST",
|
|
2289
|
+
body: JSON.stringify(params),
|
|
2290
|
+
signal: options == null ? void 0 : options.signal
|
|
2291
|
+
});
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2144
2294
|
// --- Chart data ---
|
|
2145
2295
|
/** Get the canonical TradingView-style bar series for a single venue market outcome. */
|
|
2146
2296
|
getChartBars(params, options) {
|
|
@@ -2176,7 +2326,9 @@ Issued At: ${issuedAt}`;
|
|
|
2176
2326
|
getMidpoints(paramsOrVenueMarketIds, options) {
|
|
2177
2327
|
return __async(this, null, function* () {
|
|
2178
2328
|
const venueMarketIds = Array.isArray(paramsOrVenueMarketIds) ? paramsOrVenueMarketIds : paramsOrVenueMarketIds.venueMarketIds;
|
|
2329
|
+
const bestPrice = !Array.isArray(paramsOrVenueMarketIds) ? paramsOrVenueMarketIds.bestPrice : options == null ? void 0 : options.bestPrice;
|
|
2179
2330
|
const query = { venueMarketIds };
|
|
2331
|
+
if (bestPrice) query.bestPrice = "true";
|
|
2180
2332
|
return this.request("/midpoints", {
|
|
2181
2333
|
query,
|
|
2182
2334
|
signal: options == null ? void 0 : options.signal
|
|
@@ -2208,7 +2360,7 @@ Issued At: ${issuedAt}`;
|
|
|
2208
2360
|
*/
|
|
2209
2361
|
getSmartRoute(params, options) {
|
|
2210
2362
|
return __async(this, null, function* () {
|
|
2211
|
-
var _a, _b;
|
|
2363
|
+
var _a, _b, _c;
|
|
2212
2364
|
const venueMarketOutcomeId = (_b = (_a = params.venueMarketOutcomeId) != null ? _a : params.venueMarketId) != null ? _b : params.outcomeId;
|
|
2213
2365
|
if (!venueMarketOutcomeId) {
|
|
2214
2366
|
throw new Error("getSmartRoute requires venueMarketOutcomeId");
|
|
@@ -2219,7 +2371,9 @@ Issued At: ${issuedAt}`;
|
|
|
2219
2371
|
if (params.chainBalances) query.chainBalances = JSON.stringify(params.chainBalances);
|
|
2220
2372
|
if (params.slipCapBps != null) query.slipCapBps = String(params.slipCapBps);
|
|
2221
2373
|
if (params.compareVenues) query.compareVenues = "true";
|
|
2374
|
+
if ((_c = params.allowedVenues) == null ? void 0 : _c.length) query.allowedVenues = params.allowedVenues.map(String);
|
|
2222
2375
|
if (params.tradeSide) query.side = params.tradeSide;
|
|
2376
|
+
if (params.deepEstimate) query.deepEstimate = "true";
|
|
2223
2377
|
const response = yield this.request(
|
|
2224
2378
|
`/orderbook/${encodeURIComponent(venueMarketOutcomeId)}/route`,
|
|
2225
2379
|
{ query, signal: options == null ? void 0 : options.signal }
|
|
@@ -2576,12 +2730,14 @@ function createAggClient(options) {
|
|
|
2576
2730
|
Venue,
|
|
2577
2731
|
aggregateMidpoint,
|
|
2578
2732
|
applyOrderbookDelta,
|
|
2733
|
+
buildVenueUrl,
|
|
2579
2734
|
computeBestSplitsByAmount,
|
|
2580
2735
|
computeChecksum,
|
|
2581
2736
|
createAggClient,
|
|
2582
2737
|
enumGuard,
|
|
2583
2738
|
formatMarketQuestion,
|
|
2584
2739
|
formatOutcomeLabel,
|
|
2740
|
+
formatOutcomeTitle,
|
|
2585
2741
|
getWalletAddressFromUserProfile,
|
|
2586
2742
|
hasShape,
|
|
2587
2743
|
isEmail,
|
package/dist/index.mjs
CHANGED
|
@@ -117,6 +117,29 @@ function formatMarketQuestion(venue, market) {
|
|
|
117
117
|
}
|
|
118
118
|
return market.question.trim();
|
|
119
119
|
}
|
|
120
|
+
function formatOutcomeTitle(_venue, outcome, market) {
|
|
121
|
+
var _a, _b;
|
|
122
|
+
const outcomes = (_a = market.venueMarketOutcomes) != null ? _a : [];
|
|
123
|
+
if (outcomes.length >= 2) {
|
|
124
|
+
const normalized = outcomes.map((o) => {
|
|
125
|
+
var _a2, _b2;
|
|
126
|
+
return (_b2 = (_a2 = o.title) == null ? void 0 : _a2.trim()) != null ? _b2 : "";
|
|
127
|
+
});
|
|
128
|
+
const hasAnyTitle = normalized.some((t) => t.length > 0);
|
|
129
|
+
if (hasAnyTitle && normalized.every((t) => t === normalized[0])) return null;
|
|
130
|
+
}
|
|
131
|
+
const title = (_b = outcome.title) == null ? void 0 : _b.trim();
|
|
132
|
+
if (title) return title;
|
|
133
|
+
return deriveOverUnderTitle(outcome.label, market.question);
|
|
134
|
+
}
|
|
135
|
+
var OVER_UNDER_QUESTION = /\bO\/U\s+\d/i;
|
|
136
|
+
function deriveOverUnderTitle(label, question) {
|
|
137
|
+
if (!question || !OVER_UNDER_QUESTION.test(question)) return null;
|
|
138
|
+
const normalized = label.trim().toLowerCase();
|
|
139
|
+
if (normalized === "yes") return "Over";
|
|
140
|
+
if (normalized === "no") return "Under";
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
120
143
|
|
|
121
144
|
// ../common/src/utils/auth.ts
|
|
122
145
|
function getWalletAddressFromUserProfile(user) {
|
|
@@ -463,6 +486,51 @@ var getVenueOrder = (venue) => {
|
|
|
463
486
|
};
|
|
464
487
|
var sortVenues = (venues) => [...venues].sort((a, b) => getVenueOrder(a) - getVenueOrder(b));
|
|
465
488
|
|
|
489
|
+
// ../common/src/utils/venue-url.ts
|
|
490
|
+
function buildVenueUrl(venue, opts) {
|
|
491
|
+
switch (venue) {
|
|
492
|
+
case "kalshi": {
|
|
493
|
+
const series = opts.seriesExternalId;
|
|
494
|
+
const event = opts.eventExternalId;
|
|
495
|
+
if (series && event) {
|
|
496
|
+
return `https://kalshi.com/markets/${series.toLowerCase()}/${event.toLowerCase()}`;
|
|
497
|
+
}
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
case "polymarket": {
|
|
501
|
+
if (opts.eventSlug) return `https://polymarket.com/event/${opts.eventSlug}`;
|
|
502
|
+
if (opts.conditionId) return `https://polymarket.com/market/${opts.conditionId}`;
|
|
503
|
+
return null;
|
|
504
|
+
}
|
|
505
|
+
case "predict": {
|
|
506
|
+
if (opts.eventSlug) return `https://predict.fun/market/${opts.eventSlug}`;
|
|
507
|
+
return null;
|
|
508
|
+
}
|
|
509
|
+
case "limitless": {
|
|
510
|
+
if (opts.eventSlug) return `https://limitless.exchange/markets/${opts.eventSlug}`;
|
|
511
|
+
return null;
|
|
512
|
+
}
|
|
513
|
+
case "opinion": {
|
|
514
|
+
if (opts.eventSlug) return `https://www.opinion.trade/market/${opts.eventSlug}`;
|
|
515
|
+
return null;
|
|
516
|
+
}
|
|
517
|
+
case "myriad": {
|
|
518
|
+
if (opts.eventSlug) return `https://myriad.markets/markets/${opts.eventSlug}`;
|
|
519
|
+
return null;
|
|
520
|
+
}
|
|
521
|
+
case "hyperliquid": {
|
|
522
|
+
if (opts.eventSlug) return `https://app.hyperliquid.xyz/trade/${opts.eventSlug}`;
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
case "probable": {
|
|
526
|
+
if (opts.eventSlug) return `https://probable.markets/event/${opts.eventSlug}`;
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
default:
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
466
534
|
// src/orderbook-utils.ts
|
|
467
535
|
var PRICE_KEY_SCALE = 1e9;
|
|
468
536
|
function crc32(str) {
|
|
@@ -1495,6 +1563,7 @@ var AggClient = class {
|
|
|
1495
1563
|
let message = response.status === 404 ? "Market not found" : `AGG API error: ${response.status} ${response.statusText}`;
|
|
1496
1564
|
let code;
|
|
1497
1565
|
let retryable;
|
|
1566
|
+
let errors;
|
|
1498
1567
|
try {
|
|
1499
1568
|
const body = yield response.json();
|
|
1500
1569
|
if (typeof body.message === "string" && body.message.length > 0) {
|
|
@@ -1506,12 +1575,20 @@ var AggClient = class {
|
|
|
1506
1575
|
if (typeof body.retryable === "boolean") {
|
|
1507
1576
|
retryable = body.retryable;
|
|
1508
1577
|
}
|
|
1578
|
+
if (Array.isArray(body.errors)) {
|
|
1579
|
+
const parsed = body.errors.map((e) => ({
|
|
1580
|
+
field: typeof (e == null ? void 0 : e.field) === "string" ? e.field : "",
|
|
1581
|
+
message: typeof (e == null ? void 0 : e.message) === "string" ? e.message : ""
|
|
1582
|
+
})).filter((e) => e.message.length > 0);
|
|
1583
|
+
if (parsed.length > 0) errors = parsed;
|
|
1584
|
+
}
|
|
1509
1585
|
} catch (e) {
|
|
1510
1586
|
}
|
|
1511
1587
|
const error = new Error(message);
|
|
1512
1588
|
error.status = response.status;
|
|
1513
1589
|
if (code) error.code = code;
|
|
1514
1590
|
if (retryable !== void 0) error.retryable = retryable;
|
|
1591
|
+
if (errors) error.errors = errors;
|
|
1515
1592
|
throw error;
|
|
1516
1593
|
});
|
|
1517
1594
|
}
|
|
@@ -1902,11 +1979,18 @@ Issued At: ${issuedAt}`;
|
|
|
1902
1979
|
});
|
|
1903
1980
|
});
|
|
1904
1981
|
}
|
|
1905
|
-
/**
|
|
1982
|
+
/**
|
|
1983
|
+
* List execution orders for the authenticated user (cursor pagination).
|
|
1984
|
+
*
|
|
1985
|
+
* Pass `quoteId` to fetch every leg of a multi-venue split route in
|
|
1986
|
+
* one call — `useQuoteSummary(quoteId)` reduces the list into a
|
|
1987
|
+
* rollup (total cost, share-weighted avg price, to-win).
|
|
1988
|
+
*/
|
|
1906
1989
|
getExecutionOrders() {
|
|
1907
1990
|
return __async(this, arguments, function* (params = {}) {
|
|
1908
1991
|
const query = {};
|
|
1909
1992
|
if (params.orderId) query.orderId = params.orderId;
|
|
1993
|
+
if (params.quoteId) query.quoteId = params.quoteId;
|
|
1910
1994
|
if (params.status) query.status = params.status;
|
|
1911
1995
|
if (params.cursor) query.cursor = params.cursor;
|
|
1912
1996
|
if (params.limit != null) query.limit = String(params.limit);
|
|
@@ -1973,6 +2057,7 @@ Issued At: ${issuedAt}`;
|
|
|
1973
2057
|
if ((options == null ? void 0 : options.status) && options.status.length > 0) query.status = options.status;
|
|
1974
2058
|
if (options == null ? void 0 : options.sortBy) query.sortBy = options.sortBy;
|
|
1975
2059
|
if (options == null ? void 0 : options.sortDir) query.sortDir = options.sortDir;
|
|
2060
|
+
if (options == null ? void 0 : options.recurrence) query.recurrence = options.recurrence;
|
|
1976
2061
|
if ((options == null ? void 0 : options.limit) != null) query.limit = String(options.limit);
|
|
1977
2062
|
if (options == null ? void 0 : options.cursor) query.cursor = options.cursor;
|
|
1978
2063
|
if ((options == null ? void 0 : options.minYesPrice) != null) query.minYesPrice = String(options.minYesPrice);
|
|
@@ -2018,6 +2103,7 @@ Issued At: ${issuedAt}`;
|
|
|
2018
2103
|
const query = {};
|
|
2019
2104
|
if ((options == null ? void 0 : options.limit) != null) query.limit = String(options.limit);
|
|
2020
2105
|
if (options == null ? void 0 : options.cursor) query.cursor = options.cursor;
|
|
2106
|
+
if (options == null ? void 0 : options.parentId) query.parentId = options.parentId;
|
|
2021
2107
|
return this.request("/categories", {
|
|
2022
2108
|
query: Object.keys(query).length > 0 ? query : void 0
|
|
2023
2109
|
});
|
|
@@ -2029,7 +2115,14 @@ Issued At: ${issuedAt}`;
|
|
|
2029
2115
|
return this.request("/app/config", init);
|
|
2030
2116
|
});
|
|
2031
2117
|
}
|
|
2032
|
-
/**
|
|
2118
|
+
/**
|
|
2119
|
+
* Search events or markets by query string. Supports cursor-based pagination.
|
|
2120
|
+
*
|
|
2121
|
+
* Pass `deep: true` on submit (Enter / Search button) to opt in to the
|
|
2122
|
+
* server-side reranker. Leave it off for debounced typeahead — the wire
|
|
2123
|
+
* format intentionally omits the param so the server hits the cheaper
|
|
2124
|
+
* (and longer-TTL) light cache slot.
|
|
2125
|
+
*/
|
|
2033
2126
|
search(params) {
|
|
2034
2127
|
return __async(this, null, function* () {
|
|
2035
2128
|
const query = {
|
|
@@ -2039,11 +2132,66 @@ Issued At: ${issuedAt}`;
|
|
|
2039
2132
|
if (params.categoryIds && params.categoryIds.length > 0) query.categoryIds = params.categoryIds;
|
|
2040
2133
|
if (params.limit != null) query.limit = String(params.limit);
|
|
2041
2134
|
if (params.cursor) query.cursor = params.cursor;
|
|
2135
|
+
if (params.deep) query.deepSearch = "true";
|
|
2042
2136
|
return this.request("/search", {
|
|
2043
2137
|
query
|
|
2044
2138
|
});
|
|
2045
2139
|
});
|
|
2046
2140
|
}
|
|
2141
|
+
/** Get Correlated Markets processing and embedding coverage. */
|
|
2142
|
+
getCorrelatedMarketsStatus(options) {
|
|
2143
|
+
return __async(this, null, function* () {
|
|
2144
|
+
return this.request("/correlated-markets/status", {
|
|
2145
|
+
signal: options == null ? void 0 : options.signal
|
|
2146
|
+
});
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2149
|
+
/** Get the generated correlated market signals for a market. */
|
|
2150
|
+
getMarketCorrelatedSignals(venueMarketId, options) {
|
|
2151
|
+
return __async(this, null, function* () {
|
|
2152
|
+
const query = {};
|
|
2153
|
+
if ((options == null ? void 0 : options.includeResolved) != null) query.includeResolved = String(options.includeResolved);
|
|
2154
|
+
return this.request(
|
|
2155
|
+
`/correlated-markets/${encodeURIComponent(venueMarketId)}`,
|
|
2156
|
+
{ query, signal: options == null ? void 0 : options.signal }
|
|
2157
|
+
);
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
/** Search markets by Correlated Markets signal similarity. */
|
|
2161
|
+
queryCorrelatedMarkets(params, options) {
|
|
2162
|
+
return __async(this, null, function* () {
|
|
2163
|
+
return this.request("/correlated-markets/query", {
|
|
2164
|
+
method: "POST",
|
|
2165
|
+
body: JSON.stringify(params),
|
|
2166
|
+
signal: options == null ? void 0 : options.signal
|
|
2167
|
+
});
|
|
2168
|
+
});
|
|
2169
|
+
}
|
|
2170
|
+
/** Get expansion and hedge candidates for an already-processed market. */
|
|
2171
|
+
getCorrelatedMarketCascade(params, options) {
|
|
2172
|
+
return __async(this, null, function* () {
|
|
2173
|
+
const query = {};
|
|
2174
|
+
if (params.side) query.side = params.side;
|
|
2175
|
+
if (params.mode) query.mode = params.mode;
|
|
2176
|
+
if (params.limit != null) query.limit = String(params.limit);
|
|
2177
|
+
if (params.cursor) query.cursor = params.cursor;
|
|
2178
|
+
if (params.includeResolved != null) query.includeResolved = String(params.includeResolved);
|
|
2179
|
+
return this.request(
|
|
2180
|
+
`/correlated-markets/cascade/${encodeURIComponent(params.venueMarketId)}`,
|
|
2181
|
+
{ query, signal: options == null ? void 0 : options.signal }
|
|
2182
|
+
);
|
|
2183
|
+
});
|
|
2184
|
+
}
|
|
2185
|
+
/** Resolve a market by ID, venue identifier, slug, conditionId, or text, then return candidates. */
|
|
2186
|
+
resolveCorrelatedMarkets(params, options) {
|
|
2187
|
+
return __async(this, null, function* () {
|
|
2188
|
+
return this.request("/correlated-markets/resolve", {
|
|
2189
|
+
method: "POST",
|
|
2190
|
+
body: JSON.stringify(params),
|
|
2191
|
+
signal: options == null ? void 0 : options.signal
|
|
2192
|
+
});
|
|
2193
|
+
});
|
|
2194
|
+
}
|
|
2047
2195
|
// --- Chart data ---
|
|
2048
2196
|
/** Get the canonical TradingView-style bar series for a single venue market outcome. */
|
|
2049
2197
|
getChartBars(params, options) {
|
|
@@ -2079,7 +2227,9 @@ Issued At: ${issuedAt}`;
|
|
|
2079
2227
|
getMidpoints(paramsOrVenueMarketIds, options) {
|
|
2080
2228
|
return __async(this, null, function* () {
|
|
2081
2229
|
const venueMarketIds = Array.isArray(paramsOrVenueMarketIds) ? paramsOrVenueMarketIds : paramsOrVenueMarketIds.venueMarketIds;
|
|
2230
|
+
const bestPrice = !Array.isArray(paramsOrVenueMarketIds) ? paramsOrVenueMarketIds.bestPrice : options == null ? void 0 : options.bestPrice;
|
|
2082
2231
|
const query = { venueMarketIds };
|
|
2232
|
+
if (bestPrice) query.bestPrice = "true";
|
|
2083
2233
|
return this.request("/midpoints", {
|
|
2084
2234
|
query,
|
|
2085
2235
|
signal: options == null ? void 0 : options.signal
|
|
@@ -2111,7 +2261,7 @@ Issued At: ${issuedAt}`;
|
|
|
2111
2261
|
*/
|
|
2112
2262
|
getSmartRoute(params, options) {
|
|
2113
2263
|
return __async(this, null, function* () {
|
|
2114
|
-
var _a, _b;
|
|
2264
|
+
var _a, _b, _c;
|
|
2115
2265
|
const venueMarketOutcomeId = (_b = (_a = params.venueMarketOutcomeId) != null ? _a : params.venueMarketId) != null ? _b : params.outcomeId;
|
|
2116
2266
|
if (!venueMarketOutcomeId) {
|
|
2117
2267
|
throw new Error("getSmartRoute requires venueMarketOutcomeId");
|
|
@@ -2122,7 +2272,9 @@ Issued At: ${issuedAt}`;
|
|
|
2122
2272
|
if (params.chainBalances) query.chainBalances = JSON.stringify(params.chainBalances);
|
|
2123
2273
|
if (params.slipCapBps != null) query.slipCapBps = String(params.slipCapBps);
|
|
2124
2274
|
if (params.compareVenues) query.compareVenues = "true";
|
|
2275
|
+
if ((_c = params.allowedVenues) == null ? void 0 : _c.length) query.allowedVenues = params.allowedVenues.map(String);
|
|
2125
2276
|
if (params.tradeSide) query.side = params.tradeSide;
|
|
2277
|
+
if (params.deepEstimate) query.deepEstimate = "true";
|
|
2126
2278
|
const response = yield this.request(
|
|
2127
2279
|
`/orderbook/${encodeURIComponent(venueMarketOutcomeId)}/route`,
|
|
2128
2280
|
{ query, signal: options == null ? void 0 : options.signal }
|
|
@@ -2478,12 +2630,14 @@ export {
|
|
|
2478
2630
|
Venue,
|
|
2479
2631
|
aggregateMidpoint,
|
|
2480
2632
|
applyOrderbookDelta,
|
|
2633
|
+
buildVenueUrl,
|
|
2481
2634
|
computeBestSplitsByAmount2 as computeBestSplitsByAmount,
|
|
2482
2635
|
computeChecksum,
|
|
2483
2636
|
createAggClient,
|
|
2484
2637
|
enumGuard,
|
|
2485
2638
|
formatMarketQuestion,
|
|
2486
2639
|
formatOutcomeLabel,
|
|
2640
|
+
formatOutcomeTitle,
|
|
2487
2641
|
getWalletAddressFromUserProfile,
|
|
2488
2642
|
hasShape,
|
|
2489
2643
|
isEmail,
|
package/dist/server.d.mts
CHANGED
|
@@ -12,6 +12,16 @@ interface VerifyWebhookOptions {
|
|
|
12
12
|
}
|
|
13
13
|
declare function verifyWebhook(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): void;
|
|
14
14
|
declare function parseWebhookEvent(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): WebhookEvent;
|
|
15
|
+
/**
|
|
16
|
+
* Async, edge-runtime-friendly variant of {@link verifyWebhook}. Same
|
|
17
|
+
* Svix v1 signing scheme. Use this in Cloudflare Workers / Vercel Edge /
|
|
18
|
+
* Deno / Bun. The sync variant remains available for Node.js consumers.
|
|
19
|
+
*/
|
|
20
|
+
declare function verifyWebhookAsync(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Async, edge-runtime-friendly variant of {@link parseWebhookEvent}.
|
|
23
|
+
*/
|
|
24
|
+
declare function parseWebhookEventAsync(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): Promise<WebhookEvent>;
|
|
15
25
|
interface WebhookEventBase {
|
|
16
26
|
id: string;
|
|
17
27
|
createdAt: string;
|
|
@@ -21,6 +31,8 @@ interface AccountsCreatedEvent extends WebhookEventBase {
|
|
|
21
31
|
data: {
|
|
22
32
|
userId: string;
|
|
23
33
|
appId: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
email: string | null;
|
|
24
36
|
};
|
|
25
37
|
}
|
|
26
38
|
interface AccountsLinkedEvent extends WebhookEventBase {
|
|
@@ -37,6 +49,7 @@ interface WalletsReadyEvent extends WebhookEventBase {
|
|
|
37
49
|
userId: string;
|
|
38
50
|
evmAddress: string;
|
|
39
51
|
svmAddress: string;
|
|
52
|
+
createdAt: string;
|
|
40
53
|
};
|
|
41
54
|
}
|
|
42
55
|
interface TradesPlacedEvent extends WebhookEventBase {
|
|
@@ -45,8 +58,16 @@ interface TradesPlacedEvent extends WebhookEventBase {
|
|
|
45
58
|
orderId: string;
|
|
46
59
|
userId: string;
|
|
47
60
|
side: string;
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
timestamp: string;
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated Never emitted by the server in 1.x — the SDK type lied
|
|
64
|
+
* here for several releases. Reads always return `undefined`. The field
|
|
65
|
+
* is retained as `undefined`-typed for one minor release so existing
|
|
66
|
+
* partner code that destructures it keeps compiling; remove in 2.0.
|
|
67
|
+
*/
|
|
68
|
+
venue?: undefined;
|
|
69
|
+
/** @deprecated See `venue`. */
|
|
70
|
+
venueMarketId?: undefined;
|
|
50
71
|
};
|
|
51
72
|
}
|
|
52
73
|
interface TradesFilledEvent extends WebhookEventBase {
|
|
@@ -55,16 +76,49 @@ interface TradesFilledEvent extends WebhookEventBase {
|
|
|
55
76
|
orderId: string;
|
|
56
77
|
userId: string;
|
|
57
78
|
status: string;
|
|
58
|
-
|
|
59
|
-
|
|
79
|
+
timestamp: string;
|
|
80
|
+
/**
|
|
81
|
+
* Post-execution accuracy data. All `*Raw` values are decimal strings in
|
|
82
|
+
* 6-decimal atomic units. `*PriceRaw` are decimal strings (e.g. "0.5").
|
|
83
|
+
* `partialFillReason` is set only on `status === "partial_fill"`.
|
|
84
|
+
*/
|
|
85
|
+
filledAmountRaw?: string;
|
|
86
|
+
quotedSharesRaw?: string;
|
|
87
|
+
actualSharesRaw?: string;
|
|
88
|
+
quotedToWinRaw?: string;
|
|
89
|
+
actualToWinRaw?: string;
|
|
90
|
+
quotedPriceRaw?: string;
|
|
91
|
+
executionPriceRaw?: string;
|
|
92
|
+
partialFillReason?: string;
|
|
93
|
+
/** @deprecated See `executionPriceRaw` — never emitted; remove in 2.0. */
|
|
94
|
+
fillPrice?: undefined;
|
|
95
|
+
/** @deprecated See `actualSharesRaw` / `filledAmountRaw` — never emitted; remove in 2.0. */
|
|
96
|
+
fillSize?: undefined;
|
|
60
97
|
};
|
|
61
98
|
}
|
|
62
99
|
interface MarketsResolvedEvent extends WebhookEventBase {
|
|
63
100
|
type: "markets.resolved";
|
|
64
101
|
data: {
|
|
65
102
|
venueMarketId: string;
|
|
66
|
-
|
|
103
|
+
externalIdentifier: string;
|
|
104
|
+
status: string;
|
|
105
|
+
outcomes: Array<{
|
|
106
|
+
label: string;
|
|
107
|
+
winner?: boolean;
|
|
108
|
+
externalIdentifier?: string;
|
|
109
|
+
}>;
|
|
67
110
|
affectedUsersCount: number;
|
|
111
|
+
/**
|
|
112
|
+
* Path on the AGG API where this resolution's affected users can be
|
|
113
|
+
* paginated. Combine with the configured base URL — e.g.
|
|
114
|
+
* `https://api.agg.market${detailsPath}`.
|
|
115
|
+
*/
|
|
116
|
+
detailsPath: string;
|
|
117
|
+
/**
|
|
118
|
+
* @deprecated Singular `outcome` was never emitted; use `outcomes` array.
|
|
119
|
+
* Remove in 2.0.
|
|
120
|
+
*/
|
|
121
|
+
outcome?: undefined;
|
|
68
122
|
};
|
|
69
123
|
}
|
|
70
124
|
interface UnknownWebhookEvent extends WebhookEventBase {
|
|
@@ -118,7 +172,9 @@ declare class AggAdminClient {
|
|
|
118
172
|
ordersByStatus: Record<string, number>;
|
|
119
173
|
ordersByVenue: Record<string, number>;
|
|
120
174
|
usersLast30Days: number;
|
|
175
|
+
usersLast7Days: number;
|
|
121
176
|
ordersLast30Days: number;
|
|
177
|
+
ordersLast7Days: number;
|
|
122
178
|
}>;
|
|
123
179
|
listOrders(appId: string, query?: {
|
|
124
180
|
limit?: number;
|
|
@@ -152,4 +208,4 @@ declare class AggAdminClient {
|
|
|
152
208
|
}>;
|
|
153
209
|
}
|
|
154
210
|
|
|
155
|
-
export { type AccountsCreatedEvent, type AccountsLinkedEvent, AggAdminClient, type AggAdminClientOptions, type ExternalIdAssertion, type KnownWebhookEvent, type MarketsResolvedEvent, type TradesFilledEvent, type TradesPlacedEvent, type UnknownWebhookEvent, type VerifyWebhookOptions, type WalletsReadyEvent, type WebhookEvent, WebhookVerificationError, parseWebhookEvent, signExternalId, verifyWebhook };
|
|
211
|
+
export { type AccountsCreatedEvent, type AccountsLinkedEvent, AggAdminClient, type AggAdminClientOptions, type ExternalIdAssertion, type KnownWebhookEvent, type MarketsResolvedEvent, type TradesFilledEvent, type TradesPlacedEvent, type UnknownWebhookEvent, type VerifyWebhookOptions, type WalletsReadyEvent, type WebhookEvent, WebhookVerificationError, parseWebhookEvent, parseWebhookEventAsync, signExternalId, verifyWebhook, verifyWebhookAsync };
|