@agg-build/sdk 4.34.1 → 4.37.0
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 +28 -24
- package/dist/{agg-websocket-CsURzWkQ.d.mts → agg-websocket-BRWnvGwU.d.mts} +139 -17
- package/dist/agg-websocket-BRWnvGwU.d.mts.map +1 -0
- package/dist/{agg-websocket-CsURzWkQ.d.ts → agg-websocket-BRWnvGwU.d.ts} +139 -17
- package/dist/agg-websocket-BRWnvGwU.d.ts.map +1 -0
- package/dist/{agg-websocket-C2neMzGT.mjs → agg-websocket-C9ELOadG.mjs} +377 -63
- package/dist/agg-websocket-C9ELOadG.mjs.map +1 -0
- package/dist/{agg-websocket-MYZiMRXn.js → agg-websocket-Cq4E0T0f.js} +376 -62
- 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 -1
- package/dist/browser.mjs +2 -1
- 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 +51 -10
- package/dist/index.mjs +49 -11
- 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 +2 -1
- package/dist/market-data.mjs +2 -1
- package/dist/market-data.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/agg-websocket-C2neMzGT.mjs.map +0 -1
- package/dist/agg-websocket-CsURzWkQ.d.mts.map +0 -1
- package/dist/agg-websocket-CsURzWkQ.d.ts.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-C9ELOadG.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". */
|
|
@@ -16,6 +16,7 @@ let Venue = /* @__PURE__ */ function(Venue) {
|
|
|
16
16
|
Venue["novig"] = "novig";
|
|
17
17
|
Venue["prophetx"] = "prophetx";
|
|
18
18
|
Venue["betdex"] = "betdex";
|
|
19
|
+
Venue["lighter"] = "lighter";
|
|
19
20
|
return Venue;
|
|
20
21
|
}({});
|
|
21
22
|
/** Single source of truth for venue identifiers. */
|
|
@@ -32,9 +33,12 @@ const VENUES = [
|
|
|
32
33
|
"hyperliquid",
|
|
33
34
|
"novig",
|
|
34
35
|
"prophetx",
|
|
35
|
-
"betdex"
|
|
36
|
+
"betdex",
|
|
37
|
+
"lighter"
|
|
36
38
|
];
|
|
37
|
-
/** Canonical destination chain for venues with on-chain funding or settlement.
|
|
39
|
+
/** Canonical destination chain for venues with on-chain funding or settlement.
|
|
40
|
+
* Lighter is absent: signing chain 304 and Relay funding chain 3586256 are
|
|
41
|
+
* different identities, so one map entry would pick the wrong rail. */
|
|
38
42
|
const VENUE_CHAIN_IDS = {
|
|
39
43
|
["kalshi"]: 792703809,
|
|
40
44
|
["polymarket"]: 137,
|
|
@@ -68,7 +72,8 @@ const ACTIVE_VENUES = [
|
|
|
68
72
|
"hyperliquid",
|
|
69
73
|
"novig",
|
|
70
74
|
"prophetx",
|
|
71
|
-
"betdex"
|
|
75
|
+
"betdex",
|
|
76
|
+
"lighter"
|
|
72
77
|
];
|
|
73
78
|
/**
|
|
74
79
|
* Venues excluded from new user-facing activity. BETDEX is active at the
|
|
@@ -96,7 +101,8 @@ const DEFAULT_DISABLED_VENUES = [
|
|
|
96
101
|
"tiprun",
|
|
97
102
|
"novig",
|
|
98
103
|
"prophetx",
|
|
99
|
-
"betdex"
|
|
104
|
+
"betdex",
|
|
105
|
+
"lighter"
|
|
100
106
|
];
|
|
101
107
|
const ACTIVE_VENUE_SET = new Set(ACTIVE_VENUES);
|
|
102
108
|
const INACTIVE_VENUE_SET = new Set(INACTIVE_VENUES);
|
|
@@ -676,6 +682,7 @@ const VENUE_SORT_ORDER = [
|
|
|
676
682
|
"predict",
|
|
677
683
|
"prophetx",
|
|
678
684
|
"betdex",
|
|
685
|
+
"lighter",
|
|
679
686
|
"kalshi",
|
|
680
687
|
"limitless",
|
|
681
688
|
"myriad",
|
|
@@ -1597,6 +1604,8 @@ var AggClient = class {
|
|
|
1597
1604
|
this.signer = options.signer;
|
|
1598
1605
|
this.baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
1599
1606
|
this.wsUrl = options.wsUrl;
|
|
1607
|
+
this.orderbookUrl = options.orderbookUrl;
|
|
1608
|
+
this.orderbookLatency = options.orderbookLatency;
|
|
1600
1609
|
this.preferImmutableHistory = options.preferImmutableHistory ?? false;
|
|
1601
1610
|
this.webSocketFactory = options.webSocketFactory;
|
|
1602
1611
|
this.authOptions = options.auth;
|
|
@@ -2200,14 +2209,16 @@ var AggClient = class {
|
|
|
2200
2209
|
/**
|
|
2201
2210
|
* One user's (or, with no user, the whole app's) leaderboard stats per UTC
|
|
2202
2211
|
* day (default the last 30 days, at most 366) with a running cumulative
|
|
2203
|
-
* realized P&L, optionally for a single category.
|
|
2204
|
-
*
|
|
2212
|
+
* realized P&L, optionally for a single category. `interval: "hour"` gives
|
|
2213
|
+
* one user's stats per hour over a timestamp window (needs `apiKey`). Gross
|
|
2214
|
+
* of fees; unrealized P&L is not included.
|
|
2205
2215
|
*/
|
|
2206
2216
|
async getLeaderboardSeries(params) {
|
|
2207
2217
|
const query = {};
|
|
2208
2218
|
for (const key of [
|
|
2209
2219
|
"from",
|
|
2210
2220
|
"to",
|
|
2221
|
+
"interval",
|
|
2211
2222
|
"userId",
|
|
2212
2223
|
"externalId",
|
|
2213
2224
|
"username",
|
|
@@ -2849,14 +2860,20 @@ var AggClient = class {
|
|
|
2849
2860
|
* browser Origin check). Never in a browser: browsers cannot set handshake
|
|
2850
2861
|
* headers, and keys must not ship there.
|
|
2851
2862
|
*/
|
|
2863
|
+
withAppId(raw) {
|
|
2864
|
+
const url = new URL(raw);
|
|
2865
|
+
if (this._appId) url.searchParams.set("appId", this._appId);
|
|
2866
|
+
return url.toString();
|
|
2867
|
+
}
|
|
2852
2868
|
webSocketOptions(webSocketImpl) {
|
|
2853
2869
|
if (!this.wsUrl) throw new Error("AggClient WebSockets require wsUrl to be set in client options");
|
|
2854
|
-
const url = new URL(this.wsUrl);
|
|
2855
|
-
if (this._appId) url.searchParams.set("appId", this._appId);
|
|
2856
2870
|
const isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
2857
2871
|
const headers = this.apiKey && !isBrowser ? { "x-app-api-key": this.apiKey } : void 0;
|
|
2872
|
+
const orderbookUrl = this.orderbookUrl ? this.withAppId(this.orderbookUrl) : void 0;
|
|
2858
2873
|
return {
|
|
2859
|
-
url:
|
|
2874
|
+
url: this.withAppId(this.wsUrl),
|
|
2875
|
+
...orderbookUrl ? { orderbookUrl } : {},
|
|
2876
|
+
...this.orderbookLatency ? { orderbookLatency: this.orderbookLatency } : {},
|
|
2860
2877
|
...headers ? { headers } : {},
|
|
2861
2878
|
...webSocketImpl ? { webSocketImpl } : {}
|
|
2862
2879
|
};
|
|
@@ -2874,6 +2891,8 @@ var AggClient = class {
|
|
|
2874
2891
|
if (this.apiKey) watchdogHeaders["x-app-api-key"] = this.apiKey;
|
|
2875
2892
|
const socket = createSocket({
|
|
2876
2893
|
...this.webSocketOptions(options?.webSocketImpl),
|
|
2894
|
+
...options?.orderbookUrl ? { orderbookUrl: this.withAppId(options.orderbookUrl) } : {},
|
|
2895
|
+
...options?.orderbookLatency ? { orderbookLatency: options.orderbookLatency } : {},
|
|
2877
2896
|
callbacks,
|
|
2878
2897
|
initialToken: this.accessToken,
|
|
2879
2898
|
enableLogs: options?.enableLogs ?? false,
|
|
@@ -3548,11 +3567,30 @@ async function prepareHostedVenueRoute(client, options) {
|
|
|
3548
3567
|
return quote;
|
|
3549
3568
|
}
|
|
3550
3569
|
//#endregion
|
|
3570
|
+
//#region src/lighter-netting.ts
|
|
3571
|
+
/**
|
|
3572
|
+
* Lighter native netting. A sell may close current exposure and then open
|
|
3573
|
+
* the opposite side, including market and immediate-or-cancel orders.
|
|
3574
|
+
* Reduce-only stays 0. This is not a close-only guarantee.
|
|
3575
|
+
*/
|
|
3576
|
+
const NATIVE_NETTING_SELLS_MAY_OPEN_OPPOSITE_EXPOSURE = true;
|
|
3577
|
+
const LIGHTER_REDUCE_ONLY = 0;
|
|
3578
|
+
const LIGHTER_ORDER_DISCLOSURE_TEXT = "A sell can close current exposure and then open the opposite side. Opposite exposure can follow a sell, including market and immediate-or-cancel orders. Lighter does not offer a close-only guarantee.";
|
|
3579
|
+
function lighterOrderDisclosure() {
|
|
3580
|
+
return {
|
|
3581
|
+
nativeNetting: true,
|
|
3582
|
+
sellsMayOpenOppositeExposure: true,
|
|
3583
|
+
closeOnly: false,
|
|
3584
|
+
reduceOnly: 0,
|
|
3585
|
+
text: LIGHTER_ORDER_DISCLOSURE_TEXT
|
|
3586
|
+
};
|
|
3587
|
+
}
|
|
3588
|
+
//#endregion
|
|
3551
3589
|
//#region src/index.ts
|
|
3552
3590
|
function createAggClient(options) {
|
|
3553
3591
|
return new AggClient(options);
|
|
3554
3592
|
}
|
|
3555
3593
|
//#endregion
|
|
3556
|
-
export { ACTIVE_VENUES, AccountProvider, AccountType, AggApiError, AggClient, AggWebSocket, CATALOG_DEFAULT_OVERLAP_MS, 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, isCatalogResyncRequired, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, isOptionalFeeRequest, isOrderSignatureStep, 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 };
|
|
3594
|
+
export { ACTIVE_VENUES, AccountProvider, AccountType, AggApiError, AggClient, AggWebSocket, CATALOG_DEFAULT_OVERLAP_MS, CONFIRMED_MATCH_STATUSES, CandleBuilder, Chain, DEFAULT_BALANCE_REFILL_DAILY_CAP_RAW, DEFAULT_BALANCE_REFILL_MAX_FEE_RAW, IMAGE_SIZES, INACTIVE_VENUES, ImageSize, LIGHTER_REDUCE_ONLY, LIMIT_PRICE_RAW_SCALE, MarketStatus, MatchStatus, MatchType, NATIVE_NETTING_SELLS_MAY_OPEN_OPPOSITE_EXPOSURE, 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, isCatalogResyncRequired, isEmail, isEnum, isFiniteNonNeg, isNonEmptyString, isOptionalFeeRequest, isOrderSignatureStep, isPolymarketOrderSignatureStep, isPostFillFeeRequest, isSameWalletAddress, isVenueActive, isVenueDataVisible, isVenueInactive, lighterOrderDisclosure, loadImmutableHistory, mergeCandles, mergeClosedCandles, normalizeVenueMarketCluster, optimizedImageUrl, orderSignatureRound, orderbookCrc32, parse, parseEmail, parseEmailStrict, prepareHostedVenueFunding, prepareHostedVenueRoute, projectedOrderbookChecksum, retinaImageUrl, safeParse, signatureTimeoutMs, snapshotToOrderbook, sortVenues, toChecksumAddress, userSignerAddresses, withTimeout };
|
|
3557
3595
|
|
|
3558
3596
|
//# sourceMappingURL=index.mjs.map
|