@agg-build/hooks 1.2.0 → 1.2.11
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/{chunk-U3DRHUR5.mjs → chunk-553OI6M2.mjs} +540 -88
- package/dist/{chunk-KSSPFJM2.mjs → chunk-CWEJLBYY.mjs} +66 -11
- package/dist/{chunk-FKTRXKYA.mjs → chunk-JWPZNCGY.mjs} +1 -1
- package/dist/deposit.d.mts +8 -2
- package/dist/deposit.d.ts +8 -2
- package/dist/deposit.js +190 -74
- package/dist/deposit.mjs +119 -66
- package/dist/index.d.mts +686 -42
- package/dist/index.d.ts +686 -42
- package/dist/index.js +1380 -356
- package/dist/index.mjs +681 -163
- package/dist/{use-sync-balances-B1_8tBKw.d.ts → use-sync-balances-CeD8qZWP.d.mts} +5 -2
- package/dist/{use-sync-balances-B1_8tBKw.d.mts → use-sync-balances-CeD8qZWP.d.ts} +5 -2
- package/dist/withdraw.d.mts +27 -3
- package/dist/withdraw.d.ts +27 -3
- package/dist/withdraw.js +153 -24
- package/dist/withdraw.mjs +4 -2
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -2,12 +2,12 @@ import * as _tanstack_react_query from '@tanstack/react-query';
|
|
|
2
2
|
import { QueryClient } from '@tanstack/react-query';
|
|
3
3
|
export { QueryClient, QueryClientProvider, useQueryClient } from '@tanstack/react-query';
|
|
4
4
|
import * as _agg_build_sdk from '@agg-build/sdk';
|
|
5
|
-
import { CandleBuilder, AggAuthStartBody, AggAuthStartResult, AggClientSessionInput, AggClient, RampQuote, RampQuoteRequest, RampWidgetSession, RampSessionRequest, QuoteManagedResponse, QuoteManagedParams, ExecuteManagedResponse, ExecuteManagedParams, GetPositionsParams, WsOrderSubmitted, WsBalanceUpdate, RedeemResponse, RedeemRequest, WsRedeemEvent, AggWebSocket, WsWithdrawalLifecycleEvent, WsCandleInterval, WsTrade, AggregatedOrderbookResponse, AggLinkAccountBody, AggLinkAccountResult, AggLinkAccountConfirmResult, UserActivityQuery, UserActivityItem, CandleInterval, OrderbookState, OrderbookQuoteResponse, OrderListQuery, TradeExecutorOrder, SmartRouteSide, SmartRouteResponse, MidpointRow, BatchMidpointsResponse, AppClientConfigResponse } from '@agg-build/sdk';
|
|
5
|
+
import { CandleBuilder, AggAuthStartBody, AggAuthStartResult, AggClientSessionInput, AggClient, RampQuote, RampQuoteRequest, RampWidgetSession, RampSessionRequest, QuoteManagedResponse, QuoteManagedParams, ExecuteManagedResponse, ExecuteManagedParams, GetPositionsParams, WsOrderSubmitted, WsBalanceUpdate, RedeemResponse, RedeemRequest, WsRedeemEvent, AggWebSocket, WsWithdrawalLifecycleEvent, WsCandleInterval, WsTrade, AggregatedOrderbookResponse, AggLinkAccountBody, AggLinkAccountResult, AggLinkAccountConfirmResult, UserActivityQuery, UserActivityItem, PaginatedResponse, CandleInterval, OrderbookState, OrderbookQuoteResponse, OrderListQuery, TradeExecutorOrder, SmartRouteSide, SmartRouteResponse, MidpointRow, BatchMidpointsResponse, AppClientConfigResponse } from '@agg-build/sdk';
|
|
6
6
|
export { TurnstileChallengeError } from '@agg-build/sdk';
|
|
7
7
|
import React, { ReactNode } from 'react';
|
|
8
|
-
export { UseManagedBalancesOptions, UseWithdrawFlowOptions, UseWithdrawFlowResult, UseWithdrawManagedOptions, UseWithdrawalLifecycleResult, WithdrawalLifecycleState, useManagedBalances, useWithdrawFlow, useWithdrawManaged, useWithdrawalLifecycle } from './withdraw.mjs';
|
|
8
|
+
export { UseManagedBalancesOptions, UseWithdrawEstimateParams, UseWithdrawFlowOptions, UseWithdrawFlowResult, UseWithdrawManagedOptions, UseWithdrawalLifecycleResult, WithdrawFeeEstimate, WithdrawalLifecycleState, useManagedBalances, useWithdrawEstimate, useWithdrawFlow, useWithdrawManaged, useWithdrawalLifecycle } from './withdraw.mjs';
|
|
9
9
|
export { U as UseDepositAddressesOptions, g as getDepositAddress, u as useDepositAddresses } from './use-deposit-addresses-B9ICS-3U.mjs';
|
|
10
|
-
export { U as UseSyncBalancesOptions, u as useSyncBalances } from './use-sync-balances-
|
|
10
|
+
export { U as UseSyncBalancesOptions, u as useSyncBalances } from './use-sync-balances-CeD8qZWP.mjs';
|
|
11
11
|
|
|
12
12
|
/** Use these constants instead of hardcoding "kalshi" or "polymarket". */
|
|
13
13
|
declare enum Venue {
|
|
@@ -126,6 +126,8 @@ type UnifiedBalanceResponse = {
|
|
|
126
126
|
type GetOrdersQuery = {
|
|
127
127
|
status?: OrderStatus | undefined;
|
|
128
128
|
orderId?: string | undefined;
|
|
129
|
+
/** Filter to all legs of one quote (multi-venue split routes). */
|
|
130
|
+
quoteId?: string | undefined;
|
|
129
131
|
cursor?: string | undefined;
|
|
130
132
|
limit?: number | undefined;
|
|
131
133
|
};
|
|
@@ -137,6 +139,12 @@ type GetPositionsQuery = {
|
|
|
137
139
|
type OrderListItem = {
|
|
138
140
|
status: string;
|
|
139
141
|
id: string;
|
|
142
|
+
/**
|
|
143
|
+
* Parent quote — lets the frontend correlate legs of a multi-venue
|
|
144
|
+
* split route without a second request. Nullable for sell-side /
|
|
145
|
+
* standalone orders without a Quote row.
|
|
146
|
+
*/
|
|
147
|
+
quoteId: string | null;
|
|
140
148
|
createdAt: Date;
|
|
141
149
|
updatedAt: Date;
|
|
142
150
|
venue: Venue;
|
|
@@ -145,8 +153,28 @@ type OrderListItem = {
|
|
|
145
153
|
slippageBps: number | null;
|
|
146
154
|
quotedPriceRaw: string | null;
|
|
147
155
|
quotedCostRaw: string | null;
|
|
156
|
+
/**
|
|
157
|
+
* Quote-time shares + payout, 6-decimal atomic. Lets the UI render
|
|
158
|
+
* "Quoted X shares / $Y to win" without re-deriving from cost ÷
|
|
159
|
+
* price (precision drift on fractional fills; divide-by-zero before
|
|
160
|
+
* `executionPrice` exists).
|
|
161
|
+
*/
|
|
162
|
+
quotedSharesRaw: string | null;
|
|
163
|
+
quotedToWinRaw: string | null;
|
|
148
164
|
filledAmountRaw: string | null;
|
|
149
165
|
executionPrice: string | null;
|
|
166
|
+
/**
|
|
167
|
+
* Actual shares + payout, populated by the venue's finalize handler.
|
|
168
|
+
* Pair with the quoted-side fields above to render the diff inline.
|
|
169
|
+
*/
|
|
170
|
+
actualSharesRaw: string | null;
|
|
171
|
+
actualToWinRaw: string | null;
|
|
172
|
+
/**
|
|
173
|
+
* Set only on `partial_fill`. One of `"venue_capacity"`,
|
|
174
|
+
* `"price_slipped"`, `"user_cancelled"`, `"timeout"`, `"bridge_short"`,
|
|
175
|
+
* or a venue-specific tag.
|
|
176
|
+
*/
|
|
177
|
+
partialFillReason: string | null;
|
|
150
178
|
txHash: string | null;
|
|
151
179
|
errorMessage: string | null;
|
|
152
180
|
dagRunId: string | null;
|
|
@@ -176,7 +204,7 @@ type PositionGroup = {
|
|
|
176
204
|
venue: Venue;
|
|
177
205
|
size: number;
|
|
178
206
|
venueMarketId: string;
|
|
179
|
-
venueMarketOutcomeId
|
|
207
|
+
venueMarketOutcomeId: string;
|
|
180
208
|
}[];
|
|
181
209
|
totalSize: number;
|
|
182
210
|
avgEntryPrice: number;
|
|
@@ -204,6 +232,14 @@ type VenueMarket = {
|
|
|
204
232
|
title?: string | null | undefined;
|
|
205
233
|
externalIdentifier?: string | null | undefined;
|
|
206
234
|
winner?: boolean | null | undefined;
|
|
235
|
+
/** Counterpart outcomes on matched sibling markets — only populated
|
|
236
|
+
* on the parent (queried) market's outcomes. Each entry is a
|
|
237
|
+
* `{ venueMarketId, venueMarketOutcomeId }` ref into the same
|
|
238
|
+
* response's `matchedVenueMarkets[].venueMarketOutcomes[]`. */
|
|
239
|
+
matchedVenueMarketOutcomes?: {
|
|
240
|
+
venueMarketId: string;
|
|
241
|
+
venueMarketOutcomeId: string;
|
|
242
|
+
}[];
|
|
207
243
|
}[];
|
|
208
244
|
externalIdentifier: string;
|
|
209
245
|
status?: MarketStatus | undefined;
|
|
@@ -276,6 +312,13 @@ type VenueEvent = {
|
|
|
276
312
|
venues?: Venue[];
|
|
277
313
|
venueCount?: number | undefined;
|
|
278
314
|
marketCount?: number | undefined;
|
|
315
|
+
/**
|
|
316
|
+
* ISO-8601 duration denormalized from Series.recurrence. `null` means
|
|
317
|
+
* the event has no recurring schedule (one-off). Use this value with
|
|
318
|
+
* the `?recurrence=` filter on /venue-events; discover all available
|
|
319
|
+
* values via GET /recurrences.
|
|
320
|
+
*/
|
|
321
|
+
recurrence?: string | null | undefined;
|
|
279
322
|
};
|
|
280
323
|
type Orderbook = {
|
|
281
324
|
bids: {
|
|
@@ -288,6 +331,14 @@ type Orderbook = {
|
|
|
288
331
|
}[];
|
|
289
332
|
negRisk?: boolean | undefined;
|
|
290
333
|
};
|
|
334
|
+
/** Reference to a counterpart outcome on a matched sibling market.
|
|
335
|
+
* Resolves into the same response's `matchedVenueMarkets[].venueMarketOutcomes[]`
|
|
336
|
+
* by id. Sourced from `MatchedVenueMarketOutcome` so the alignment is
|
|
337
|
+
* robust to inversely-framed binary markets and multi-outcome markets. */
|
|
338
|
+
type MatchedVenueMarketOutcomeRef = {
|
|
339
|
+
venueMarketId: string;
|
|
340
|
+
venueMarketOutcomeId: string;
|
|
341
|
+
};
|
|
291
342
|
type VenueMarketOutcome = {
|
|
292
343
|
id: string;
|
|
293
344
|
price: number;
|
|
@@ -296,6 +347,9 @@ type VenueMarketOutcome = {
|
|
|
296
347
|
title?: string | null | undefined;
|
|
297
348
|
externalIdentifier?: string | null | undefined;
|
|
298
349
|
winner?: boolean | null | undefined;
|
|
350
|
+
/** Counterpart outcomes on matched sibling markets — only populated on
|
|
351
|
+
* the parent (queried) market's outcomes. */
|
|
352
|
+
matchedVenueMarketOutcomes?: MatchedVenueMarketOutcomeRef[];
|
|
299
353
|
};
|
|
300
354
|
type VenueEventWithMarkets = VenueEvent & {
|
|
301
355
|
venueMarkets: VenueMarket[];
|
|
@@ -508,6 +562,12 @@ interface AggUiLabels {
|
|
|
508
562
|
max: string;
|
|
509
563
|
tokenLabel: string;
|
|
510
564
|
networkLabel: string;
|
|
565
|
+
estimatedFees: string;
|
|
566
|
+
networkReserve: string;
|
|
567
|
+
networkReserveTooltipAria: string;
|
|
568
|
+
networkReserveTooltipLineOne: string;
|
|
569
|
+
networkReserveTooltipLineTwo: string;
|
|
570
|
+
youReceive: string;
|
|
511
571
|
confirm: string;
|
|
512
572
|
successTitle: string;
|
|
513
573
|
successDescription: (tokenSymbol: string) => string;
|
|
@@ -517,7 +577,11 @@ interface AggUiLabels {
|
|
|
517
577
|
successDescriptionPartial: (tokenSymbol: string) => string;
|
|
518
578
|
successTitleFailed: string;
|
|
519
579
|
successDescriptionFailed: (tokenSymbol: string) => string;
|
|
580
|
+
retry: string;
|
|
581
|
+
close: string;
|
|
582
|
+
loadingDescription: string;
|
|
520
583
|
summary: {
|
|
584
|
+
requestedWithdrawal: string;
|
|
521
585
|
amountReceived: string;
|
|
522
586
|
network: string;
|
|
523
587
|
toWallet: string;
|
|
@@ -535,6 +599,12 @@ interface AggUiLabels {
|
|
|
535
599
|
completed: string;
|
|
536
600
|
partial: string;
|
|
537
601
|
failed: string;
|
|
602
|
+
loadingSteps: {
|
|
603
|
+
preparing: string;
|
|
604
|
+
bridging: string;
|
|
605
|
+
sending: string;
|
|
606
|
+
confirming: string;
|
|
607
|
+
};
|
|
538
608
|
/**
|
|
539
609
|
* Per-leg step labels rendered in the success step's execution
|
|
540
610
|
* timeline. `bridge` covers cross-chain hops, `transfer` covers
|
|
@@ -592,6 +662,40 @@ interface AggUiLabels {
|
|
|
592
662
|
externalWallet: string;
|
|
593
663
|
card: string;
|
|
594
664
|
};
|
|
665
|
+
/**
|
|
666
|
+
* Status-aware titles per activity status. The activity row reads
|
|
667
|
+
* the appropriate variant based on the normalized status
|
|
668
|
+
* ("completed" | "pending" | "failed" | "canceled") so the cell
|
|
669
|
+
* matches the icon and tone — e.g. a pending withdrawal reads
|
|
670
|
+
* "Processing withdrawal", a failed card deposit reads
|
|
671
|
+
* "Failed deposit with card".
|
|
672
|
+
*/
|
|
673
|
+
depositStatusTitles: {
|
|
674
|
+
connectedWallet: {
|
|
675
|
+
pending: string;
|
|
676
|
+
completed: string;
|
|
677
|
+
failed: string;
|
|
678
|
+
canceled: string;
|
|
679
|
+
};
|
|
680
|
+
externalWallet: {
|
|
681
|
+
pending: string;
|
|
682
|
+
completed: string;
|
|
683
|
+
failed: string;
|
|
684
|
+
canceled: string;
|
|
685
|
+
};
|
|
686
|
+
card: {
|
|
687
|
+
pending: string;
|
|
688
|
+
completed: string;
|
|
689
|
+
failed: string;
|
|
690
|
+
canceled: string;
|
|
691
|
+
};
|
|
692
|
+
};
|
|
693
|
+
withdrawalStatusTitles: {
|
|
694
|
+
pending: string;
|
|
695
|
+
completed: string;
|
|
696
|
+
failed: string;
|
|
697
|
+
canceled: string;
|
|
698
|
+
};
|
|
595
699
|
withdrawalTitle: (tokenSymbol: string) => string;
|
|
596
700
|
};
|
|
597
701
|
positions: {
|
|
@@ -806,6 +910,7 @@ interface AggUiLabels {
|
|
|
806
910
|
noMarketSelected: string;
|
|
807
911
|
noOrderbooks: string;
|
|
808
912
|
quoteUnavailable: string;
|
|
913
|
+
quoteBalanceMismatch: string;
|
|
809
914
|
selectedVenueUnavailable: string;
|
|
810
915
|
engineUnavailable: string;
|
|
811
916
|
insufficientInputAmount: string;
|
|
@@ -843,6 +948,7 @@ interface AggUiLabels {
|
|
|
843
948
|
buyingOutcome: (label: string) => string;
|
|
844
949
|
sellingOutcome: (label: string) => string;
|
|
845
950
|
findingBestRoute: string;
|
|
951
|
+
checkingBalance: string;
|
|
846
952
|
submittingOrderProgress: string;
|
|
847
953
|
orderSubmittedProgress: (orderId: string) => string;
|
|
848
954
|
executingOnVenue: (venueLabel: string) => string;
|
|
@@ -1093,6 +1199,12 @@ interface AggUiConfig {
|
|
|
1093
1199
|
enableLogs: boolean;
|
|
1094
1200
|
/** Enable AGG websocket pipeline logs */
|
|
1095
1201
|
enableWebsocketsLogs: boolean;
|
|
1202
|
+
/**
|
|
1203
|
+
* Enable developer-only debug instrumentation
|
|
1204
|
+
* (e.g. the Place Order execution-debug collector)
|
|
1205
|
+
* Off by default
|
|
1206
|
+
*/
|
|
1207
|
+
enableDebug: boolean;
|
|
1096
1208
|
/** General UI settings */
|
|
1097
1209
|
general: AggUiGeneralConfig;
|
|
1098
1210
|
/** UI feature flags */
|
|
@@ -1124,6 +1236,8 @@ interface AggUiConfigInput {
|
|
|
1124
1236
|
enableLogs?: boolean;
|
|
1125
1237
|
/** Enable AGG websocket pipeline logs */
|
|
1126
1238
|
enableWebsocketsLogs?: boolean;
|
|
1239
|
+
/** Enable developer-only debug instrumentation (Place Order debug, etc.). */
|
|
1240
|
+
enableDebug?: boolean;
|
|
1127
1241
|
/** General UI overrides */
|
|
1128
1242
|
general?: AggUiGeneralConfigInput;
|
|
1129
1243
|
/** Feature flag overrides */
|
|
@@ -1326,10 +1440,27 @@ declare const resolveOrderEligibility: (params: {
|
|
|
1326
1440
|
}) => OrderEligibility;
|
|
1327
1441
|
declare function resolveDefaultMarket(event: VenueEventWithMarkets | null): VenueMarket | null;
|
|
1328
1442
|
|
|
1443
|
+
/**
|
|
1444
|
+
* Active trade side. Modeled as a frozen const-object so callers can use
|
|
1445
|
+
* enum-style access (`TradeSide.Buy`, `TradeSide.Sell`) while the resulting
|
|
1446
|
+
* type is still the plain `"buy" | "sell"` string union — interoperable
|
|
1447
|
+
* everywhere a literal is expected (URL params, JSON payloads, helper
|
|
1448
|
+
* function signatures).
|
|
1449
|
+
*/
|
|
1450
|
+
declare const TradeSide: {
|
|
1451
|
+
readonly Buy: "buy";
|
|
1452
|
+
readonly Sell: "sell";
|
|
1453
|
+
};
|
|
1454
|
+
type TradeSide = (typeof TradeSide)[keyof typeof TradeSide];
|
|
1329
1455
|
interface TradingState {
|
|
1330
1456
|
event: VenueEventWithMarkets | null;
|
|
1331
1457
|
market: VenueMarket | null;
|
|
1332
1458
|
outcome: VenueMarketOutcome | null;
|
|
1459
|
+
/**
|
|
1460
|
+
* Currently selected buy/sell side. Optional in shape (older fixtures and
|
|
1461
|
+
* snapshots may omit it) — readers should treat `undefined` as `Buy`.
|
|
1462
|
+
*/
|
|
1463
|
+
tradeSide?: TradeSide;
|
|
1333
1464
|
}
|
|
1334
1465
|
type TradingAction = {
|
|
1335
1466
|
type: "INITIALIZE_EVENT";
|
|
@@ -1348,6 +1479,9 @@ type TradingAction = {
|
|
|
1348
1479
|
type: "SELECT_MARKET_AND_OUTCOME";
|
|
1349
1480
|
marketId: string;
|
|
1350
1481
|
outcomeId: string;
|
|
1482
|
+
} | {
|
|
1483
|
+
type: "SET_TRADE_SIDE";
|
|
1484
|
+
tradeSide: TradeSide;
|
|
1351
1485
|
};
|
|
1352
1486
|
declare function tradingReducer(state: TradingState, action: TradingAction): TradingState;
|
|
1353
1487
|
interface EventTradingContextValue {
|
|
@@ -1358,6 +1492,14 @@ interface EventTradingContextValue {
|
|
|
1358
1492
|
selectedMarketId: string | null;
|
|
1359
1493
|
selectedOutcomeId: string | null;
|
|
1360
1494
|
selectedVenue: string | null;
|
|
1495
|
+
/**
|
|
1496
|
+
* Currently selected trade side. Drives `bestAsk` vs `bestBid` selection
|
|
1497
|
+
* across all price-display surfaces (home tile, event details, market
|
|
1498
|
+
* details, place-order outcome buttons) so flipping Buy/Sell in PlaceOrder
|
|
1499
|
+
* is reflected everywhere. Defaults to `"buy"`.
|
|
1500
|
+
*/
|
|
1501
|
+
tradeSide: TradeSide;
|
|
1502
|
+
setTradeSide: (tradeSide: TradeSide) => void;
|
|
1361
1503
|
initializeFromEvent: (event: VenueEventWithMarkets | null) => void;
|
|
1362
1504
|
syncEvent: (event: VenueEventWithMarkets) => void;
|
|
1363
1505
|
selectMarket: (marketId: string, market?: VenueMarket) => void;
|
|
@@ -1381,6 +1523,49 @@ declare const invalidateBalanceQueries: (queryClient: QueryClient, options?: Inv
|
|
|
1381
1523
|
* holdings, so positions need to be refetched alongside balances.
|
|
1382
1524
|
*/
|
|
1383
1525
|
declare const invalidatePositionQueries: (queryClient: QueryClient, options?: InvalidateBalanceQueriesOptions) => void;
|
|
1526
|
+
declare const userActivityQueryKeys: {
|
|
1527
|
+
all: () => readonly ["user-activity"];
|
|
1528
|
+
};
|
|
1529
|
+
type UserActivityInvalidationStrategy = "remove" | "invalidate";
|
|
1530
|
+
interface InvalidateUserActivityOptions {
|
|
1531
|
+
/**
|
|
1532
|
+
* - "remove" (default): drop the entire `["user-activity"]` family from the
|
|
1533
|
+
* cache so the observed `useInfiniteQuery` refetches from page 1 only.
|
|
1534
|
+
* Avoids duplicate/shifted rows when a new entry appears at the top after
|
|
1535
|
+
* a deposit/withdraw — page 2's cursor was computed against the old head.
|
|
1536
|
+
* - "invalidate": invalidate in place; refetches all currently cached pages.
|
|
1537
|
+
* Cheaper paint-wise (keeps prior data visible) but can momentarily show
|
|
1538
|
+
* duplicate rows during the refetch.
|
|
1539
|
+
*/
|
|
1540
|
+
strategy?: UserActivityInvalidationStrategy;
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Refresh the `useUserActivity` infinite query family after money movement.
|
|
1544
|
+
* Defaults to `removeQueries` so the next render refetches page 1 cleanly
|
|
1545
|
+
* (cursor-based pagination can't guarantee ordering after a new head row).
|
|
1546
|
+
*/
|
|
1547
|
+
declare const invalidateUserActivityQueries: (queryClient: QueryClient, options?: InvalidateUserActivityOptions) => void;
|
|
1548
|
+
interface InvalidateUserMoneyStateOptions {
|
|
1549
|
+
/** Forwarded to balance + position invalidations. Defaults to "active". */
|
|
1550
|
+
refetchType?: BalanceRefetchType;
|
|
1551
|
+
/** Forwarded to activity invalidation. Defaults to "remove". */
|
|
1552
|
+
activityStrategy?: UserActivityInvalidationStrategy;
|
|
1553
|
+
}
|
|
1554
|
+
/**
|
|
1555
|
+
* Invalidate every cache surface affected by a successful deposit or
|
|
1556
|
+
* withdrawal. Call AFTER the backend has confirmed the operation — not on
|
|
1557
|
+
* modal close, not on optimistic submit.
|
|
1558
|
+
*
|
|
1559
|
+
* Scope (kept narrow on purpose):
|
|
1560
|
+
* - balances (canonical + venue) — the balance number changed
|
|
1561
|
+
* - positions — derived "available to trade" / share-count UIs read this
|
|
1562
|
+
* alongside balances; refetch keeps them consistent
|
|
1563
|
+
* - user activity — the deposit/withdraw row needs to appear in the feed
|
|
1564
|
+
*
|
|
1565
|
+
* Out of scope: orders / execution-orders (trade-side, not money movement),
|
|
1566
|
+
* current-user (no money fields change on deposit/withdraw today).
|
|
1567
|
+
*/
|
|
1568
|
+
declare const invalidateUserMoneyState: (queryClient: QueryClient, options?: InvalidateUserMoneyStateOptions) => void;
|
|
1384
1569
|
|
|
1385
1570
|
declare function useRampQuotes(): _tanstack_react_query.UseMutationResult<RampQuote[], Error, RampQuoteRequest, unknown>;
|
|
1386
1571
|
|
|
@@ -1623,6 +1808,19 @@ interface ExecutionTerminalOrderEvent {
|
|
|
1623
1808
|
event: "filled" | "partial_fill" | "failed";
|
|
1624
1809
|
filledAmountRaw?: string;
|
|
1625
1810
|
remainingAmountRaw?: string;
|
|
1811
|
+
/** Actual shares + payout received, 6-decimal atomic. Set by the venue's
|
|
1812
|
+
* finalize handler on filled/partial_fill — the source of truth for the
|
|
1813
|
+
* execution summary so it never reuses the stale quote estimate. */
|
|
1814
|
+
actualSharesRaw?: string;
|
|
1815
|
+
actualToWinRaw?: string;
|
|
1816
|
+
/** Quote-time shares + payout, 6-decimal atomic. Snapshot of what the user
|
|
1817
|
+
* accepted; surfaced for "Quoted X / Got Y" diffs. */
|
|
1818
|
+
quotedSharesRaw?: string;
|
|
1819
|
+
quotedToWinRaw?: string;
|
|
1820
|
+
/** Avg execution price (decimal string). Pair with `quotedPriceRaw`
|
|
1821
|
+
* for inline slippage diffs and to derive shares when actual*Raw is absent. */
|
|
1822
|
+
executionPriceRaw?: string;
|
|
1823
|
+
quotedPriceRaw?: string;
|
|
1626
1824
|
errorReason?: string;
|
|
1627
1825
|
timestamp: number;
|
|
1628
1826
|
}
|
|
@@ -1648,6 +1846,10 @@ interface ClosedPositionTotals {
|
|
|
1648
1846
|
}
|
|
1649
1847
|
declare const computeClosedPositionTotals: (group: PositionGroup) => ClosedPositionTotals;
|
|
1650
1848
|
|
|
1849
|
+
declare class RedeemRejectedError extends Error {
|
|
1850
|
+
readonly response: RedeemResponse;
|
|
1851
|
+
constructor(message: string, response: RedeemResponse);
|
|
1852
|
+
}
|
|
1651
1853
|
declare const useRedeem: () => _tanstack_react_query.UseMutationResult<RedeemResponse, Error, RedeemRequest, unknown>;
|
|
1652
1854
|
|
|
1653
1855
|
type RedeemEvent = WsRedeemEvent;
|
|
@@ -1655,6 +1857,96 @@ declare const useOnRedeemEvent: (listener: ((event: RedeemEvent) => void) | null
|
|
|
1655
1857
|
|
|
1656
1858
|
declare const useRedeemEligibleCount: () => number;
|
|
1657
1859
|
|
|
1860
|
+
interface RedeemLegLifecycle {
|
|
1861
|
+
status: "submitted" | "confirmed" | "failed";
|
|
1862
|
+
txHash: string | null;
|
|
1863
|
+
errorMessage: string | null;
|
|
1864
|
+
}
|
|
1865
|
+
interface RedeemLifecycleState {
|
|
1866
|
+
/** True until terminal — drives the claim button spinner. */
|
|
1867
|
+
pending: boolean;
|
|
1868
|
+
/** True once every expected leg has flipped to confirmed or failed. */
|
|
1869
|
+
terminal: boolean;
|
|
1870
|
+
/** True iff terminal AND every leg.status === "confirmed". */
|
|
1871
|
+
allConfirmed: boolean;
|
|
1872
|
+
/** True iff any leg.status === "failed" (including pre-failed legs). */
|
|
1873
|
+
anyFailed: boolean;
|
|
1874
|
+
/** First non-null leg.errorMessage when anyFailed; null otherwise. */
|
|
1875
|
+
errorMessage: string | null;
|
|
1876
|
+
/** Per-leg lifecycle keyed by venueMarketOutcomeId. */
|
|
1877
|
+
legs: Record<string, RedeemLegLifecycle>;
|
|
1878
|
+
}
|
|
1879
|
+
interface UseRedeemLifecycleInput {
|
|
1880
|
+
redeemId: string;
|
|
1881
|
+
/**
|
|
1882
|
+
* Legs the API returned with status === "submitted" (EVM async path).
|
|
1883
|
+
* Each receives a redeem_event with status confirmed or failed.
|
|
1884
|
+
*/
|
|
1885
|
+
expectedOutcomeIds: string[];
|
|
1886
|
+
/**
|
|
1887
|
+
* Legs the API returned with status === "ineligible" or "rejected".
|
|
1888
|
+
* Pre-seeded into legs as terminal-failed; no WS event will ever arrive.
|
|
1889
|
+
*/
|
|
1890
|
+
preFailedOutcomeIds?: string[];
|
|
1891
|
+
/** Optional pre-seeded errorMessage per pre-failed leg, indexed by venueMarketOutcomeId. */
|
|
1892
|
+
preFailedReasons?: Record<string, string | null>;
|
|
1893
|
+
/**
|
|
1894
|
+
* Legs the API returned with status === "confirmed" (SVM sync path:
|
|
1895
|
+
* tx landed inline inside the HTTP call, VMP.redeemedAt already set
|
|
1896
|
+
* server-side). Pre-seeded into legs as terminal-confirmed; no WS
|
|
1897
|
+
* event will ever arrive.
|
|
1898
|
+
*/
|
|
1899
|
+
preConfirmedOutcomeIds?: string[];
|
|
1900
|
+
/** Optional pre-seeded txHash per pre-confirmed leg, indexed by venueMarketOutcomeId. */
|
|
1901
|
+
preConfirmedTxHashes?: Record<string, string | null>;
|
|
1902
|
+
}
|
|
1903
|
+
/**
|
|
1904
|
+
* Subscribes once to `redeem_event` WS events and materializes a per-`redeemId`
|
|
1905
|
+
* lifecycle record for every in-flight redeem the caller is tracking.
|
|
1906
|
+
*
|
|
1907
|
+
* **Input shape** — the caller passes one {@link UseRedeemLifecycleInput} entry
|
|
1908
|
+
* per in-flight redeem. Legs are split into three buckets:
|
|
1909
|
+
* - `expectedOutcomeIds` — the EVM async path. The API returned these legs with
|
|
1910
|
+
* `status === "submitted"`; each will eventually receive a `redeem_event` WS
|
|
1911
|
+
* message with `status === "confirmed"` or `"failed"`.
|
|
1912
|
+
* - `preFailedOutcomeIds` — legs the API returned as `"ineligible"` or
|
|
1913
|
+
* `"rejected"` at submit time. Pre-seeded into the returned state as
|
|
1914
|
+
* terminal-failed; no WS event will ever arrive for them.
|
|
1915
|
+
* - `preConfirmedOutcomeIds` — the SVM sync path. The transaction landed inline
|
|
1916
|
+
* inside the HTTP call so `VenueMarketPosition.redeemedAt` is already set
|
|
1917
|
+
* server-side before the response returns. Pre-seeded as terminal-confirmed;
|
|
1918
|
+
* no WS event will ever arrive.
|
|
1919
|
+
*
|
|
1920
|
+
* **Entry lifecycle** — when the caller drops a `redeemId` from `inputs`, its
|
|
1921
|
+
* entry disappears from the returned record on the next render. There is no
|
|
1922
|
+
* tombstone or TTL — the lifecycle is purely driven by what is in `inputs`.
|
|
1923
|
+
*
|
|
1924
|
+
* **Performance** — the `inputs` array's reference identity matters. The hook
|
|
1925
|
+
* re-derives the internal `redeemId → input` map on every render where
|
|
1926
|
+
* `inputs` is a new reference. Callers should memoize the array via `useMemo`
|
|
1927
|
+
* to avoid the re-derivation overhead. A common pattern:
|
|
1928
|
+
* ```ts
|
|
1929
|
+
* const inputs = useMemo(
|
|
1930
|
+
* () => Object.values(activeRedeems).map(toLifecycleInput),
|
|
1931
|
+
* [activeRedeems],
|
|
1932
|
+
* );
|
|
1933
|
+
* ```
|
|
1934
|
+
*
|
|
1935
|
+
* **New-entry gap** — when the caller adds a new `redeemId` to `inputs`, the
|
|
1936
|
+
* returned record does not include it for the render where it was added. The
|
|
1937
|
+
* seed entry is written inside a `useEffect` (which runs after paint). Treat a
|
|
1938
|
+
* missing entry as "pending / not terminal yet" — the same as
|
|
1939
|
+
* `state.pending === true`.
|
|
1940
|
+
*
|
|
1941
|
+
* **No REST backfill** — if the WS subscription drops mid-flight (page refresh,
|
|
1942
|
+
* disconnect), the in-memory lifecycle state is lost. Redeems typically settle
|
|
1943
|
+
* in seconds and each position's `redeemStatus` is polled separately, so no
|
|
1944
|
+
* REST backfill is provided here.
|
|
1945
|
+
*/
|
|
1946
|
+
declare function useRedeemLifecycles(inputs: UseRedeemLifecycleInput[]): Record<string, RedeemLifecycleState>;
|
|
1947
|
+
|
|
1948
|
+
declare function useRedeemLifecycle(input: UseRedeemLifecycleInput | null): RedeemLifecycleState;
|
|
1949
|
+
|
|
1658
1950
|
declare function useAggWebSocket(): AggWebSocket | null;
|
|
1659
1951
|
declare function useOnOrderSubmitted(callback: ((msg: WsOrderSubmitted) => void) | null): void;
|
|
1660
1952
|
declare function useOnBalanceUpdate(callback: ((msg: WsBalanceUpdate) => void) | null): void;
|
|
@@ -1667,7 +1959,7 @@ interface MarketChartCandle {
|
|
|
1667
1959
|
low: number;
|
|
1668
1960
|
close: number;
|
|
1669
1961
|
volume: number | null;
|
|
1670
|
-
source: "rest" | "ws" | "trade";
|
|
1962
|
+
source: "rest" | "ws" | "trade" | "midpoint";
|
|
1671
1963
|
}
|
|
1672
1964
|
interface MarketChartVenueData {
|
|
1673
1965
|
venue: string;
|
|
@@ -1677,6 +1969,13 @@ interface MarketChartVenueData {
|
|
|
1677
1969
|
liveCandle: MarketChartCandle | null;
|
|
1678
1970
|
lineValue: number | undefined;
|
|
1679
1971
|
lastTrade: WsTrade | null;
|
|
1972
|
+
/**
|
|
1973
|
+
* Epoch seconds of the most recent real REST or WS update that touched this
|
|
1974
|
+
* venue (REST candle, trade, or midpoint). Used by the renderer's stale-data
|
|
1975
|
+
* indicator — independent of any synthetic point that `extendSeriesToNow`
|
|
1976
|
+
* projects onto the line. `null` when nothing has been seen yet.
|
|
1977
|
+
*/
|
|
1978
|
+
lastUpdateTs: number | null;
|
|
1680
1979
|
}
|
|
1681
1980
|
interface MarketChartData {
|
|
1682
1981
|
marketId: string;
|
|
@@ -1689,6 +1988,11 @@ interface MarketChartData {
|
|
|
1689
1988
|
endTs: number | null;
|
|
1690
1989
|
/** Per-venue chart state. The primary venue contains the canonical REST history. */
|
|
1691
1990
|
venues: Record<string, MarketChartVenueData>;
|
|
1991
|
+
/**
|
|
1992
|
+
* Max of `lastUpdateTs` across all venues. Surfaced separately so the
|
|
1993
|
+
* renderer can show a stale indicator without crawling the venues map.
|
|
1994
|
+
*/
|
|
1995
|
+
lastUpdateTs: number | null;
|
|
1692
1996
|
}
|
|
1693
1997
|
|
|
1694
1998
|
type MarketOrderbookIntegrity = "ok" | "resyncing";
|
|
@@ -2209,11 +2513,20 @@ declare function useExecutionOrders(options?: UseExecutionOrdersOptions): {
|
|
|
2209
2513
|
|
|
2210
2514
|
interface UseUserActivityOptions extends Omit<UserActivityQuery, "cursor"> {
|
|
2211
2515
|
enabled?: boolean;
|
|
2516
|
+
/**
|
|
2517
|
+
* Poll interval (ms) used while any cached activity row is mid-lifecycle
|
|
2518
|
+
* (deposit pending, withdrawal bridging, trade submitted, etc.). Idle
|
|
2519
|
+
* feeds — every row in a terminal state — don't poll. Set to `false` to
|
|
2520
|
+
* disable the lifecycle-aware poll entirely.
|
|
2521
|
+
*
|
|
2522
|
+
* Defaults to 15s.
|
|
2523
|
+
*/
|
|
2524
|
+
pendingRefetchIntervalMs?: number | false;
|
|
2212
2525
|
}
|
|
2213
2526
|
declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
2214
2527
|
activities: UserActivityItem[];
|
|
2215
2528
|
hasNextPage: boolean;
|
|
2216
|
-
data: _tanstack_react_query.InfiniteData<
|
|
2529
|
+
data: _tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>;
|
|
2217
2530
|
error: Error;
|
|
2218
2531
|
isError: true;
|
|
2219
2532
|
isPending: false;
|
|
@@ -2223,8 +2536,8 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2223
2536
|
isSuccess: false;
|
|
2224
2537
|
isPlaceholderData: false;
|
|
2225
2538
|
status: "error";
|
|
2226
|
-
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2227
|
-
fetchPreviousPage: (options?: _tanstack_react_query.FetchPreviousPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2539
|
+
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2540
|
+
fetchPreviousPage: (options?: _tanstack_react_query.FetchPreviousPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2228
2541
|
hasPreviousPage: boolean;
|
|
2229
2542
|
isFetchNextPageError: boolean;
|
|
2230
2543
|
isFetchingNextPage: boolean;
|
|
@@ -2243,13 +2556,13 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2243
2556
|
isRefetching: boolean;
|
|
2244
2557
|
isStale: boolean;
|
|
2245
2558
|
isEnabled: boolean;
|
|
2246
|
-
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2559
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2247
2560
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
2248
|
-
promise: Promise<_tanstack_react_query.InfiniteData<
|
|
2561
|
+
promise: Promise<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>>;
|
|
2249
2562
|
} | {
|
|
2250
2563
|
activities: UserActivityItem[];
|
|
2251
2564
|
hasNextPage: boolean;
|
|
2252
|
-
data: _tanstack_react_query.InfiniteData<
|
|
2565
|
+
data: _tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>;
|
|
2253
2566
|
error: null;
|
|
2254
2567
|
isError: false;
|
|
2255
2568
|
isPending: false;
|
|
@@ -2261,8 +2574,8 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2261
2574
|
isSuccess: true;
|
|
2262
2575
|
isPlaceholderData: false;
|
|
2263
2576
|
status: "success";
|
|
2264
|
-
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2265
|
-
fetchPreviousPage: (options?: _tanstack_react_query.FetchPreviousPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2577
|
+
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2578
|
+
fetchPreviousPage: (options?: _tanstack_react_query.FetchPreviousPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2266
2579
|
hasPreviousPage: boolean;
|
|
2267
2580
|
isFetchingNextPage: boolean;
|
|
2268
2581
|
isFetchingPreviousPage: boolean;
|
|
@@ -2279,9 +2592,9 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2279
2592
|
isRefetching: boolean;
|
|
2280
2593
|
isStale: boolean;
|
|
2281
2594
|
isEnabled: boolean;
|
|
2282
|
-
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2595
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2283
2596
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
2284
|
-
promise: Promise<_tanstack_react_query.InfiniteData<
|
|
2597
|
+
promise: Promise<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>>;
|
|
2285
2598
|
} | {
|
|
2286
2599
|
activities: UserActivityItem[];
|
|
2287
2600
|
hasNextPage: boolean;
|
|
@@ -2297,8 +2610,8 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2297
2610
|
isSuccess: false;
|
|
2298
2611
|
isPlaceholderData: false;
|
|
2299
2612
|
status: "error";
|
|
2300
|
-
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2301
|
-
fetchPreviousPage: (options?: _tanstack_react_query.FetchPreviousPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2613
|
+
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2614
|
+
fetchPreviousPage: (options?: _tanstack_react_query.FetchPreviousPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2302
2615
|
hasPreviousPage: boolean;
|
|
2303
2616
|
isFetchingNextPage: boolean;
|
|
2304
2617
|
isFetchingPreviousPage: boolean;
|
|
@@ -2315,9 +2628,9 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2315
2628
|
isRefetching: boolean;
|
|
2316
2629
|
isStale: boolean;
|
|
2317
2630
|
isEnabled: boolean;
|
|
2318
|
-
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2631
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2319
2632
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
2320
|
-
promise: Promise<_tanstack_react_query.InfiniteData<
|
|
2633
|
+
promise: Promise<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>>;
|
|
2321
2634
|
} | {
|
|
2322
2635
|
activities: UserActivityItem[];
|
|
2323
2636
|
hasNextPage: boolean;
|
|
@@ -2333,8 +2646,8 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2333
2646
|
isSuccess: false;
|
|
2334
2647
|
isPlaceholderData: false;
|
|
2335
2648
|
status: "pending";
|
|
2336
|
-
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2337
|
-
fetchPreviousPage: (options?: _tanstack_react_query.FetchPreviousPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2649
|
+
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2650
|
+
fetchPreviousPage: (options?: _tanstack_react_query.FetchPreviousPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2338
2651
|
hasPreviousPage: boolean;
|
|
2339
2652
|
isFetchingNextPage: boolean;
|
|
2340
2653
|
isFetchingPreviousPage: boolean;
|
|
@@ -2351,9 +2664,9 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2351
2664
|
isRefetching: boolean;
|
|
2352
2665
|
isStale: boolean;
|
|
2353
2666
|
isEnabled: boolean;
|
|
2354
|
-
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2667
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2355
2668
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
2356
|
-
promise: Promise<_tanstack_react_query.InfiniteData<
|
|
2669
|
+
promise: Promise<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>>;
|
|
2357
2670
|
} | {
|
|
2358
2671
|
activities: UserActivityItem[];
|
|
2359
2672
|
hasNextPage: boolean;
|
|
@@ -2368,8 +2681,8 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2368
2681
|
isSuccess: false;
|
|
2369
2682
|
isPlaceholderData: false;
|
|
2370
2683
|
status: "pending";
|
|
2371
|
-
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2372
|
-
fetchPreviousPage: (options?: _tanstack_react_query.FetchPreviousPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2684
|
+
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2685
|
+
fetchPreviousPage: (options?: _tanstack_react_query.FetchPreviousPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2373
2686
|
hasPreviousPage: boolean;
|
|
2374
2687
|
isFetchingNextPage: boolean;
|
|
2375
2688
|
isFetchingPreviousPage: boolean;
|
|
@@ -2387,13 +2700,13 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2387
2700
|
isRefetching: boolean;
|
|
2388
2701
|
isStale: boolean;
|
|
2389
2702
|
isEnabled: boolean;
|
|
2390
|
-
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2703
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2391
2704
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
2392
|
-
promise: Promise<_tanstack_react_query.InfiniteData<
|
|
2705
|
+
promise: Promise<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>>;
|
|
2393
2706
|
} | {
|
|
2394
2707
|
activities: UserActivityItem[];
|
|
2395
2708
|
hasNextPage: boolean;
|
|
2396
|
-
data: _tanstack_react_query.InfiniteData<
|
|
2709
|
+
data: _tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>;
|
|
2397
2710
|
isError: false;
|
|
2398
2711
|
error: null;
|
|
2399
2712
|
isPending: false;
|
|
@@ -2405,8 +2718,8 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2405
2718
|
isFetchNextPageError: false;
|
|
2406
2719
|
isFetchPreviousPageError: false;
|
|
2407
2720
|
status: "success";
|
|
2408
|
-
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2409
|
-
fetchPreviousPage: (options?: _tanstack_react_query.FetchPreviousPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2721
|
+
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2722
|
+
fetchPreviousPage: (options?: _tanstack_react_query.FetchPreviousPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2410
2723
|
hasPreviousPage: boolean;
|
|
2411
2724
|
isFetchingNextPage: boolean;
|
|
2412
2725
|
isFetchingPreviousPage: boolean;
|
|
@@ -2423,9 +2736,9 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2423
2736
|
isRefetching: boolean;
|
|
2424
2737
|
isStale: boolean;
|
|
2425
2738
|
isEnabled: boolean;
|
|
2426
|
-
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2739
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>, Error>>;
|
|
2427
2740
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
2428
|
-
promise: Promise<_tanstack_react_query.InfiniteData<
|
|
2741
|
+
promise: Promise<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>>;
|
|
2429
2742
|
};
|
|
2430
2743
|
|
|
2431
2744
|
interface UseExternalIdOptions {
|
|
@@ -2780,6 +3093,38 @@ declare function useLiveOutcomePrices(venueMarkets: VenueMarket[] | null | undef
|
|
|
2780
3093
|
*/
|
|
2781
3094
|
declare function findLivePriceById(livePrices: Map<string, number>, id: string): number | undefined;
|
|
2782
3095
|
|
|
3096
|
+
type LiveBestPrices = ReadonlyMap<string, {
|
|
3097
|
+
bestBid?: number;
|
|
3098
|
+
bestAsk?: number;
|
|
3099
|
+
}>;
|
|
3100
|
+
/**
|
|
3101
|
+
* WS-derived cross-venue + cross-outcome best bid/ask per outcome.
|
|
3102
|
+
*
|
|
3103
|
+
* For each outcome in `venueMarkets` (plus matched twins via MVMO refs):
|
|
3104
|
+
* - bestBid/bestAsk taken from the per-outcome aggregated top of book.
|
|
3105
|
+
* - Then folded across MVMO groups: lowest bestAsk wins (cheapest to buy),
|
|
3106
|
+
* highest bestBid wins (best to sell). The chosen best is broadcast to
|
|
3107
|
+
* every member of the group so display surfaces pick it up regardless
|
|
3108
|
+
* of which outcome they look up.
|
|
3109
|
+
*
|
|
3110
|
+
* Empty until WS snapshots/deltas land for the subscribed outcomes. Designed
|
|
3111
|
+
* to merge as overrides on top of REST `bestPrices` from `useMidpoints`, with
|
|
3112
|
+
* WS winning where present.
|
|
3113
|
+
*/
|
|
3114
|
+
declare function useLiveBestPrices(venueMarkets: VenueMarket[] | null | undefined): LiveBestPrices;
|
|
3115
|
+
/**
|
|
3116
|
+
* Merge WS bestBid/bestAsk over a REST `bestPrices` map, WS values winning
|
|
3117
|
+
* where present. Returns the REST map unchanged when WS is empty. Designed
|
|
3118
|
+
* for callers that need to pass a single `bestPrices` map to display logic.
|
|
3119
|
+
*/
|
|
3120
|
+
declare function mergeBestPricesPreferringLive(rest: ReadonlyMap<string, {
|
|
3121
|
+
bestBid?: number;
|
|
3122
|
+
bestAsk?: number;
|
|
3123
|
+
}> | null | undefined, live: LiveBestPrices): ReadonlyMap<string, {
|
|
3124
|
+
bestBid?: number;
|
|
3125
|
+
bestAsk?: number;
|
|
3126
|
+
}>;
|
|
3127
|
+
|
|
2783
3128
|
/**
|
|
2784
3129
|
* Subscribe to real-time trade feed for a canonical market.
|
|
2785
3130
|
* Manages a separate trade subscription on the WS (trades use a different channel).
|
|
@@ -2790,27 +3135,100 @@ declare function useLiveTrades(canonicalMarketId: string | null): WsTrade[];
|
|
|
2790
3135
|
interface UseMidpointsResult {
|
|
2791
3136
|
/** Map of outcomeId → price. Empty while loading. */
|
|
2792
3137
|
prices: Map<string, number>;
|
|
3138
|
+
/**
|
|
3139
|
+
* Map of outcomeId → lowest midpoint available for that exact semantic outcome
|
|
3140
|
+
* across the selected market cluster. Alias of `prices`, exposed under a
|
|
3141
|
+
* clearer name for display surfaces that want a single source of truth.
|
|
3142
|
+
*/
|
|
3143
|
+
bestMidpointsByOutcomeId: Map<string, number>;
|
|
2793
3144
|
/**
|
|
2794
3145
|
* Map of outcomeId → venue name that provided the price in `prices`.
|
|
2795
|
-
* When a matched
|
|
2796
|
-
*
|
|
3146
|
+
* When a matched sibling offers a lower midpoint for the same semantic
|
|
3147
|
+
* side, this records that sibling's venue so callers can show the
|
|
3148
|
+
* correct venue logo alongside the best price.
|
|
2797
3149
|
* Empty while loading or when the API response omits `venue` fields.
|
|
2798
3150
|
*/
|
|
2799
3151
|
venueByOutcomeId: Map<string, string>;
|
|
3152
|
+
/**
|
|
3153
|
+
* Map of outcomeId → { bestBid?, bestAsk? }. Top-of-book prices extracted
|
|
3154
|
+
* from the midpoints response when bestPrice=true. Empty while loading
|
|
3155
|
+
* or when bestPrice data is unavailable.
|
|
3156
|
+
*/
|
|
3157
|
+
bestPrices: Map<string, {
|
|
3158
|
+
bestBid?: number;
|
|
3159
|
+
bestAsk?: number;
|
|
3160
|
+
}>;
|
|
3161
|
+
/**
|
|
3162
|
+
* Map of outcomeId → { bestBidVenue?, bestAskVenue? }. Tracks which venue
|
|
3163
|
+
* supplied the winning side of the book across the MVMO group so display
|
|
3164
|
+
* surfaces can pair the logo with the price. Distinct per side because
|
|
3165
|
+
* "best buy" and "best sell" can come from different venues.
|
|
3166
|
+
*/
|
|
3167
|
+
bestPriceVenuesByOutcomeId: Map<string, {
|
|
3168
|
+
bestBidVenue?: string;
|
|
3169
|
+
bestAskVenue?: string;
|
|
3170
|
+
}>;
|
|
2800
3171
|
/** True while the midpoints fetch is in flight. */
|
|
2801
3172
|
isLoading: boolean;
|
|
3173
|
+
/** Best midpoint value across all venues. Undefined while loading. */
|
|
3174
|
+
bestMidpoint: number | undefined;
|
|
3175
|
+
/**
|
|
3176
|
+
* Venue that produced `bestMidpoint`. Paired with `bestMidpoint` from the
|
|
3177
|
+
* same winning outcome so display surfaces can render a matching logo +
|
|
3178
|
+
* price. Undefined when no candidate produced a price or when the
|
|
3179
|
+
* response lacked a `venue` field.
|
|
3180
|
+
*/
|
|
3181
|
+
bestMidpointVenue: string | undefined;
|
|
2802
3182
|
}
|
|
2803
3183
|
/**
|
|
2804
3184
|
* Fetches live midpoints for the given venue markets.
|
|
2805
3185
|
*
|
|
2806
3186
|
* Returns { prices, isLoading } so callers can show a skeleton while loading.
|
|
2807
3187
|
*
|
|
2808
|
-
*
|
|
2809
|
-
*
|
|
2810
|
-
*
|
|
3188
|
+
* Cross-venue best-price selection walks each parent outcome's
|
|
3189
|
+
* `matchedVenueMarketOutcomes` (MVMO references) and looks up the matched
|
|
3190
|
+
* counterpart's per-outcome midpoint in `matched[].outcomes`. The lowest
|
|
3191
|
+
* midpoint wins per outcome — semantically correct for both Yes and No
|
|
3192
|
+
* sides because MVMO links same-side counterparts regardless of label
|
|
3193
|
+
* inversion. No label heuristics; no `1 - midpoint` flips.
|
|
2811
3194
|
*/
|
|
2812
3195
|
declare function useMidpoints(venueMarkets: VenueMarket[] | null | undefined): UseMidpointsResult;
|
|
2813
3196
|
|
|
3197
|
+
interface UseTradableVenuesResult {
|
|
3198
|
+
/**
|
|
3199
|
+
* Set of venue strings that have at least one outcome with a non-null
|
|
3200
|
+
* midpoint from the engine. When non-null, this is the authoritative
|
|
3201
|
+
* set of venues that have a live orderbook for the given cluster.
|
|
3202
|
+
*
|
|
3203
|
+
* `null` while midpoints are still loading — callers should treat this
|
|
3204
|
+
* as "unknown, don't filter yet" and show all venues optimistically.
|
|
3205
|
+
*/
|
|
3206
|
+
tradableVenues: ReadonlySet<string> | null;
|
|
3207
|
+
/** True while the underlying midpoints fetch is in flight. */
|
|
3208
|
+
isLoading: boolean;
|
|
3209
|
+
}
|
|
3210
|
+
/**
|
|
3211
|
+
* Dynamic venue-orderbook availability check.
|
|
3212
|
+
*
|
|
3213
|
+
* Walks the cluster's midpoints (already fetched via /midpoints by the
|
|
3214
|
+
* surrounding component, or fetched fresh here if not) and returns the
|
|
3215
|
+
* set of venues that have at least one outcome with a non-null midpoint.
|
|
3216
|
+
* A venue with NO non-null midpoints across all its outcomes is treated
|
|
3217
|
+
* as "no live orderbook" — it appeared in matching/discovery but the
|
|
3218
|
+
* engine isn't quoting it (e.g. opinion).
|
|
3219
|
+
*
|
|
3220
|
+
* The signal is purely runtime: no hardcoded venue allowlist. New
|
|
3221
|
+
* venues that join without orderbook support get filtered automatically;
|
|
3222
|
+
* venues whose orderbook stream temporarily drops also get filtered
|
|
3223
|
+
* until midpoints come back. This keeps the FE in lockstep with what the
|
|
3224
|
+
* engine is actually able to quote, without coordinating constants
|
|
3225
|
+
* across BE/FE on every venue addition.
|
|
3226
|
+
*
|
|
3227
|
+
* Use this in surfaces that need to show "X tradeable venues" or filter
|
|
3228
|
+
* a venue logo strip — see `getVenueSummary`'s `tradableVenues` option.
|
|
3229
|
+
*/
|
|
3230
|
+
declare function useTradableVenues(venueMarkets: VenueMarket[] | null | undefined): UseTradableVenuesResult;
|
|
3231
|
+
|
|
2814
3232
|
interface UseMarketChartOptions {
|
|
2815
3233
|
/** VenueMarketOutcome.id */
|
|
2816
3234
|
marketId: string | null;
|
|
@@ -2823,6 +3241,25 @@ interface UseMarketChartOptions {
|
|
|
2823
3241
|
enabled?: boolean;
|
|
2824
3242
|
/** Enable live WS updates. Defaults to the global `enableLiveUpdates` config. */
|
|
2825
3243
|
live?: boolean;
|
|
3244
|
+
/**
|
|
3245
|
+
* Auto-refetch the REST history at this cadence (ms). Pair with a rolling
|
|
3246
|
+
* window whose `endTs` advances at the same bucket interval — each tick
|
|
3247
|
+
* refetches the latest window under a stable cache key, so closed bars
|
|
3248
|
+
* the WebSocket missed are backfilled. `null`/omitted disables auto-refetch.
|
|
3249
|
+
*/
|
|
3250
|
+
refetchIntervalMs?: number | null;
|
|
3251
|
+
/**
|
|
3252
|
+
* Stable identifier for the user-selected range (e.g. `"1H"`, `"6H"`).
|
|
3253
|
+
* Used as the React Query cache key so the entry survives bucket rollovers
|
|
3254
|
+
* and tab/page revisits. The concrete `startTs`/`endTs` advance under the
|
|
3255
|
+
* same key and are passed to the fetch via closure.
|
|
3256
|
+
*
|
|
3257
|
+
* If omitted, falls back to `interval` — preserves cache reuse for callers
|
|
3258
|
+
* that don't drive a rolling window. Note that 6H and 1D both use a 5m
|
|
3259
|
+
* interval, so callers using rolling windows should pass an explicit
|
|
3260
|
+
* `rangeKey` to keep their cache entries separate.
|
|
3261
|
+
*/
|
|
3262
|
+
rangeKey?: string;
|
|
2826
3263
|
}
|
|
2827
3264
|
interface UseMarketChartResult {
|
|
2828
3265
|
data: MarketChartData | null;
|
|
@@ -2833,6 +3270,93 @@ interface UseMarketChartResult {
|
|
|
2833
3270
|
}
|
|
2834
3271
|
declare function useMarketChart(options: UseMarketChartOptions): UseMarketChartResult;
|
|
2835
3272
|
|
|
3273
|
+
interface UseRollingChartWindowOptions {
|
|
3274
|
+
range: ChartTimeRange;
|
|
3275
|
+
/**
|
|
3276
|
+
* Override the WS candle interval. Defaults to the canonical mapping from
|
|
3277
|
+
* `timeRangeToInterval`. Tests use this to inject a deterministic value.
|
|
3278
|
+
*/
|
|
3279
|
+
interval?: WsCandleInterval;
|
|
3280
|
+
/**
|
|
3281
|
+
* Tick cadence for `nowSec`, in milliseconds. Defaults to 1s. The query
|
|
3282
|
+
* boundary (`endTs`) is bucketized so React Query only refetches when the
|
|
3283
|
+
* candle bucket advances, not on every tick.
|
|
3284
|
+
*/
|
|
3285
|
+
tickMs?: number;
|
|
3286
|
+
/**
|
|
3287
|
+
* Read of `Date.now()` (ms). Overridable for tests.
|
|
3288
|
+
*/
|
|
3289
|
+
nowMs?: () => number;
|
|
3290
|
+
}
|
|
3291
|
+
interface RollingChartWindow {
|
|
3292
|
+
range: ChartTimeRange;
|
|
3293
|
+
interval: WsCandleInterval;
|
|
3294
|
+
/** Width of the visible/rolling domain in seconds. */
|
|
3295
|
+
rangeSeconds: number;
|
|
3296
|
+
/** Width of one closed bar in seconds. */
|
|
3297
|
+
intervalSeconds: number;
|
|
3298
|
+
/**
|
|
3299
|
+
* Current wall-clock seconds, updated on every tick. The visible domain is
|
|
3300
|
+
* always `[nowSec - rangeSeconds, nowSec]` — use this for filtering points
|
|
3301
|
+
* to the rolling window.
|
|
3302
|
+
*/
|
|
3303
|
+
nowSec: number;
|
|
3304
|
+
/**
|
|
3305
|
+
* Bucketized end of the rolling window. Snaps to the next interval
|
|
3306
|
+
* boundary so the React Query key (and therefore REST refetch) only
|
|
3307
|
+
* advances when a new candle bucket starts. Use this as `endTs` for the
|
|
3308
|
+
* REST query.
|
|
3309
|
+
*/
|
|
3310
|
+
endTs: number;
|
|
3311
|
+
/**
|
|
3312
|
+
* Bucketized start: `endTs - rangeSeconds`. Use as `startTs` for the
|
|
3313
|
+
* REST query.
|
|
3314
|
+
*/
|
|
3315
|
+
startTs: number;
|
|
3316
|
+
/**
|
|
3317
|
+
* Refetch interval to pass to React Query, in milliseconds. Matches one
|
|
3318
|
+
* candle bucket so historical bars roll in cleanly even without WS.
|
|
3319
|
+
*/
|
|
3320
|
+
refetchIntervalMs: number;
|
|
3321
|
+
}
|
|
3322
|
+
declare const rangeToSeconds: (range: ChartTimeRange) => number;
|
|
3323
|
+
/**
|
|
3324
|
+
* Pure resolver for the rolling window, factored out of `useRollingChartWindow`
|
|
3325
|
+
* so the time-math can be unit-tested without rendering React.
|
|
3326
|
+
*
|
|
3327
|
+
* Invariants:
|
|
3328
|
+
* - `nowSec - rangeSeconds === domainStartTs` (the visible domain is
|
|
3329
|
+
* always exactly `rangeSeconds` wide regardless of how long mounted).
|
|
3330
|
+
* - `endTs - startTs === rangeSeconds` (the bucketized query window is
|
|
3331
|
+
* also exactly `rangeSeconds` wide; only the alignment to bucket
|
|
3332
|
+
* boundaries differs from the visible domain).
|
|
3333
|
+
* - `endTs % intervalSeconds === 0` (snaps to next bucket boundary so
|
|
3334
|
+
* the React Query key stays stable between bucket rollovers).
|
|
3335
|
+
*/
|
|
3336
|
+
declare const resolveRollingWindow: (params: {
|
|
3337
|
+
range: ChartTimeRange;
|
|
3338
|
+
nowSec: number;
|
|
3339
|
+
interval?: WsCandleInterval;
|
|
3340
|
+
}) => RollingChartWindow;
|
|
3341
|
+
/**
|
|
3342
|
+
* Drives a rolling time domain `[nowSec - rangeSeconds, nowSec]` that ticks
|
|
3343
|
+
* while the chart is mounted.
|
|
3344
|
+
*
|
|
3345
|
+
* Why two timestamps (`nowSec` vs `endTs`):
|
|
3346
|
+
* - `nowSec` updates every `tickMs` (default 1s) so the visible domain
|
|
3347
|
+
* stays exactly `rangeSeconds` wide. Series points outside that domain
|
|
3348
|
+
* should be filtered out by the caller.
|
|
3349
|
+
* - `endTs` is bucketized to the next interval boundary so React Query's
|
|
3350
|
+
* key only changes when a new candle bucket actually starts. Without
|
|
3351
|
+
* this, the chart would refetch every tick.
|
|
3352
|
+
*
|
|
3353
|
+
* The bucket advance is also what drives REST refetches that backfill any
|
|
3354
|
+
* closed bars the WebSocket missed. WS updates feed the in-flight candle
|
|
3355
|
+
* and promote it on rollover (see `chart-cache.applyMidpointToMarketChart`);
|
|
3356
|
+
* the REST refetch only matters when WS is disconnected or quiet.
|
|
3357
|
+
*/
|
|
3358
|
+
declare const useRollingChartWindow: (options: UseRollingChartWindowOptions) => RollingChartWindow;
|
|
3359
|
+
|
|
2836
3360
|
interface UseMarketOrderbookVenueOutcome {
|
|
2837
3361
|
venue: VenueMarket["venue"];
|
|
2838
3362
|
venueMarketOutcomeId: string;
|
|
@@ -3092,6 +3616,15 @@ interface UseSearchOptions {
|
|
|
3092
3616
|
limit?: number;
|
|
3093
3617
|
/** If provided, enable/disable the query. Defaults to true. */
|
|
3094
3618
|
enabled?: boolean;
|
|
3619
|
+
/**
|
|
3620
|
+
* Opt in to the server-side reranker for higher-quality top results.
|
|
3621
|
+
*
|
|
3622
|
+
* Recommended for the full search-results page (submit / Enter) and NOT
|
|
3623
|
+
* for debounced typeahead — the latter shouldn't pay reranker latency on
|
|
3624
|
+
* every keystroke. The flag is baked into the query cache key, so deep
|
|
3625
|
+
* and light variants of the same query never share results. Default false.
|
|
3626
|
+
*/
|
|
3627
|
+
deep?: boolean;
|
|
3095
3628
|
}
|
|
3096
3629
|
/**
|
|
3097
3630
|
* Search events or markets via the /search endpoint with cursor-based pagination.
|
|
@@ -3101,6 +3634,9 @@ interface UseSearchOptions {
|
|
|
3101
3634
|
* ```ts
|
|
3102
3635
|
* const { data } = useSearch<VenueEventWithMarkets>({ q: "...", type: "events" });
|
|
3103
3636
|
* ```
|
|
3637
|
+
*
|
|
3638
|
+
* For typeahead + full-results in one hook, prefer `useMarketSearch` — it
|
|
3639
|
+
* wires up the debounce, submit, and cancellation semantics out of the box.
|
|
3104
3640
|
*/
|
|
3105
3641
|
declare function useSearch<T = VenueEvent>(options: UseSearchOptions): {
|
|
3106
3642
|
data: T[];
|
|
@@ -3118,6 +3654,100 @@ declare function useSearch<T = VenueEvent>(options: UseSearchOptions): {
|
|
|
3118
3654
|
isPlaceholderData: boolean;
|
|
3119
3655
|
};
|
|
3120
3656
|
|
|
3657
|
+
interface UseMarketSearchOptions {
|
|
3658
|
+
/** Search type: "events" or "markets". */
|
|
3659
|
+
type: "events" | "markets";
|
|
3660
|
+
/** Optional category ID filter. */
|
|
3661
|
+
categoryIds?: string[];
|
|
3662
|
+
/** Page size for both modes. Default 20. */
|
|
3663
|
+
limit?: number;
|
|
3664
|
+
/**
|
|
3665
|
+
* Debounce delay applied to the typeahead/light query, in ms. The submit
|
|
3666
|
+
* path bypasses debounce entirely. Default 200.
|
|
3667
|
+
*/
|
|
3668
|
+
debounceMs?: number;
|
|
3669
|
+
/**
|
|
3670
|
+
* Set to `false` to disable the typeahead/light query (no /search call
|
|
3671
|
+
* while the user types). The submit path still fires deep searches.
|
|
3672
|
+
* Default true.
|
|
3673
|
+
*/
|
|
3674
|
+
enableSuggestions?: boolean;
|
|
3675
|
+
/**
|
|
3676
|
+
* Minimum query length before the typeahead fires. Default 1 — set higher
|
|
3677
|
+
* (e.g. 3) if `/search` cost per keystroke is a concern. The submit path
|
|
3678
|
+
* ignores this threshold.
|
|
3679
|
+
*/
|
|
3680
|
+
minLength?: number;
|
|
3681
|
+
}
|
|
3682
|
+
/**
|
|
3683
|
+
* Combined typeahead + submit hook for the canonical search UX.
|
|
3684
|
+
*
|
|
3685
|
+
* ┌─────────────────────────────┐
|
|
3686
|
+
* │ user types "tru" │ → debounced light /search → suggestions[]
|
|
3687
|
+
* │ user types "trum" │ → debounced light /search → suggestions[]
|
|
3688
|
+
* │ user presses Enter │ → deep /search → results[]
|
|
3689
|
+
* └─────────────────────────────┘
|
|
3690
|
+
*
|
|
3691
|
+
* Typeahead (`suggestions`) and submit-results (`results`) are cached under
|
|
3692
|
+
* separate TanStack Query keys, so navigating away and back doesn't lose
|
|
3693
|
+
* either. Server-side the same separation holds: the `deep` flag is part of
|
|
3694
|
+
* the cache key, so the two modes never collide.
|
|
3695
|
+
*
|
|
3696
|
+
* ```tsx
|
|
3697
|
+
* const { query, setQuery, submit, suggestions, results } = useMarketSearch({
|
|
3698
|
+
* type: "markets",
|
|
3699
|
+
* });
|
|
3700
|
+
*
|
|
3701
|
+
* <input
|
|
3702
|
+
* value={query}
|
|
3703
|
+
* onChange={(e) => setQuery(e.target.value)}
|
|
3704
|
+
* onKeyDown={(e) => { if (e.key === "Enter") submit(); }}
|
|
3705
|
+
* />
|
|
3706
|
+
* {suggestions.data.map(...)} // dropdown
|
|
3707
|
+
* {results.data.map(...)} // full page after Enter
|
|
3708
|
+
* ```
|
|
3709
|
+
*/
|
|
3710
|
+
declare function useMarketSearch<T = VenueEvent>(options: UseMarketSearchOptions): {
|
|
3711
|
+
/** Current input value (controlled). */
|
|
3712
|
+
query: string;
|
|
3713
|
+
/** Update the input value. Triggers the debounced typeahead. */
|
|
3714
|
+
setQuery: (value: string) => void;
|
|
3715
|
+
/** The query value that produced the current `results`, or null if none. */
|
|
3716
|
+
submittedQuery: string | null;
|
|
3717
|
+
/** Fire a deep search. Use this on Enter / Search button. */
|
|
3718
|
+
submit: (q?: string) => void;
|
|
3719
|
+
/** Reset both input and results state. */
|
|
3720
|
+
clear: () => void;
|
|
3721
|
+
/**
|
|
3722
|
+
* Typeahead state. Backed by a light /search call (no reranker).
|
|
3723
|
+
* `data` is paginated like `useSearch.data` (flattened across pages).
|
|
3724
|
+
*/
|
|
3725
|
+
suggestions: {
|
|
3726
|
+
data: T[];
|
|
3727
|
+
isLoading: boolean;
|
|
3728
|
+
isError: boolean;
|
|
3729
|
+
error: Error | null;
|
|
3730
|
+
};
|
|
3731
|
+
/**
|
|
3732
|
+
* Full-page results state. Backed by a deep /search call (reranker on).
|
|
3733
|
+
* Cursor pagination is exposed via `fetchNextPage` / `hasNextPage`.
|
|
3734
|
+
*/
|
|
3735
|
+
results: {
|
|
3736
|
+
data: T[];
|
|
3737
|
+
isLoading: boolean;
|
|
3738
|
+
isError: boolean;
|
|
3739
|
+
error: Error | null;
|
|
3740
|
+
hasNextPage: boolean;
|
|
3741
|
+
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<{
|
|
3742
|
+
type: "markets" | "events";
|
|
3743
|
+
data: T[];
|
|
3744
|
+
nextCursor: string | null;
|
|
3745
|
+
hasMore: boolean;
|
|
3746
|
+
}, unknown>, Error>>;
|
|
3747
|
+
isFetchingNextPage: boolean;
|
|
3748
|
+
};
|
|
3749
|
+
};
|
|
3750
|
+
|
|
3121
3751
|
interface UseSmartRouteOptions {
|
|
3122
3752
|
/** Venue market outcome ID used by the smart-route endpoint. */
|
|
3123
3753
|
venueMarketOutcomeId?: string | null;
|
|
@@ -3139,8 +3769,18 @@ interface UseSmartRouteOptions {
|
|
|
3139
3769
|
slipCapBps?: number;
|
|
3140
3770
|
/** Include venue-by-venue comparison quotes. */
|
|
3141
3771
|
compareVenues?: boolean;
|
|
3772
|
+
/**
|
|
3773
|
+
* Opt in to the deep cost-estimate surface — response `feeBreakdown`
|
|
3774
|
+
* gains `setupCosts` (chain approvals + Kalshi ATAs) with `alreadyPaid`
|
|
3775
|
+
* flags from prior trade history, and `setupCostsTotal` is folded into
|
|
3776
|
+
* `totalCostIncFees` (with `estimatedProfit` / `returnPct` recomputed).
|
|
3777
|
+
* Buy-only.
|
|
3778
|
+
*/
|
|
3779
|
+
deepEstimate?: boolean;
|
|
3142
3780
|
/** Enable/disable the query. Default true. */
|
|
3143
3781
|
enabled?: boolean;
|
|
3782
|
+
/** Cache freshness and polling interval in milliseconds. Defaults to SMART_ROUTE_STALE_TIME_MS. */
|
|
3783
|
+
staleTimeMs?: number;
|
|
3144
3784
|
}
|
|
3145
3785
|
interface UseSmartRouteResult {
|
|
3146
3786
|
data: SmartRouteResponse | null;
|
|
@@ -4495,15 +5135,18 @@ declare function computePriceGaps(input: ComputePriceGapsInput): Map<string, num
|
|
|
4495
5135
|
* • Markets that become visible for the first time are batched into a
|
|
4496
5136
|
* single request on the next render.
|
|
4497
5137
|
*
|
|
4498
|
-
*
|
|
4499
|
-
*
|
|
4500
|
-
*
|
|
5138
|
+
* Cross-venue best-price selection walks each parent outcome's
|
|
5139
|
+
* `matchedVenueMarketOutcomes` (MVMO references) and looks up the matched
|
|
5140
|
+
* counterpart's per-outcome midpoint. The lowest midpoint wins per
|
|
5141
|
+
* outcome — semantically correct for both Yes and No sides because MVMO
|
|
5142
|
+
* links same-side counterparts regardless of label inversion.
|
|
4501
5143
|
*/
|
|
4502
5144
|
declare function useViewportMidpoints(visibleMarkets: VenueMarket[]): {
|
|
4503
5145
|
prices: Map<string, number>;
|
|
4504
5146
|
/**
|
|
4505
5147
|
* Map of outcomeId → venue name that provided the price in `prices`.
|
|
4506
|
-
* Populated when a matched
|
|
5148
|
+
* Populated when a matched sibling offers a lower midpoint for the same
|
|
5149
|
+
* semantic side.
|
|
4507
5150
|
*/
|
|
4508
5151
|
venueByOutcomeId: Map<string, string>;
|
|
4509
5152
|
};
|
|
@@ -4536,6 +5179,7 @@ interface UseAppConfigResult {
|
|
|
4536
5179
|
disabledVenues: AppClientConfigResponse["disabledVenues"];
|
|
4537
5180
|
disabledCategoryPresets: AppClientConfigResponse["disabledCategoryPresets"];
|
|
4538
5181
|
earlyAccessEnabled: AppClientConfigResponse["earlyAccessEnabled"];
|
|
5182
|
+
authOptions: AppClientConfigResponse["authOptions"];
|
|
4539
5183
|
isLoading: boolean;
|
|
4540
5184
|
error: unknown;
|
|
4541
5185
|
}
|
|
@@ -4545,4 +5189,4 @@ interface UseAppConfigResult {
|
|
|
4545
5189
|
*/
|
|
4546
5190
|
declare function useAppConfig(): UseAppConfigResult;
|
|
4547
5191
|
|
|
4548
|
-
export { AUTH_CHOOSER_OPEN_EVENT, type AggAuthContextValue, type AggAuthSignInOptions, type AggBalanceContextValue, AggBalanceProvider, AggProvider, type AggProviderProps, AggProvider as AggSdkProvider, type AggProviderProps as AggSdkProviderProps, type AggUiConfig, type AggUiConfigInput, type AggUiLabels, type AggUiLabelsInput, AggUiProvider, CHART_TIME_RANGES, CONFIRMED_MATCH_STATUSES, type ChartTimeRange, type ClosedPositionTotals, type ComputePriceGapsInput, DEFAULT_AGG_ROOT_CLASS_NAME, type DagStepProgress, type EventListStateContextValue, EventListStateProvider, type EventListStateSnapshot, type EventTradingContextValue, type EventTradingState, type ExecutionProgressPhase, type ExecutionTerminalOrderEvent, type GeoBlockState, type GetOrdersQuery, type GetPositionsQuery, type LiveCandle, type MarketChartCandle, type MarketChartData, type MarketChartVenueData, type MarketOrderbookData, type MarketOrderbookIntegrity, MarketStatus, type MarketTradingState, MatchStatus, MatchType, type OrderEligibility, type OrderEligibilityReason, type OrderListItem, type OrderbookResult, type PositionGroup, type PriceGapMarket, type RedeemEvent, type ScaledCandlePoint, type SdkUiConfig, type SdkUiConfigInput, type SdkUiProviderProps, type ThemeMode, type TradingAction, type TradingState, type TradingStateBase, type TradingStateKind, type UseAggAuthOptions, type UseAggAuthReturn, type UseAppConfigResult, type UseCategoriesOptions, type UseEnrichedVenueEventOptions, type UseExecuteManagedOptions, type UseExecutionOrdersOptions, type UseExecutionPositionsOptions, type UseExecutionProgressOptions, type UseExecutionProgressResult, type UseExternalIdOptions, type UseExternalIdReturn, type UseLinkAccountReturn, type UseLiveCandleOverlayOptions, type UseLiveCandleOverlayResult, type UseLiveCandlesOptions, type UseLiveCandlesResult, type UseLiveMarketResult, type UseMarketChartOptions, type UseMarketChartResult, type UseMarketOrderbookOptions, type UseMarketOrderbookResult, type UseMarketOrderbookVenueOutcome, type UseOrderBookOptions, type UseOrderbookQuoteOptions, type UseOrderbookQuoteResult, type UseOrdersOptions, type UsePositionsOptions, type UseQuoteManagedOptions, type UseSearchOptions, type UseSmartRouteOptions, type UseSmartRouteResult, type UseUserActivityOptions, type UseUserHoldingsOptions, type UseVenueEventOptions, type UseVenueEventsOptions, type UseVenueMarketMidpointsOptions, type UseVenueMarketsOptions, type UseVisibleIdsOptions, type UseVisibleIdsResult, Venue, type VenueEvent, type VenueEventWithMarkets, type VenueMarket, type VenueMarketOutcome, type WalletActionSendTokenParams, type WalletActions, computeClosedPositionTotals, computePriceGaps, defaultAggUiConfig, defaultAggUiConfig as defaultSdkUiConfig, executionKeys, findLivePriceById, getBuilder, getOrCreateBuilder, getWalletAddressFromUserProfile, invalidateBalanceQueries, invalidatePositionQueries, optimizedImageUrl, parseEmail, parseEmailStrict, requestAggAuthChooserOpen, resolveAggUiLabels, resolveDefaultMarket as resolveDefaultTradingMarket, resolveEventTradingState, resolveMarketTradingState, resolveMarketWinningOutcome, resolveOrderEligibility, resolveTradingStateKind, sortVenues, timeRangeToInterval, tradingReducer, useAggAuth, useAggAuthContext, useAggAuthState, useAggBalance, useAggBalanceContext, useAggBalanceState, useAggClient, useAggLabels, useAggUiConfig, useAggWebSocket, useAppConfig, useCategories, useDebouncedValue, useEnrichedVenueEvent, useEventListState, useEventOrderbookData, useEventTradingContext, useExecuteManaged, useExecutionOrders, useExecutionPositions, useExecutionProgress, useExternalId, useGeoBlock, useLabels, useLinkAccount, useLiveCandleOverlay, useLiveCandles, useLiveMarket, useLiveMarketStores, useLiveOutcomePrices, useLiveTrades, useMarketChart, useMarketOrderbook, useMidpoints, useOnBalanceUpdate, useOnOrderSubmitted, useOnRedeemEvent, useOnWithdrawalLifecycle, useOrderBook, useOrderbookQuote, useOrders, usePositions, useQuoteManaged, useRampQuotes, useRampSession, useRedeem, useRedeemEligibleCount, useSdkLabels, useSdkUiConfig, useSearch, useSmartRoute, useUserActivity, useUserHoldings, useVenueEvent, useVenueEvents, useVenueMarketMidpoints, useVenueMarkets, useViewportMidpoints, useVisibleIds };
|
|
5192
|
+
export { AUTH_CHOOSER_OPEN_EVENT, type AggAuthContextValue, type AggAuthSignInOptions, type AggBalanceContextValue, AggBalanceProvider, AggProvider, type AggProviderProps, AggProvider as AggSdkProvider, type AggProviderProps as AggSdkProviderProps, type AggUiConfig, type AggUiConfigInput, type AggUiLabels, type AggUiLabelsInput, AggUiProvider, CHART_TIME_RANGES, CONFIRMED_MATCH_STATUSES, type ChartTimeRange, type ClosedPositionTotals, type ComputePriceGapsInput, DEFAULT_AGG_ROOT_CLASS_NAME, type DagStepProgress, type EventListStateContextValue, EventListStateProvider, type EventListStateSnapshot, type EventTradingContextValue, type EventTradingState, type ExecutionProgressPhase, type ExecutionTerminalOrderEvent, type GeoBlockState, type GetOrdersQuery, type GetPositionsQuery, type InvalidateUserActivityOptions, type InvalidateUserMoneyStateOptions, type LiveBestPrices, type LiveCandle, type MarketChartCandle, type MarketChartData, type MarketChartVenueData, type MarketOrderbookData, type MarketOrderbookIntegrity, MarketStatus, type MarketTradingState, MatchStatus, MatchType, type OrderEligibility, type OrderEligibilityReason, type OrderListItem, type OrderbookResult, type PositionGroup, type PriceGapMarket, type RedeemEvent, type RedeemLegLifecycle, type RedeemLifecycleState, RedeemRejectedError, type RollingChartWindow, type ScaledCandlePoint, type SdkUiConfig, type SdkUiConfigInput, type SdkUiProviderProps, type ThemeMode, TradeSide, type TradingAction, type TradingState, type TradingStateBase, type TradingStateKind, type UseAggAuthOptions, type UseAggAuthReturn, type UseAppConfigResult, type UseCategoriesOptions, type UseEnrichedVenueEventOptions, type UseExecuteManagedOptions, type UseExecutionOrdersOptions, type UseExecutionPositionsOptions, type UseExecutionProgressOptions, type UseExecutionProgressResult, type UseExternalIdOptions, type UseExternalIdReturn, type UseLinkAccountReturn, type UseLiveCandleOverlayOptions, type UseLiveCandleOverlayResult, type UseLiveCandlesOptions, type UseLiveCandlesResult, type UseLiveMarketResult, type UseMarketChartOptions, type UseMarketChartResult, type UseMarketOrderbookOptions, type UseMarketOrderbookResult, type UseMarketOrderbookVenueOutcome, type UseMarketSearchOptions, type UseMidpointsResult, type UseOrderBookOptions, type UseOrderbookQuoteOptions, type UseOrderbookQuoteResult, type UseOrdersOptions, type UsePositionsOptions, type UseQuoteManagedOptions, type UseRedeemLifecycleInput, type UseRollingChartWindowOptions, type UseSearchOptions, type UseSmartRouteOptions, type UseSmartRouteResult, type UseTradableVenuesResult, type UseUserActivityOptions, type UseUserHoldingsOptions, type UseVenueEventOptions, type UseVenueEventsOptions, type UseVenueMarketMidpointsOptions, type UseVenueMarketsOptions, type UseVisibleIdsOptions, type UseVisibleIdsResult, type UserActivityInvalidationStrategy, Venue, type VenueEvent, type VenueEventWithMarkets, type VenueMarket, type VenueMarketOutcome, type WalletActionSendTokenParams, type WalletActions, computeClosedPositionTotals, computePriceGaps, defaultAggUiConfig, defaultAggUiConfig as defaultSdkUiConfig, executionKeys, findLivePriceById, getBuilder, getOrCreateBuilder, getWalletAddressFromUserProfile, invalidateBalanceQueries, invalidatePositionQueries, invalidateUserActivityQueries, invalidateUserMoneyState, mergeBestPricesPreferringLive, optimizedImageUrl, parseEmail, parseEmailStrict, rangeToSeconds, requestAggAuthChooserOpen, resolveAggUiLabels, resolveDefaultMarket as resolveDefaultTradingMarket, resolveEventTradingState, resolveMarketTradingState, resolveMarketWinningOutcome, resolveOrderEligibility, resolveRollingWindow, resolveTradingStateKind, sortVenues, timeRangeToInterval, tradingReducer, useAggAuth, useAggAuthContext, useAggAuthState, useAggBalance, useAggBalanceContext, useAggBalanceState, useAggClient, useAggLabels, useAggUiConfig, useAggWebSocket, useAppConfig, useCategories, useDebouncedValue, useEnrichedVenueEvent, useEventListState, useEventOrderbookData, useEventTradingContext, useExecuteManaged, useExecutionOrders, useExecutionPositions, useExecutionProgress, useExternalId, useGeoBlock, useLabels, useLinkAccount, useLiveBestPrices, useLiveCandleOverlay, useLiveCandles, useLiveMarket, useLiveMarketStores, useLiveOutcomePrices, useLiveTrades, useMarketChart, useMarketOrderbook, useMarketSearch, useMidpoints, useOnBalanceUpdate, useOnOrderSubmitted, useOnRedeemEvent, useOnWithdrawalLifecycle, useOrderBook, useOrderbookQuote, useOrders, usePositions, useQuoteManaged, useRampQuotes, useRampSession, useRedeem, useRedeemEligibleCount, useRedeemLifecycle, useRedeemLifecycles, useRollingChartWindow, useSdkLabels, useSdkUiConfig, useSearch, useSmartRoute, useTradableVenues, useUserActivity, useUserHoldings, useVenueEvent, useVenueEvents, useVenueMarketMidpoints, useVenueMarkets, useViewportMidpoints, useVisibleIds, userActivityQueryKeys };
|