@agg-build/ui 2.1.1 → 2.1.2
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-TERG43WW.mjs → chunk-5RBHMMY3.mjs} +1 -1
- package/dist/{chunk-RPXRTXCY.mjs → chunk-75AMJAWR.mjs} +1 -1
- package/dist/{chunk-IQT4I5B4.mjs → chunk-7ZR5JYB3.mjs} +39 -241
- package/dist/{chunk-NK57KMYN.mjs → chunk-JJDYOBVG.mjs} +117 -48
- package/dist/{chunk-WU2C3C6K.mjs → chunk-NRNBJPYK.mjs} +1 -1
- package/dist/{chunk-YJO6LMRT.mjs → chunk-TBD3N4T4.mjs} +69 -7
- package/dist/{chunk-XHDGSRG7.mjs → chunk-ZOECARZW.mjs} +359 -14
- package/dist/events.js +175 -59
- package/dist/events.mjs +3 -3
- package/dist/index.js +1080 -820
- package/dist/index.mjs +12 -8
- package/dist/modals.js +1 -1
- package/dist/modals.mjs +3 -3
- package/dist/pages.js +845 -589
- package/dist/pages.mjs +6 -6
- package/dist/primitives.js +68 -7
- package/dist/primitives.mjs +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/trading.js +679 -339
- package/dist/trading.mjs +10 -6
- package/dist/types/events/shared/format-event-title.d.mts +25 -0
- package/dist/types/events/shared/format-event-title.d.ts +25 -0
- package/dist/types/events/shared/select-best-outcome.d.mts +88 -0
- package/dist/types/events/shared/select-best-outcome.d.ts +88 -0
- package/dist/types/pages/event-market/event-market.types.d.mts +7 -0
- package/dist/types/pages/event-market/event-market.types.d.ts +7 -0
- package/dist/types/primitives/search/search.utils.d.mts +3 -1
- package/dist/types/primitives/search/search.utils.d.ts +3 -1
- package/dist/types/trading/index.d.mts +2 -0
- package/dist/types/trading/index.d.ts +2 -0
- package/dist/types/trading/place-order/index.d.mts +1 -1
- package/dist/types/trading/place-order/index.d.ts +1 -1
- package/dist/types/trading/place-order/index.place-order.types.d.mts +23 -1
- package/dist/types/trading/place-order/index.place-order.types.d.ts +23 -1
- package/dist/types/trading/use-claim-winnings.d.mts +84 -0
- package/dist/types/trading/use-claim-winnings.d.ts +84 -0
- package/dist/types/trading/use-resolved-market-claim.d.mts +26 -0
- package/dist/types/trading/use-resolved-market-claim.d.ts +26 -0
- package/package.json +3 -3
package/dist/trading.mjs
CHANGED
|
@@ -5,8 +5,10 @@ import {
|
|
|
5
5
|
PlaceOrderSuccessView,
|
|
6
6
|
SettlementDetails,
|
|
7
7
|
parseAmount,
|
|
8
|
-
parseVenue
|
|
9
|
-
|
|
8
|
+
parseVenue,
|
|
9
|
+
useClaimWinnings,
|
|
10
|
+
useResolvedMarketClaim
|
|
11
|
+
} from "./chunk-ZOECARZW.mjs";
|
|
10
12
|
import {
|
|
11
13
|
SETTLEMENT_SECTION_ID,
|
|
12
14
|
Settlement,
|
|
@@ -21,9 +23,9 @@ import {
|
|
|
21
23
|
getTradingValueLabel,
|
|
22
24
|
getTradingVenueLabel,
|
|
23
25
|
useEventTradingContext
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
26
|
+
} from "./chunk-5RBHMMY3.mjs";
|
|
27
|
+
import "./chunk-75AMJAWR.mjs";
|
|
28
|
+
import "./chunk-TBD3N4T4.mjs";
|
|
27
29
|
export {
|
|
28
30
|
PlaceOrder,
|
|
29
31
|
PlaceOrderFailureView,
|
|
@@ -43,5 +45,7 @@ export {
|
|
|
43
45
|
getTradingVenueLabel,
|
|
44
46
|
parseAmount,
|
|
45
47
|
parseVenue,
|
|
46
|
-
|
|
48
|
+
useClaimWinnings,
|
|
49
|
+
useEventTradingContext,
|
|
50
|
+
useResolvedMarketClaim
|
|
47
51
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type EventCategoryLike = {
|
|
2
|
+
id?: string | null;
|
|
3
|
+
category?: {
|
|
4
|
+
id?: string | null;
|
|
5
|
+
name?: string | null;
|
|
6
|
+
displayName?: string | null;
|
|
7
|
+
parentId?: string | null;
|
|
8
|
+
} | null;
|
|
9
|
+
};
|
|
10
|
+
type FormatEventTitleWithDateSuffixParams = {
|
|
11
|
+
title: string;
|
|
12
|
+
categories?: readonly EventCategoryLike[] | null;
|
|
13
|
+
structureType?: string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Scheduled kickoff of the underlying game. Preferred over `endDate` for
|
|
16
|
+
* the date suffix because `endDate` is the market close/expiration, which
|
|
17
|
+
* can sit well after the game (e.g. Kalshi World Cup markets expire weeks
|
|
18
|
+
* later — a June 22 game would otherwise read "- July 6").
|
|
19
|
+
*/
|
|
20
|
+
gameStartTime?: string | null;
|
|
21
|
+
endDate?: string | null;
|
|
22
|
+
locale?: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const formatEventTitleWithDateSuffix: ({ title, categories, structureType, gameStartTime, endDate, locale, }: FormatEventTitleWithDateSuffixParams) => string;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type EventCategoryLike = {
|
|
2
|
+
id?: string | null;
|
|
3
|
+
category?: {
|
|
4
|
+
id?: string | null;
|
|
5
|
+
name?: string | null;
|
|
6
|
+
displayName?: string | null;
|
|
7
|
+
parentId?: string | null;
|
|
8
|
+
} | null;
|
|
9
|
+
};
|
|
10
|
+
type FormatEventTitleWithDateSuffixParams = {
|
|
11
|
+
title: string;
|
|
12
|
+
categories?: readonly EventCategoryLike[] | null;
|
|
13
|
+
structureType?: string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Scheduled kickoff of the underlying game. Preferred over `endDate` for
|
|
16
|
+
* the date suffix because `endDate` is the market close/expiration, which
|
|
17
|
+
* can sit well after the game (e.g. Kalshi World Cup markets expire weeks
|
|
18
|
+
* later — a June 22 game would otherwise read "- July 6").
|
|
19
|
+
*/
|
|
20
|
+
gameStartTime?: string | null;
|
|
21
|
+
endDate?: string | null;
|
|
22
|
+
locale?: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const formatEventTitleWithDateSuffix: ({ title, categories, structureType, gameStartTime, endDate, locale, }: FormatEventTitleWithDateSuffixParams) => string;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { LiveBestPriceCandidate } from "@agg-build/hooks";
|
|
2
|
+
/** Which data tier produced the winning price + venue. */
|
|
3
|
+
export type BestOutcomeSource = "ws" | "rest-best" | "rest-midpoint" | "static";
|
|
4
|
+
/**
|
|
5
|
+
* The single, unified result for an outcome pill: price and venue resolved
|
|
6
|
+
* together from the *same* tier, so the displayed price and the venue logo can
|
|
7
|
+
* never disagree. `venueMarketId`, `source` and `updatedAt` are carried for
|
|
8
|
+
* telemetry/debugging and to let callers reason about freshness.
|
|
9
|
+
*/
|
|
10
|
+
export interface BestOutcomeCandidate {
|
|
11
|
+
price: number;
|
|
12
|
+
venue: string | undefined;
|
|
13
|
+
venueMarketId: string | undefined;
|
|
14
|
+
outcomeId: string;
|
|
15
|
+
source: BestOutcomeSource;
|
|
16
|
+
updatedAt: number | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface SelectBestOutcomeArgs {
|
|
19
|
+
outcomeId: string | null | undefined;
|
|
20
|
+
outcomeLabel?: string | null | undefined;
|
|
21
|
+
/** Active trade side. When set, the best ask (buy) / best bid (sell) wins. */
|
|
22
|
+
selection?: "buy" | "sell" | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Live WS candidate for this outcome — already folded across all venues for
|
|
25
|
+
* the outcome's MVMO group (see `buildLiveBestPriceCandidates`). Carries the
|
|
26
|
+
* venue that owns each side, so when a different venue takes the best live
|
|
27
|
+
* price the logo follows the price.
|
|
28
|
+
*/
|
|
29
|
+
live?: LiveBestPriceCandidate | null | undefined;
|
|
30
|
+
/** REST cross-venue best bid/ask (fallback when WS hasn't landed). */
|
|
31
|
+
restBest?: {
|
|
32
|
+
bestBid?: number;
|
|
33
|
+
bestAsk?: number;
|
|
34
|
+
} | null | undefined;
|
|
35
|
+
/** REST venue that produced each side of `restBest`. */
|
|
36
|
+
restBestVenues?: {
|
|
37
|
+
bestBidVenue?: string;
|
|
38
|
+
bestAskVenue?: string;
|
|
39
|
+
} | null | undefined;
|
|
40
|
+
/** REST per-outcome midpoint (display-path fallback). */
|
|
41
|
+
restMidpoint?: number | null | undefined;
|
|
42
|
+
/** Venue that produced `restMidpoint`. */
|
|
43
|
+
restMidpointVenue?: string | null | undefined;
|
|
44
|
+
/** Cluster-wide "Yes" reference midpoint (display path, "yes" labels only). */
|
|
45
|
+
bestMidpoint?: number | null | undefined;
|
|
46
|
+
/** Venue that produced `bestMidpoint`. */
|
|
47
|
+
bestMidpointVenue?: string | null | undefined;
|
|
48
|
+
/** Final static fallback — the outcome's payload price. */
|
|
49
|
+
staticPrice?: number | null | undefined;
|
|
50
|
+
/** Venue for the static fallback (typically the local market's own venue). */
|
|
51
|
+
staticVenue?: string | null | undefined;
|
|
52
|
+
/** Resolves a venue name → its venueMarketId within the cluster (best effort). */
|
|
53
|
+
venueMarketIdByVenue?: ReadonlyMap<string, string> | null | undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the single best price + venue for an outcome across all venues.
|
|
57
|
+
*
|
|
58
|
+
* Candidate priority (price and venue are always taken from the SAME tier):
|
|
59
|
+
* With a trade selection (buy/sell):
|
|
60
|
+
* 1. fresh WS best ask/bid for that side → source "ws"
|
|
61
|
+
* 2. REST best ask/bid for that side → source "rest-best"
|
|
62
|
+
* 3. fresh WS midpoint → source "ws"
|
|
63
|
+
* 4. REST per-outcome midpoint → source "rest-midpoint"
|
|
64
|
+
* 5. static outcome price → source "static"
|
|
65
|
+
* Display path (no selection):
|
|
66
|
+
* 1. fresh WS midpoint → source "ws"
|
|
67
|
+
* 2. cluster "Yes" reference (yes labels) → source "rest-midpoint"
|
|
68
|
+
* 3. REST per-outcome midpoint → source "rest-midpoint"
|
|
69
|
+
* 4. static outcome price → source "static"
|
|
70
|
+
*
|
|
71
|
+
* Because WS is preferred per side over REST, a stale REST snapshot can never
|
|
72
|
+
* override newer live data — and because the venue is read from whichever tier
|
|
73
|
+
* supplied the price, the logo and the price switch together.
|
|
74
|
+
*/
|
|
75
|
+
export declare const selectBestOutcomeCandidate: (args: SelectBestOutcomeArgs) => BestOutcomeCandidate | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Build a venue-name → venueMarketId lookup across a cluster (including matched
|
|
78
|
+
* siblings). First occurrence wins. Used to resolve the winning venue's market
|
|
79
|
+
* id for {@link selectBestOutcomeCandidate}.
|
|
80
|
+
*/
|
|
81
|
+
export declare const buildVenueMarketIdByVenue: (venueMarkets: ReadonlyArray<{
|
|
82
|
+
id?: string;
|
|
83
|
+
venue?: string | null;
|
|
84
|
+
matchedVenueMarkets?: ReadonlyArray<{
|
|
85
|
+
id?: string;
|
|
86
|
+
venue?: string | null;
|
|
87
|
+
}> | null;
|
|
88
|
+
}> | null | undefined) => Map<string, string>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { LiveBestPriceCandidate } from "@agg-build/hooks";
|
|
2
|
+
/** Which data tier produced the winning price + venue. */
|
|
3
|
+
export type BestOutcomeSource = "ws" | "rest-best" | "rest-midpoint" | "static";
|
|
4
|
+
/**
|
|
5
|
+
* The single, unified result for an outcome pill: price and venue resolved
|
|
6
|
+
* together from the *same* tier, so the displayed price and the venue logo can
|
|
7
|
+
* never disagree. `venueMarketId`, `source` and `updatedAt` are carried for
|
|
8
|
+
* telemetry/debugging and to let callers reason about freshness.
|
|
9
|
+
*/
|
|
10
|
+
export interface BestOutcomeCandidate {
|
|
11
|
+
price: number;
|
|
12
|
+
venue: string | undefined;
|
|
13
|
+
venueMarketId: string | undefined;
|
|
14
|
+
outcomeId: string;
|
|
15
|
+
source: BestOutcomeSource;
|
|
16
|
+
updatedAt: number | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface SelectBestOutcomeArgs {
|
|
19
|
+
outcomeId: string | null | undefined;
|
|
20
|
+
outcomeLabel?: string | null | undefined;
|
|
21
|
+
/** Active trade side. When set, the best ask (buy) / best bid (sell) wins. */
|
|
22
|
+
selection?: "buy" | "sell" | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Live WS candidate for this outcome — already folded across all venues for
|
|
25
|
+
* the outcome's MVMO group (see `buildLiveBestPriceCandidates`). Carries the
|
|
26
|
+
* venue that owns each side, so when a different venue takes the best live
|
|
27
|
+
* price the logo follows the price.
|
|
28
|
+
*/
|
|
29
|
+
live?: LiveBestPriceCandidate | null | undefined;
|
|
30
|
+
/** REST cross-venue best bid/ask (fallback when WS hasn't landed). */
|
|
31
|
+
restBest?: {
|
|
32
|
+
bestBid?: number;
|
|
33
|
+
bestAsk?: number;
|
|
34
|
+
} | null | undefined;
|
|
35
|
+
/** REST venue that produced each side of `restBest`. */
|
|
36
|
+
restBestVenues?: {
|
|
37
|
+
bestBidVenue?: string;
|
|
38
|
+
bestAskVenue?: string;
|
|
39
|
+
} | null | undefined;
|
|
40
|
+
/** REST per-outcome midpoint (display-path fallback). */
|
|
41
|
+
restMidpoint?: number | null | undefined;
|
|
42
|
+
/** Venue that produced `restMidpoint`. */
|
|
43
|
+
restMidpointVenue?: string | null | undefined;
|
|
44
|
+
/** Cluster-wide "Yes" reference midpoint (display path, "yes" labels only). */
|
|
45
|
+
bestMidpoint?: number | null | undefined;
|
|
46
|
+
/** Venue that produced `bestMidpoint`. */
|
|
47
|
+
bestMidpointVenue?: string | null | undefined;
|
|
48
|
+
/** Final static fallback — the outcome's payload price. */
|
|
49
|
+
staticPrice?: number | null | undefined;
|
|
50
|
+
/** Venue for the static fallback (typically the local market's own venue). */
|
|
51
|
+
staticVenue?: string | null | undefined;
|
|
52
|
+
/** Resolves a venue name → its venueMarketId within the cluster (best effort). */
|
|
53
|
+
venueMarketIdByVenue?: ReadonlyMap<string, string> | null | undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the single best price + venue for an outcome across all venues.
|
|
57
|
+
*
|
|
58
|
+
* Candidate priority (price and venue are always taken from the SAME tier):
|
|
59
|
+
* With a trade selection (buy/sell):
|
|
60
|
+
* 1. fresh WS best ask/bid for that side → source "ws"
|
|
61
|
+
* 2. REST best ask/bid for that side → source "rest-best"
|
|
62
|
+
* 3. fresh WS midpoint → source "ws"
|
|
63
|
+
* 4. REST per-outcome midpoint → source "rest-midpoint"
|
|
64
|
+
* 5. static outcome price → source "static"
|
|
65
|
+
* Display path (no selection):
|
|
66
|
+
* 1. fresh WS midpoint → source "ws"
|
|
67
|
+
* 2. cluster "Yes" reference (yes labels) → source "rest-midpoint"
|
|
68
|
+
* 3. REST per-outcome midpoint → source "rest-midpoint"
|
|
69
|
+
* 4. static outcome price → source "static"
|
|
70
|
+
*
|
|
71
|
+
* Because WS is preferred per side over REST, a stale REST snapshot can never
|
|
72
|
+
* override newer live data — and because the venue is read from whichever tier
|
|
73
|
+
* supplied the price, the logo and the price switch together.
|
|
74
|
+
*/
|
|
75
|
+
export declare const selectBestOutcomeCandidate: (args: SelectBestOutcomeArgs) => BestOutcomeCandidate | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Build a venue-name → venueMarketId lookup across a cluster (including matched
|
|
78
|
+
* siblings). First occurrence wins. Used to resolve the winning venue's market
|
|
79
|
+
* id for {@link selectBestOutcomeCandidate}.
|
|
80
|
+
*/
|
|
81
|
+
export declare const buildVenueMarketIdByVenue: (venueMarkets: ReadonlyArray<{
|
|
82
|
+
id?: string;
|
|
83
|
+
venue?: string | null;
|
|
84
|
+
matchedVenueMarkets?: ReadonlyArray<{
|
|
85
|
+
id?: string;
|
|
86
|
+
venue?: string | null;
|
|
87
|
+
}> | null;
|
|
88
|
+
}> | null | undefined) => Map<string, string>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { VenueEventWithMarkets } from "../../events/item/event-list-item.types";
|
|
2
2
|
import type { PlaceOrderResolvedClaimSummary } from "../../trading";
|
|
3
|
+
import type { PlaceOrderProps } from "../../trading/place-order/index.place-order.types";
|
|
3
4
|
export type EventMarketPageClassNames = Partial<{
|
|
4
5
|
root: string;
|
|
5
6
|
content: string;
|
|
@@ -44,6 +45,12 @@ export type EventMarketPageBaseProps = {
|
|
|
44
45
|
defaultOutcomeId?: string;
|
|
45
46
|
/** Whether to render the place-order panel. */
|
|
46
47
|
showPlaceOrder?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Pre-flight gate run before the internal quote execution, forwarded to the
|
|
50
|
+
* place-order panel. When it resolves the order fills as usual; return
|
|
51
|
+
* `false` to cancel or throw to abort. See `PlaceOrderProps.onBeforePrimaryAction`.
|
|
52
|
+
*/
|
|
53
|
+
onBeforePrimaryAction?: PlaceOrderProps["onBeforePrimaryAction"];
|
|
47
54
|
executionMode?: "live" | "paper";
|
|
48
55
|
/** Optional resolved-event claim summary shown inside the read-only order panel. */
|
|
49
56
|
resolvedClaim?: PlaceOrderResolvedClaimSummary;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { VenueEventWithMarkets } from "../../events/item/event-list-item.types";
|
|
2
2
|
import type { PlaceOrderResolvedClaimSummary } from "../../trading";
|
|
3
|
+
import type { PlaceOrderProps } from "../../trading/place-order/index.place-order.types";
|
|
3
4
|
export type EventMarketPageClassNames = Partial<{
|
|
4
5
|
root: string;
|
|
5
6
|
content: string;
|
|
@@ -44,6 +45,12 @@ export type EventMarketPageBaseProps = {
|
|
|
44
45
|
defaultOutcomeId?: string;
|
|
45
46
|
/** Whether to render the place-order panel. */
|
|
46
47
|
showPlaceOrder?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Pre-flight gate run before the internal quote execution, forwarded to the
|
|
50
|
+
* place-order panel. When it resolves the order fills as usual; return
|
|
51
|
+
* `false` to cancel or throw to abort. See `PlaceOrderProps.onBeforePrimaryAction`.
|
|
52
|
+
*/
|
|
53
|
+
onBeforePrimaryAction?: PlaceOrderProps["onBeforePrimaryAction"];
|
|
47
54
|
executionMode?: "live" | "paper";
|
|
48
55
|
/** Optional resolved-event claim summary shown inside the read-only order panel. */
|
|
49
56
|
resolvedClaim?: PlaceOrderResolvedClaimSummary;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { AggUiLabels } from "@agg-build/hooks";
|
|
2
2
|
import type { VenueEventWithMarkets } from "../../events/item";
|
|
3
3
|
import type { SearchResultItem } from "./search.types";
|
|
4
|
-
export declare const mapVenueEventToSearchResult: (event: VenueEventWithMarkets, labels: AggUiLabels, formatPercent: (value: number) => string, formatCompactCurrency: (value: number) => string
|
|
4
|
+
export declare const mapVenueEventToSearchResult: (event: VenueEventWithMarkets, labels: AggUiLabels, formatPercent: (value: number) => string, formatCompactCurrency: (value: number) => string, options?: {
|
|
5
|
+
locale?: string;
|
|
6
|
+
}) => SearchResultItem | null;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { AggUiLabels } from "@agg-build/hooks";
|
|
2
2
|
import type { VenueEventWithMarkets } from "../../events/item";
|
|
3
3
|
import type { SearchResultItem } from "./search.types";
|
|
4
|
-
export declare const mapVenueEventToSearchResult: (event: VenueEventWithMarkets, labels: AggUiLabels, formatPercent: (value: number) => string, formatCompactCurrency: (value: number) => string
|
|
4
|
+
export declare const mapVenueEventToSearchResult: (event: VenueEventWithMarkets, labels: AggUiLabels, formatPercent: (value: number) => string, formatCompactCurrency: (value: number) => string, options?: {
|
|
5
|
+
locale?: string;
|
|
6
|
+
}) => SearchResultItem | null;
|
|
@@ -5,6 +5,6 @@ export { PlaceOrderSuccessView } from "./index.place-order.success";
|
|
|
5
5
|
export type { PlaceOrderSuccessViewProps } from "./index.place-order.success";
|
|
6
6
|
export type { PlaceOrderClassNames, PlaceOrderExecutionSummary, PlaceOrderResolvedClaimSummary, PlaceOrderTradingLabels, } from "./index.place-order.types";
|
|
7
7
|
export declare const PlaceOrder: {
|
|
8
|
-
({ className, classNames, eventTradingState, executionMode, isLoading, isPrimaryActionDisabled, isPrimaryActionLoading, chainBalancesOverride, onAmountChange, onClose, onOutcomeChange, onPrimaryAction, onTabChange, onSuccess, onError, onExecutionStateChange, resolvedClaim, midpointsResult, }: PlaceOrderProps): JSX.Element;
|
|
8
|
+
({ className, classNames, eventTradingState, executionMode, isLoading, isPrimaryActionDisabled, isPrimaryActionLoading, chainBalancesOverride, onAmountChange, onClose, onOutcomeChange, onPrimaryAction, onBeforePrimaryAction, onTabChange, onSuccess, onError, onExecutionStateChange, resolvedClaim, midpointsResult, }: PlaceOrderProps): JSX.Element;
|
|
9
9
|
displayName: string;
|
|
10
10
|
};
|
|
@@ -5,6 +5,6 @@ export { PlaceOrderSuccessView } from "./index.place-order.success";
|
|
|
5
5
|
export type { PlaceOrderSuccessViewProps } from "./index.place-order.success";
|
|
6
6
|
export type { PlaceOrderClassNames, PlaceOrderExecutionSummary, PlaceOrderResolvedClaimSummary, PlaceOrderTradingLabels, } from "./index.place-order.types";
|
|
7
7
|
export declare const PlaceOrder: {
|
|
8
|
-
({ className, classNames, eventTradingState, executionMode, isLoading, isPrimaryActionDisabled, isPrimaryActionLoading, chainBalancesOverride, onAmountChange, onClose, onOutcomeChange, onPrimaryAction, onTabChange, onSuccess, onError, onExecutionStateChange, resolvedClaim, midpointsResult, }: PlaceOrderProps): JSX.Element;
|
|
8
|
+
({ className, classNames, eventTradingState, executionMode, isLoading, isPrimaryActionDisabled, isPrimaryActionLoading, chainBalancesOverride, onAmountChange, onClose, onOutcomeChange, onPrimaryAction, onBeforePrimaryAction, onTabChange, onSuccess, onError, onExecutionStateChange, resolvedClaim, midpointsResult, }: PlaceOrderProps): JSX.Element;
|
|
9
9
|
displayName: string;
|
|
10
10
|
};
|
|
@@ -22,11 +22,33 @@ export type PlaceOrderProps = {
|
|
|
22
22
|
onClose?: () => void;
|
|
23
23
|
/** Called when the selected outcome changes. */
|
|
24
24
|
onOutcomeChange?: (outcomeId: string) => void;
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Called when the primary action is triggered, in place of the internal
|
|
27
|
+
* quote execution. When provided, the component delegates the fill entirely
|
|
28
|
+
* to this callback and does NOT run its own execution. For a pre-flight gate
|
|
29
|
+
* that should run *before* the normal fill (and let it proceed), use
|
|
30
|
+
* `onBeforePrimaryAction` instead.
|
|
31
|
+
*/
|
|
26
32
|
onPrimaryAction?: (context?: {
|
|
27
33
|
quoteId?: string;
|
|
28
34
|
mode?: ExecutionMode;
|
|
29
35
|
}) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Called when the primary action is triggered, BEFORE the internal quote
|
|
38
|
+
* execution. Unlike `onPrimaryAction`, this does not replace the fill — it
|
|
39
|
+
* runs in between and, when it resolves, the order is filled as usual. Use it
|
|
40
|
+
* for a partner gate such as a verification/KYC modal that must complete
|
|
41
|
+
* before the order goes through.
|
|
42
|
+
*
|
|
43
|
+
* The returned promise is awaited before execution proceeds:
|
|
44
|
+
* - resolve (return `undefined`/`true`) → continue with the normal fill
|
|
45
|
+
* - return `false` → cancel silently; the panel returns to idle
|
|
46
|
+
* - throw → abort and surface the error as submission feedback
|
|
47
|
+
*/
|
|
48
|
+
onBeforePrimaryAction?: (context?: {
|
|
49
|
+
quoteId?: string;
|
|
50
|
+
mode?: ExecutionMode;
|
|
51
|
+
}) => void | boolean | Promise<void | boolean>;
|
|
30
52
|
/** Called when the slippage control value changes. */
|
|
31
53
|
onSlippageChange?: (value: string) => void;
|
|
32
54
|
/** Called when the active trade tab changes. */
|
|
@@ -22,11 +22,33 @@ export type PlaceOrderProps = {
|
|
|
22
22
|
onClose?: () => void;
|
|
23
23
|
/** Called when the selected outcome changes. */
|
|
24
24
|
onOutcomeChange?: (outcomeId: string) => void;
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Called when the primary action is triggered, in place of the internal
|
|
27
|
+
* quote execution. When provided, the component delegates the fill entirely
|
|
28
|
+
* to this callback and does NOT run its own execution. For a pre-flight gate
|
|
29
|
+
* that should run *before* the normal fill (and let it proceed), use
|
|
30
|
+
* `onBeforePrimaryAction` instead.
|
|
31
|
+
*/
|
|
26
32
|
onPrimaryAction?: (context?: {
|
|
27
33
|
quoteId?: string;
|
|
28
34
|
mode?: ExecutionMode;
|
|
29
35
|
}) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Called when the primary action is triggered, BEFORE the internal quote
|
|
38
|
+
* execution. Unlike `onPrimaryAction`, this does not replace the fill — it
|
|
39
|
+
* runs in between and, when it resolves, the order is filled as usual. Use it
|
|
40
|
+
* for a partner gate such as a verification/KYC modal that must complete
|
|
41
|
+
* before the order goes through.
|
|
42
|
+
*
|
|
43
|
+
* The returned promise is awaited before execution proceeds:
|
|
44
|
+
* - resolve (return `undefined`/`true`) → continue with the normal fill
|
|
45
|
+
* - return `false` → cancel silently; the panel returns to idle
|
|
46
|
+
* - throw → abort and surface the error as submission feedback
|
|
47
|
+
*/
|
|
48
|
+
onBeforePrimaryAction?: (context?: {
|
|
49
|
+
quoteId?: string;
|
|
50
|
+
mode?: ExecutionMode;
|
|
51
|
+
}) => void | boolean | Promise<void | boolean>;
|
|
30
52
|
/** Called when the slippage control value changes. */
|
|
31
53
|
onSlippageChange?: (value: string) => void;
|
|
32
54
|
/** Called when the active trade tab changes. */
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape of the `notifications.claim` label block consumed by the claim flow.
|
|
3
|
+
* Mirrors the typed labels so callers can reason about the toast copy.
|
|
4
|
+
*/
|
|
5
|
+
export type ClaimNotificationLabels = {
|
|
6
|
+
pendingTitle: string;
|
|
7
|
+
pendingMessage: string;
|
|
8
|
+
submittedTitle: string;
|
|
9
|
+
submittedMessage: string;
|
|
10
|
+
successTitle: string;
|
|
11
|
+
successMessage: string;
|
|
12
|
+
partialTitle: string;
|
|
13
|
+
partialMessage: (errorReason?: string) => string;
|
|
14
|
+
failedTitle: string;
|
|
15
|
+
failedMessage: (errorReason?: string) => string;
|
|
16
|
+
missingOutcomeMessage: string;
|
|
17
|
+
};
|
|
18
|
+
/** Terminal lifecycle summary forwarded to `onClaimResult`. */
|
|
19
|
+
export type ClaimLifecycleResult = {
|
|
20
|
+
allConfirmed: boolean;
|
|
21
|
+
anyFailed: boolean;
|
|
22
|
+
errorMessage: string | null;
|
|
23
|
+
};
|
|
24
|
+
/** A single claim request keyed by `claimKey`. */
|
|
25
|
+
export type ClaimWinningsInput<TPayload = void> = {
|
|
26
|
+
/** Stable identifier for the position being claimed (e.g. `marketId`). */
|
|
27
|
+
claimKey: string;
|
|
28
|
+
/** Winning venue-market-outcome ids to redeem. */
|
|
29
|
+
winningOutcomeIds: string[];
|
|
30
|
+
/** Opaque payload forwarded verbatim to a caller-provided `onClaim`. */
|
|
31
|
+
payload?: TPayload;
|
|
32
|
+
};
|
|
33
|
+
export type UseClaimWinningsOptions<TPayload = void> = {
|
|
34
|
+
/**
|
|
35
|
+
* Caller-owned claim handler. When provided, the hook delegates the actual
|
|
36
|
+
* redeem to this callback and toasts a simple pending → success/failure
|
|
37
|
+
* lifecycle (no WS lifecycle tracking). Partners who own the claim flow pass
|
|
38
|
+
* this; omit it to let the hook drive the internal redeem mutation.
|
|
39
|
+
*/
|
|
40
|
+
onClaim?: (payload: TPayload) => Promise<void> | void;
|
|
41
|
+
/**
|
|
42
|
+
* Fired once per redeem when its WS lifecycle reaches terminal. Only fired on
|
|
43
|
+
* the internal claim path (i.e. when `onClaim` is omitted).
|
|
44
|
+
*/
|
|
45
|
+
onClaimResult?: (claimKey: string, lifecycle: ClaimLifecycleResult) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Fired when the redeem mutation itself rejects (transport error, validation
|
|
48
|
+
* error, or all legs ineligible/rejected at submit time). The redeem never
|
|
49
|
+
* enters the WS lifecycle in these cases, so `onClaimResult` does NOT fire.
|
|
50
|
+
*/
|
|
51
|
+
onClaimSubmitError?: (claimKey: string, error: Error) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Caller-owned spinner map. When provided, it fully replaces the hook's
|
|
54
|
+
* lifecycle-derived spinner state for display purposes (mirrors the legacy
|
|
55
|
+
* `claimingPositionKeys ?? internal` behavior).
|
|
56
|
+
*/
|
|
57
|
+
externalClaimingKeys?: Record<string, boolean>;
|
|
58
|
+
};
|
|
59
|
+
export type UseClaimWinningsResult<TPayload = void> = {
|
|
60
|
+
/** Start a claim for a single position. Resolves once the submit settles. */
|
|
61
|
+
claim: (input: ClaimWinningsInput<TPayload>) => Promise<void>;
|
|
62
|
+
/** Map of claim key → in-flight flag, suitable to pass to a row renderer. */
|
|
63
|
+
claimingKeys: Record<string, boolean>;
|
|
64
|
+
/** Whether a given claim key is currently in-flight (submit or lifecycle). */
|
|
65
|
+
isClaiming: (claimKey: string) => boolean;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Encapsulates the full "claim winnings" (redeem) lifecycle so multiple
|
|
69
|
+
* surfaces (the profile positions list, the resolved market trade panel) can
|
|
70
|
+
* share one implementation instead of duplicating the redeem → WS lifecycle →
|
|
71
|
+
* toast → cache-invalidation orchestration.
|
|
72
|
+
*
|
|
73
|
+
* The flow has two paths:
|
|
74
|
+
* - **Internal** (`onClaim` omitted): submit via the redeem mutation, bucket
|
|
75
|
+
* the response legs (submitted / confirmed / ineligible / rejected), track
|
|
76
|
+
* EVM async legs through their WS lifecycle, and toast pending → submitted →
|
|
77
|
+
* success/partial/failed.
|
|
78
|
+
* - **Delegated** (`onClaim` provided): the caller performs the redeem; the
|
|
79
|
+
* hook only toasts pending → success/failure.
|
|
80
|
+
*
|
|
81
|
+
* Both paths invalidate balances, positions, the claimable count, the activity
|
|
82
|
+
* feed, and the current-user query so dependent UI refreshes.
|
|
83
|
+
*/
|
|
84
|
+
export declare function useClaimWinnings<TPayload = void>(options?: UseClaimWinningsOptions<TPayload>): UseClaimWinningsResult<TPayload>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape of the `notifications.claim` label block consumed by the claim flow.
|
|
3
|
+
* Mirrors the typed labels so callers can reason about the toast copy.
|
|
4
|
+
*/
|
|
5
|
+
export type ClaimNotificationLabels = {
|
|
6
|
+
pendingTitle: string;
|
|
7
|
+
pendingMessage: string;
|
|
8
|
+
submittedTitle: string;
|
|
9
|
+
submittedMessage: string;
|
|
10
|
+
successTitle: string;
|
|
11
|
+
successMessage: string;
|
|
12
|
+
partialTitle: string;
|
|
13
|
+
partialMessage: (errorReason?: string) => string;
|
|
14
|
+
failedTitle: string;
|
|
15
|
+
failedMessage: (errorReason?: string) => string;
|
|
16
|
+
missingOutcomeMessage: string;
|
|
17
|
+
};
|
|
18
|
+
/** Terminal lifecycle summary forwarded to `onClaimResult`. */
|
|
19
|
+
export type ClaimLifecycleResult = {
|
|
20
|
+
allConfirmed: boolean;
|
|
21
|
+
anyFailed: boolean;
|
|
22
|
+
errorMessage: string | null;
|
|
23
|
+
};
|
|
24
|
+
/** A single claim request keyed by `claimKey`. */
|
|
25
|
+
export type ClaimWinningsInput<TPayload = void> = {
|
|
26
|
+
/** Stable identifier for the position being claimed (e.g. `marketId`). */
|
|
27
|
+
claimKey: string;
|
|
28
|
+
/** Winning venue-market-outcome ids to redeem. */
|
|
29
|
+
winningOutcomeIds: string[];
|
|
30
|
+
/** Opaque payload forwarded verbatim to a caller-provided `onClaim`. */
|
|
31
|
+
payload?: TPayload;
|
|
32
|
+
};
|
|
33
|
+
export type UseClaimWinningsOptions<TPayload = void> = {
|
|
34
|
+
/**
|
|
35
|
+
* Caller-owned claim handler. When provided, the hook delegates the actual
|
|
36
|
+
* redeem to this callback and toasts a simple pending → success/failure
|
|
37
|
+
* lifecycle (no WS lifecycle tracking). Partners who own the claim flow pass
|
|
38
|
+
* this; omit it to let the hook drive the internal redeem mutation.
|
|
39
|
+
*/
|
|
40
|
+
onClaim?: (payload: TPayload) => Promise<void> | void;
|
|
41
|
+
/**
|
|
42
|
+
* Fired once per redeem when its WS lifecycle reaches terminal. Only fired on
|
|
43
|
+
* the internal claim path (i.e. when `onClaim` is omitted).
|
|
44
|
+
*/
|
|
45
|
+
onClaimResult?: (claimKey: string, lifecycle: ClaimLifecycleResult) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Fired when the redeem mutation itself rejects (transport error, validation
|
|
48
|
+
* error, or all legs ineligible/rejected at submit time). The redeem never
|
|
49
|
+
* enters the WS lifecycle in these cases, so `onClaimResult` does NOT fire.
|
|
50
|
+
*/
|
|
51
|
+
onClaimSubmitError?: (claimKey: string, error: Error) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Caller-owned spinner map. When provided, it fully replaces the hook's
|
|
54
|
+
* lifecycle-derived spinner state for display purposes (mirrors the legacy
|
|
55
|
+
* `claimingPositionKeys ?? internal` behavior).
|
|
56
|
+
*/
|
|
57
|
+
externalClaimingKeys?: Record<string, boolean>;
|
|
58
|
+
};
|
|
59
|
+
export type UseClaimWinningsResult<TPayload = void> = {
|
|
60
|
+
/** Start a claim for a single position. Resolves once the submit settles. */
|
|
61
|
+
claim: (input: ClaimWinningsInput<TPayload>) => Promise<void>;
|
|
62
|
+
/** Map of claim key → in-flight flag, suitable to pass to a row renderer. */
|
|
63
|
+
claimingKeys: Record<string, boolean>;
|
|
64
|
+
/** Whether a given claim key is currently in-flight (submit or lifecycle). */
|
|
65
|
+
isClaiming: (claimKey: string) => boolean;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Encapsulates the full "claim winnings" (redeem) lifecycle so multiple
|
|
69
|
+
* surfaces (the profile positions list, the resolved market trade panel) can
|
|
70
|
+
* share one implementation instead of duplicating the redeem → WS lifecycle →
|
|
71
|
+
* toast → cache-invalidation orchestration.
|
|
72
|
+
*
|
|
73
|
+
* The flow has two paths:
|
|
74
|
+
* - **Internal** (`onClaim` omitted): submit via the redeem mutation, bucket
|
|
75
|
+
* the response legs (submitted / confirmed / ineligible / rejected), track
|
|
76
|
+
* EVM async legs through their WS lifecycle, and toast pending → submitted →
|
|
77
|
+
* success/partial/failed.
|
|
78
|
+
* - **Delegated** (`onClaim` provided): the caller performs the redeem; the
|
|
79
|
+
* hook only toasts pending → success/failure.
|
|
80
|
+
*
|
|
81
|
+
* Both paths invalidate balances, positions, the claimable count, the activity
|
|
82
|
+
* feed, and the current-user query so dependent UI refreshes.
|
|
83
|
+
*/
|
|
84
|
+
export declare function useClaimWinnings<TPayload = void>(options?: UseClaimWinningsOptions<TPayload>): UseClaimWinningsResult<TPayload>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type VenueMarket } from "@agg-build/hooks";
|
|
2
|
+
import type { PlaceOrderResolvedClaimSummary } from "./place-order";
|
|
3
|
+
export type UseResolvedMarketClaimOptions = {
|
|
4
|
+
/** The resolved market whose claimable winnings should be summarized. */
|
|
5
|
+
market?: VenueMarket | null;
|
|
6
|
+
/** Gate fetching/computation (e.g. only when the trade panel is resolved). */
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
/** Execution mode — paper positions are fetched from the paper bucket. */
|
|
9
|
+
executionMode?: "live" | "paper";
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Derives the resolved-market claim summary (resolution date, winning shares,
|
|
13
|
+
* total payout, and a wired claim action) for the position the current user
|
|
14
|
+
* holds in `market`, reusing the same redeem flow as the profile positions
|
|
15
|
+
* list via {@link useClaimWinnings}.
|
|
16
|
+
*
|
|
17
|
+
* Returns `undefined` (so the caller renders the plain resolved view) when:
|
|
18
|
+
* - fetching is disabled, the user is unauthenticated, or the market is open;
|
|
19
|
+
* - the user holds no position in this market;
|
|
20
|
+
* - the user's position lost (no winning outcome with shares).
|
|
21
|
+
*
|
|
22
|
+
* When the user won but the position is already redeemed / pending / ineligible
|
|
23
|
+
* (i.e. not `eligible`), the summary is returned WITHOUT an `onClaim` action so
|
|
24
|
+
* the earnings show without a duplicate claim CTA.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useResolvedMarketClaim(options?: UseResolvedMarketClaimOptions): PlaceOrderResolvedClaimSummary | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type VenueMarket } from "@agg-build/hooks";
|
|
2
|
+
import type { PlaceOrderResolvedClaimSummary } from "./place-order";
|
|
3
|
+
export type UseResolvedMarketClaimOptions = {
|
|
4
|
+
/** The resolved market whose claimable winnings should be summarized. */
|
|
5
|
+
market?: VenueMarket | null;
|
|
6
|
+
/** Gate fetching/computation (e.g. only when the trade panel is resolved). */
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
/** Execution mode — paper positions are fetched from the paper bucket. */
|
|
9
|
+
executionMode?: "live" | "paper";
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Derives the resolved-market claim summary (resolution date, winning shares,
|
|
13
|
+
* total payout, and a wired claim action) for the position the current user
|
|
14
|
+
* holds in `market`, reusing the same redeem flow as the profile positions
|
|
15
|
+
* list via {@link useClaimWinnings}.
|
|
16
|
+
*
|
|
17
|
+
* Returns `undefined` (so the caller renders the plain resolved view) when:
|
|
18
|
+
* - fetching is disabled, the user is unauthenticated, or the market is open;
|
|
19
|
+
* - the user holds no position in this market;
|
|
20
|
+
* - the user's position lost (no winning outcome with shares).
|
|
21
|
+
*
|
|
22
|
+
* When the user won but the position is already redeemed / pending / ineligible
|
|
23
|
+
* (i.e. not `eligible`), the summary is returned WITHOUT an `onClaim` action so
|
|
24
|
+
* the earnings show without a duplicate claim CTA.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useResolvedMarketClaim(options?: UseResolvedMarketClaimOptions): PlaceOrderResolvedClaimSummary | undefined;
|