@liberfi.io/react-predict 0.3.37 → 0.3.39
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 +14 -11
- package/dist/index.d.ts +14 -11
- package/dist/index.js +38 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -35
- package/dist/index.mjs.map +1 -1
- package/dist/{server-DfzGla54.d.mts → server-Da_gQzNk.d.mts} +9 -3
- package/dist/{server-DfzGla54.d.ts → server-Da_gQzNk.d.ts} +9 -3
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +3 -3
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +3 -3
- package/dist/server.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as
|
|
2
|
-
export {
|
|
1
|
+
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as OrderbookOutcome, h as Orderbook, i as ListMarketTradesParams, j as PredictTrade, k as PriceHistoryRange, l as PriceHistoryResponse, m as ListCandlesticksParams, C as Candlestick, n as ListCommentsParams, o as PredictComment, p as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, q as ListOrdersParams, r as PredictOrder, s as ListOrdersMultiParams, t as PredictOrdersResponse, u as CancelOrderResult, M as MatchesParams, v as MatchGroupPage, w as MatchGroup, x as MatchMarketParams, y as MatchMarketPage, z as ListTradesParams, D as ListTradesMultiParams, F as DFlowQuoteRequest, G as DFlowQuoteResponse, H as DFlowSubmitResponse, I as DFlowSubmitRequest, J as DFlowKYCStatus, K as PolymarketSetupStatus, N as PolymarketDepositWalletDeployResponse, W as WithdrawBuildResponse, Q as WithdrawBuildRequest, R as WithdrawSubmitResponse, T as WithdrawSubmitRequest, U as WithdrawStatusResponse, V as PolymarketDepositAddresses, X as PolymarketSupportedAsset, Y as PolymarketWithdrawResponse, Z as PolymarketWithdrawRequest, _ as PolymarketRedeemResponse, $ as TickSizeResponse, a0 as FeeRateResponse, a1 as RebateConfig, a2 as WsConnectionStatus, a3 as WsDataMessage, a4 as WsPriceEvent, a5 as WsOrderbookEvent, a6 as WsTradeEvent, a7 as CreateOrderInput } from './server-Da_gQzNk.mjs';
|
|
2
|
+
export { bm as BuildClobAuthMessageInput, bA as BuildOrderMessageInput, bd as CLOB_AUTH_DOMAIN, be as CLOB_AUTH_TYPES, bn as CTF_EXCHANGE_ADDRESS, bs as CTF_ORDER_TYPES, bz as ClobOrderPayload, aq as DFlowOrderContext, au as DepositBuildRequest, av as DepositBuildResponse, ay as DepositStatusResponse, aw as DepositSubmitRequest, ax as DepositSubmitResponse, aj as EventSummary, bj as HttpMethod, ag as MarketOutcome, af as MarketResult, ae as MarketStatus, ak as MarketSummary, aJ as MatchConfidenceTier, aF as MatchGroupEntry, aG as MatchGroupMarket, aL as MatchLeg, aM as MatchMarketFlat, aH as MatchSortField, aE as MatchStatus, aI as MatchesStats, bo as NEG_RISK_CTF_EXCHANGE_ADDRESS, bt as ORDER_TYPE, bB as OrderMessage, ap as OrderSide, ao as OrderStatus, ah as OrderbookLevel, bq as POLYGON_CHAIN_ID, aA as PolymarketBridgeToken, at as PolymarketDepositWalletDeployRequest, bl as PolymarketL2Headers, bk as PolymarketL2HeadersInput, ar as PolymarketOrderType, aZ as PolymarketRedeemInput, aX as PolymarketRedeemPrepareInput, aY as PolymarketRedeemPrepareResponse, aB as PolymarketSupportedAssetsResponse, as as PolymarketWalletKind, aC as PolymarketWithdrawPrepareRequest, aD as PolymarketWithdrawPrepareResponse, al as PredictCommentProfile, an as PredictPosition, ac as PredictTag, aa as PredictWsClientConfig, am as PricePoint, ab as ProviderMeta, b4 as ResolveEventsParamsInput, bu as SIDE, ad as SettlementSource, aK as SignalTag, bC as SignedOrder, b5 as TagSlugSelection, ai as TradeType, bp as USDC_ADDRESS, az as UnsignedTx, aN as WsChannel, aO as WsChannelEvent, aP as WsClientMessage, aV as WsErrorCode, aW as WsErrorMessage, aR as WsPingMessage, aT as WsPongMessage, aS as WsServerMessage, aQ as WsSubscribeMessage, aU as WsSubscribedMessage, bf as buildClobAuthMessage, bx as buildClobPayload, br as buildCtfExchangeDomain, bv as buildOrderMessage, bh as buildPolymarketL2Headers, bw as buildSignedOrder, a8 as createPredictClient, a9 as createPredictWsClient, bi as derivePolymarketApiKey, a_ as eventQueryKey, a$ as fetchEvent, b3 as fetchEventsPage, b7 as fetchMarket, bc as fetchMatchMarketsPage, ba as fetchMatchesPage, by as getPolymarketSharesPrecision, bg as hmacSha256Base64, b2 as infiniteEventsQueryKey, b6 as marketQueryKey, bb as matchMarketsQueryKey, b9 as matchQueryKey, b8 as matchesQueryKey, b1 as resolveEventsParams, b0 as resolveTagSlug } from './server-Da_gQzNk.mjs';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { PropsWithChildren } from 'react';
|
|
@@ -338,10 +338,11 @@ interface UseMarketHistoryResult {
|
|
|
338
338
|
*/
|
|
339
339
|
declare function useMarketHistory(markets: PredictMarket[], range?: ChartRangeType): UseMarketHistoryResult;
|
|
340
340
|
|
|
341
|
-
declare function orderbookQueryKey(slug: string, source: ProviderSource): unknown[];
|
|
341
|
+
declare function orderbookQueryKey(slug: string, source: ProviderSource, outcome?: OrderbookOutcome): unknown[];
|
|
342
342
|
interface UseOrderbookParams {
|
|
343
343
|
slug: string;
|
|
344
344
|
source: ProviderSource;
|
|
345
|
+
outcome?: OrderbookOutcome;
|
|
345
346
|
}
|
|
346
347
|
declare function useOrderbook(params: UseOrderbookParams, queryOptions?: Omit<UseQueryOptions<Orderbook, Error, Orderbook, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<Orderbook, Error>;
|
|
347
348
|
|
|
@@ -776,6 +777,8 @@ interface UseOrderbookSubscriptionParams {
|
|
|
776
777
|
slug: string;
|
|
777
778
|
/** Enable/disable the subscription. Default: `true`. */
|
|
778
779
|
enabled?: boolean;
|
|
780
|
+
/** Optional outcome filter for the returned local snapshot. */
|
|
781
|
+
outcome?: OrderbookOutcome;
|
|
779
782
|
/** Optional callback fired on every orderbook snapshot. */
|
|
780
783
|
onUpdate?: (msg: WsDataMessage<WsOrderbookEvent>) => void;
|
|
781
784
|
}
|
|
@@ -791,7 +794,7 @@ interface UseOrderbookSubscriptionResult {
|
|
|
791
794
|
* Each incoming message is a **full snapshot** — no delta merging needed.
|
|
792
795
|
* Does **not** interact with React Query.
|
|
793
796
|
*/
|
|
794
|
-
declare function useOrderbookSubscription({ wsClient, slug, enabled, onUpdate, }: UseOrderbookSubscriptionParams): UseOrderbookSubscriptionResult;
|
|
797
|
+
declare function useOrderbookSubscription({ wsClient, slug, enabled, outcome, onUpdate, }: UseOrderbookSubscriptionParams): UseOrderbookSubscriptionResult;
|
|
795
798
|
|
|
796
799
|
interface UseTradesSubscriptionParams {
|
|
797
800
|
/** WebSocket client (from `usePredictWsClient`). */
|
|
@@ -824,6 +827,7 @@ declare function useTradesSubscription({ wsClient, slug, enabled, maxHistory, on
|
|
|
824
827
|
interface UseRealtimeOrderbookParams {
|
|
825
828
|
slug: string;
|
|
826
829
|
source: ProviderSource;
|
|
830
|
+
outcome?: OrderbookOutcome;
|
|
827
831
|
}
|
|
828
832
|
/**
|
|
829
833
|
* Orderbook with automatic WS → REST fallback.
|
|
@@ -1023,10 +1027,9 @@ declare function updatePolymarketBalanceAllowance(params: SyncBalanceAllowancePa
|
|
|
1023
1027
|
/**
|
|
1024
1028
|
* Orderbook-aware pricing utilities for prediction-market orders.
|
|
1025
1029
|
*
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
* callers can reason about a single outcome at a time.
|
|
1030
|
+
* Orderbooks are per-outcome: a YES book contains YES bids/asks and a NO
|
|
1031
|
+
* book contains NO bids/asks. These helpers never infer one side from the
|
|
1032
|
+
* other; callers must pass the real book for the selected outcome.
|
|
1030
1033
|
*
|
|
1031
1034
|
* Market-style orders (FOK on Polymarket) require a price that actually
|
|
1032
1035
|
* crosses every level we intend to fill into; a price quoted at top-of-book
|
|
@@ -1042,13 +1045,13 @@ type WalkOutcome = "yes" | "no";
|
|
|
1042
1045
|
type WalkStatus = "ok" | "insufficient_liquidity" | "exceeds_slippage" | "no_orderbook";
|
|
1043
1046
|
interface WalkResult {
|
|
1044
1047
|
status: WalkStatus;
|
|
1045
|
-
/** Top-of-book price
|
|
1048
|
+
/** Top-of-book price (best ask for buy, best bid for sell). */
|
|
1046
1049
|
bestPrice: number | null;
|
|
1047
1050
|
/** Worst price walked into; equals `bestPrice` when one level fully covers the request. */
|
|
1048
1051
|
worstPrice: number | null;
|
|
1049
1052
|
/** Volume-weighted average price across all levels actually consumed. */
|
|
1050
1053
|
vwap: number | null;
|
|
1051
|
-
/** Total share size available on the relevant side
|
|
1054
|
+
/** Total share size available on the relevant side. */
|
|
1052
1055
|
totalAvailable: number;
|
|
1053
1056
|
/** Share size that was actually filled while walking (≤ totalAvailable). */
|
|
1054
1057
|
filled: number;
|
|
@@ -1087,4 +1090,4 @@ interface WalkOrderbookParams {
|
|
|
1087
1090
|
*/
|
|
1088
1091
|
declare function walkOrderbook({ orderbook, outcome, side, sharesNeeded, slippageBps, }: WalkOrderbookParams): WalkResult;
|
|
1089
1092
|
|
|
1090
|
-
export { AvailableSharesResponse, BalanceResponse, type BuildV2OrderParams, CancelOrderResult, type CancelOrderVariables, Candlestick, ChartRange, type ChartRangeType, type ClobOrderV2Payload, CreateOrderInput, type CreatePolymarketOrderVariables, DFlowKYCStatus, DFlowQuoteRequest, DFlowQuoteResponse, DFlowSubmitRequest, DFlowSubmitResponse, EventSortField, EventStats, EventStatus, FeeRateResponse, ListCandlesticksParams, ListCommentsParams, ListEventsParams, ListMarketTradesParams, ListOrdersMultiParams, ListOrdersParams, ListTradesMultiParams, ListTradesParams, type MarketHistoryPoint, type MarketHistorySeries, MatchGroup, MatchGroupPage, MatchMarketPage, MatchMarketParams, MatchesParams, Orderbook, PolymarketContext, type PolymarketContextValue, type PolymarketCredentials, PolymarketDepositAddresses, type PolymarketDepositResult, type PolymarketDepositVariables, PolymarketDepositWalletDeployResponse, PolymarketProvider, type PolymarketProviderProps, PolymarketRedeemResponse, PolymarketSetupStatus, type PolymarketSigner, PolymarketSupportedAsset, PolymarketWithdrawRequest, PolymarketWithdrawResponse, PositionsResponse, PredictClient, PredictComment, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictOrdersResponse, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryRange, PriceHistoryResponse, ProviderSource, RebateConfig, type RedeemPositionVariables, SimilarEventsParams, type SyncBalanceAllowanceParams, TickSizeResponse, type UseAvailableSharesOptions, type UseAvailableSharesParams, type UseBalanceParams, type UseCancelOrderOptions, type UseCandlesticksParams, type UseEventParams, type UseInfiniteCommentsParams, type UseInfiniteMatchMarketsParams, type UseInfiniteMatchesParams, type UseInfiniteOrdersOptions, type UseInfiniteOrdersParams, type UseInfiniteTradesMultiParams, type UseInfiniteTradesParams, type UseMarketHistoryResult, type UseMarketParams, type UseMarketTradesParams, type UseOrderParams, type UseOrderbookParams, type UseOrderbookSubscriptionParams, type UseOrderbookSubscriptionResult, type UseOrdersMultiOptions, type UseOrdersOptions, type UsePositionsMultiParams, type UsePositionsParams, type UsePredictWsClientResult, type UsePriceHistoryParams, type UsePricesSubscriptionParams, type UsePricesSubscriptionResult, type UseRealtimeOrderbookParams, type UseRealtimePricesParams, type UseRealtimeTradesParams, type UseRealtimeTradesResult, type UseSearchEventsParams, type UseSimilarEventsParams, type UseTradesSubscriptionParams, type UseTradesSubscriptionResult, type UseWithdrawStatusQueryParams, type WalkOrderbookParams, type WalkOutcome, type WalkResult, type WalkSide, type WalkStatus, WithdrawBuildRequest, WithdrawBuildResponse, WithdrawStatusResponse, WithdrawSubmitRequest, WithdrawSubmitResponse, WsConnectionStatus, WsDataMessage, WsOrderbookEvent, WsPriceEvent, WsTradeEvent, availableSharesQueryKey, balanceQueryKey, buildSignedV2OrderPayload, candlesticksQueryKey, dflowKYCQueryKey, dflowQuoteQueryKey, eventStatsQueryKey, eventsQueryKey, feeRateQueryKey, fetchEvents, infiniteCommentsQueryKey, infiniteOrdersQueryKey, infiniteTradesMultiQueryKey, infiniteTradesQueryKey, marketTradesQueryKey, orderQueryKey, orderbookQueryKey, ordersMultiQueryKey, ordersQueryKey, pickBestAsk, pickBestBid, polymarketDepositAddressesQueryKey, polymarketSetupQueryKey, polymarketSupportedAssetsQueryKey, positionsMultiQueryKey, positionsQueryKey, priceHistoryQueryKey, rebateConfigQueryKey, similarEventsQueryKey, tickSizeQueryKey, tradesQueryKey, updatePolymarketBalanceAllowance, useAvailableShares, useBalance, useCancelOrder, useCandlesticks, useCreatePolymarketOrder, useDFlowKYC, useDFlowQuote, useDFlowSubmit, useDeployPolymarketDepositWallet, useEvent, useEventStats, useEvents, useFeeRate, useInfiniteComments, useInfiniteEvents, useInfiniteMatchMarkets, useInfiniteMatches, useInfiniteOrders, useInfiniteTrades, useInfiniteTradesMulti, useMarket, useMarketHistory, useMarketTrades, useMatch, useOrder, useOrderbook, useOrderbookSubscription, useOrders, useOrdersMulti, usePolymarket, usePolymarketDeposit, usePolymarketDepositAddresses, usePolymarketSetup, usePolymarketSupportedAssets, usePolymarketWithdraw, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRebateConfig, useRedeemPosition, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTickSize, useTrades, useTradesSubscription, useWithdrawBuildMutation, useWithdrawStatusQuery, useWithdrawSubmitMutation, walkOrderbook, withdrawStatusQueryKey };
|
|
1093
|
+
export { AvailableSharesResponse, BalanceResponse, type BuildV2OrderParams, CancelOrderResult, type CancelOrderVariables, Candlestick, ChartRange, type ChartRangeType, type ClobOrderV2Payload, CreateOrderInput, type CreatePolymarketOrderVariables, DFlowKYCStatus, DFlowQuoteRequest, DFlowQuoteResponse, DFlowSubmitRequest, DFlowSubmitResponse, EventSortField, EventStats, EventStatus, FeeRateResponse, ListCandlesticksParams, ListCommentsParams, ListEventsParams, ListMarketTradesParams, ListOrdersMultiParams, ListOrdersParams, ListTradesMultiParams, ListTradesParams, type MarketHistoryPoint, type MarketHistorySeries, MatchGroup, MatchGroupPage, MatchMarketPage, MatchMarketParams, MatchesParams, Orderbook, OrderbookOutcome, PolymarketContext, type PolymarketContextValue, type PolymarketCredentials, PolymarketDepositAddresses, type PolymarketDepositResult, type PolymarketDepositVariables, PolymarketDepositWalletDeployResponse, PolymarketProvider, type PolymarketProviderProps, PolymarketRedeemResponse, PolymarketSetupStatus, type PolymarketSigner, PolymarketSupportedAsset, PolymarketWithdrawRequest, PolymarketWithdrawResponse, PositionsResponse, PredictClient, PredictComment, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictOrdersResponse, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryRange, PriceHistoryResponse, ProviderSource, RebateConfig, type RedeemPositionVariables, SimilarEventsParams, type SyncBalanceAllowanceParams, TickSizeResponse, type UseAvailableSharesOptions, type UseAvailableSharesParams, type UseBalanceParams, type UseCancelOrderOptions, type UseCandlesticksParams, type UseEventParams, type UseInfiniteCommentsParams, type UseInfiniteMatchMarketsParams, type UseInfiniteMatchesParams, type UseInfiniteOrdersOptions, type UseInfiniteOrdersParams, type UseInfiniteTradesMultiParams, type UseInfiniteTradesParams, type UseMarketHistoryResult, type UseMarketParams, type UseMarketTradesParams, type UseOrderParams, type UseOrderbookParams, type UseOrderbookSubscriptionParams, type UseOrderbookSubscriptionResult, type UseOrdersMultiOptions, type UseOrdersOptions, type UsePositionsMultiParams, type UsePositionsParams, type UsePredictWsClientResult, type UsePriceHistoryParams, type UsePricesSubscriptionParams, type UsePricesSubscriptionResult, type UseRealtimeOrderbookParams, type UseRealtimePricesParams, type UseRealtimeTradesParams, type UseRealtimeTradesResult, type UseSearchEventsParams, type UseSimilarEventsParams, type UseTradesSubscriptionParams, type UseTradesSubscriptionResult, type UseWithdrawStatusQueryParams, type WalkOrderbookParams, type WalkOutcome, type WalkResult, type WalkSide, type WalkStatus, WithdrawBuildRequest, WithdrawBuildResponse, WithdrawStatusResponse, WithdrawSubmitRequest, WithdrawSubmitResponse, WsConnectionStatus, WsDataMessage, WsOrderbookEvent, WsPriceEvent, WsTradeEvent, availableSharesQueryKey, balanceQueryKey, buildSignedV2OrderPayload, candlesticksQueryKey, dflowKYCQueryKey, dflowQuoteQueryKey, eventStatsQueryKey, eventsQueryKey, feeRateQueryKey, fetchEvents, infiniteCommentsQueryKey, infiniteOrdersQueryKey, infiniteTradesMultiQueryKey, infiniteTradesQueryKey, marketTradesQueryKey, orderQueryKey, orderbookQueryKey, ordersMultiQueryKey, ordersQueryKey, pickBestAsk, pickBestBid, polymarketDepositAddressesQueryKey, polymarketSetupQueryKey, polymarketSupportedAssetsQueryKey, positionsMultiQueryKey, positionsQueryKey, priceHistoryQueryKey, rebateConfigQueryKey, similarEventsQueryKey, tickSizeQueryKey, tradesQueryKey, updatePolymarketBalanceAllowance, useAvailableShares, useBalance, useCancelOrder, useCandlesticks, useCreatePolymarketOrder, useDFlowKYC, useDFlowQuote, useDFlowSubmit, useDeployPolymarketDepositWallet, useEvent, useEventStats, useEvents, useFeeRate, useInfiniteComments, useInfiniteEvents, useInfiniteMatchMarkets, useInfiniteMatches, useInfiniteOrders, useInfiniteTrades, useInfiniteTradesMulti, useMarket, useMarketHistory, useMarketTrades, useMatch, useOrder, useOrderbook, useOrderbookSubscription, useOrders, useOrdersMulti, usePolymarket, usePolymarketDeposit, usePolymarketDepositAddresses, usePolymarketSetup, usePolymarketSupportedAssets, usePolymarketWithdraw, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRebateConfig, useRedeemPosition, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTickSize, useTrades, useTradesSubscription, useWithdrawBuildMutation, useWithdrawStatusQuery, useWithdrawSubmitMutation, walkOrderbook, withdrawStatusQueryKey };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as
|
|
2
|
-
export {
|
|
1
|
+
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as OrderbookOutcome, h as Orderbook, i as ListMarketTradesParams, j as PredictTrade, k as PriceHistoryRange, l as PriceHistoryResponse, m as ListCandlesticksParams, C as Candlestick, n as ListCommentsParams, o as PredictComment, p as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, q as ListOrdersParams, r as PredictOrder, s as ListOrdersMultiParams, t as PredictOrdersResponse, u as CancelOrderResult, M as MatchesParams, v as MatchGroupPage, w as MatchGroup, x as MatchMarketParams, y as MatchMarketPage, z as ListTradesParams, D as ListTradesMultiParams, F as DFlowQuoteRequest, G as DFlowQuoteResponse, H as DFlowSubmitResponse, I as DFlowSubmitRequest, J as DFlowKYCStatus, K as PolymarketSetupStatus, N as PolymarketDepositWalletDeployResponse, W as WithdrawBuildResponse, Q as WithdrawBuildRequest, R as WithdrawSubmitResponse, T as WithdrawSubmitRequest, U as WithdrawStatusResponse, V as PolymarketDepositAddresses, X as PolymarketSupportedAsset, Y as PolymarketWithdrawResponse, Z as PolymarketWithdrawRequest, _ as PolymarketRedeemResponse, $ as TickSizeResponse, a0 as FeeRateResponse, a1 as RebateConfig, a2 as WsConnectionStatus, a3 as WsDataMessage, a4 as WsPriceEvent, a5 as WsOrderbookEvent, a6 as WsTradeEvent, a7 as CreateOrderInput } from './server-Da_gQzNk.js';
|
|
2
|
+
export { bm as BuildClobAuthMessageInput, bA as BuildOrderMessageInput, bd as CLOB_AUTH_DOMAIN, be as CLOB_AUTH_TYPES, bn as CTF_EXCHANGE_ADDRESS, bs as CTF_ORDER_TYPES, bz as ClobOrderPayload, aq as DFlowOrderContext, au as DepositBuildRequest, av as DepositBuildResponse, ay as DepositStatusResponse, aw as DepositSubmitRequest, ax as DepositSubmitResponse, aj as EventSummary, bj as HttpMethod, ag as MarketOutcome, af as MarketResult, ae as MarketStatus, ak as MarketSummary, aJ as MatchConfidenceTier, aF as MatchGroupEntry, aG as MatchGroupMarket, aL as MatchLeg, aM as MatchMarketFlat, aH as MatchSortField, aE as MatchStatus, aI as MatchesStats, bo as NEG_RISK_CTF_EXCHANGE_ADDRESS, bt as ORDER_TYPE, bB as OrderMessage, ap as OrderSide, ao as OrderStatus, ah as OrderbookLevel, bq as POLYGON_CHAIN_ID, aA as PolymarketBridgeToken, at as PolymarketDepositWalletDeployRequest, bl as PolymarketL2Headers, bk as PolymarketL2HeadersInput, ar as PolymarketOrderType, aZ as PolymarketRedeemInput, aX as PolymarketRedeemPrepareInput, aY as PolymarketRedeemPrepareResponse, aB as PolymarketSupportedAssetsResponse, as as PolymarketWalletKind, aC as PolymarketWithdrawPrepareRequest, aD as PolymarketWithdrawPrepareResponse, al as PredictCommentProfile, an as PredictPosition, ac as PredictTag, aa as PredictWsClientConfig, am as PricePoint, ab as ProviderMeta, b4 as ResolveEventsParamsInput, bu as SIDE, ad as SettlementSource, aK as SignalTag, bC as SignedOrder, b5 as TagSlugSelection, ai as TradeType, bp as USDC_ADDRESS, az as UnsignedTx, aN as WsChannel, aO as WsChannelEvent, aP as WsClientMessage, aV as WsErrorCode, aW as WsErrorMessage, aR as WsPingMessage, aT as WsPongMessage, aS as WsServerMessage, aQ as WsSubscribeMessage, aU as WsSubscribedMessage, bf as buildClobAuthMessage, bx as buildClobPayload, br as buildCtfExchangeDomain, bv as buildOrderMessage, bh as buildPolymarketL2Headers, bw as buildSignedOrder, a8 as createPredictClient, a9 as createPredictWsClient, bi as derivePolymarketApiKey, a_ as eventQueryKey, a$ as fetchEvent, b3 as fetchEventsPage, b7 as fetchMarket, bc as fetchMatchMarketsPage, ba as fetchMatchesPage, by as getPolymarketSharesPrecision, bg as hmacSha256Base64, b2 as infiniteEventsQueryKey, b6 as marketQueryKey, bb as matchMarketsQueryKey, b9 as matchQueryKey, b8 as matchesQueryKey, b1 as resolveEventsParams, b0 as resolveTagSlug } from './server-Da_gQzNk.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { PropsWithChildren } from 'react';
|
|
@@ -338,10 +338,11 @@ interface UseMarketHistoryResult {
|
|
|
338
338
|
*/
|
|
339
339
|
declare function useMarketHistory(markets: PredictMarket[], range?: ChartRangeType): UseMarketHistoryResult;
|
|
340
340
|
|
|
341
|
-
declare function orderbookQueryKey(slug: string, source: ProviderSource): unknown[];
|
|
341
|
+
declare function orderbookQueryKey(slug: string, source: ProviderSource, outcome?: OrderbookOutcome): unknown[];
|
|
342
342
|
interface UseOrderbookParams {
|
|
343
343
|
slug: string;
|
|
344
344
|
source: ProviderSource;
|
|
345
|
+
outcome?: OrderbookOutcome;
|
|
345
346
|
}
|
|
346
347
|
declare function useOrderbook(params: UseOrderbookParams, queryOptions?: Omit<UseQueryOptions<Orderbook, Error, Orderbook, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<Orderbook, Error>;
|
|
347
348
|
|
|
@@ -776,6 +777,8 @@ interface UseOrderbookSubscriptionParams {
|
|
|
776
777
|
slug: string;
|
|
777
778
|
/** Enable/disable the subscription. Default: `true`. */
|
|
778
779
|
enabled?: boolean;
|
|
780
|
+
/** Optional outcome filter for the returned local snapshot. */
|
|
781
|
+
outcome?: OrderbookOutcome;
|
|
779
782
|
/** Optional callback fired on every orderbook snapshot. */
|
|
780
783
|
onUpdate?: (msg: WsDataMessage<WsOrderbookEvent>) => void;
|
|
781
784
|
}
|
|
@@ -791,7 +794,7 @@ interface UseOrderbookSubscriptionResult {
|
|
|
791
794
|
* Each incoming message is a **full snapshot** — no delta merging needed.
|
|
792
795
|
* Does **not** interact with React Query.
|
|
793
796
|
*/
|
|
794
|
-
declare function useOrderbookSubscription({ wsClient, slug, enabled, onUpdate, }: UseOrderbookSubscriptionParams): UseOrderbookSubscriptionResult;
|
|
797
|
+
declare function useOrderbookSubscription({ wsClient, slug, enabled, outcome, onUpdate, }: UseOrderbookSubscriptionParams): UseOrderbookSubscriptionResult;
|
|
795
798
|
|
|
796
799
|
interface UseTradesSubscriptionParams {
|
|
797
800
|
/** WebSocket client (from `usePredictWsClient`). */
|
|
@@ -824,6 +827,7 @@ declare function useTradesSubscription({ wsClient, slug, enabled, maxHistory, on
|
|
|
824
827
|
interface UseRealtimeOrderbookParams {
|
|
825
828
|
slug: string;
|
|
826
829
|
source: ProviderSource;
|
|
830
|
+
outcome?: OrderbookOutcome;
|
|
827
831
|
}
|
|
828
832
|
/**
|
|
829
833
|
* Orderbook with automatic WS → REST fallback.
|
|
@@ -1023,10 +1027,9 @@ declare function updatePolymarketBalanceAllowance(params: SyncBalanceAllowancePa
|
|
|
1023
1027
|
/**
|
|
1024
1028
|
* Orderbook-aware pricing utilities for prediction-market orders.
|
|
1025
1029
|
*
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
* callers can reason about a single outcome at a time.
|
|
1030
|
+
* Orderbooks are per-outcome: a YES book contains YES bids/asks and a NO
|
|
1031
|
+
* book contains NO bids/asks. These helpers never infer one side from the
|
|
1032
|
+
* other; callers must pass the real book for the selected outcome.
|
|
1030
1033
|
*
|
|
1031
1034
|
* Market-style orders (FOK on Polymarket) require a price that actually
|
|
1032
1035
|
* crosses every level we intend to fill into; a price quoted at top-of-book
|
|
@@ -1042,13 +1045,13 @@ type WalkOutcome = "yes" | "no";
|
|
|
1042
1045
|
type WalkStatus = "ok" | "insufficient_liquidity" | "exceeds_slippage" | "no_orderbook";
|
|
1043
1046
|
interface WalkResult {
|
|
1044
1047
|
status: WalkStatus;
|
|
1045
|
-
/** Top-of-book price
|
|
1048
|
+
/** Top-of-book price (best ask for buy, best bid for sell). */
|
|
1046
1049
|
bestPrice: number | null;
|
|
1047
1050
|
/** Worst price walked into; equals `bestPrice` when one level fully covers the request. */
|
|
1048
1051
|
worstPrice: number | null;
|
|
1049
1052
|
/** Volume-weighted average price across all levels actually consumed. */
|
|
1050
1053
|
vwap: number | null;
|
|
1051
|
-
/** Total share size available on the relevant side
|
|
1054
|
+
/** Total share size available on the relevant side. */
|
|
1052
1055
|
totalAvailable: number;
|
|
1053
1056
|
/** Share size that was actually filled while walking (≤ totalAvailable). */
|
|
1054
1057
|
filled: number;
|
|
@@ -1087,4 +1090,4 @@ interface WalkOrderbookParams {
|
|
|
1087
1090
|
*/
|
|
1088
1091
|
declare function walkOrderbook({ orderbook, outcome, side, sharesNeeded, slippageBps, }: WalkOrderbookParams): WalkResult;
|
|
1089
1092
|
|
|
1090
|
-
export { AvailableSharesResponse, BalanceResponse, type BuildV2OrderParams, CancelOrderResult, type CancelOrderVariables, Candlestick, ChartRange, type ChartRangeType, type ClobOrderV2Payload, CreateOrderInput, type CreatePolymarketOrderVariables, DFlowKYCStatus, DFlowQuoteRequest, DFlowQuoteResponse, DFlowSubmitRequest, DFlowSubmitResponse, EventSortField, EventStats, EventStatus, FeeRateResponse, ListCandlesticksParams, ListCommentsParams, ListEventsParams, ListMarketTradesParams, ListOrdersMultiParams, ListOrdersParams, ListTradesMultiParams, ListTradesParams, type MarketHistoryPoint, type MarketHistorySeries, MatchGroup, MatchGroupPage, MatchMarketPage, MatchMarketParams, MatchesParams, Orderbook, PolymarketContext, type PolymarketContextValue, type PolymarketCredentials, PolymarketDepositAddresses, type PolymarketDepositResult, type PolymarketDepositVariables, PolymarketDepositWalletDeployResponse, PolymarketProvider, type PolymarketProviderProps, PolymarketRedeemResponse, PolymarketSetupStatus, type PolymarketSigner, PolymarketSupportedAsset, PolymarketWithdrawRequest, PolymarketWithdrawResponse, PositionsResponse, PredictClient, PredictComment, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictOrdersResponse, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryRange, PriceHistoryResponse, ProviderSource, RebateConfig, type RedeemPositionVariables, SimilarEventsParams, type SyncBalanceAllowanceParams, TickSizeResponse, type UseAvailableSharesOptions, type UseAvailableSharesParams, type UseBalanceParams, type UseCancelOrderOptions, type UseCandlesticksParams, type UseEventParams, type UseInfiniteCommentsParams, type UseInfiniteMatchMarketsParams, type UseInfiniteMatchesParams, type UseInfiniteOrdersOptions, type UseInfiniteOrdersParams, type UseInfiniteTradesMultiParams, type UseInfiniteTradesParams, type UseMarketHistoryResult, type UseMarketParams, type UseMarketTradesParams, type UseOrderParams, type UseOrderbookParams, type UseOrderbookSubscriptionParams, type UseOrderbookSubscriptionResult, type UseOrdersMultiOptions, type UseOrdersOptions, type UsePositionsMultiParams, type UsePositionsParams, type UsePredictWsClientResult, type UsePriceHistoryParams, type UsePricesSubscriptionParams, type UsePricesSubscriptionResult, type UseRealtimeOrderbookParams, type UseRealtimePricesParams, type UseRealtimeTradesParams, type UseRealtimeTradesResult, type UseSearchEventsParams, type UseSimilarEventsParams, type UseTradesSubscriptionParams, type UseTradesSubscriptionResult, type UseWithdrawStatusQueryParams, type WalkOrderbookParams, type WalkOutcome, type WalkResult, type WalkSide, type WalkStatus, WithdrawBuildRequest, WithdrawBuildResponse, WithdrawStatusResponse, WithdrawSubmitRequest, WithdrawSubmitResponse, WsConnectionStatus, WsDataMessage, WsOrderbookEvent, WsPriceEvent, WsTradeEvent, availableSharesQueryKey, balanceQueryKey, buildSignedV2OrderPayload, candlesticksQueryKey, dflowKYCQueryKey, dflowQuoteQueryKey, eventStatsQueryKey, eventsQueryKey, feeRateQueryKey, fetchEvents, infiniteCommentsQueryKey, infiniteOrdersQueryKey, infiniteTradesMultiQueryKey, infiniteTradesQueryKey, marketTradesQueryKey, orderQueryKey, orderbookQueryKey, ordersMultiQueryKey, ordersQueryKey, pickBestAsk, pickBestBid, polymarketDepositAddressesQueryKey, polymarketSetupQueryKey, polymarketSupportedAssetsQueryKey, positionsMultiQueryKey, positionsQueryKey, priceHistoryQueryKey, rebateConfigQueryKey, similarEventsQueryKey, tickSizeQueryKey, tradesQueryKey, updatePolymarketBalanceAllowance, useAvailableShares, useBalance, useCancelOrder, useCandlesticks, useCreatePolymarketOrder, useDFlowKYC, useDFlowQuote, useDFlowSubmit, useDeployPolymarketDepositWallet, useEvent, useEventStats, useEvents, useFeeRate, useInfiniteComments, useInfiniteEvents, useInfiniteMatchMarkets, useInfiniteMatches, useInfiniteOrders, useInfiniteTrades, useInfiniteTradesMulti, useMarket, useMarketHistory, useMarketTrades, useMatch, useOrder, useOrderbook, useOrderbookSubscription, useOrders, useOrdersMulti, usePolymarket, usePolymarketDeposit, usePolymarketDepositAddresses, usePolymarketSetup, usePolymarketSupportedAssets, usePolymarketWithdraw, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRebateConfig, useRedeemPosition, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTickSize, useTrades, useTradesSubscription, useWithdrawBuildMutation, useWithdrawStatusQuery, useWithdrawSubmitMutation, walkOrderbook, withdrawStatusQueryKey };
|
|
1093
|
+
export { AvailableSharesResponse, BalanceResponse, type BuildV2OrderParams, CancelOrderResult, type CancelOrderVariables, Candlestick, ChartRange, type ChartRangeType, type ClobOrderV2Payload, CreateOrderInput, type CreatePolymarketOrderVariables, DFlowKYCStatus, DFlowQuoteRequest, DFlowQuoteResponse, DFlowSubmitRequest, DFlowSubmitResponse, EventSortField, EventStats, EventStatus, FeeRateResponse, ListCandlesticksParams, ListCommentsParams, ListEventsParams, ListMarketTradesParams, ListOrdersMultiParams, ListOrdersParams, ListTradesMultiParams, ListTradesParams, type MarketHistoryPoint, type MarketHistorySeries, MatchGroup, MatchGroupPage, MatchMarketPage, MatchMarketParams, MatchesParams, Orderbook, OrderbookOutcome, PolymarketContext, type PolymarketContextValue, type PolymarketCredentials, PolymarketDepositAddresses, type PolymarketDepositResult, type PolymarketDepositVariables, PolymarketDepositWalletDeployResponse, PolymarketProvider, type PolymarketProviderProps, PolymarketRedeemResponse, PolymarketSetupStatus, type PolymarketSigner, PolymarketSupportedAsset, PolymarketWithdrawRequest, PolymarketWithdrawResponse, PositionsResponse, PredictClient, PredictComment, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictOrdersResponse, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryRange, PriceHistoryResponse, ProviderSource, RebateConfig, type RedeemPositionVariables, SimilarEventsParams, type SyncBalanceAllowanceParams, TickSizeResponse, type UseAvailableSharesOptions, type UseAvailableSharesParams, type UseBalanceParams, type UseCancelOrderOptions, type UseCandlesticksParams, type UseEventParams, type UseInfiniteCommentsParams, type UseInfiniteMatchMarketsParams, type UseInfiniteMatchesParams, type UseInfiniteOrdersOptions, type UseInfiniteOrdersParams, type UseInfiniteTradesMultiParams, type UseInfiniteTradesParams, type UseMarketHistoryResult, type UseMarketParams, type UseMarketTradesParams, type UseOrderParams, type UseOrderbookParams, type UseOrderbookSubscriptionParams, type UseOrderbookSubscriptionResult, type UseOrdersMultiOptions, type UseOrdersOptions, type UsePositionsMultiParams, type UsePositionsParams, type UsePredictWsClientResult, type UsePriceHistoryParams, type UsePricesSubscriptionParams, type UsePricesSubscriptionResult, type UseRealtimeOrderbookParams, type UseRealtimePricesParams, type UseRealtimeTradesParams, type UseRealtimeTradesResult, type UseSearchEventsParams, type UseSimilarEventsParams, type UseTradesSubscriptionParams, type UseTradesSubscriptionResult, type UseWithdrawStatusQueryParams, type WalkOrderbookParams, type WalkOutcome, type WalkResult, type WalkSide, type WalkStatus, WithdrawBuildRequest, WithdrawBuildResponse, WithdrawStatusResponse, WithdrawSubmitRequest, WithdrawSubmitResponse, WsConnectionStatus, WsDataMessage, WsOrderbookEvent, WsPriceEvent, WsTradeEvent, availableSharesQueryKey, balanceQueryKey, buildSignedV2OrderPayload, candlesticksQueryKey, dflowKYCQueryKey, dflowQuoteQueryKey, eventStatsQueryKey, eventsQueryKey, feeRateQueryKey, fetchEvents, infiniteCommentsQueryKey, infiniteOrdersQueryKey, infiniteTradesMultiQueryKey, infiniteTradesQueryKey, marketTradesQueryKey, orderQueryKey, orderbookQueryKey, ordersMultiQueryKey, ordersQueryKey, pickBestAsk, pickBestBid, polymarketDepositAddressesQueryKey, polymarketSetupQueryKey, polymarketSupportedAssetsQueryKey, positionsMultiQueryKey, positionsQueryKey, priceHistoryQueryKey, rebateConfigQueryKey, similarEventsQueryKey, tickSizeQueryKey, tradesQueryKey, updatePolymarketBalanceAllowance, useAvailableShares, useBalance, useCancelOrder, useCandlesticks, useCreatePolymarketOrder, useDFlowKYC, useDFlowQuote, useDFlowSubmit, useDeployPolymarketDepositWallet, useEvent, useEventStats, useEvents, useFeeRate, useInfiniteComments, useInfiniteEvents, useInfiniteMatchMarkets, useInfiniteMatches, useInfiniteOrders, useInfiniteTrades, useInfiniteTradesMulti, useMarket, useMarketHistory, useMarketTrades, useMatch, useOrder, useOrderbook, useOrderbookSubscription, useOrders, useOrdersMulti, usePolymarket, usePolymarketDeposit, usePolymarketDepositAddresses, usePolymarketSetup, usePolymarketSupportedAssets, usePolymarketWithdraw, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRebateConfig, useRedeemPosition, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTickSize, useTrades, useTradesSubscription, useWithdrawBuildMutation, useWithdrawStatusQuery, useWithdrawSubmitMutation, walkOrderbook, withdrawStatusQueryKey };
|
package/dist/index.js
CHANGED
|
@@ -109,9 +109,9 @@ var PredictClient = class {
|
|
|
109
109
|
const url = `${this.endpoint}/api/v1/markets/${encodeURIComponent(slug)}${query}`;
|
|
110
110
|
return await utils.httpGet(url);
|
|
111
111
|
}
|
|
112
|
-
/** Maps to `GET /api/v1/markets/:slug/orderbook?source=...`. */
|
|
113
|
-
async getOrderbook(slug, source) {
|
|
114
|
-
const query = buildQuery({ source });
|
|
112
|
+
/** Maps to `GET /api/v1/markets/:slug/orderbook?source=...&outcome=...`. */
|
|
113
|
+
async getOrderbook(slug, source, outcome) {
|
|
114
|
+
const query = buildQuery({ source, outcome });
|
|
115
115
|
const url = `${this.endpoint}/api/v1/markets/${encodeURIComponent(slug)}/orderbook${query}`;
|
|
116
116
|
return await utils.httpGet(url);
|
|
117
117
|
}
|
|
@@ -1297,14 +1297,15 @@ function useMarketHistory(markets, range = ChartRange.ALL) {
|
|
|
1297
1297
|
}, [markets, queries]);
|
|
1298
1298
|
return { series, isLoading };
|
|
1299
1299
|
}
|
|
1300
|
-
function orderbookQueryKey(slug, source) {
|
|
1301
|
-
return ["predict", "orderbook", slug, source];
|
|
1300
|
+
function orderbookQueryKey(slug, source, outcome = "yes") {
|
|
1301
|
+
return ["predict", "orderbook", slug, source, outcome];
|
|
1302
1302
|
}
|
|
1303
1303
|
function useOrderbook(params, queryOptions = {}) {
|
|
1304
1304
|
const client = usePredictClient();
|
|
1305
|
+
const outcome = params.outcome ?? "yes";
|
|
1305
1306
|
return reactQuery.useQuery({
|
|
1306
|
-
queryKey: orderbookQueryKey(params.slug, params.source),
|
|
1307
|
-
queryFn: () => client.getOrderbook(params.slug, params.source),
|
|
1307
|
+
queryKey: orderbookQueryKey(params.slug, params.source, outcome),
|
|
1308
|
+
queryFn: () => client.getOrderbook(params.slug, params.source, outcome),
|
|
1308
1309
|
enabled: Boolean(params.slug),
|
|
1309
1310
|
refetchInterval: 3e4,
|
|
1310
1311
|
...queryOptions
|
|
@@ -1963,6 +1964,7 @@ function useOrderbookSubscription({
|
|
|
1963
1964
|
wsClient,
|
|
1964
1965
|
slug,
|
|
1965
1966
|
enabled = true,
|
|
1967
|
+
outcome,
|
|
1966
1968
|
onUpdate
|
|
1967
1969
|
}) {
|
|
1968
1970
|
const [orderbook, setOrderbook] = react.useState(null);
|
|
@@ -1972,11 +1974,13 @@ function useOrderbookSubscription({
|
|
|
1972
1974
|
const handleUpdate = react.useCallback(
|
|
1973
1975
|
(msg) => {
|
|
1974
1976
|
if (msg.data.market_slug === slug) {
|
|
1975
|
-
|
|
1977
|
+
if (!outcome || msg.data.outcome === outcome) {
|
|
1978
|
+
setOrderbook(msg.data);
|
|
1979
|
+
}
|
|
1976
1980
|
onUpdateRef.current?.(msg);
|
|
1977
1981
|
}
|
|
1978
1982
|
},
|
|
1979
|
-
[slug]
|
|
1983
|
+
[slug, outcome]
|
|
1980
1984
|
);
|
|
1981
1985
|
react.useEffect(() => {
|
|
1982
1986
|
if (!wsClient || !enabled || !slug) {
|
|
@@ -2041,28 +2045,33 @@ var REST_POLL_INTERVAL = 5e3;
|
|
|
2041
2045
|
function useRealtimeOrderbook(params, queryOptions = {}) {
|
|
2042
2046
|
const { wsClient } = usePredictWsClient();
|
|
2043
2047
|
const queryClient = reactQuery.useQueryClient();
|
|
2044
|
-
const
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
const { isSubscribed } = useOrderbookSubscription(subParams);
|
|
2050
|
-
const qk = orderbookQueryKey(params.slug, params.source);
|
|
2051
|
-
const qkRef = react.useRef(qk);
|
|
2052
|
-
qkRef.current = qk;
|
|
2053
|
-
react.useEffect(() => {
|
|
2054
|
-
if (!wsClient || !params.slug) return;
|
|
2055
|
-
const unsub = wsClient.subscribeOrderbook([params.slug], (msg) => {
|
|
2048
|
+
const outcome = params.outcome ?? "yes";
|
|
2049
|
+
const handleUpdate = react.useCallback(
|
|
2050
|
+
(msg) => {
|
|
2051
|
+
if (msg.data.market_slug !== params.slug) return;
|
|
2052
|
+
if (msg.data.outcome !== "yes" && msg.data.outcome !== "no") return;
|
|
2056
2053
|
const ob = {
|
|
2057
2054
|
market_id: msg.data.market_slug,
|
|
2055
|
+
outcome: msg.data.outcome,
|
|
2058
2056
|
bids: msg.data.bids,
|
|
2059
2057
|
asks: msg.data.asks,
|
|
2060
2058
|
spread: msg.data.spread
|
|
2061
2059
|
};
|
|
2062
|
-
queryClient.setQueryData(
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2060
|
+
queryClient.setQueryData(
|
|
2061
|
+
orderbookQueryKey(params.slug, params.source, msg.data.outcome),
|
|
2062
|
+
ob
|
|
2063
|
+
);
|
|
2064
|
+
},
|
|
2065
|
+
[params.slug, params.source, queryClient]
|
|
2066
|
+
);
|
|
2067
|
+
const subParams = {
|
|
2068
|
+
wsClient,
|
|
2069
|
+
slug: params.slug,
|
|
2070
|
+
enabled: Boolean(params.slug),
|
|
2071
|
+
outcome,
|
|
2072
|
+
onUpdate: handleUpdate
|
|
2073
|
+
};
|
|
2074
|
+
const { isSubscribed } = useOrderbookSubscription(subParams);
|
|
2066
2075
|
return useOrderbook(params, {
|
|
2067
2076
|
refetchInterval: isSubscribed ? false : REST_POLL_INTERVAL,
|
|
2068
2077
|
...queryOptions
|
|
@@ -2493,20 +2502,14 @@ async function pollTxConfirmed(fetchStatus, txHash) {
|
|
|
2493
2502
|
}
|
|
2494
2503
|
|
|
2495
2504
|
// src/utils/orderbook-pricing.ts
|
|
2496
|
-
function getWalkLevels(orderbook,
|
|
2505
|
+
function getWalkLevels(orderbook, _outcome, side) {
|
|
2497
2506
|
if (!orderbook) return [];
|
|
2498
|
-
const
|
|
2499
|
-
const useAsks = side === "buy" && !isNo || side === "sell" && isNo;
|
|
2500
|
-
const raw = useAsks ? orderbook.asks : orderbook.bids;
|
|
2507
|
+
const raw = side === "buy" ? orderbook.asks : orderbook.bids;
|
|
2501
2508
|
if (!raw || raw.length === 0) return [];
|
|
2502
|
-
const mapped = raw.map((lvl) => ({
|
|
2503
|
-
price: isNo ? 1 - lvl.price : lvl.price,
|
|
2504
|
-
size: lvl.size
|
|
2505
|
-
}));
|
|
2506
2509
|
if (side === "buy") {
|
|
2507
|
-
return [...
|
|
2510
|
+
return [...raw].sort((a, b) => a.price - b.price);
|
|
2508
2511
|
}
|
|
2509
|
-
return [...
|
|
2512
|
+
return [...raw].sort((a, b) => b.price - a.price);
|
|
2510
2513
|
}
|
|
2511
2514
|
function pickBestAsk(orderbook, outcome) {
|
|
2512
2515
|
const levels = getWalkLevels(orderbook, outcome, "buy");
|