@liberfi.io/react-predict 0.3.46 → 0.3.48
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/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +51 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -8
- package/dist/index.mjs.map +1 -1
- package/dist/{server-BYvRRFCr.d.mts → server-DcZETqAE.d.mts} +42 -1
- package/dist/{server-BYvRRFCr.d.ts → server-DcZETqAE.d.ts} +42 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +51 -7
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +52 -8
- package/dist/server.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -167,6 +167,35 @@ interface Orderbook {
|
|
|
167
167
|
/** best_ask − best_bid; absent when either side is empty. */
|
|
168
168
|
spread?: number;
|
|
169
169
|
}
|
|
170
|
+
/** One market to fetch in a batch order book request. */
|
|
171
|
+
interface OrderbookBatchItem {
|
|
172
|
+
slug: string;
|
|
173
|
+
source: ProviderSource;
|
|
174
|
+
/** Outcome side; defaults to `"yes"`. */
|
|
175
|
+
outcome?: OrderbookOutcome;
|
|
176
|
+
}
|
|
177
|
+
/** Request body for `POST /api/v1/markets/orderbooks`. */
|
|
178
|
+
interface OrderbooksBatchRequest {
|
|
179
|
+
/** Up to 100 markets to fetch in one call. */
|
|
180
|
+
items: OrderbookBatchItem[];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* One result of a batch order book response, aligned with the request order.
|
|
184
|
+
* `orderbook` is `null` when the item failed (see `error`); per-item failures
|
|
185
|
+
* never fail the whole batch.
|
|
186
|
+
*/
|
|
187
|
+
interface OrderbookBatchResult {
|
|
188
|
+
slug: string;
|
|
189
|
+
source: ProviderSource;
|
|
190
|
+
outcome: OrderbookOutcome;
|
|
191
|
+
orderbook: Orderbook | null;
|
|
192
|
+
/** Present only when this item failed. */
|
|
193
|
+
error?: string;
|
|
194
|
+
}
|
|
195
|
+
/** Response from `POST /api/v1/markets/orderbooks`. */
|
|
196
|
+
interface OrderbooksBatchResponse {
|
|
197
|
+
results: OrderbookBatchResult[];
|
|
198
|
+
}
|
|
170
199
|
/** On-chain trade type. */
|
|
171
200
|
type TradeType = "TRADE" | "SPLIT" | "MERGE" | "REDEEM" | "REWARD" | "CONVERSION" | "MAKER_REBATE" | "REFERRAL_REWARD";
|
|
172
201
|
/** Lightweight event summary embedded in a trade. */
|
|
@@ -1161,6 +1190,13 @@ declare class PredictClient {
|
|
|
1161
1190
|
getMarket(slug: string, source?: ProviderSource): Promise<PredictMarket>;
|
|
1162
1191
|
/** Maps to `GET /api/v1/markets/:slug/orderbook?source=...&outcome=...`. */
|
|
1163
1192
|
getOrderbook(slug: string, source: ProviderSource, outcome?: OrderbookOutcome): Promise<Orderbook>;
|
|
1193
|
+
/**
|
|
1194
|
+
* Maps to `POST /api/v1/markets/orderbooks`.
|
|
1195
|
+
* Fetches order books for many markets in a single request (max 100 items).
|
|
1196
|
+
* Results are returned in the same order as `items`; per-item failures are
|
|
1197
|
+
* reported via `OrderbookBatchResult.error` and never fail the whole batch.
|
|
1198
|
+
*/
|
|
1199
|
+
getOrderbooks(items: OrderbookBatchItem[]): Promise<OrderbookBatchResult[]>;
|
|
1164
1200
|
/** Maps to `GET /api/v1/markets/:slug/trades?source=...`. */
|
|
1165
1201
|
listMarketTrades(slug: string, params: ListMarketTradesParams): Promise<PredictPage<PredictTrade>>;
|
|
1166
1202
|
/** Maps to `GET /api/v1/markets/:slug/price-history?source=...&range=...`. */
|
|
@@ -1504,6 +1540,11 @@ declare class PredictWsClient {
|
|
|
1504
1540
|
private scheduleReconnect;
|
|
1505
1541
|
private clearReconnectTimer;
|
|
1506
1542
|
private restoreSubscriptions;
|
|
1543
|
+
/**
|
|
1544
|
+
* Send a subscribe/unsubscribe message, splitting `marketSlugs` across
|
|
1545
|
+
* multiple frames so no single frame exceeds the server read limit.
|
|
1546
|
+
*/
|
|
1547
|
+
private sendChunkedSubscription;
|
|
1507
1548
|
private startPing;
|
|
1508
1549
|
private stopPing;
|
|
1509
1550
|
/**
|
|
@@ -1958,4 +1999,4 @@ declare function buildClobPayload(signedOrder: SignedOrder, owner: string): Clob
|
|
|
1958
1999
|
*/
|
|
1959
2000
|
declare function getPolymarketSharesPrecision(tickSize: string): number;
|
|
1960
2001
|
|
|
1961
|
-
export { type PolymarketWithdrawPrepareRequest as $, type AvailableSharesResponse as A, type BalanceResponse as B, type Candlestick as C, type ListTradesMultiParams as D, type EventStats as E, type DFlowQuoteRequest as F, type DFlowQuoteResponse as G, type DFlowSubmitResponse as H, type DFlowSubmitRequest as I, type DFlowKYCStatus as J, type PolymarketSetupStatus as K, type ListEventsParams as L, type MatchesParams as M, type PolymarketDepositWalletDeployResponse as N, type OrderbookOutcome as O, PredictClient as P, type WithdrawBuildRequest as Q, type WithdrawSubmitResponse as R, type SimilarEventsParams as S, type WithdrawSubmitRequest as T, type WithdrawStatusResponse as U, type PolymarketDepositAddresses as V, type WithdrawBuildResponse as W, type PolymarketSupportedAsset as X, type PolymarketWithdrawResponse as Y, type PolymarketWithdrawRequest as Z, type PolymarketWithdrawPrepareResponse as _, PredictWsClient as a, type
|
|
2002
|
+
export { type PolymarketWithdrawPrepareRequest as $, type AvailableSharesResponse as A, type BalanceResponse as B, type Candlestick as C, type ListTradesMultiParams as D, type EventStats as E, type DFlowQuoteRequest as F, type DFlowQuoteResponse as G, type DFlowSubmitResponse as H, type DFlowSubmitRequest as I, type DFlowKYCStatus as J, type PolymarketSetupStatus as K, type ListEventsParams as L, type MatchesParams as M, type PolymarketDepositWalletDeployResponse as N, type OrderbookOutcome as O, PredictClient as P, type WithdrawBuildRequest as Q, type WithdrawSubmitResponse as R, type SimilarEventsParams as S, type WithdrawSubmitRequest as T, type WithdrawStatusResponse as U, type PolymarketDepositAddresses as V, type WithdrawBuildResponse as W, type PolymarketSupportedAsset as X, type PolymarketWithdrawResponse as Y, type PolymarketWithdrawRequest as Z, type PolymarketWithdrawPrepareResponse as _, PredictWsClient as a, type WsChannelEvent as a$, type PolymarketWithdrawQuoteResponse as a0, type PolymarketWithdrawQuoteRequest as a1, type PolymarketWithdrawRelayBuildResponse as a2, type PolymarketWithdrawRelayBuildRequest as a3, type PolymarketWithdrawRelaySubmitResponse as a4, type PolymarketWithdrawRelaySubmitRequest as a5, type PolymarketWithdrawBridgeStatusResponse as a6, type PolymarketRedeemResponse as a7, type TickSizeResponse as a8, type FeeRateResponse as a9, type PredictPosition as aA, type OrderStatus as aB, type OrderSide as aC, type DFlowOrderContext as aD, type PolymarketOrderType as aE, type PolymarketWalletKind as aF, type PolymarketDepositWalletDeployRequest as aG, type DepositBuildRequest as aH, type DepositBuildResponse as aI, type DepositSubmitRequest as aJ, type DepositSubmitResponse as aK, type DepositStatusResponse as aL, type UnsignedTx as aM, type PolymarketBridgeToken as aN, type PolymarketSupportedAssetsResponse as aO, type PolymarketTypedData as aP, type PolymarketTypedDataArg as aQ, type MatchStatus as aR, type MatchGroupEntry as aS, type MatchGroupMarket as aT, type MatchSortField as aU, type MatchesStats as aV, type MatchConfidenceTier as aW, type SignalTag as aX, type MatchLeg as aY, type MatchMarketFlat as aZ, type WsChannel as a_, type RebateConfig as aa, type WsConnectionStatus as ab, type WsDataMessage as ac, type WsPriceEvent as ad, type WsOrderbookEvent as ae, type WsTradeEvent as af, type CreateOrderInput as ag, createPredictClient as ah, createPredictWsClient as ai, type PredictWsClientConfig as aj, type ProviderMeta as ak, type PredictTag as al, type SettlementSource as am, type MarketStatus as an, type MarketResult as ao, type MarketOutcome as ap, type OrderbookLevel as aq, type OrderbookBatchItem as ar, type OrderbookBatchResult as as, type OrderbooksBatchRequest as at, type OrderbooksBatchResponse as au, type TradeType as av, type EventSummary as aw, type MarketSummary as ax, type PredictCommentProfile as ay, type PricePoint as az, type PredictPage as b, type WsClientMessage as b0, type WsSubscribeMessage as b1, type WsPingMessage as b2, type WsServerMessage as b3, type WsPongMessage as b4, type WsSubscribedMessage as b5, type WsErrorCode as b6, type WsErrorMessage as b7, type PolymarketRedeemPrepareInput as b8, type PolymarketRedeemPrepareResponse as b9, CTF_EXCHANGE_ADDRESS as bA, NEG_RISK_CTF_EXCHANGE_ADDRESS as bB, USDC_ADDRESS as bC, POLYGON_CHAIN_ID as bD, buildCtfExchangeDomain as bE, CTF_ORDER_TYPES as bF, ORDER_TYPE as bG, SIDE as bH, buildOrderMessage as bI, buildSignedOrder as bJ, buildClobPayload as bK, getPolymarketSharesPrecision as bL, type ClobOrderPayload as bM, type BuildOrderMessageInput as bN, type OrderMessage as bO, type SignedOrder as bP, DEFAULT_PAGE_SIZE as bQ, type PolymarketRedeemInput as ba, eventQueryKey as bb, fetchEvent as bc, resolveTagSlug as bd, resolveEventsParams as be, infiniteEventsQueryKey as bf, fetchEventsPage as bg, type ResolveEventsParamsInput as bh, type TagSlugSelection as bi, marketQueryKey as bj, fetchMarket as bk, matchesQueryKey as bl, matchQueryKey as bm, fetchMatchesPage as bn, matchMarketsQueryKey as bo, fetchMatchMarketsPage as bp, CLOB_AUTH_DOMAIN as bq, CLOB_AUTH_TYPES as br, buildClobAuthMessage as bs, hmacSha256Base64 as bt, buildPolymarketL2Headers as bu, derivePolymarketApiKey as bv, type HttpMethod as bw, type PolymarketL2HeadersInput as bx, type PolymarketL2Headers as by, type BuildClobAuthMessageInput as bz, type PredictEvent as c, type ProviderSource as d, type EventStatus as e, type EventSortField as f, type PredictMarket as g, type Orderbook as h, type ListMarketTradesParams as i, type PredictTrade as j, type PriceHistoryRange as k, type PriceHistoryResponse as l, type ListCandlesticksParams as m, type ListCommentsParams as n, type PredictComment as o, type PositionsResponse as p, type ListOrdersParams as q, type PredictOrder as r, type ListOrdersMultiParams as s, type PredictOrdersResponse as t, type CancelOrderResult as u, type MatchGroupPage as v, type MatchGroup as w, type MatchMarketParams as x, type MatchMarketPage as y, type ListTradesParams as z };
|
|
@@ -167,6 +167,35 @@ interface Orderbook {
|
|
|
167
167
|
/** best_ask − best_bid; absent when either side is empty. */
|
|
168
168
|
spread?: number;
|
|
169
169
|
}
|
|
170
|
+
/** One market to fetch in a batch order book request. */
|
|
171
|
+
interface OrderbookBatchItem {
|
|
172
|
+
slug: string;
|
|
173
|
+
source: ProviderSource;
|
|
174
|
+
/** Outcome side; defaults to `"yes"`. */
|
|
175
|
+
outcome?: OrderbookOutcome;
|
|
176
|
+
}
|
|
177
|
+
/** Request body for `POST /api/v1/markets/orderbooks`. */
|
|
178
|
+
interface OrderbooksBatchRequest {
|
|
179
|
+
/** Up to 100 markets to fetch in one call. */
|
|
180
|
+
items: OrderbookBatchItem[];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* One result of a batch order book response, aligned with the request order.
|
|
184
|
+
* `orderbook` is `null` when the item failed (see `error`); per-item failures
|
|
185
|
+
* never fail the whole batch.
|
|
186
|
+
*/
|
|
187
|
+
interface OrderbookBatchResult {
|
|
188
|
+
slug: string;
|
|
189
|
+
source: ProviderSource;
|
|
190
|
+
outcome: OrderbookOutcome;
|
|
191
|
+
orderbook: Orderbook | null;
|
|
192
|
+
/** Present only when this item failed. */
|
|
193
|
+
error?: string;
|
|
194
|
+
}
|
|
195
|
+
/** Response from `POST /api/v1/markets/orderbooks`. */
|
|
196
|
+
interface OrderbooksBatchResponse {
|
|
197
|
+
results: OrderbookBatchResult[];
|
|
198
|
+
}
|
|
170
199
|
/** On-chain trade type. */
|
|
171
200
|
type TradeType = "TRADE" | "SPLIT" | "MERGE" | "REDEEM" | "REWARD" | "CONVERSION" | "MAKER_REBATE" | "REFERRAL_REWARD";
|
|
172
201
|
/** Lightweight event summary embedded in a trade. */
|
|
@@ -1161,6 +1190,13 @@ declare class PredictClient {
|
|
|
1161
1190
|
getMarket(slug: string, source?: ProviderSource): Promise<PredictMarket>;
|
|
1162
1191
|
/** Maps to `GET /api/v1/markets/:slug/orderbook?source=...&outcome=...`. */
|
|
1163
1192
|
getOrderbook(slug: string, source: ProviderSource, outcome?: OrderbookOutcome): Promise<Orderbook>;
|
|
1193
|
+
/**
|
|
1194
|
+
* Maps to `POST /api/v1/markets/orderbooks`.
|
|
1195
|
+
* Fetches order books for many markets in a single request (max 100 items).
|
|
1196
|
+
* Results are returned in the same order as `items`; per-item failures are
|
|
1197
|
+
* reported via `OrderbookBatchResult.error` and never fail the whole batch.
|
|
1198
|
+
*/
|
|
1199
|
+
getOrderbooks(items: OrderbookBatchItem[]): Promise<OrderbookBatchResult[]>;
|
|
1164
1200
|
/** Maps to `GET /api/v1/markets/:slug/trades?source=...`. */
|
|
1165
1201
|
listMarketTrades(slug: string, params: ListMarketTradesParams): Promise<PredictPage<PredictTrade>>;
|
|
1166
1202
|
/** Maps to `GET /api/v1/markets/:slug/price-history?source=...&range=...`. */
|
|
@@ -1504,6 +1540,11 @@ declare class PredictWsClient {
|
|
|
1504
1540
|
private scheduleReconnect;
|
|
1505
1541
|
private clearReconnectTimer;
|
|
1506
1542
|
private restoreSubscriptions;
|
|
1543
|
+
/**
|
|
1544
|
+
* Send a subscribe/unsubscribe message, splitting `marketSlugs` across
|
|
1545
|
+
* multiple frames so no single frame exceeds the server read limit.
|
|
1546
|
+
*/
|
|
1547
|
+
private sendChunkedSubscription;
|
|
1507
1548
|
private startPing;
|
|
1508
1549
|
private stopPing;
|
|
1509
1550
|
/**
|
|
@@ -1958,4 +1999,4 @@ declare function buildClobPayload(signedOrder: SignedOrder, owner: string): Clob
|
|
|
1958
1999
|
*/
|
|
1959
2000
|
declare function getPolymarketSharesPrecision(tickSize: string): number;
|
|
1960
2001
|
|
|
1961
|
-
export { type PolymarketWithdrawPrepareRequest as $, type AvailableSharesResponse as A, type BalanceResponse as B, type Candlestick as C, type ListTradesMultiParams as D, type EventStats as E, type DFlowQuoteRequest as F, type DFlowQuoteResponse as G, type DFlowSubmitResponse as H, type DFlowSubmitRequest as I, type DFlowKYCStatus as J, type PolymarketSetupStatus as K, type ListEventsParams as L, type MatchesParams as M, type PolymarketDepositWalletDeployResponse as N, type OrderbookOutcome as O, PredictClient as P, type WithdrawBuildRequest as Q, type WithdrawSubmitResponse as R, type SimilarEventsParams as S, type WithdrawSubmitRequest as T, type WithdrawStatusResponse as U, type PolymarketDepositAddresses as V, type WithdrawBuildResponse as W, type PolymarketSupportedAsset as X, type PolymarketWithdrawResponse as Y, type PolymarketWithdrawRequest as Z, type PolymarketWithdrawPrepareResponse as _, PredictWsClient as a, type
|
|
2002
|
+
export { type PolymarketWithdrawPrepareRequest as $, type AvailableSharesResponse as A, type BalanceResponse as B, type Candlestick as C, type ListTradesMultiParams as D, type EventStats as E, type DFlowQuoteRequest as F, type DFlowQuoteResponse as G, type DFlowSubmitResponse as H, type DFlowSubmitRequest as I, type DFlowKYCStatus as J, type PolymarketSetupStatus as K, type ListEventsParams as L, type MatchesParams as M, type PolymarketDepositWalletDeployResponse as N, type OrderbookOutcome as O, PredictClient as P, type WithdrawBuildRequest as Q, type WithdrawSubmitResponse as R, type SimilarEventsParams as S, type WithdrawSubmitRequest as T, type WithdrawStatusResponse as U, type PolymarketDepositAddresses as V, type WithdrawBuildResponse as W, type PolymarketSupportedAsset as X, type PolymarketWithdrawResponse as Y, type PolymarketWithdrawRequest as Z, type PolymarketWithdrawPrepareResponse as _, PredictWsClient as a, type WsChannelEvent as a$, type PolymarketWithdrawQuoteResponse as a0, type PolymarketWithdrawQuoteRequest as a1, type PolymarketWithdrawRelayBuildResponse as a2, type PolymarketWithdrawRelayBuildRequest as a3, type PolymarketWithdrawRelaySubmitResponse as a4, type PolymarketWithdrawRelaySubmitRequest as a5, type PolymarketWithdrawBridgeStatusResponse as a6, type PolymarketRedeemResponse as a7, type TickSizeResponse as a8, type FeeRateResponse as a9, type PredictPosition as aA, type OrderStatus as aB, type OrderSide as aC, type DFlowOrderContext as aD, type PolymarketOrderType as aE, type PolymarketWalletKind as aF, type PolymarketDepositWalletDeployRequest as aG, type DepositBuildRequest as aH, type DepositBuildResponse as aI, type DepositSubmitRequest as aJ, type DepositSubmitResponse as aK, type DepositStatusResponse as aL, type UnsignedTx as aM, type PolymarketBridgeToken as aN, type PolymarketSupportedAssetsResponse as aO, type PolymarketTypedData as aP, type PolymarketTypedDataArg as aQ, type MatchStatus as aR, type MatchGroupEntry as aS, type MatchGroupMarket as aT, type MatchSortField as aU, type MatchesStats as aV, type MatchConfidenceTier as aW, type SignalTag as aX, type MatchLeg as aY, type MatchMarketFlat as aZ, type WsChannel as a_, type RebateConfig as aa, type WsConnectionStatus as ab, type WsDataMessage as ac, type WsPriceEvent as ad, type WsOrderbookEvent as ae, type WsTradeEvent as af, type CreateOrderInput as ag, createPredictClient as ah, createPredictWsClient as ai, type PredictWsClientConfig as aj, type ProviderMeta as ak, type PredictTag as al, type SettlementSource as am, type MarketStatus as an, type MarketResult as ao, type MarketOutcome as ap, type OrderbookLevel as aq, type OrderbookBatchItem as ar, type OrderbookBatchResult as as, type OrderbooksBatchRequest as at, type OrderbooksBatchResponse as au, type TradeType as av, type EventSummary as aw, type MarketSummary as ax, type PredictCommentProfile as ay, type PricePoint as az, type PredictPage as b, type WsClientMessage as b0, type WsSubscribeMessage as b1, type WsPingMessage as b2, type WsServerMessage as b3, type WsPongMessage as b4, type WsSubscribedMessage as b5, type WsErrorCode as b6, type WsErrorMessage as b7, type PolymarketRedeemPrepareInput as b8, type PolymarketRedeemPrepareResponse as b9, CTF_EXCHANGE_ADDRESS as bA, NEG_RISK_CTF_EXCHANGE_ADDRESS as bB, USDC_ADDRESS as bC, POLYGON_CHAIN_ID as bD, buildCtfExchangeDomain as bE, CTF_ORDER_TYPES as bF, ORDER_TYPE as bG, SIDE as bH, buildOrderMessage as bI, buildSignedOrder as bJ, buildClobPayload as bK, getPolymarketSharesPrecision as bL, type ClobOrderPayload as bM, type BuildOrderMessageInput as bN, type OrderMessage as bO, type SignedOrder as bP, DEFAULT_PAGE_SIZE as bQ, type PolymarketRedeemInput as ba, eventQueryKey as bb, fetchEvent as bc, resolveTagSlug as bd, resolveEventsParams as be, infiniteEventsQueryKey as bf, fetchEventsPage as bg, type ResolveEventsParamsInput as bh, type TagSlugSelection as bi, marketQueryKey as bj, fetchMarket as bk, matchesQueryKey as bl, matchQueryKey as bm, fetchMatchesPage as bn, matchMarketsQueryKey as bo, fetchMatchMarketsPage as bp, CLOB_AUTH_DOMAIN as bq, CLOB_AUTH_TYPES as br, buildClobAuthMessage as bs, hmacSha256Base64 as bt, buildPolymarketL2Headers as bu, derivePolymarketApiKey as bv, type HttpMethod as bw, type PolymarketL2HeadersInput as bx, type PolymarketL2Headers as by, type BuildClobAuthMessageInput as bz, type PredictEvent as c, type ProviderSource as d, type EventStatus as e, type EventSortField as f, type PredictMarket as g, type Orderbook as h, type ListMarketTradesParams as i, type PredictTrade as j, type PriceHistoryRange as k, type PriceHistoryResponse as l, type ListCandlesticksParams as m, type ListCommentsParams as n, type PredictComment as o, type PositionsResponse as p, type ListOrdersParams as q, type PredictOrder as r, type ListOrdersMultiParams as s, type PredictOrdersResponse as t, type CancelOrderResult as u, type MatchGroupPage as v, type MatchGroup as w, type MatchMarketParams as x, type MatchMarketPage as y, type ListTradesParams as z };
|
package/dist/server.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BalanceResponse,
|
|
1
|
+
export { B as BalanceResponse, bz as BuildClobAuthMessageInput, bN as BuildOrderMessageInput, bq as CLOB_AUTH_DOMAIN, br as CLOB_AUTH_TYPES, bA as CTF_EXCHANGE_ADDRESS, bF as CTF_ORDER_TYPES, u as CancelOrderResult, C as Candlestick, bM as ClobOrderPayload, ag as CreateOrderInput, bQ as DEFAULT_PAGE_SIZE, aD as DFlowOrderContext, F as DFlowQuoteRequest, G as DFlowQuoteResponse, I as DFlowSubmitRequest, H as DFlowSubmitResponse, aH as DepositBuildRequest, aI as DepositBuildResponse, aL as DepositStatusResponse, aJ as DepositSubmitRequest, aK as DepositSubmitResponse, f as EventSortField, e as EventStatus, aw as EventSummary, bw as HttpMethod, m as ListCandlesticksParams, L as ListEventsParams, i as ListMarketTradesParams, q as ListOrdersParams, z as ListTradesParams, ap as MarketOutcome, ao as MarketResult, an as MarketStatus, ax as MarketSummary, aW as MatchConfidenceTier, w as MatchGroup, aS as MatchGroupEntry, aT as MatchGroupMarket, v as MatchGroupPage, aY as MatchLeg, aZ as MatchMarketFlat, y as MatchMarketPage, x as MatchMarketParams, aU as MatchSortField, aR as MatchStatus, M as MatchesParams, aV as MatchesStats, bB as NEG_RISK_CTF_EXCHANGE_ADDRESS, bG as ORDER_TYPE, bO as OrderMessage, aC as OrderSide, aB as OrderStatus, h as Orderbook, aq as OrderbookLevel, bD as POLYGON_CHAIN_ID, by as PolymarketL2Headers, bx as PolymarketL2HeadersInput, aE as PolymarketOrderType, p as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, r as PredictOrder, b as PredictPage, aA as PredictPosition, al as PredictTag, j as PredictTrade, a as PredictWsClient, aj as PredictWsClientConfig, k as PriceHistoryRange, l as PriceHistoryResponse, az as PricePoint, ak as ProviderMeta, d as ProviderSource, bh as ResolveEventsParamsInput, bH as SIDE, am as SettlementSource, aX as SignalTag, bP as SignedOrder, S as SimilarEventsParams, bi as TagSlugSelection, av as TradeType, bC as USDC_ADDRESS, aM as UnsignedTx, a_ as WsChannel, a$ as WsChannelEvent, b0 as WsClientMessage, ab as WsConnectionStatus, ac as WsDataMessage, b6 as WsErrorCode, b7 as WsErrorMessage, ae as WsOrderbookEvent, b2 as WsPingMessage, b4 as WsPongMessage, ad as WsPriceEvent, b3 as WsServerMessage, b1 as WsSubscribeMessage, b5 as WsSubscribedMessage, af as WsTradeEvent, bs as buildClobAuthMessage, bK as buildClobPayload, bE as buildCtfExchangeDomain, bI as buildOrderMessage, bu as buildPolymarketL2Headers, bJ as buildSignedOrder, ah as createPredictClient, ai as createPredictWsClient, bv as derivePolymarketApiKey, bb as eventQueryKey, bc as fetchEvent, bg as fetchEventsPage, bk as fetchMarket, bp as fetchMatchMarketsPage, bn as fetchMatchesPage, bt as hmacSha256Base64, bf as infiniteEventsQueryKey, bj as marketQueryKey, bo as matchMarketsQueryKey, bm as matchQueryKey, bl as matchesQueryKey, be as resolveEventsParams, bd as resolveTagSlug } from './server-DcZETqAE.mjs';
|
package/dist/server.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BalanceResponse,
|
|
1
|
+
export { B as BalanceResponse, bz as BuildClobAuthMessageInput, bN as BuildOrderMessageInput, bq as CLOB_AUTH_DOMAIN, br as CLOB_AUTH_TYPES, bA as CTF_EXCHANGE_ADDRESS, bF as CTF_ORDER_TYPES, u as CancelOrderResult, C as Candlestick, bM as ClobOrderPayload, ag as CreateOrderInput, bQ as DEFAULT_PAGE_SIZE, aD as DFlowOrderContext, F as DFlowQuoteRequest, G as DFlowQuoteResponse, I as DFlowSubmitRequest, H as DFlowSubmitResponse, aH as DepositBuildRequest, aI as DepositBuildResponse, aL as DepositStatusResponse, aJ as DepositSubmitRequest, aK as DepositSubmitResponse, f as EventSortField, e as EventStatus, aw as EventSummary, bw as HttpMethod, m as ListCandlesticksParams, L as ListEventsParams, i as ListMarketTradesParams, q as ListOrdersParams, z as ListTradesParams, ap as MarketOutcome, ao as MarketResult, an as MarketStatus, ax as MarketSummary, aW as MatchConfidenceTier, w as MatchGroup, aS as MatchGroupEntry, aT as MatchGroupMarket, v as MatchGroupPage, aY as MatchLeg, aZ as MatchMarketFlat, y as MatchMarketPage, x as MatchMarketParams, aU as MatchSortField, aR as MatchStatus, M as MatchesParams, aV as MatchesStats, bB as NEG_RISK_CTF_EXCHANGE_ADDRESS, bG as ORDER_TYPE, bO as OrderMessage, aC as OrderSide, aB as OrderStatus, h as Orderbook, aq as OrderbookLevel, bD as POLYGON_CHAIN_ID, by as PolymarketL2Headers, bx as PolymarketL2HeadersInput, aE as PolymarketOrderType, p as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, r as PredictOrder, b as PredictPage, aA as PredictPosition, al as PredictTag, j as PredictTrade, a as PredictWsClient, aj as PredictWsClientConfig, k as PriceHistoryRange, l as PriceHistoryResponse, az as PricePoint, ak as ProviderMeta, d as ProviderSource, bh as ResolveEventsParamsInput, bH as SIDE, am as SettlementSource, aX as SignalTag, bP as SignedOrder, S as SimilarEventsParams, bi as TagSlugSelection, av as TradeType, bC as USDC_ADDRESS, aM as UnsignedTx, a_ as WsChannel, a$ as WsChannelEvent, b0 as WsClientMessage, ab as WsConnectionStatus, ac as WsDataMessage, b6 as WsErrorCode, b7 as WsErrorMessage, ae as WsOrderbookEvent, b2 as WsPingMessage, b4 as WsPongMessage, ad as WsPriceEvent, b3 as WsServerMessage, b1 as WsSubscribeMessage, b5 as WsSubscribedMessage, af as WsTradeEvent, bs as buildClobAuthMessage, bK as buildClobPayload, bE as buildCtfExchangeDomain, bI as buildOrderMessage, bu as buildPolymarketL2Headers, bJ as buildSignedOrder, ah as createPredictClient, ai as createPredictWsClient, bv as derivePolymarketApiKey, bb as eventQueryKey, bc as fetchEvent, bg as fetchEventsPage, bk as fetchMarket, bp as fetchMatchMarketsPage, bn as fetchMatchesPage, bt as hmacSha256Base64, bf as infiniteEventsQueryKey, bj as marketQueryKey, bo as matchMarketsQueryKey, bm as matchQueryKey, bl as matchesQueryKey, be as resolveEventsParams, bd as resolveTagSlug } from './server-DcZETqAE.js';
|
package/dist/server.js
CHANGED
|
@@ -192,6 +192,17 @@ var PredictClient = class {
|
|
|
192
192
|
const url = `${this.endpoint}/api/v1/markets/${encodeURIComponent(slug)}/orderbook${query}`;
|
|
193
193
|
return await utils.httpGet(url);
|
|
194
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Maps to `POST /api/v1/markets/orderbooks`.
|
|
197
|
+
* Fetches order books for many markets in a single request (max 100 items).
|
|
198
|
+
* Results are returned in the same order as `items`; per-item failures are
|
|
199
|
+
* reported via `OrderbookBatchResult.error` and never fail the whole batch.
|
|
200
|
+
*/
|
|
201
|
+
async getOrderbooks(items) {
|
|
202
|
+
const url = `${this.endpoint}/api/v1/markets/orderbooks`;
|
|
203
|
+
const res = await utils.httpPost(url, { items });
|
|
204
|
+
return res.results;
|
|
205
|
+
}
|
|
195
206
|
/** Maps to `GET /api/v1/markets/:slug/trades?source=...`. */
|
|
196
207
|
async listMarketTrades(slug, params) {
|
|
197
208
|
const query = buildQuery(params);
|
|
@@ -616,6 +627,13 @@ var DEFAULT_RECONNECT_BASE = 1e3;
|
|
|
616
627
|
var DEFAULT_RECONNECT_MAX = 3e4;
|
|
617
628
|
var DEFAULT_PING_INTERVAL = 2e4;
|
|
618
629
|
var DEFAULT_PONG_TIMEOUT = 1e4;
|
|
630
|
+
var MAX_SUBSCRIPTION_FRAME_BYTES = 3500;
|
|
631
|
+
function byteLength(str) {
|
|
632
|
+
if (typeof TextEncoder !== "undefined") {
|
|
633
|
+
return new TextEncoder().encode(str).length;
|
|
634
|
+
}
|
|
635
|
+
return str.length;
|
|
636
|
+
}
|
|
619
637
|
var PredictWsClient = class {
|
|
620
638
|
ws = null;
|
|
621
639
|
wsUrl;
|
|
@@ -733,7 +751,7 @@ var PredictWsClient = class {
|
|
|
733
751
|
const set = this.subs.channels.get(ch);
|
|
734
752
|
for (const slug of marketSlugs) set.add(slug);
|
|
735
753
|
}
|
|
736
|
-
this.
|
|
754
|
+
this.sendChunkedSubscription("subscribe", channels, marketSlugs);
|
|
737
755
|
}
|
|
738
756
|
/**
|
|
739
757
|
* Unsubscribe from one or more channels for the given market slugs.
|
|
@@ -743,7 +761,7 @@ var PredictWsClient = class {
|
|
|
743
761
|
const set = this.subs.channels.get(ch);
|
|
744
762
|
for (const slug of marketSlugs) set.delete(slug);
|
|
745
763
|
}
|
|
746
|
-
this.
|
|
764
|
+
this.sendChunkedSubscription("unsubscribe", channels, marketSlugs);
|
|
747
765
|
}
|
|
748
766
|
// -------------------------------------------------------------------------
|
|
749
767
|
// Subscription — convenience (single channel)
|
|
@@ -899,13 +917,39 @@ var PredictWsClient = class {
|
|
|
899
917
|
restoreSubscriptions() {
|
|
900
918
|
for (const [channel, slugs] of this.subs.channels.entries()) {
|
|
901
919
|
if (slugs.size > 0) {
|
|
902
|
-
this.
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
920
|
+
this.sendChunkedSubscription("subscribe", [channel], Array.from(slugs));
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Send a subscribe/unsubscribe message, splitting `marketSlugs` across
|
|
926
|
+
* multiple frames so no single frame exceeds the server read limit.
|
|
927
|
+
*/
|
|
928
|
+
sendChunkedSubscription(type, channels, marketSlugs) {
|
|
929
|
+
if (marketSlugs.length === 0) {
|
|
930
|
+
this.send({ type, channels, market_slugs: [] });
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
const envelopeBytes = byteLength(
|
|
934
|
+
JSON.stringify({ type, channels, market_slugs: [] })
|
|
935
|
+
);
|
|
936
|
+
const budget = MAX_SUBSCRIPTION_FRAME_BYTES - envelopeBytes;
|
|
937
|
+
let chunk = [];
|
|
938
|
+
let chunkBytes = 0;
|
|
939
|
+
const flush = () => {
|
|
940
|
+
if (chunk.length > 0) {
|
|
941
|
+
this.send({ type, channels, market_slugs: chunk });
|
|
942
|
+
chunk = [];
|
|
943
|
+
chunkBytes = 0;
|
|
907
944
|
}
|
|
945
|
+
};
|
|
946
|
+
for (const slug of marketSlugs) {
|
|
947
|
+
const slugBytes = byteLength(JSON.stringify(slug)) + 1;
|
|
948
|
+
if (chunk.length > 0 && chunkBytes + slugBytes > budget) flush();
|
|
949
|
+
chunk.push(slug);
|
|
950
|
+
chunkBytes += slugBytes;
|
|
908
951
|
}
|
|
952
|
+
flush();
|
|
909
953
|
}
|
|
910
954
|
startPing() {
|
|
911
955
|
this.stopPing();
|