@agg-build/ui 2.1.1 → 2.1.3

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.
Files changed (74) hide show
  1. package/dist/{chunk-XHDGSRG7.mjs → chunk-BW7S2YR3.mjs} +1139 -308
  2. package/dist/{chunk-TERG43WW.mjs → chunk-R2YNZJZ3.mjs} +69 -27
  3. package/dist/{chunk-RPXRTXCY.mjs → chunk-T4YZGAYS.mjs} +22 -1
  4. package/dist/{chunk-IQT4I5B4.mjs → chunk-TAGPAADA.mjs} +2108 -767
  5. package/dist/{chunk-NK57KMYN.mjs → chunk-TBZWRUFB.mjs} +752 -589
  6. package/dist/{chunk-YJO6LMRT.mjs → chunk-VP76G6PN.mjs} +87 -25
  7. package/dist/{chunk-WU2C3C6K.mjs → chunk-XHE2VO3S.mjs} +4 -21
  8. package/dist/events.js +1014 -760
  9. package/dist/events.mjs +5 -3
  10. package/dist/index.js +9937 -7880
  11. package/dist/index.mjs +117 -456
  12. package/dist/modals.js +1 -1
  13. package/dist/modals.mjs +3 -3
  14. package/dist/pages.js +8513 -6380
  15. package/dist/pages.mjs +6 -6
  16. package/dist/primitives.js +85 -25
  17. package/dist/primitives.mjs +1 -1
  18. package/dist/styles.css +1 -1
  19. package/dist/tailwind.css +1 -1
  20. package/dist/trading.js +979 -402
  21. package/dist/trading.mjs +10 -6
  22. package/dist/types/events/item/event-list-item.utils.d.mts +1 -25
  23. package/dist/types/events/item/event-list-item.utils.d.ts +1 -25
  24. package/dist/types/events/item-details/index.d.mts +2 -1
  25. package/dist/types/events/item-details/index.d.ts +2 -1
  26. package/dist/types/events/market-details/market-details-graph-panel.d.mts +39 -0
  27. package/dist/types/events/market-details/market-details-graph-panel.d.ts +39 -0
  28. package/dist/types/events/market-details/market-details-outcome-button.d.mts +2 -1
  29. package/dist/types/events/market-details/market-details-outcome-button.d.ts +2 -1
  30. package/dist/types/events/market-details/market-details.types.d.mts +31 -0
  31. package/dist/types/events/market-details/market-details.types.d.ts +31 -0
  32. package/dist/types/events/market-details/market-details.utils.d.mts +3 -16
  33. package/dist/types/events/market-details/market-details.utils.d.ts +3 -16
  34. package/dist/types/events/shared/format-event-title.d.mts +24 -0
  35. package/dist/types/events/shared/format-event-title.d.ts +24 -0
  36. package/dist/types/events/shared/format-sports-event-time.d.mts +2 -0
  37. package/dist/types/events/shared/format-sports-event-time.d.ts +2 -0
  38. package/dist/types/events/shared/select-best-outcome.d.mts +88 -0
  39. package/dist/types/events/shared/select-best-outcome.d.ts +88 -0
  40. package/dist/types/notifications/agg-notification-events-provider.d.mts +10 -1
  41. package/dist/types/notifications/agg-notification-events-provider.d.ts +10 -1
  42. package/dist/types/pages/event-market/event-market.shared.d.mts +30 -0
  43. package/dist/types/pages/event-market/event-market.shared.d.ts +30 -0
  44. package/dist/types/pages/event-market/event-market.types.d.mts +7 -0
  45. package/dist/types/pages/event-market/event-market.types.d.ts +7 -0
  46. package/dist/types/pages/event-market/sports-event-market-page.d.mts +8 -0
  47. package/dist/types/pages/event-market/sports-event-market-page.d.ts +8 -0
  48. package/dist/types/pages/event-market/sports-event-market.fixtures.d.mts +13 -0
  49. package/dist/types/pages/event-market/sports-event-market.fixtures.d.ts +13 -0
  50. package/dist/types/pages/event-market/sports-event-market.utils.d.mts +156 -0
  51. package/dist/types/pages/event-market/sports-event-market.utils.d.ts +156 -0
  52. package/dist/types/pages/event-market/sports-line-rail.d.mts +17 -0
  53. package/dist/types/pages/event-market/sports-line-rail.d.ts +17 -0
  54. package/dist/types/pages/event-market/sports-market-card.d.mts +22 -0
  55. package/dist/types/pages/event-market/sports-market-card.d.ts +22 -0
  56. package/dist/types/pages/event-market/sports-markets.d.mts +13 -0
  57. package/dist/types/pages/event-market/sports-markets.d.ts +13 -0
  58. package/dist/types/primitives/state-message/index.d.mts +1 -1
  59. package/dist/types/primitives/state-message/index.d.ts +1 -1
  60. package/dist/types/primitives/state-message/state-message.types.d.mts +1 -1
  61. package/dist/types/primitives/state-message/state-message.types.d.ts +1 -1
  62. package/dist/types/trading/index.d.mts +2 -0
  63. package/dist/types/trading/index.d.ts +2 -0
  64. package/dist/types/trading/place-order/index.d.mts +1 -1
  65. package/dist/types/trading/place-order/index.d.ts +1 -1
  66. package/dist/types/trading/place-order/index.place-order.types.d.mts +30 -1
  67. package/dist/types/trading/place-order/index.place-order.types.d.ts +30 -1
  68. package/dist/types/trading/settlement/settlement-text.utils.d.mts +5 -2
  69. package/dist/types/trading/settlement/settlement-text.utils.d.ts +5 -2
  70. package/dist/types/trading/use-claim-winnings.d.mts +84 -0
  71. package/dist/types/trading/use-claim-winnings.d.ts +84 -0
  72. package/dist/types/trading/use-resolved-market-claim.d.mts +26 -0
  73. package/dist/types/trading/use-resolved-market-claim.d.ts +26 -0
  74. package/package.json +3 -3
