@liberfi.io/react-predict 0.3.66 → 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 +11 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.js +120 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -31
- package/dist/index.mjs.map +1 -1
- package/dist/{server-pS5Vlydo.d.mts → server-B6SSpkMN.d.mts} +14 -3
- package/dist/{server-pS5Vlydo.d.ts → server-B6SSpkMN.d.ts} +14 -3
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +3 -2
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +3 -2
- 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 OrderbookOutcome, h as Orderbook, i as ListMarketTradesParams, j as PredictTrade, k as PriceHistoryRange, l 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 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,
|
|
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
|
|
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 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,
|
|
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,
|
|
149
|
-
const
|
|
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,
|
|
1323
|
-
return ["predict", "price-history", slug, source,
|
|
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
|
-
|
|
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
|
|
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:
|
|
1354
|
-
queryKey: priceHistoryQueryKey(market.slug, market.source,
|
|
1355
|
-
queryFn: () => client.getPriceHistory(market.slug,
|
|
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
|
|
1467
|
+
return marketParams.map(({ market, params }, idx) => {
|
|
1363
1468
|
const result = queries[idx];
|
|
1364
1469
|
const points = result?.data?.points ?? [];
|
|
1365
|
-
|
|
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
|
-
}, [
|
|
1477
|
+
}, [marketParams, queries]);
|
|
1389
1478
|
return { series, isLoading };
|
|
1390
1479
|
}
|
|
1391
1480
|
function orderbookQueryKey(slug, source, outcome = "yes") {
|