@agg-build/hooks 1.0.2 → 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/README.md +1 -1
- package/dist/{chunk-V6VNA7MX.mjs → chunk-553OI6M2.mjs} +565 -89
- package/dist/{chunk-NOYHQUW2.mjs → chunk-CWEJLBYY.mjs} +66 -11
- package/dist/{chunk-EB64HHYM.mjs → chunk-JWPZNCGY.mjs} +1 -1
- package/dist/deposit.d.mts +8 -2
- package/dist/deposit.d.ts +8 -2
- package/dist/deposit.js +215 -76
- package/dist/deposit.mjs +119 -66
- package/dist/index.d.mts +712 -42
- package/dist/index.d.ts +712 -42
- package/dist/index.js +1405 -357
- 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 +178 -26
- package/dist/withdraw.mjs +4 -2
- package/package.json +2 -2
package/dist/index.d.ts
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.js';
|
|
8
|
+
export { UseManagedBalancesOptions, UseWithdrawEstimateParams, UseWithdrawFlowOptions, UseWithdrawFlowResult, UseWithdrawManagedOptions, UseWithdrawalLifecycleResult, WithdrawFeeEstimate, WithdrawalLifecycleState, useManagedBalances, useWithdrawEstimate, useWithdrawFlow, useWithdrawManaged, useWithdrawalLifecycle } from './withdraw.js';
|
|
9
9
|
export { U as UseDepositAddressesOptions, g as getDepositAddress, u as useDepositAddresses } from './use-deposit-addresses-B9ICS-3U.js';
|
|
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.js';
|
|
11
11
|
|
|
12
12
|
/** Use these constants instead of hardcoding "kalshi" or "polymarket". */
|
|
13
13
|
declare enum Venue {
|
|
@@ -101,6 +101,7 @@ type UserProfile = {
|
|
|
101
101
|
kycStatus: string;
|
|
102
102
|
}[] | null;
|
|
103
103
|
};
|
|
104
|
+
type PriceSource = "orderbook" | "cached" | "entry" | "settled";
|
|
104
105
|
type UnifiedBalanceResponse = {
|
|
105
106
|
cash: {
|
|
106
107
|
tokenSymbol: string;
|
|
@@ -125,6 +126,8 @@ type UnifiedBalanceResponse = {
|
|
|
125
126
|
type GetOrdersQuery = {
|
|
126
127
|
status?: OrderStatus | undefined;
|
|
127
128
|
orderId?: string | undefined;
|
|
129
|
+
/** Filter to all legs of one quote (multi-venue split routes). */
|
|
130
|
+
quoteId?: string | undefined;
|
|
128
131
|
cursor?: string | undefined;
|
|
129
132
|
limit?: number | undefined;
|
|
130
133
|
};
|
|
@@ -136,6 +139,12 @@ type GetPositionsQuery = {
|
|
|
136
139
|
type OrderListItem = {
|
|
137
140
|
status: string;
|
|
138
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;
|
|
139
148
|
createdAt: Date;
|
|
140
149
|
updatedAt: Date;
|
|
141
150
|
venue: Venue;
|
|
@@ -144,8 +153,28 @@ type OrderListItem = {
|
|
|
144
153
|
slippageBps: number | null;
|
|
145
154
|
quotedPriceRaw: string | null;
|
|
146
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;
|
|
147
164
|
filledAmountRaw: string | null;
|
|
148
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;
|
|
149
178
|
txHash: string | null;
|
|
150
179
|
errorMessage: string | null;
|
|
151
180
|
dagRunId: string | null;
|
|
@@ -175,13 +204,14 @@ type PositionGroup = {
|
|
|
175
204
|
venue: Venue;
|
|
176
205
|
size: number;
|
|
177
206
|
venueMarketId: string;
|
|
178
|
-
venueMarketOutcomeId
|
|
207
|
+
venueMarketOutcomeId: string;
|
|
179
208
|
}[];
|
|
180
209
|
totalSize: number;
|
|
181
210
|
avgEntryPrice: number;
|
|
182
211
|
currentPrice: number;
|
|
183
212
|
totalValue: number;
|
|
184
213
|
unrealizedPnlPercent: number;
|
|
214
|
+
priceSource: PriceSource;
|
|
185
215
|
}[];
|
|
186
216
|
};
|
|
187
217
|
targetMarketId: string;
|
|
@@ -202,6 +232,14 @@ type VenueMarket = {
|
|
|
202
232
|
title?: string | null | undefined;
|
|
203
233
|
externalIdentifier?: string | null | undefined;
|
|
204
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
|
+
}[];
|
|
205
243
|
}[];
|
|
206
244
|
externalIdentifier: string;
|
|
207
245
|
status?: MarketStatus | undefined;
|
|
@@ -274,6 +312,13 @@ type VenueEvent = {
|
|
|
274
312
|
venues?: Venue[];
|
|
275
313
|
venueCount?: number | undefined;
|
|
276
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;
|
|
277
322
|
};
|
|
278
323
|
type Orderbook = {
|
|
279
324
|
bids: {
|
|
@@ -286,6 +331,14 @@ type Orderbook = {
|
|
|
286
331
|
}[];
|
|
287
332
|
negRisk?: boolean | undefined;
|
|
288
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
|
+
};
|
|
289
342
|
type VenueMarketOutcome = {
|
|
290
343
|
id: string;
|
|
291
344
|
price: number;
|
|
@@ -294,6 +347,9 @@ type VenueMarketOutcome = {
|
|
|
294
347
|
title?: string | null | undefined;
|
|
295
348
|
externalIdentifier?: string | null | undefined;
|
|
296
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[];
|
|
297
353
|
};
|
|
298
354
|
type VenueEventWithMarkets = VenueEvent & {
|
|
299
355
|
venueMarkets: VenueMarket[];
|
|
@@ -506,6 +562,12 @@ interface AggUiLabels {
|
|
|
506
562
|
max: string;
|
|
507
563
|
tokenLabel: string;
|
|
508
564
|
networkLabel: string;
|
|
565
|
+
estimatedFees: string;
|
|
566
|
+
networkReserve: string;
|
|
567
|
+
networkReserveTooltipAria: string;
|
|
568
|
+
networkReserveTooltipLineOne: string;
|
|
569
|
+
networkReserveTooltipLineTwo: string;
|
|
570
|
+
youReceive: string;
|
|
509
571
|
confirm: string;
|
|
510
572
|
successTitle: string;
|
|
511
573
|
successDescription: (tokenSymbol: string) => string;
|
|
@@ -515,7 +577,11 @@ interface AggUiLabels {
|
|
|
515
577
|
successDescriptionPartial: (tokenSymbol: string) => string;
|
|
516
578
|
successTitleFailed: string;
|
|
517
579
|
successDescriptionFailed: (tokenSymbol: string) => string;
|
|
580
|
+
retry: string;
|
|
581
|
+
close: string;
|
|
582
|
+
loadingDescription: string;
|
|
518
583
|
summary: {
|
|
584
|
+
requestedWithdrawal: string;
|
|
519
585
|
amountReceived: string;
|
|
520
586
|
network: string;
|
|
521
587
|
toWallet: string;
|
|
@@ -533,6 +599,12 @@ interface AggUiLabels {
|
|
|
533
599
|
completed: string;
|
|
534
600
|
partial: string;
|
|
535
601
|
failed: string;
|
|
602
|
+
loadingSteps: {
|
|
603
|
+
preparing: string;
|
|
604
|
+
bridging: string;
|
|
605
|
+
sending: string;
|
|
606
|
+
confirming: string;
|
|
607
|
+
};
|
|
536
608
|
/**
|
|
537
609
|
* Per-leg step labels rendered in the success step's execution
|
|
538
610
|
* timeline. `bridge` covers cross-chain hops, `transfer` covers
|
|
@@ -590,20 +662,69 @@ interface AggUiLabels {
|
|
|
590
662
|
externalWallet: string;
|
|
591
663
|
card: string;
|
|
592
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
|
+
};
|
|
593
699
|
withdrawalTitle: (tokenSymbol: string) => string;
|
|
594
700
|
};
|
|
595
701
|
positions: {
|
|
702
|
+
activeFilter: string;
|
|
703
|
+
closedFilter: string;
|
|
704
|
+
marketHeader: string;
|
|
596
705
|
totalTradedHeader: string;
|
|
706
|
+
currentValueHeader: string;
|
|
707
|
+
statusHeader: string;
|
|
708
|
+
resolutionHeader: string;
|
|
709
|
+
payoutHeader: string;
|
|
710
|
+
resultHeader: string;
|
|
597
711
|
amountWonHeader: string;
|
|
598
712
|
claimHeader: string;
|
|
599
713
|
claim: string;
|
|
600
714
|
claimed: string;
|
|
601
715
|
pending: string;
|
|
716
|
+
open: string;
|
|
602
717
|
won: string;
|
|
603
718
|
lost: string;
|
|
719
|
+
sold: string;
|
|
604
720
|
resolved: string;
|
|
605
721
|
marketClosed: string;
|
|
606
722
|
closed: string;
|
|
723
|
+
searchPlaceholder: string;
|
|
724
|
+
noResults: string;
|
|
725
|
+
avgPrefix: string;
|
|
726
|
+
nowPrefix: string;
|
|
727
|
+
finalPrefix: string;
|
|
607
728
|
};
|
|
608
729
|
};
|
|
609
730
|
eventList: {
|
|
@@ -789,6 +910,7 @@ interface AggUiLabels {
|
|
|
789
910
|
noMarketSelected: string;
|
|
790
911
|
noOrderbooks: string;
|
|
791
912
|
quoteUnavailable: string;
|
|
913
|
+
quoteBalanceMismatch: string;
|
|
792
914
|
selectedVenueUnavailable: string;
|
|
793
915
|
engineUnavailable: string;
|
|
794
916
|
insufficientInputAmount: string;
|
|
@@ -815,10 +937,18 @@ interface AggUiLabels {
|
|
|
815
937
|
splitOrderDescription: string;
|
|
816
938
|
viewAllRoutes: (count: number) => string;
|
|
817
939
|
venueUnavailableInRegion: string;
|
|
940
|
+
platformFee: string;
|
|
941
|
+
estimatedFees: string;
|
|
942
|
+
estimatedFeesTooltipAria: string;
|
|
943
|
+
feeBreakdownVenueFees: string;
|
|
944
|
+
feeBreakdownBridgeFees: string;
|
|
945
|
+
feeBreakdownExecutionGas: string;
|
|
946
|
+
feeBreakdownTotalFees: string;
|
|
818
947
|
toWin: (tab: "buy" | "sell") => string;
|
|
819
948
|
buyingOutcome: (label: string) => string;
|
|
820
949
|
sellingOutcome: (label: string) => string;
|
|
821
950
|
findingBestRoute: string;
|
|
951
|
+
checkingBalance: string;
|
|
822
952
|
submittingOrderProgress: string;
|
|
823
953
|
orderSubmittedProgress: (orderId: string) => string;
|
|
824
954
|
executingOnVenue: (venueLabel: string) => string;
|
|
@@ -1013,6 +1143,8 @@ interface AggUiFeatureFlagsConfig {
|
|
|
1013
1143
|
enableAnimations: boolean;
|
|
1014
1144
|
/** Enable live updates */
|
|
1015
1145
|
enableLiveUpdates: boolean;
|
|
1146
|
+
/** Enable fee UI in trading flows */
|
|
1147
|
+
showFeesBreakdown: boolean;
|
|
1016
1148
|
/** Enable gradients */
|
|
1017
1149
|
enableGradients: boolean;
|
|
1018
1150
|
}
|
|
@@ -1067,6 +1199,12 @@ interface AggUiConfig {
|
|
|
1067
1199
|
enableLogs: boolean;
|
|
1068
1200
|
/** Enable AGG websocket pipeline logs */
|
|
1069
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;
|
|
1070
1208
|
/** General UI settings */
|
|
1071
1209
|
general: AggUiGeneralConfig;
|
|
1072
1210
|
/** UI feature flags */
|
|
@@ -1098,6 +1236,8 @@ interface AggUiConfigInput {
|
|
|
1098
1236
|
enableLogs?: boolean;
|
|
1099
1237
|
/** Enable AGG websocket pipeline logs */
|
|
1100
1238
|
enableWebsocketsLogs?: boolean;
|
|
1239
|
+
/** Enable developer-only debug instrumentation (Place Order debug, etc.). */
|
|
1240
|
+
enableDebug?: boolean;
|
|
1101
1241
|
/** General UI overrides */
|
|
1102
1242
|
general?: AggUiGeneralConfigInput;
|
|
1103
1243
|
/** Feature flag overrides */
|
|
@@ -1300,10 +1440,27 @@ declare const resolveOrderEligibility: (params: {
|
|
|
1300
1440
|
}) => OrderEligibility;
|
|
1301
1441
|
declare function resolveDefaultMarket(event: VenueEventWithMarkets | null): VenueMarket | null;
|
|
1302
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];
|
|
1303
1455
|
interface TradingState {
|
|
1304
1456
|
event: VenueEventWithMarkets | null;
|
|
1305
1457
|
market: VenueMarket | null;
|
|
1306
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;
|
|
1307
1464
|
}
|
|
1308
1465
|
type TradingAction = {
|
|
1309
1466
|
type: "INITIALIZE_EVENT";
|
|
@@ -1322,6 +1479,9 @@ type TradingAction = {
|
|
|
1322
1479
|
type: "SELECT_MARKET_AND_OUTCOME";
|
|
1323
1480
|
marketId: string;
|
|
1324
1481
|
outcomeId: string;
|
|
1482
|
+
} | {
|
|
1483
|
+
type: "SET_TRADE_SIDE";
|
|
1484
|
+
tradeSide: TradeSide;
|
|
1325
1485
|
};
|
|
1326
1486
|
declare function tradingReducer(state: TradingState, action: TradingAction): TradingState;
|
|
1327
1487
|
interface EventTradingContextValue {
|
|
@@ -1332,6 +1492,14 @@ interface EventTradingContextValue {
|
|
|
1332
1492
|
selectedMarketId: string | null;
|
|
1333
1493
|
selectedOutcomeId: string | null;
|
|
1334
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;
|
|
1335
1503
|
initializeFromEvent: (event: VenueEventWithMarkets | null) => void;
|
|
1336
1504
|
syncEvent: (event: VenueEventWithMarkets) => void;
|
|
1337
1505
|
selectMarket: (marketId: string, market?: VenueMarket) => void;
|
|
@@ -1355,6 +1523,49 @@ declare const invalidateBalanceQueries: (queryClient: QueryClient, options?: Inv
|
|
|
1355
1523
|
* holdings, so positions need to be refetched alongside balances.
|
|
1356
1524
|
*/
|
|
1357
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;
|
|
1358
1569
|
|
|
1359
1570
|
declare function useRampQuotes(): _tanstack_react_query.UseMutationResult<RampQuote[], Error, RampQuoteRequest, unknown>;
|
|
1360
1571
|
|
|
@@ -1597,6 +1808,19 @@ interface ExecutionTerminalOrderEvent {
|
|
|
1597
1808
|
event: "filled" | "partial_fill" | "failed";
|
|
1598
1809
|
filledAmountRaw?: string;
|
|
1599
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;
|
|
1600
1824
|
errorReason?: string;
|
|
1601
1825
|
timestamp: number;
|
|
1602
1826
|
}
|
|
@@ -1622,6 +1846,10 @@ interface ClosedPositionTotals {
|
|
|
1622
1846
|
}
|
|
1623
1847
|
declare const computeClosedPositionTotals: (group: PositionGroup) => ClosedPositionTotals;
|
|
1624
1848
|
|
|
1849
|
+
declare class RedeemRejectedError extends Error {
|
|
1850
|
+
readonly response: RedeemResponse;
|
|
1851
|
+
constructor(message: string, response: RedeemResponse);
|
|
1852
|
+
}
|
|
1625
1853
|
declare const useRedeem: () => _tanstack_react_query.UseMutationResult<RedeemResponse, Error, RedeemRequest, unknown>;
|
|
1626
1854
|
|
|
1627
1855
|
type RedeemEvent = WsRedeemEvent;
|
|
@@ -1629,6 +1857,96 @@ declare const useOnRedeemEvent: (listener: ((event: RedeemEvent) => void) | null
|
|
|
1629
1857
|
|
|
1630
1858
|
declare const useRedeemEligibleCount: () => number;
|
|
1631
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
|
+
|
|
1632
1950
|
declare function useAggWebSocket(): AggWebSocket | null;
|
|
1633
1951
|
declare function useOnOrderSubmitted(callback: ((msg: WsOrderSubmitted) => void) | null): void;
|
|
1634
1952
|
declare function useOnBalanceUpdate(callback: ((msg: WsBalanceUpdate) => void) | null): void;
|
|
@@ -1641,7 +1959,7 @@ interface MarketChartCandle {
|
|
|
1641
1959
|
low: number;
|
|
1642
1960
|
close: number;
|
|
1643
1961
|
volume: number | null;
|
|
1644
|
-
source: "rest" | "ws" | "trade";
|
|
1962
|
+
source: "rest" | "ws" | "trade" | "midpoint";
|
|
1645
1963
|
}
|
|
1646
1964
|
interface MarketChartVenueData {
|
|
1647
1965
|
venue: string;
|
|
@@ -1651,6 +1969,13 @@ interface MarketChartVenueData {
|
|
|
1651
1969
|
liveCandle: MarketChartCandle | null;
|
|
1652
1970
|
lineValue: number | undefined;
|
|
1653
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;
|
|
1654
1979
|
}
|
|
1655
1980
|
interface MarketChartData {
|
|
1656
1981
|
marketId: string;
|
|
@@ -1663,6 +1988,11 @@ interface MarketChartData {
|
|
|
1663
1988
|
endTs: number | null;
|
|
1664
1989
|
/** Per-venue chart state. The primary venue contains the canonical REST history. */
|
|
1665
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;
|
|
1666
1996
|
}
|
|
1667
1997
|
|
|
1668
1998
|
type MarketOrderbookIntegrity = "ok" | "resyncing";
|
|
@@ -2183,11 +2513,20 @@ declare function useExecutionOrders(options?: UseExecutionOrdersOptions): {
|
|
|
2183
2513
|
|
|
2184
2514
|
interface UseUserActivityOptions extends Omit<UserActivityQuery, "cursor"> {
|
|
2185
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;
|
|
2186
2525
|
}
|
|
2187
2526
|
declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
2188
2527
|
activities: UserActivityItem[];
|
|
2189
2528
|
hasNextPage: boolean;
|
|
2190
|
-
data: _tanstack_react_query.InfiniteData<
|
|
2529
|
+
data: _tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>;
|
|
2191
2530
|
error: Error;
|
|
2192
2531
|
isError: true;
|
|
2193
2532
|
isPending: false;
|
|
@@ -2197,8 +2536,8 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2197
2536
|
isSuccess: false;
|
|
2198
2537
|
isPlaceholderData: false;
|
|
2199
2538
|
status: "error";
|
|
2200
|
-
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2201
|
-
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>>;
|
|
2202
2541
|
hasPreviousPage: boolean;
|
|
2203
2542
|
isFetchNextPageError: boolean;
|
|
2204
2543
|
isFetchingNextPage: boolean;
|
|
@@ -2217,13 +2556,13 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2217
2556
|
isRefetching: boolean;
|
|
2218
2557
|
isStale: boolean;
|
|
2219
2558
|
isEnabled: boolean;
|
|
2220
|
-
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>>;
|
|
2221
2560
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
2222
|
-
promise: Promise<_tanstack_react_query.InfiniteData<
|
|
2561
|
+
promise: Promise<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>>;
|
|
2223
2562
|
} | {
|
|
2224
2563
|
activities: UserActivityItem[];
|
|
2225
2564
|
hasNextPage: boolean;
|
|
2226
|
-
data: _tanstack_react_query.InfiniteData<
|
|
2565
|
+
data: _tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>;
|
|
2227
2566
|
error: null;
|
|
2228
2567
|
isError: false;
|
|
2229
2568
|
isPending: false;
|
|
@@ -2235,8 +2574,8 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2235
2574
|
isSuccess: true;
|
|
2236
2575
|
isPlaceholderData: false;
|
|
2237
2576
|
status: "success";
|
|
2238
|
-
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2239
|
-
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>>;
|
|
2240
2579
|
hasPreviousPage: boolean;
|
|
2241
2580
|
isFetchingNextPage: boolean;
|
|
2242
2581
|
isFetchingPreviousPage: boolean;
|
|
@@ -2253,9 +2592,9 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2253
2592
|
isRefetching: boolean;
|
|
2254
2593
|
isStale: boolean;
|
|
2255
2594
|
isEnabled: boolean;
|
|
2256
|
-
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>>;
|
|
2257
2596
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
2258
|
-
promise: Promise<_tanstack_react_query.InfiniteData<
|
|
2597
|
+
promise: Promise<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>>;
|
|
2259
2598
|
} | {
|
|
2260
2599
|
activities: UserActivityItem[];
|
|
2261
2600
|
hasNextPage: boolean;
|
|
@@ -2271,8 +2610,8 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2271
2610
|
isSuccess: false;
|
|
2272
2611
|
isPlaceholderData: false;
|
|
2273
2612
|
status: "error";
|
|
2274
|
-
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2275
|
-
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>>;
|
|
2276
2615
|
hasPreviousPage: boolean;
|
|
2277
2616
|
isFetchingNextPage: boolean;
|
|
2278
2617
|
isFetchingPreviousPage: boolean;
|
|
@@ -2289,9 +2628,9 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2289
2628
|
isRefetching: boolean;
|
|
2290
2629
|
isStale: boolean;
|
|
2291
2630
|
isEnabled: boolean;
|
|
2292
|
-
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>>;
|
|
2293
2632
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
2294
|
-
promise: Promise<_tanstack_react_query.InfiniteData<
|
|
2633
|
+
promise: Promise<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>>;
|
|
2295
2634
|
} | {
|
|
2296
2635
|
activities: UserActivityItem[];
|
|
2297
2636
|
hasNextPage: boolean;
|
|
@@ -2307,8 +2646,8 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2307
2646
|
isSuccess: false;
|
|
2308
2647
|
isPlaceholderData: false;
|
|
2309
2648
|
status: "pending";
|
|
2310
|
-
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2311
|
-
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>>;
|
|
2312
2651
|
hasPreviousPage: boolean;
|
|
2313
2652
|
isFetchingNextPage: boolean;
|
|
2314
2653
|
isFetchingPreviousPage: boolean;
|
|
@@ -2325,9 +2664,9 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2325
2664
|
isRefetching: boolean;
|
|
2326
2665
|
isStale: boolean;
|
|
2327
2666
|
isEnabled: boolean;
|
|
2328
|
-
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>>;
|
|
2329
2668
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
2330
|
-
promise: Promise<_tanstack_react_query.InfiniteData<
|
|
2669
|
+
promise: Promise<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>>;
|
|
2331
2670
|
} | {
|
|
2332
2671
|
activities: UserActivityItem[];
|
|
2333
2672
|
hasNextPage: boolean;
|
|
@@ -2342,8 +2681,8 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2342
2681
|
isSuccess: false;
|
|
2343
2682
|
isPlaceholderData: false;
|
|
2344
2683
|
status: "pending";
|
|
2345
|
-
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2346
|
-
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>>;
|
|
2347
2686
|
hasPreviousPage: boolean;
|
|
2348
2687
|
isFetchingNextPage: boolean;
|
|
2349
2688
|
isFetchingPreviousPage: boolean;
|
|
@@ -2361,13 +2700,13 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2361
2700
|
isRefetching: boolean;
|
|
2362
2701
|
isStale: boolean;
|
|
2363
2702
|
isEnabled: boolean;
|
|
2364
|
-
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>>;
|
|
2365
2704
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
2366
|
-
promise: Promise<_tanstack_react_query.InfiniteData<
|
|
2705
|
+
promise: Promise<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>>;
|
|
2367
2706
|
} | {
|
|
2368
2707
|
activities: UserActivityItem[];
|
|
2369
2708
|
hasNextPage: boolean;
|
|
2370
|
-
data: _tanstack_react_query.InfiniteData<
|
|
2709
|
+
data: _tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>;
|
|
2371
2710
|
isError: false;
|
|
2372
2711
|
error: null;
|
|
2373
2712
|
isPending: false;
|
|
@@ -2379,8 +2718,8 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2379
2718
|
isFetchNextPageError: false;
|
|
2380
2719
|
isFetchPreviousPageError: false;
|
|
2381
2720
|
status: "success";
|
|
2382
|
-
fetchNextPage: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<_tanstack_react_query.InfiniteData<
|
|
2383
|
-
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>>;
|
|
2384
2723
|
hasPreviousPage: boolean;
|
|
2385
2724
|
isFetchingNextPage: boolean;
|
|
2386
2725
|
isFetchingPreviousPage: boolean;
|
|
@@ -2397,9 +2736,9 @@ declare function useUserActivity(options?: UseUserActivityOptions): {
|
|
|
2397
2736
|
isRefetching: boolean;
|
|
2398
2737
|
isStale: boolean;
|
|
2399
2738
|
isEnabled: boolean;
|
|
2400
|
-
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>>;
|
|
2401
2740
|
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
2402
|
-
promise: Promise<_tanstack_react_query.InfiniteData<
|
|
2741
|
+
promise: Promise<_tanstack_react_query.InfiniteData<PaginatedResponse<UserActivityItem>, unknown>>;
|
|
2403
2742
|
};
|
|
2404
2743
|
|
|
2405
2744
|
interface UseExternalIdOptions {
|
|
@@ -2754,6 +3093,38 @@ declare function useLiveOutcomePrices(venueMarkets: VenueMarket[] | null | undef
|
|
|
2754
3093
|
*/
|
|
2755
3094
|
declare function findLivePriceById(livePrices: Map<string, number>, id: string): number | undefined;
|
|
2756
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
|
+
|
|
2757
3128
|
/**
|
|
2758
3129
|
* Subscribe to real-time trade feed for a canonical market.
|
|
2759
3130
|
* Manages a separate trade subscription on the WS (trades use a different channel).
|
|
@@ -2764,27 +3135,100 @@ declare function useLiveTrades(canonicalMarketId: string | null): WsTrade[];
|
|
|
2764
3135
|
interface UseMidpointsResult {
|
|
2765
3136
|
/** Map of outcomeId → price. Empty while loading. */
|
|
2766
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>;
|
|
2767
3144
|
/**
|
|
2768
3145
|
* Map of outcomeId → venue name that provided the price in `prices`.
|
|
2769
|
-
* When a matched
|
|
2770
|
-
*
|
|
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.
|
|
2771
3149
|
* Empty while loading or when the API response omits `venue` fields.
|
|
2772
3150
|
*/
|
|
2773
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
|
+
}>;
|
|
2774
3171
|
/** True while the midpoints fetch is in flight. */
|
|
2775
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;
|
|
2776
3182
|
}
|
|
2777
3183
|
/**
|
|
2778
3184
|
* Fetches live midpoints for the given venue markets.
|
|
2779
3185
|
*
|
|
2780
3186
|
* Returns { prices, isLoading } so callers can show a skeleton while loading.
|
|
2781
3187
|
*
|
|
2782
|
-
*
|
|
2783
|
-
*
|
|
2784
|
-
*
|
|
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.
|
|
2785
3194
|
*/
|
|
2786
3195
|
declare function useMidpoints(venueMarkets: VenueMarket[] | null | undefined): UseMidpointsResult;
|
|
2787
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
|
+
|
|
2788
3232
|
interface UseMarketChartOptions {
|
|
2789
3233
|
/** VenueMarketOutcome.id */
|
|
2790
3234
|
marketId: string | null;
|
|
@@ -2797,6 +3241,25 @@ interface UseMarketChartOptions {
|
|
|
2797
3241
|
enabled?: boolean;
|
|
2798
3242
|
/** Enable live WS updates. Defaults to the global `enableLiveUpdates` config. */
|
|
2799
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;
|
|
2800
3263
|
}
|
|
2801
3264
|
interface UseMarketChartResult {
|
|
2802
3265
|
data: MarketChartData | null;
|
|
@@ -2807,6 +3270,93 @@ interface UseMarketChartResult {
|
|
|
2807
3270
|
}
|
|
2808
3271
|
declare function useMarketChart(options: UseMarketChartOptions): UseMarketChartResult;
|
|
2809
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
|
+
|
|
2810
3360
|
interface UseMarketOrderbookVenueOutcome {
|
|
2811
3361
|
venue: VenueMarket["venue"];
|
|
2812
3362
|
venueMarketOutcomeId: string;
|
|
@@ -3066,6 +3616,15 @@ interface UseSearchOptions {
|
|
|
3066
3616
|
limit?: number;
|
|
3067
3617
|
/** If provided, enable/disable the query. Defaults to true. */
|
|
3068
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;
|
|
3069
3628
|
}
|
|
3070
3629
|
/**
|
|
3071
3630
|
* Search events or markets via the /search endpoint with cursor-based pagination.
|
|
@@ -3075,6 +3634,9 @@ interface UseSearchOptions {
|
|
|
3075
3634
|
* ```ts
|
|
3076
3635
|
* const { data } = useSearch<VenueEventWithMarkets>({ q: "...", type: "events" });
|
|
3077
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.
|
|
3078
3640
|
*/
|
|
3079
3641
|
declare function useSearch<T = VenueEvent>(options: UseSearchOptions): {
|
|
3080
3642
|
data: T[];
|
|
@@ -3092,6 +3654,100 @@ declare function useSearch<T = VenueEvent>(options: UseSearchOptions): {
|
|
|
3092
3654
|
isPlaceholderData: boolean;
|
|
3093
3655
|
};
|
|
3094
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
|
+
|
|
3095
3751
|
interface UseSmartRouteOptions {
|
|
3096
3752
|
/** Venue market outcome ID used by the smart-route endpoint. */
|
|
3097
3753
|
venueMarketOutcomeId?: string | null;
|
|
@@ -3113,8 +3769,18 @@ interface UseSmartRouteOptions {
|
|
|
3113
3769
|
slipCapBps?: number;
|
|
3114
3770
|
/** Include venue-by-venue comparison quotes. */
|
|
3115
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;
|
|
3116
3780
|
/** Enable/disable the query. Default true. */
|
|
3117
3781
|
enabled?: boolean;
|
|
3782
|
+
/** Cache freshness and polling interval in milliseconds. Defaults to SMART_ROUTE_STALE_TIME_MS. */
|
|
3783
|
+
staleTimeMs?: number;
|
|
3118
3784
|
}
|
|
3119
3785
|
interface UseSmartRouteResult {
|
|
3120
3786
|
data: SmartRouteResponse | null;
|
|
@@ -4469,15 +5135,18 @@ declare function computePriceGaps(input: ComputePriceGapsInput): Map<string, num
|
|
|
4469
5135
|
* • Markets that become visible for the first time are batched into a
|
|
4470
5136
|
* single request on the next render.
|
|
4471
5137
|
*
|
|
4472
|
-
*
|
|
4473
|
-
*
|
|
4474
|
-
*
|
|
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.
|
|
4475
5143
|
*/
|
|
4476
5144
|
declare function useViewportMidpoints(visibleMarkets: VenueMarket[]): {
|
|
4477
5145
|
prices: Map<string, number>;
|
|
4478
5146
|
/**
|
|
4479
5147
|
* Map of outcomeId → venue name that provided the price in `prices`.
|
|
4480
|
-
* Populated when a matched
|
|
5148
|
+
* Populated when a matched sibling offers a lower midpoint for the same
|
|
5149
|
+
* semantic side.
|
|
4481
5150
|
*/
|
|
4482
5151
|
venueByOutcomeId: Map<string, string>;
|
|
4483
5152
|
};
|
|
@@ -4510,6 +5179,7 @@ interface UseAppConfigResult {
|
|
|
4510
5179
|
disabledVenues: AppClientConfigResponse["disabledVenues"];
|
|
4511
5180
|
disabledCategoryPresets: AppClientConfigResponse["disabledCategoryPresets"];
|
|
4512
5181
|
earlyAccessEnabled: AppClientConfigResponse["earlyAccessEnabled"];
|
|
5182
|
+
authOptions: AppClientConfigResponse["authOptions"];
|
|
4513
5183
|
isLoading: boolean;
|
|
4514
5184
|
error: unknown;
|
|
4515
5185
|
}
|
|
@@ -4519,4 +5189,4 @@ interface UseAppConfigResult {
|
|
|
4519
5189
|
*/
|
|
4520
5190
|
declare function useAppConfig(): UseAppConfigResult;
|
|
4521
5191
|
|
|
4522
|
-
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 };
|