@@ -7,7 +7,7 @@ export type StateMessageClassNames = {
7
7
  description?: string;
8
8
  action?: string;
9
9
  };
10
- export type StateMessageProps = {
10
+ export type StateMessageProps = Omit<React.HTMLAttributes<HTMLDivElement>, "title"> & {
11
11
  /** Heading shown for the state message. */
12
12
  title: string;
13
13
  /** Supporting description shown under the title. */
@@ -7,7 +7,7 @@ export type StateMessageClassNames = {
7
7
  description?: string;
8
8
  action?: string;
9
9
  };
10
- export type StateMessageProps = {
10
+ export type StateMessageProps = Omit<React.HTMLAttributes<HTMLDivElement>, "title"> & {
11
11
  /** Heading shown for the state message. */
12
12
  title: string;
13
13
  /** Supporting description shown under the title. */
@@ -4,3 +4,5 @@ export * from "./settlement";
4
4
  export * from "./settlement/settlement-details";
5
5
  export * from "./place-order";
6
6
  export * from "./trading-context";
7
+ export * from "./use-claim-winnings";
8
+ export * from "./use-resolved-market-claim";
@@ -4,3 +4,5 @@ export * from "./settlement";
4
4
  export * from "./settlement/settlement-details";
5
5
  export * from "./place-order";
6
6
  export * from "./trading-context";
7
+ export * from "./use-claim-winnings";
8
+ export * from "./use-resolved-market-claim";
@@ -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, isQuotePanelActive, 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, isQuotePanelActive, chainBalancesOverride, onAmountChange, onClose, onOutcomeChange, onPrimaryAction, onBeforePrimaryAction, onTabChange, onSuccess, onError, onExecutionStateChange, resolvedClaim, midpointsResult, }: PlaceOrderProps): JSX.Element;
9
9
  displayName: string;
10
10
  };
@@ -16,17 +16,45 @@ export type PlaceOrderProps = {
16
16
  isPrimaryActionDisabled?: boolean;
17
17
  /** Whether the primary submit action should show a loading spinner. */
18
18
  isPrimaryActionLoading?: boolean;
19
+ /**
20
+ * Whether this place-order instance is the active, visible quote surface.
21
+ * Hidden or closed surfaces should pass false so quote polling can pause.
22
+ * Defaults to true.
23
+ */
24
+ isQuotePanelActive?: boolean;
19
25
  /** Called when the entered order amount changes. */
20
26
  onAmountChange?: (amount: number) => void;
21
27
  /** Called when the place-order panel should close. */
22
28
  onClose?: () => void;
23
29
  /** Called when the selected outcome changes. */
24
30
  onOutcomeChange?: (outcomeId: string) => void;
25
- /** Called when the primary action is triggered. */
31
+ /**
32
+ * Called when the primary action is triggered, in place of the internal
33
+ * quote execution. When provided, the component delegates the fill entirely
34
+ * to this callback and does NOT run its own execution. For a pre-flight gate
35
+ * that should run *before* the normal fill (and let it proceed), use
36
+ * `onBeforePrimaryAction` instead.
37
+ */
26
38
  onPrimaryAction?: (context?: {
27
39
  quoteId?: string;
28
40
  mode?: ExecutionMode;
29
41
  }) => void;
42
+ /**
43
+ * Called when the primary action is triggered, BEFORE the internal quote
44
+ * execution. Unlike `onPrimaryAction`, this does not replace the fill — it
45
+ * runs in between and, when it resolves, the order is filled as usual. Use it
46
+ * for a partner gate such as a verification/KYC modal that must complete
47
+ * before the order goes through.
48
+ *
49
+ * The returned promise is awaited before execution proceeds:
50
+ * - resolve (return `undefined`/`true`) → continue with the normal fill
51
+ * - return `false` → cancel silently; the panel returns to idle
52
+ * - throw → abort and surface the error as submission feedback
53
+ */
54
+ onBeforePrimaryAction?: (context?: {
55
+ quoteId?: string;
56
+ mode?: ExecutionMode;
57
+ }) => void | boolean | Promise<void | boolean>;
30
58
  /** Called when the slippage control value changes. */
31
59
  onSlippageChange?: (value: string) => void;
32
60
  /** Called when the active trade tab changes. */
@@ -207,6 +235,7 @@ export type PlaceOrderSubmissionProgressState = {
207
235
  failureSummary?: PlaceOrderFailureSummary;
208
236
  orderId?: string;
209
237
  orderIds?: string[];
238
+ quoteId?: string;
210
239
  phase: PlaceOrderSubmissionProgressPhase;
211
240
  summary?: PlaceOrderExecutionSummary;
212
241
  dagProgress?: DagStepProgress | null;
@@ -16,17 +16,45 @@ export type PlaceOrderProps = {
16
16
  isPrimaryActionDisabled?: boolean;
17
17
  /** Whether the primary submit action should show a loading spinner. */
18
18
  isPrimaryActionLoading?: boolean;
19
+ /**
20
+ * Whether this place-order instance is the active, visible quote surface.
21
+ * Hidden or closed surfaces should pass false so quote polling can pause.
22
+ * Defaults to true.
23
+ */
24
+ isQuotePanelActive?: boolean;
19
25
  /** Called when the entered order amount changes. */
20
26
  onAmountChange?: (amount: number) => void;
21
27
  /** Called when the place-order panel should close. */
22
28
  onClose?: () => void;
23
29
  /** Called when the selected outcome changes. */
24
30
  onOutcomeChange?: (outcomeId: string) => void;
25
- /** Called when the primary action is triggered. */
31
+ /**
32
+ * Called when the primary action is triggered, in place of the internal
33
+ * quote execution. When provided, the component delegates the fill entirely
34
+ * to this callback and does NOT run its own execution. For a pre-flight gate
35
+ * that should run *before* the normal fill (and let it proceed), use
36
+ * `onBeforePrimaryAction` instead.
37
+ */
26
38
  onPrimaryAction?: (context?: {
27
39
  quoteId?: string;
28
40
  mode?: ExecutionMode;
29
41
  }) => void;
42
+ /**
43
+ * Called when the primary action is triggered, BEFORE the internal quote
44
+ * execution. Unlike `onPrimaryAction`, this does not replace the fill — it
45
+ * runs in between and, when it resolves, the order is filled as usual. Use it
46
+ * for a partner gate such as a verification/KYC modal that must complete
47
+ * before the order goes through.
48
+ *
49
+ * The returned promise is awaited before execution proceeds:
50
+ * - resolve (return `undefined`/`true`) → continue with the normal fill
51
+ * - return `false` → cancel silently; the panel returns to idle
52
+ * - throw → abort and surface the error as submission feedback
53
+ */
54
+ onBeforePrimaryAction?: (context?: {
55
+ quoteId?: string;
56
+ mode?: ExecutionMode;
57
+ }) => void | boolean | Promise<void | boolean>;
30
58
  /** Called when the slippage control value changes. */
31
59
  onSlippageChange?: (value: string) => void;
32
60
  /** Called when the active trade tab changes. */
@@ -207,6 +235,7 @@ export type PlaceOrderSubmissionProgressState = {
207
235
  failureSummary?: PlaceOrderFailureSummary;
208
236
  orderId?: string;
209
237
  orderIds?: string[];
238
+ quoteId?: string;
210
239
  phase: PlaceOrderSubmissionProgressPhase;
211
240
  summary?: PlaceOrderExecutionSummary;
212
241
  dagProgress?: DagStepProgress | null;
@@ -30,7 +30,10 @@ export type SettlementSourceBlock = {
30
30
  };
31
31
  /**
32
32
  * Produces the ordered list of non-empty settlement blocks for the Settlement
33
- * section, dropping any source whose normalized text is identical to a block
34
- * already included.
33
+ * section, dropping any source whose normalized text is contained within
34
+ * another source's — keeping the superset. Containment (not just equality) is
35
+ * required because some venues (e.g. predict) store the same rules text on both
36
+ * the event and its markets, with the market copy adding only a trailing
37
+ * "Created At: ..." line, so the two are a prefix relationship, not identical.
35
38
  */
36
39
  export declare const dedupeSettlementSources: (sources: SettlementSourceInput) => SettlementSourceBlock[];
@@ -30,7 +30,10 @@ export type SettlementSourceBlock = {
30
30
  };
31
31
  /**
32
32
  * Produces the ordered list of non-empty settlement blocks for the Settlement
33
- * section, dropping any source whose normalized text is identical to a block
34
- * already included.
33
+ * section, dropping any source whose normalized text is contained within
34
+ * another source's — keeping the superset. Containment (not just equality) is
35
+ * required because some venues (e.g. predict) store the same rules text on both
36
+ * the event and its markets, with the market copy adding only a trailing
37
+ * "Created At: ..." line, so the two are a prefix relationship, not identical.
35
38
  */
36
39
  export declare const dedupeSettlementSources: (sources: SettlementSourceInput) => SettlementSourceBlock[];
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agg-build/ui",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Pre-built React component library for the AGG prediction market aggregator. Tailwind-based, themeable, with primitives, event surfaces, trading flows, full pages, and modals.",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -100,8 +100,8 @@
100
100
  "liveline": "^0.0.7",
101
101
  "react": "^18.0.0 || ^19.0.0",
102
102
  "react-dom": "^18.0.0 || ^19.0.0",
103
- "@agg-build/hooks": "^2.1.1",
104
- "@agg-build/sdk": "^2.1.0"
103
+ "@agg-build/hooks": "^2.1.3",
104
+ "@agg-build/sdk": "^2.1.3"
105
105
  },
106
106
  "dependencies": {
107
107
  "@number-flow/react": "^0.6.0",