@liberfi.io/react-predict 0.3.65 → 0.3.67

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 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 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, q as PositionValueResponse, A as AvailableSharesResponse, B as BalanceResponse, r as ListOrdersParams, s as PredictOrder, t as ListOrdersMultiParams, u as PredictOrdersResponse, v as CancelOrderResult, M as MatchesParams, w as MatchGroupPage, x as MatchGroup, y as MatchMarketParams, z as MatchMarketPage, D as ListTradesParams, F as ListTradesMultiParams, G as DFlowQuoteRequest, H as DFlowQuoteResponse, I as DFlowSubmitResponse, J as DFlowSubmitRequest, K as DFlowKYCStatus, N as PolymarketSetupStatus, Q as PolymarketDepositWalletDeployResponse, W as WithdrawBuildResponse, R as WithdrawBuildRequest, T as WithdrawSubmitResponse, U as WithdrawSubmitRequest, V as WithdrawStatusResponse, X as PolymarketDepositAddresses, Y as PolymarketSupportedAsset, Z as PolymarketWithdrawResponse, _ as PolymarketWithdrawRequest, $ as PolymarketWithdrawPrepareResponse, a0 as PolymarketWithdrawPrepareRequest, a1 as PolymarketWithdrawQuoteResponse, a2 as PolymarketWithdrawQuoteRequest, a3 as PolymarketWithdrawRelayBuildResponse, a4 as PolymarketWithdrawRelayBuildRequest, a5 as PolymarketWithdrawRelaySubmitResponse, a6 as PolymarketWithdrawRelaySubmitRequest, a7 as PolymarketWithdrawBridgeStatusResponse, a8 as PolymarketRedeemResponse, a9 as PolymarketTypedData, aa as TickSizeResponse, ab as FeeRateResponse, ac as RebateConfig, ad as WsConnectionStatus, ae as WsDataMessage, af as WsPriceEvent, ag as WsOrderbookEvent, ah as WsTradeEvent, ai as CreateOrderInput } from './server-pS5Vlydo.mjs';
2
- export { bE as BuildClobAuthMessageInput, bT as BuildOrderMessageInput, bv as CLOB_AUTH_DOMAIN, bw as CLOB_AUTH_TYPES, bF as CTF_EXCHANGE_ADDRESS, bK as CTF_ORDER_TYPES, bS as ClobOrderPayload, aI as DFlowOrderContext, aN as DepositBuildRequest, aO as DepositBuildResponse, aR as DepositStatusResponse, aP as DepositSubmitRequest, aQ as DepositSubmitResponse, az as EventSummary, bB as HttpMethod, as as MarketOutcome, ar as MarketResult, aq as MarketStatus, aA as MarketSummary, a$ as MatchConfidenceTier, aX as MatchGroupEntry, aY as MatchGroupMarket, b1 as MatchLeg, b2 as MatchMarketFlat, aZ as MatchSortField, aW as MatchStatus, a_ as MatchesStats, bG as NEG_RISK_CTF_EXCHANGE_ADDRESS, bL as ORDER_TYPE, bU as OrderMessage, aH as OrderSide, aG as OrderStatus, au as OrderbookBatchItem, av as OrderbookBatchResult, at as OrderbookLevel, aw as OrderbooksBatchRequest, ax as OrderbooksBatchResponse, bI as POLYGON_CHAIN_ID, aT as PolymarketBridgeToken, aM as PolymarketDepositWalletDeployRequest, bD as PolymarketL2Headers, bC as PolymarketL2HeadersInput, aJ as PolymarketOrderType, bf as PolymarketRedeemInput, bd as PolymarketRedeemPrepareInput, be as PolymarketRedeemPrepareResponse, aU as PolymarketSupportedAssetsResponse, aK as PolymarketTickSize, aV as PolymarketTypedDataArg, aL as PolymarketWalletKind, aE as PositionValue, aF as PositionValueError, ak as PredictClientOptions, aB as PredictCommentProfile, aD as PredictPosition, ao as PredictTag, am as PredictWsClientConfig, aC as PricePoint, an as ProviderMeta, bm as ResolveEventsParamsInput, bM as SIDE, ap as SettlementSource, b0 as SignalTag, bV as SignedOrder, bn as TagSlugSelection, ay as TradeType, bH as USDC_ADDRESS, aS as UnsignedTx, b3 as WsChannel, b4 as WsChannelEvent, b5 as WsClientMessage, bb as WsErrorCode, bc as WsErrorMessage, b7 as WsPingMessage, b9 as WsPongMessage, b8 as WsServerMessage, b6 as WsSubscribeMessage, ba as WsSubscribedMessage, bx as buildClobAuthMessage, bP as buildClobPayload, bJ as buildCtfExchangeDomain, bN as buildOrderMessage, bz as buildPolymarketL2Headers, bO as buildSignedOrder, aj as createPredictClient, al as createPredictWsClient, bA as derivePolymarketApiKey, bg as eventQueryKey, bh as fetchEvent, bl as fetchEventsPage, bp as fetchMarket, bu as fetchMatchMarketsPage, bs as fetchMatchesPage, bQ as getPolymarketSharesPrecision, by as hmacSha256Base64, bk as infiniteEventsQueryKey, bo as marketQueryKey, bt as matchMarketsQueryKey, br as matchQueryKey, bq as matchesQueryKey, bR as normalizePolymarketTickSize, bj as resolveEventsParams, bi as resolveTagSlug } from './server-pS5Vlydo.mjs';
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 PriceHistoryParams, m as PriceHistoryResponse, n as ListCandlesticksParams, C as Candlestick, o as ListCommentsParams, p as PredictComment, q as PositionsResponse, r as PositionValueResponse, A as AvailableSharesResponse, B as BalanceResponse, s as ListOrdersParams, t as PredictOrder, u as ListOrdersMultiParams, v as PredictOrdersResponse, w as CancelOrderResult, M as MatchesParams, x as MatchGroupPage, y as MatchGroup, z as MatchMarketParams, D as MatchMarketPage, F as ListTradesParams, G as ListTradesMultiParams, H as DFlowQuoteRequest, I as DFlowQuoteResponse, J as DFlowSubmitResponse, K as DFlowSubmitRequest, N as DFlowKYCStatus, Q as PolymarketSetupStatus, R as PolymarketDepositWalletDeployResponse, W as WithdrawBuildResponse, T as WithdrawBuildRequest, U as WithdrawSubmitResponse, V as WithdrawSubmitRequest, X as WithdrawStatusResponse, Y as PolymarketDepositAddresses, Z as PolymarketSupportedAsset, _ as PolymarketWithdrawResponse, $ as PolymarketWithdrawRequest, a0 as PolymarketWithdrawPrepareResponse, a1 as PolymarketWithdrawPrepareRequest, a2 as PolymarketWithdrawQuoteResponse, a3 as PolymarketWithdrawQuoteRequest, a4 as PolymarketWithdrawRelayBuildResponse, a5 as PolymarketWithdrawRelayBuildRequest, a6 as PolymarketWithdrawRelaySubmitResponse, a7 as PolymarketWithdrawRelaySubmitRequest, a8 as PolymarketWithdrawBridgeStatusResponse, a9 as PolymarketRedeemResponse, aa as PolymarketTypedData, ab as TickSizeResponse, ac as FeeRateResponse, ad as RebateConfig, ae as WsConnectionStatus, af as WsDataMessage, ag as WsPriceEvent, ah as WsOrderbookEvent, ai as WsTradeEvent, aj as CreateOrderInput } from './server-B6SSpkMN.mjs';
2
+ export { bF as BuildClobAuthMessageInput, bU as BuildOrderMessageInput, bw as CLOB_AUTH_DOMAIN, bx as CLOB_AUTH_TYPES, bG as CTF_EXCHANGE_ADDRESS, bL as CTF_ORDER_TYPES, bT as ClobOrderPayload, aJ as DFlowOrderContext, aO as DepositBuildRequest, aP as DepositBuildResponse, aS as DepositStatusResponse, aQ as DepositSubmitRequest, aR as DepositSubmitResponse, aA as EventSummary, bC as HttpMethod, at as MarketOutcome, as as MarketResult, ar as MarketStatus, aB as MarketSummary, b0 as MatchConfidenceTier, aY as MatchGroupEntry, aZ as MatchGroupMarket, b2 as MatchLeg, b3 as MatchMarketFlat, a_ as MatchSortField, aX as MatchStatus, a$ as MatchesStats, bH as NEG_RISK_CTF_EXCHANGE_ADDRESS, bM as ORDER_TYPE, bV as OrderMessage, aI as OrderSide, aH as OrderStatus, av as OrderbookBatchItem, aw as OrderbookBatchResult, au as OrderbookLevel, ax as OrderbooksBatchRequest, ay as OrderbooksBatchResponse, bJ as POLYGON_CHAIN_ID, aU as PolymarketBridgeToken, aN as PolymarketDepositWalletDeployRequest, bE as PolymarketL2Headers, bD as PolymarketL2HeadersInput, aK as PolymarketOrderType, bg as PolymarketRedeemInput, be as PolymarketRedeemPrepareInput, bf as PolymarketRedeemPrepareResponse, aV as PolymarketSupportedAssetsResponse, aL as PolymarketTickSize, aW as PolymarketTypedDataArg, aM as PolymarketWalletKind, aF as PositionValue, aG as PositionValueError, al as PredictClientOptions, aC as PredictCommentProfile, aE as PredictPosition, ap as PredictTag, an as PredictWsClientConfig, aD as PricePoint, ao as ProviderMeta, bn as ResolveEventsParamsInput, bN as SIDE, aq as SettlementSource, b1 as SignalTag, bW as SignedOrder, bo as TagSlugSelection, az as TradeType, bI as USDC_ADDRESS, aT as UnsignedTx, b4 as WsChannel, b5 as WsChannelEvent, b6 as WsClientMessage, bc as WsErrorCode, bd as WsErrorMessage, b8 as WsPingMessage, ba as WsPongMessage, b9 as WsServerMessage, b7 as WsSubscribeMessage, bb as WsSubscribedMessage, by as buildClobAuthMessage, bQ as buildClobPayload, bK as buildCtfExchangeDomain, bO as buildOrderMessage, bA as buildPolymarketL2Headers, bP as buildSignedOrder, ak as createPredictClient, am as createPredictWsClient, bB as derivePolymarketApiKey, bh as eventQueryKey, bi as fetchEvent, bm as fetchEventsPage, bq as fetchMarket, bv as fetchMatchMarketsPage, bt as fetchMatchesPage, bR as getPolymarketSharesPrecision, bz as hmacSha256Base64, bl as infiniteEventsQueryKey, bp as marketQueryKey, bu as matchMarketsQueryKey, bs as matchQueryKey, br as matchesQueryKey, bS as normalizePolymarketTickSize, bk as resolveEventsParams, bj as resolveTagSlug } from './server-B6SSpkMN.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';
@@ -314,8 +314,9 @@ interface UseMarketParams {
314
314
  declare function useMarket(params: UseMarketParams, queryOptions?: Omit<UseQueryOptions<PredictMarket, Error, PredictMarket, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<PredictMarket, Error>;
315
315
 
316
316
  declare const ChartRange: {
317
+ readonly ONE_HOUR: "1h";
318
+ readonly SIX_HOURS: "6h";
317
319
  readonly ONE_DAY: "1d";
318
- readonly ONE_WEEK: "1w";
319
320
  readonly ONE_MONTH: "1m";
320
321
  readonly ALL: "all";
321
322
  };
@@ -336,11 +337,15 @@ interface UseMarketHistoryResult {
336
337
  series: MarketHistorySeries[];
337
338
  isLoading: boolean;
338
339
  }
340
+ interface UseMarketHistoryOptions {
341
+ /** Anchored unix end timestamp in seconds, shared with the chart x-axis. */
342
+ endTs?: number;
343
+ }
339
344
  /**
340
345
  * Returns price history series for the provided markets using
341
346
  * `GET /api/v1/markets/{slug}/price-history`.
342
347
  */
343
- declare function useMarketHistory(markets: PredictMarket[], range?: ChartRangeType): UseMarketHistoryResult;
348
+ declare function useMarketHistory(markets: PredictMarket[], range?: ChartRangeType, options?: UseMarketHistoryOptions): UseMarketHistoryResult;
344
349
 
345
350
  declare function orderbookQueryKey(slug: string, source: ProviderSource, outcome?: OrderbookOutcome): unknown[];
346
351
  interface UseOrderbookParams {
@@ -360,7 +365,7 @@ interface UseMarketTradesParams {
360
365
  }
361
366
  declare function useMarketTrades(params: UseMarketTradesParams, queryOptions?: Omit<UseQueryOptions<PredictPage<PredictTrade>, Error, PredictPage<PredictTrade>, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<PredictPage<PredictTrade>, Error>;
362
367
 
363
- declare function priceHistoryQueryKey(slug: string, source: ProviderSource, range?: PriceHistoryRange): unknown[];
368
+ declare function priceHistoryQueryKey(slug: string, source: ProviderSource, rangeOrParams?: PriceHistoryRange | Omit<PriceHistoryParams, "source">): unknown[];
364
369
  interface UsePriceHistoryParams {
365
370
  slug: string;
366
371
  source: ProviderSource;
@@ -1169,4 +1174,4 @@ interface WalkOrderbookParams {
1169
1174
  */
1170
1175
  declare function walkOrderbook({ orderbook, outcome, side, sharesNeeded, slippageBps, }: WalkOrderbookParams): WalkResult;
1171
1176
 
1172
- 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, PolymarketTypedData, PolymarketWithdrawBridgeStatusResponse, PolymarketWithdrawPrepareRequest, PolymarketWithdrawPrepareResponse, PolymarketWithdrawQuoteRequest, PolymarketWithdrawQuoteResponse, PolymarketWithdrawRelayBuildRequest, PolymarketWithdrawRelayBuildResponse, PolymarketWithdrawRelaySubmitRequest, PolymarketWithdrawRelaySubmitResponse, PolymarketWithdrawRequest, PolymarketWithdrawResponse, PositionValueResponse, PositionsResponse, PredictClient, PredictComment, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictOrdersResponse, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryRange, PriceHistoryResponse, ProviderSource, RebateConfig, type RedeemPositionVariables, SimilarEventsParams, type StartTradeResultConfirmationInput, type SyncBalanceAllowanceParams, TickSizeResponse, type TradeResultConfirmationState, type TradeResultExpectation, 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 UsePositionValueMultiParams, type UsePositionValueParams, 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, polymarketWithdrawStatusQueryKey, positionValueMultiQueryKey, positionValueQueryKey, 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, usePolymarketWithdrawPrepareMutation, usePolymarketWithdrawQuoteMutation, usePolymarketWithdrawRelayBuildMutation, usePolymarketWithdrawRelaySubmitMutation, usePolymarketWithdrawStatusQuery, usePositionValue, usePositionValueMulti, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRebateConfig, useRedeemPosition, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTickSize, useTradeResultConfirmation, useTrades, useTradesSubscription, useWithdrawBuildMutation, useWithdrawStatusQuery, useWithdrawSubmitMutation, walkOrderbook, withdrawStatusQueryKey };
1177
+ 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, PolymarketTypedData, PolymarketWithdrawBridgeStatusResponse, PolymarketWithdrawPrepareRequest, PolymarketWithdrawPrepareResponse, PolymarketWithdrawQuoteRequest, PolymarketWithdrawQuoteResponse, PolymarketWithdrawRelayBuildRequest, PolymarketWithdrawRelayBuildResponse, PolymarketWithdrawRelaySubmitRequest, PolymarketWithdrawRelaySubmitResponse, PolymarketWithdrawRequest, PolymarketWithdrawResponse, PositionValueResponse, PositionsResponse, PredictClient, PredictComment, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictOrdersResponse, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryParams, PriceHistoryRange, PriceHistoryResponse, ProviderSource, RebateConfig, type RedeemPositionVariables, SimilarEventsParams, type StartTradeResultConfirmationInput, type SyncBalanceAllowanceParams, TickSizeResponse, type TradeResultConfirmationState, type TradeResultExpectation, 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 UsePositionValueMultiParams, type UsePositionValueParams, 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, polymarketWithdrawStatusQueryKey, positionValueMultiQueryKey, positionValueQueryKey, 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, usePolymarketWithdrawPrepareMutation, usePolymarketWithdrawQuoteMutation, usePolymarketWithdrawRelayBuildMutation, usePolymarketWithdrawRelaySubmitMutation, usePolymarketWithdrawStatusQuery, usePositionValue, usePositionValueMulti, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRebateConfig, useRedeemPosition, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTickSize, useTradeResultConfirmation, 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 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, q as PositionValueResponse, A as AvailableSharesResponse, B as BalanceResponse, r as ListOrdersParams, s as PredictOrder, t as ListOrdersMultiParams, u as PredictOrdersResponse, v as CancelOrderResult, M as MatchesParams, w as MatchGroupPage, x as MatchGroup, y as MatchMarketParams, z as MatchMarketPage, D as ListTradesParams, F as ListTradesMultiParams, G as DFlowQuoteRequest, H as DFlowQuoteResponse, I as DFlowSubmitResponse, J as DFlowSubmitRequest, K as DFlowKYCStatus, N as PolymarketSetupStatus, Q as PolymarketDepositWalletDeployResponse, W as WithdrawBuildResponse, R as WithdrawBuildRequest, T as WithdrawSubmitResponse, U as WithdrawSubmitRequest, V as WithdrawStatusResponse, X as PolymarketDepositAddresses, Y as PolymarketSupportedAsset, Z as PolymarketWithdrawResponse, _ as PolymarketWithdrawRequest, $ as PolymarketWithdrawPrepareResponse, a0 as PolymarketWithdrawPrepareRequest, a1 as PolymarketWithdrawQuoteResponse, a2 as PolymarketWithdrawQuoteRequest, a3 as PolymarketWithdrawRelayBuildResponse, a4 as PolymarketWithdrawRelayBuildRequest, a5 as PolymarketWithdrawRelaySubmitResponse, a6 as PolymarketWithdrawRelaySubmitRequest, a7 as PolymarketWithdrawBridgeStatusResponse, a8 as PolymarketRedeemResponse, a9 as PolymarketTypedData, aa as TickSizeResponse, ab as FeeRateResponse, ac as RebateConfig, ad as WsConnectionStatus, ae as WsDataMessage, af as WsPriceEvent, ag as WsOrderbookEvent, ah as WsTradeEvent, ai as CreateOrderInput } from './server-pS5Vlydo.js';
2
- export { bE as BuildClobAuthMessageInput, bT as BuildOrderMessageInput, bv as CLOB_AUTH_DOMAIN, bw as CLOB_AUTH_TYPES, bF as CTF_EXCHANGE_ADDRESS, bK as CTF_ORDER_TYPES, bS as ClobOrderPayload, aI as DFlowOrderContext, aN as DepositBuildRequest, aO as DepositBuildResponse, aR as DepositStatusResponse, aP as DepositSubmitRequest, aQ as DepositSubmitResponse, az as EventSummary, bB as HttpMethod, as as MarketOutcome, ar as MarketResult, aq as MarketStatus, aA as MarketSummary, a$ as MatchConfidenceTier, aX as MatchGroupEntry, aY as MatchGroupMarket, b1 as MatchLeg, b2 as MatchMarketFlat, aZ as MatchSortField, aW as MatchStatus, a_ as MatchesStats, bG as NEG_RISK_CTF_EXCHANGE_ADDRESS, bL as ORDER_TYPE, bU as OrderMessage, aH as OrderSide, aG as OrderStatus, au as OrderbookBatchItem, av as OrderbookBatchResult, at as OrderbookLevel, aw as OrderbooksBatchRequest, ax as OrderbooksBatchResponse, bI as POLYGON_CHAIN_ID, aT as PolymarketBridgeToken, aM as PolymarketDepositWalletDeployRequest, bD as PolymarketL2Headers, bC as PolymarketL2HeadersInput, aJ as PolymarketOrderType, bf as PolymarketRedeemInput, bd as PolymarketRedeemPrepareInput, be as PolymarketRedeemPrepareResponse, aU as PolymarketSupportedAssetsResponse, aK as PolymarketTickSize, aV as PolymarketTypedDataArg, aL as PolymarketWalletKind, aE as PositionValue, aF as PositionValueError, ak as PredictClientOptions, aB as PredictCommentProfile, aD as PredictPosition, ao as PredictTag, am as PredictWsClientConfig, aC as PricePoint, an as ProviderMeta, bm as ResolveEventsParamsInput, bM as SIDE, ap as SettlementSource, b0 as SignalTag, bV as SignedOrder, bn as TagSlugSelection, ay as TradeType, bH as USDC_ADDRESS, aS as UnsignedTx, b3 as WsChannel, b4 as WsChannelEvent, b5 as WsClientMessage, bb as WsErrorCode, bc as WsErrorMessage, b7 as WsPingMessage, b9 as WsPongMessage, b8 as WsServerMessage, b6 as WsSubscribeMessage, ba as WsSubscribedMessage, bx as buildClobAuthMessage, bP as buildClobPayload, bJ as buildCtfExchangeDomain, bN as buildOrderMessage, bz as buildPolymarketL2Headers, bO as buildSignedOrder, aj as createPredictClient, al as createPredictWsClient, bA as derivePolymarketApiKey, bg as eventQueryKey, bh as fetchEvent, bl as fetchEventsPage, bp as fetchMarket, bu as fetchMatchMarketsPage, bs as fetchMatchesPage, bQ as getPolymarketSharesPrecision, by as hmacSha256Base64, bk as infiniteEventsQueryKey, bo as marketQueryKey, bt as matchMarketsQueryKey, br as matchQueryKey, bq as matchesQueryKey, bR as normalizePolymarketTickSize, bj as resolveEventsParams, bi as resolveTagSlug } from './server-pS5Vlydo.js';
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 PriceHistoryParams, m as PriceHistoryResponse, n as ListCandlesticksParams, C as Candlestick, o as ListCommentsParams, p as PredictComment, q as PositionsResponse, r as PositionValueResponse, A as AvailableSharesResponse, B as BalanceResponse, s as ListOrdersParams, t as PredictOrder, u as ListOrdersMultiParams, v as PredictOrdersResponse, w as CancelOrderResult, M as MatchesParams, x as MatchGroupPage, y as MatchGroup, z as MatchMarketParams, D as MatchMarketPage, F as ListTradesParams, G as ListTradesMultiParams, H as DFlowQuoteRequest, I as DFlowQuoteResponse, J as DFlowSubmitResponse, K as DFlowSubmitRequest, N as DFlowKYCStatus, Q as PolymarketSetupStatus, R as PolymarketDepositWalletDeployResponse, W as WithdrawBuildResponse, T as WithdrawBuildRequest, U as WithdrawSubmitResponse, V as WithdrawSubmitRequest, X as WithdrawStatusResponse, Y as PolymarketDepositAddresses, Z as PolymarketSupportedAsset, _ as PolymarketWithdrawResponse, $ as PolymarketWithdrawRequest, a0 as PolymarketWithdrawPrepareResponse, a1 as PolymarketWithdrawPrepareRequest, a2 as PolymarketWithdrawQuoteResponse, a3 as PolymarketWithdrawQuoteRequest, a4 as PolymarketWithdrawRelayBuildResponse, a5 as PolymarketWithdrawRelayBuildRequest, a6 as PolymarketWithdrawRelaySubmitResponse, a7 as PolymarketWithdrawRelaySubmitRequest, a8 as PolymarketWithdrawBridgeStatusResponse, a9 as PolymarketRedeemResponse, aa as PolymarketTypedData, ab as TickSizeResponse, ac as FeeRateResponse, ad as RebateConfig, ae as WsConnectionStatus, af as WsDataMessage, ag as WsPriceEvent, ah as WsOrderbookEvent, ai as WsTradeEvent, aj as CreateOrderInput } from './server-B6SSpkMN.js';
2
+ export { bF as BuildClobAuthMessageInput, bU as BuildOrderMessageInput, bw as CLOB_AUTH_DOMAIN, bx as CLOB_AUTH_TYPES, bG as CTF_EXCHANGE_ADDRESS, bL as CTF_ORDER_TYPES, bT as ClobOrderPayload, aJ as DFlowOrderContext, aO as DepositBuildRequest, aP as DepositBuildResponse, aS as DepositStatusResponse, aQ as DepositSubmitRequest, aR as DepositSubmitResponse, aA as EventSummary, bC as HttpMethod, at as MarketOutcome, as as MarketResult, ar as MarketStatus, aB as MarketSummary, b0 as MatchConfidenceTier, aY as MatchGroupEntry, aZ as MatchGroupMarket, b2 as MatchLeg, b3 as MatchMarketFlat, a_ as MatchSortField, aX as MatchStatus, a$ as MatchesStats, bH as NEG_RISK_CTF_EXCHANGE_ADDRESS, bM as ORDER_TYPE, bV as OrderMessage, aI as OrderSide, aH as OrderStatus, av as OrderbookBatchItem, aw as OrderbookBatchResult, au as OrderbookLevel, ax as OrderbooksBatchRequest, ay as OrderbooksBatchResponse, bJ as POLYGON_CHAIN_ID, aU as PolymarketBridgeToken, aN as PolymarketDepositWalletDeployRequest, bE as PolymarketL2Headers, bD as PolymarketL2HeadersInput, aK as PolymarketOrderType, bg as PolymarketRedeemInput, be as PolymarketRedeemPrepareInput, bf as PolymarketRedeemPrepareResponse, aV as PolymarketSupportedAssetsResponse, aL as PolymarketTickSize, aW as PolymarketTypedDataArg, aM as PolymarketWalletKind, aF as PositionValue, aG as PositionValueError, al as PredictClientOptions, aC as PredictCommentProfile, aE as PredictPosition, ap as PredictTag, an as PredictWsClientConfig, aD as PricePoint, ao as ProviderMeta, bn as ResolveEventsParamsInput, bN as SIDE, aq as SettlementSource, b1 as SignalTag, bW as SignedOrder, bo as TagSlugSelection, az as TradeType, bI as USDC_ADDRESS, aT as UnsignedTx, b4 as WsChannel, b5 as WsChannelEvent, b6 as WsClientMessage, bc as WsErrorCode, bd as WsErrorMessage, b8 as WsPingMessage, ba as WsPongMessage, b9 as WsServerMessage, b7 as WsSubscribeMessage, bb as WsSubscribedMessage, by as buildClobAuthMessage, bQ as buildClobPayload, bK as buildCtfExchangeDomain, bO as buildOrderMessage, bA as buildPolymarketL2Headers, bP as buildSignedOrder, ak as createPredictClient, am as createPredictWsClient, bB as derivePolymarketApiKey, bh as eventQueryKey, bi as fetchEvent, bm as fetchEventsPage, bq as fetchMarket, bv as fetchMatchMarketsPage, bt as fetchMatchesPage, bR as getPolymarketSharesPrecision, bz as hmacSha256Base64, bl as infiniteEventsQueryKey, bp as marketQueryKey, bu as matchMarketsQueryKey, bs as matchQueryKey, br as matchesQueryKey, bS as normalizePolymarketTickSize, bk as resolveEventsParams, bj as resolveTagSlug } from './server-B6SSpkMN.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';
@@ -314,8 +314,9 @@ interface UseMarketParams {
314
314
  declare function useMarket(params: UseMarketParams, queryOptions?: Omit<UseQueryOptions<PredictMarket, Error, PredictMarket, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<PredictMarket, Error>;
315
315
 
316
316
  declare const ChartRange: {
317
+ readonly ONE_HOUR: "1h";
318
+ readonly SIX_HOURS: "6h";
317
319
  readonly ONE_DAY: "1d";
318
- readonly ONE_WEEK: "1w";
319
320
  readonly ONE_MONTH: "1m";
320
321
  readonly ALL: "all";
321
322
  };
@@ -336,11 +337,15 @@ interface UseMarketHistoryResult {
336
337
  series: MarketHistorySeries[];
337
338
  isLoading: boolean;
338
339
  }
340
+ interface UseMarketHistoryOptions {
341
+ /** Anchored unix end timestamp in seconds, shared with the chart x-axis. */
342
+ endTs?: number;
343
+ }
339
344
  /**
340
345
  * Returns price history series for the provided markets using
341
346
  * `GET /api/v1/markets/{slug}/price-history`.
342
347
  */
343
- declare function useMarketHistory(markets: PredictMarket[], range?: ChartRangeType): UseMarketHistoryResult;
348
+ declare function useMarketHistory(markets: PredictMarket[], range?: ChartRangeType, options?: UseMarketHistoryOptions): UseMarketHistoryResult;
344
349
 
345
350
  declare function orderbookQueryKey(slug: string, source: ProviderSource, outcome?: OrderbookOutcome): unknown[];
346
351
  interface UseOrderbookParams {
@@ -360,7 +365,7 @@ interface UseMarketTradesParams {
360
365
  }
361
366
  declare function useMarketTrades(params: UseMarketTradesParams, queryOptions?: Omit<UseQueryOptions<PredictPage<PredictTrade>, Error, PredictPage<PredictTrade>, unknown[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<PredictPage<PredictTrade>, Error>;
362
367
 
363
- declare function priceHistoryQueryKey(slug: string, source: ProviderSource, range?: PriceHistoryRange): unknown[];
368
+ declare function priceHistoryQueryKey(slug: string, source: ProviderSource, rangeOrParams?: PriceHistoryRange | Omit<PriceHistoryParams, "source">): unknown[];
364
369
  interface UsePriceHistoryParams {
365
370
  slug: string;
366
371
  source: ProviderSource;
@@ -1169,4 +1174,4 @@ interface WalkOrderbookParams {
1169
1174
  */
1170
1175
  declare function walkOrderbook({ orderbook, outcome, side, sharesNeeded, slippageBps, }: WalkOrderbookParams): WalkResult;
1171
1176
 
1172
- 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, PolymarketTypedData, PolymarketWithdrawBridgeStatusResponse, PolymarketWithdrawPrepareRequest, PolymarketWithdrawPrepareResponse, PolymarketWithdrawQuoteRequest, PolymarketWithdrawQuoteResponse, PolymarketWithdrawRelayBuildRequest, PolymarketWithdrawRelayBuildResponse, PolymarketWithdrawRelaySubmitRequest, PolymarketWithdrawRelaySubmitResponse, PolymarketWithdrawRequest, PolymarketWithdrawResponse, PositionValueResponse, PositionsResponse, PredictClient, PredictComment, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictOrdersResponse, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryRange, PriceHistoryResponse, ProviderSource, RebateConfig, type RedeemPositionVariables, SimilarEventsParams, type StartTradeResultConfirmationInput, type SyncBalanceAllowanceParams, TickSizeResponse, type TradeResultConfirmationState, type TradeResultExpectation, 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 UsePositionValueMultiParams, type UsePositionValueParams, 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, polymarketWithdrawStatusQueryKey, positionValueMultiQueryKey, positionValueQueryKey, 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, usePolymarketWithdrawPrepareMutation, usePolymarketWithdrawQuoteMutation, usePolymarketWithdrawRelayBuildMutation, usePolymarketWithdrawRelaySubmitMutation, usePolymarketWithdrawStatusQuery, usePositionValue, usePositionValueMulti, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRebateConfig, useRedeemPosition, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTickSize, useTradeResultConfirmation, useTrades, useTradesSubscription, useWithdrawBuildMutation, useWithdrawStatusQuery, useWithdrawSubmitMutation, walkOrderbook, withdrawStatusQueryKey };
1177
+ 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, PolymarketTypedData, PolymarketWithdrawBridgeStatusResponse, PolymarketWithdrawPrepareRequest, PolymarketWithdrawPrepareResponse, PolymarketWithdrawQuoteRequest, PolymarketWithdrawQuoteResponse, PolymarketWithdrawRelayBuildRequest, PolymarketWithdrawRelayBuildResponse, PolymarketWithdrawRelaySubmitRequest, PolymarketWithdrawRelaySubmitResponse, PolymarketWithdrawRequest, PolymarketWithdrawResponse, PositionValueResponse, PositionsResponse, PredictClient, PredictComment, PredictContext, type PredictContextValue, PredictEvent, PredictMarket, PredictOrder, PredictOrdersResponse, PredictPage, PredictProvider, type PredictProviderProps, PredictTrade, PredictWsClient, PriceHistoryParams, PriceHistoryRange, PriceHistoryResponse, ProviderSource, RebateConfig, type RedeemPositionVariables, SimilarEventsParams, type StartTradeResultConfirmationInput, type SyncBalanceAllowanceParams, TickSizeResponse, type TradeResultConfirmationState, type TradeResultExpectation, 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 UsePositionValueMultiParams, type UsePositionValueParams, 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, polymarketWithdrawStatusQueryKey, positionValueMultiQueryKey, positionValueQueryKey, 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, usePolymarketWithdrawPrepareMutation, usePolymarketWithdrawQuoteMutation, usePolymarketWithdrawRelayBuildMutation, usePolymarketWithdrawRelaySubmitMutation, usePolymarketWithdrawStatusQuery, usePositionValue, usePositionValueMulti, usePositions, usePositionsMulti, usePredictClient, usePredictWsClient, usePriceHistory, usePricesSubscription, useRealtimeOrderbook, useRealtimePrices, useRealtimeTrades, useRebateConfig, useRedeemPosition, useRunPolymarketSetup, useSearchEvents, useSimilarEvents, useTickSize, useTradeResultConfirmation, useTrades, useTradesSubscription, useWithdrawBuildMutation, useWithdrawStatusQuery, useWithdrawSubmitMutation, walkOrderbook, withdrawStatusQueryKey };
package/dist/index.js CHANGED
@@ -145,8 +145,9 @@ var PredictClient = class {
145
145
  return await utils.httpGet(url);
146
146
  }
147
147
  /** Maps to `GET /api/v1/markets/:slug/price-history?source=...&range=...`. */
148
- async getPriceHistory(slug, source, range) {
149
- const query = buildQuery({ source, range });
148
+ async getPriceHistory(slug, sourceOrParams, range) {
149
+ const params = typeof sourceOrParams === "string" ? { source: sourceOrParams, range } : sourceOrParams;
150
+ const query = buildQuery(params);
150
151
  const url = `${this.endpoint}/api/v1/markets/${encodeURIComponent(slug)}/price-history${query}`;
151
152
  return await utils.httpGet(url);
152
153
  }
@@ -1319,8 +1320,8 @@ function useMarket(params, queryOptions = {}) {
1319
1320
  ...queryOptions
1320
1321
  });
1321
1322
  }
1322
- function priceHistoryQueryKey(slug, source, range) {
1323
- return ["predict", "price-history", slug, source, range];
1323
+ function priceHistoryQueryKey(slug, source, rangeOrParams) {
1324
+ return ["predict", "price-history", slug, source, rangeOrParams];
1324
1325
  }
1325
1326
  function usePriceHistory(params, queryOptions = {}) {
1326
1327
  const client = usePredictClient();
@@ -1335,57 +1336,145 @@ function usePriceHistory(params, queryOptions = {}) {
1335
1336
 
1336
1337
  // src/hooks/predict/useMarketHistory.ts
1337
1338
  var ChartRange = {
1339
+ ONE_HOUR: "1h",
1340
+ SIX_HOURS: "6h",
1338
1341
  ONE_DAY: "1d",
1339
- ONE_WEEK: "1w",
1340
1342
  ONE_MONTH: "1m",
1341
1343
  ALL: "all"
1342
1344
  };
1343
1345
  var RANGE_MAP = {
1346
+ [ChartRange.ONE_HOUR]: "1h",
1347
+ [ChartRange.SIX_HOURS]: "6h",
1344
1348
  [ChartRange.ONE_DAY]: "1d",
1345
- [ChartRange.ONE_WEEK]: "1w",
1346
1349
  [ChartRange.ONE_MONTH]: "1m",
1347
1350
  [ChartRange.ALL]: "all"
1348
1351
  };
1349
- function useMarketHistory(markets, range = ChartRange.ALL) {
1352
+ var RANGE_DURATION_SECONDS = {
1353
+ [ChartRange.ONE_HOUR]: 60 * 60,
1354
+ [ChartRange.SIX_HOURS]: 6 * 60 * 60,
1355
+ [ChartRange.ONE_DAY]: 24 * 60 * 60,
1356
+ [ChartRange.ONE_MONTH]: 30 * 24 * 60 * 60,
1357
+ [ChartRange.ALL]: null
1358
+ };
1359
+ var RANGE_FIDELITY_MINUTES = {
1360
+ [ChartRange.ONE_HOUR]: 1,
1361
+ [ChartRange.SIX_HOURS]: 1,
1362
+ [ChartRange.ONE_DAY]: 5,
1363
+ [ChartRange.ONE_MONTH]: 15,
1364
+ [ChartRange.ALL]: 15
1365
+ };
1366
+ var LONG_RANGE_FIDELITY_MINUTES = {
1367
+ SHORT: 15,
1368
+ MONTH: 4 * 60,
1369
+ LONG: 24 * 60
1370
+ };
1371
+ var LONG_RANGE_SPAN_SECONDS = {
1372
+ WEEK: 7 * 24 * 60 * 60,
1373
+ MONTH: 31 * 24 * 60 * 60
1374
+ };
1375
+ function unixSecondsFromIso(value) {
1376
+ if (!value) return void 0;
1377
+ const ms = Date.parse(value);
1378
+ return Number.isFinite(ms) ? Math.floor(ms / 1e3) : void 0;
1379
+ }
1380
+ function firstFinitePrice(market) {
1381
+ const yesOutcome = market.outcomes?.find((o) => o.label.toLowerCase() === "yes") ?? market.outcomes?.[0];
1382
+ const price = yesOutcome?.best_ask ?? yesOutcome?.best_bid ?? yesOutcome?.price;
1383
+ return price != null && Number.isFinite(price) ? price : 0.5;
1384
+ }
1385
+ function fidelityMinutesForRange(range, startTs, endTs) {
1386
+ if (range !== ChartRange.ONE_MONTH && range !== ChartRange.ALL) {
1387
+ return RANGE_FIDELITY_MINUTES[range];
1388
+ }
1389
+ const spanSeconds = startTs != null ? Math.max(0, endTs - startTs) : 0;
1390
+ if (spanSeconds <= LONG_RANGE_SPAN_SECONDS.WEEK) {
1391
+ return LONG_RANGE_FIDELITY_MINUTES.SHORT;
1392
+ }
1393
+ if (spanSeconds <= LONG_RANGE_SPAN_SECONDS.MONTH) {
1394
+ return LONG_RANGE_FIDELITY_MINUTES.MONTH;
1395
+ }
1396
+ return LONG_RANGE_FIDELITY_MINUTES.LONG;
1397
+ }
1398
+ function buildRangeParams(range, market, anchoredEndTs) {
1399
+ const endTs = anchoredEndTs;
1400
+ const duration = RANGE_DURATION_SECONDS[range];
1401
+ const createdAt = unixSecondsFromIso(market.created_at);
1402
+ const rangeStartTs = duration == null ? void 0 : Math.max(0, endTs - duration);
1403
+ const startTs = createdAt != null && rangeStartTs != null ? Math.max(createdAt, rangeStartTs) : createdAt ?? rangeStartTs;
1404
+ return {
1405
+ range: RANGE_MAP[range],
1406
+ startTs,
1407
+ endTs,
1408
+ fidelity: fidelityMinutesForRange(range, startTs, endTs)
1409
+ };
1410
+ }
1411
+ function normalizeHistoryPoints(points, params, fallbackPrice) {
1412
+ const startMs = params.startTs != null ? params.startTs * 1e3 : void 0;
1413
+ const endMs = params.endTs != null ? params.endTs * 1e3 : void 0;
1414
+ const sorted = points.filter((pt) => Number.isFinite(pt.t) && Number.isFinite(pt.p)).map((pt) => ({ timestamp: pt.t * 1e3, price: pt.p })).filter((pt) => {
1415
+ if (startMs != null && pt.timestamp < startMs) return false;
1416
+ if (endMs != null && pt.timestamp > endMs) return false;
1417
+ return true;
1418
+ }).sort((a, b) => a.timestamp - b.timestamp);
1419
+ if (sorted.length === 0) {
1420
+ const now = endMs ?? Date.now();
1421
+ const start = startMs ?? now - 7 * 864e5;
1422
+ return [
1423
+ { timestamp: start, price: fallbackPrice },
1424
+ { timestamp: now, price: fallbackPrice }
1425
+ ];
1426
+ }
1427
+ const result = [...sorted];
1428
+ if (endMs != null && result[result.length - 1].timestamp < endMs) {
1429
+ result.push({
1430
+ timestamp: endMs,
1431
+ price: result[result.length - 1].price
1432
+ });
1433
+ }
1434
+ return result;
1435
+ }
1436
+ function useMarketHistory(markets, range = ChartRange.ALL, options = {}) {
1350
1437
  const client = usePredictClient();
1351
- const apiRange = RANGE_MAP[range];
1438
+ const rangeAnchorRef = react.useRef(null);
1439
+ const requestedEndTs = options.endTs;
1440
+ if (rangeAnchorRef.current?.range !== range || requestedEndTs != null && rangeAnchorRef.current?.endTs !== requestedEndTs) {
1441
+ rangeAnchorRef.current = {
1442
+ range,
1443
+ endTs: requestedEndTs ?? Math.floor(Date.now() / 1e3)
1444
+ };
1445
+ }
1446
+ const anchoredEndTs = rangeAnchorRef.current.endTs;
1447
+ const marketParams = react.useMemo(
1448
+ () => markets.map((market) => ({
1449
+ market,
1450
+ params: buildRangeParams(range, market, anchoredEndTs)
1451
+ })),
1452
+ [markets, range, anchoredEndTs]
1453
+ );
1352
1454
  const queries = reactQuery.useQueries({
1353
- queries: markets.map((market) => ({
1354
- queryKey: priceHistoryQueryKey(market.slug, market.source, apiRange),
1355
- queryFn: () => client.getPriceHistory(market.slug, market.source, apiRange),
1455
+ queries: marketParams.map(({ market, params }) => ({
1456
+ queryKey: priceHistoryQueryKey(market.slug, market.source, params),
1457
+ queryFn: () => client.getPriceHistory(market.slug, {
1458
+ source: market.source,
1459
+ ...params
1460
+ }),
1356
1461
  staleTime: 6e4,
1357
1462
  enabled: Boolean(market.slug)
1358
1463
  }))
1359
1464
  });
1360
1465
  const isLoading = queries.some((q) => q.isLoading);
1361
1466
  const series = react.useMemo(() => {
1362
- return markets.map((market, idx) => {
1467
+ return marketParams.map(({ market, params }, idx) => {
1363
1468
  const result = queries[idx];
1364
1469
  const points = result?.data?.points ?? [];
1365
- if (points.length > 0) {
1366
- return {
1367
- marketSlug: market.slug,
1368
- label: market.outcomes?.[0]?.label ?? market.question,
1369
- data: points.map((pt) => ({
1370
- timestamp: pt.t * 1e3,
1371
- price: pt.p
1372
- }))
1373
- };
1374
- }
1375
- const yesOutcome = market.outcomes?.find((o) => o.label.toLowerCase() === "yes") ?? market.outcomes?.[0];
1376
- const currentPrice = yesOutcome?.price ?? 0.5;
1377
- const now = Date.now();
1378
- const dayMs = 864e5;
1470
+ const fallbackPrice = firstFinitePrice(market);
1379
1471
  return {
1380
1472
  marketSlug: market.slug,
1381
1473
  label: market.outcomes?.[0]?.label ?? market.question,
1382
- data: [
1383
- { timestamp: now - 7 * dayMs, price: currentPrice },
1384
- { timestamp: now, price: currentPrice }
1385
- ]
1474
+ data: normalizeHistoryPoints(points, params, fallbackPrice)
1386
1475
  };
1387
1476
  });
1388
- }, [markets, queries]);
1477
+ }, [marketParams, queries]);
1389
1478
  return { series, isLoading };
1390
1479
  }
1391
1480
  function orderbookQueryKey(slug, source, outcome = "yes") {