@agg-build/ui 1.2.9 → 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.
Files changed (100) hide show
  1. package/dist/{chunk-PFOSEY46.mjs → chunk-3ZSNHGAB.mjs} +835 -401
  2. package/dist/{chunk-5PSAIGOT.mjs → chunk-54PCEK6G.mjs} +137 -61
  3. package/dist/{chunk-7JKGAWU5.mjs → chunk-ENAGASVU.mjs} +1538 -1369
  4. package/dist/{chunk-K23CJ5UP.mjs → chunk-J7K2U44E.mjs} +481 -258
  5. package/dist/{chunk-5MDFM2MX.mjs → chunk-NWJHFGBZ.mjs} +1 -1
  6. package/dist/{chunk-QFW5NDJ6.mjs → chunk-SJLHOAKK.mjs} +1001 -1015
  7. package/dist/{chunk-PYKD4W4T.mjs → chunk-YP75TIY6.mjs} +601 -326
  8. package/dist/events.js +2038 -1559
  9. package/dist/events.mjs +3 -3
  10. package/dist/index.js +5417 -4261
  11. package/dist/index.mjs +56 -50
  12. package/dist/modals.js +3262 -2384
  13. package/dist/modals.mjs +3 -3
  14. package/dist/pages.js +3677 -2709
  15. package/dist/pages.mjs +6 -6
  16. package/dist/primitives.js +992 -918
  17. package/dist/primitives.mjs +5 -1
  18. package/dist/styles.css +1 -1
  19. package/dist/tailwind.css +1 -1
  20. package/dist/trading.js +1360 -1129
  21. package/dist/trading.mjs +4 -4
  22. package/dist/types/deposit/deposit-modal.types.d.mts +10 -1
  23. package/dist/types/deposit/deposit-modal.types.d.ts +10 -1
  24. package/dist/types/deposit/index.d.mts +1 -1
  25. package/dist/types/deposit/index.d.ts +1 -1
  26. package/dist/types/deposit/steps/crypto-transfer.d.mts +1 -2
  27. package/dist/types/deposit/steps/crypto-transfer.d.ts +1 -2
  28. package/dist/types/deposit/steps/deposit-method.d.mts +2 -1
  29. package/dist/types/deposit/steps/deposit-method.d.ts +2 -1
  30. package/dist/types/events/item/event-list-item.types.d.mts +3 -1
  31. package/dist/types/events/item/event-list-item.types.d.ts +3 -1
  32. package/dist/types/events/item/event-list-item.utils.d.mts +26 -2
  33. package/dist/types/events/item/event-list-item.utils.d.ts +26 -2
  34. package/dist/types/events/item-details/event-list-item-details.types.d.mts +30 -1
  35. package/dist/types/events/item-details/event-list-item-details.types.d.ts +30 -1
  36. package/dist/types/events/market-details/index.d.mts +1 -1
  37. package/dist/types/events/market-details/index.d.ts +1 -1
  38. package/dist/types/events/market-details/market-details.types.d.mts +27 -2
  39. package/dist/types/events/market-details/market-details.types.d.ts +27 -2
  40. package/dist/types/events/market-details/market-details.utils.d.mts +18 -4
  41. package/dist/types/events/market-details/market-details.utils.d.ts +18 -4
  42. package/dist/types/events/market-details/orderbook-aggregation.d.mts +38 -2
  43. package/dist/types/events/market-details/orderbook-aggregation.d.ts +38 -2
  44. package/dist/types/events/shared/chart-auto-fallback.d.mts +43 -0
  45. package/dist/types/events/shared/chart-auto-fallback.d.ts +43 -0
  46. package/dist/types/events/shared/display-outcome-price.d.mts +14 -0
  47. package/dist/types/events/shared/display-outcome-price.d.ts +14 -0
  48. package/dist/types/events/shared/display-outcome-venue.d.mts +30 -0
  49. package/dist/types/events/shared/display-outcome-venue.d.ts +30 -0
  50. package/dist/types/events/shared/display-reference-price.d.mts +4 -0
  51. package/dist/types/events/shared/display-reference-price.d.ts +4 -0
  52. package/dist/types/events/shared/select-outcome-price.d.mts +21 -0
  53. package/dist/types/events/shared/select-outcome-price.d.ts +21 -0
  54. package/dist/types/pages/user-profile/components/available-balance-card.d.mts +2 -1
  55. package/dist/types/pages/user-profile/components/available-balance-card.d.ts +2 -1
  56. package/dist/types/pages/user-profile/components/positions-value-card.d.mts +2 -1
  57. package/dist/types/pages/user-profile/components/positions-value-card.d.ts +2 -1
  58. package/dist/types/pages/user-profile/index.d.mts +2 -2
  59. package/dist/types/pages/user-profile/index.d.ts +2 -2
  60. package/dist/types/pages/user-profile/user-profile.types.d.mts +54 -1
  61. package/dist/types/pages/user-profile/user-profile.types.d.ts +54 -1
  62. package/dist/types/primitives/chart/chart.utils.d.mts +9 -10
  63. package/dist/types/primitives/chart/chart.utils.d.ts +9 -10
  64. package/dist/types/primitives/icon/index.d.mts +2 -1
  65. package/dist/types/primitives/icon/index.d.ts +2 -1
  66. package/dist/types/primitives/icon/registry.d.mts +8 -0
  67. package/dist/types/primitives/icon/registry.d.ts +8 -0
  68. package/dist/types/primitives/icon/svg/circle-xmark.d.mts +5 -0
  69. package/dist/types/primitives/icon/svg/circle-xmark.d.ts +5 -0
  70. package/dist/types/primitives/icon/svg/spinner.d.mts +5 -0
  71. package/dist/types/primitives/icon/svg/spinner.d.ts +5 -0
  72. package/dist/types/primitives/toast/index.d.mts +2 -0
  73. package/dist/types/primitives/toast/index.d.ts +2 -0
  74. package/dist/types/primitives/tooltip/tooltip.types.d.mts +1 -0
  75. package/dist/types/primitives/tooltip/tooltip.types.d.ts +1 -0
  76. package/dist/types/primitives/typography/index.d.mts +1 -1
  77. package/dist/types/primitives/typography/index.d.ts +1 -1
  78. package/dist/types/primitives/typography/typography.types.d.mts +2 -0
  79. package/dist/types/primitives/typography/typography.types.d.ts +2 -0
  80. package/dist/types/shared/transfer-fee-summary.d.mts +10 -0
  81. package/dist/types/shared/transfer-fee-summary.d.ts +10 -0
  82. package/dist/types/shared/utils.d.mts +3 -0
  83. package/dist/types/shared/utils.d.ts +3 -0
  84. package/dist/types/trading/place-order/index.d.mts +1 -1
  85. package/dist/types/trading/place-order/index.d.ts +1 -1
  86. package/dist/types/trading/place-order/index.place-order.execution-steps.d.mts +9 -0
  87. package/dist/types/trading/place-order/index.place-order.execution-steps.d.ts +9 -0
  88. package/dist/types/trading/place-order/index.place-order.types.d.mts +15 -2
  89. package/dist/types/trading/place-order/index.place-order.types.d.ts +15 -2
  90. package/dist/types/trading/place-order/index.place-order.utils.d.mts +49 -6
  91. package/dist/types/trading/place-order/index.place-order.utils.d.ts +49 -6
  92. package/dist/types/withdraw/index.d.mts +1 -1
  93. package/dist/types/withdraw/index.d.ts +1 -1
  94. package/dist/types/withdraw/steps/withdraw-success.d.mts +13 -7
  95. package/dist/types/withdraw/steps/withdraw-success.d.ts +13 -7
  96. package/dist/types/withdraw/steps/withdraw-success.utils.d.mts +2 -0
  97. package/dist/types/withdraw/steps/withdraw-success.utils.d.ts +2 -0
  98. package/dist/types/withdraw/withdraw-modal.types.d.mts +5 -0
  99. package/dist/types/withdraw/withdraw-modal.types.d.ts +5 -0
  100. package/package.json +3 -3
@@ -49,18 +49,61 @@ export declare const buildPlaceOrderExecutionStepGroupsFromFailureSummary: ({ la
49
49
  summary: PlaceOrderFailureSummary;
50
50
  treatPartialAsComplete?: boolean;
51
51
  }) => PlaceOrderExecutionStepGroup[];
52
- export declare const normalizePlaceOrderErrorMessage: ({ errorMessage, fallbackMessage, }: {
52
+ export declare const normalizePlaceOrderErrorMessage: ({ errorMessage, fallbackMessage, labels, }: {
53
53
  errorMessage?: string | null;
54
54
  fallbackMessage: string;
55
+ labels?: Pick<PlaceOrderTradingLabels, "quoteBalanceMismatch">;
55
56
  }) => string;
56
57
  /**
57
- * Sum filled + partially-filled amounts (1e6-atomic) across terminal events
58
- * and subtract from the originally-requested amount. Works for both buy
59
- * (USD remainder) and sell (share remainder) — the executor uses the same
60
- * 1e6 atomic convention for `filledAmountRaw` in both directions.
58
+ * Resolves the actual execution economics from terminal WS events, overriding
59
+ * the stale quote estimate after a `partial_fill` (or `filled`) event arrives.
60
+ *
61
+ * Returns the same shape as the relevant fields on `SmartRouteResponse`
62
+ * (`rawExecCost` = USD side, `totalFilled` = shares side) so call sites can
63
+ * swap the quote estimate for actuals without restructuring.
64
+ *
65
+ * Per-side semantics (matches `polymarket-finalize` / `kalshi-finalize`):
66
+ * - BUY: `filledAmountRaw` is USD spent (6dp atomic). Shares received come
67
+ * from `actualSharesRaw` if present, else derived from filled ÷ price.
68
+ * - SELL: `actualSharesRaw` is the authoritative share count (always set by
69
+ * `OrderExecutionService`). USD payout is `actualSharesRaw ×
70
+ * executionPriceRaw`; `filledAmountRaw` is venue-specific (USD on
71
+ * Polymarket, shares on Kalshi) so we don't rely on it here.
72
+ * - `actualToWinRaw` mirrors `actualSharesRaw` (binary outcome: 1 share = $1
73
+ * if it resolves YES) — it's NOT the realized sell payout.
74
+ *
75
+ * Execution-price precedence: `executionPriceRaw` → submittedOrders.price →
76
+ * quote fill avgPrice for the same venue → quote-wide vwap.
77
+ *
78
+ * When no fill data is present (`hasActualFillData === false`), callers should
79
+ * fall back to the quote estimate.
80
+ */
81
+ export type PlaceOrderActualEconomics = {
82
+ hasActualFillData: boolean;
83
+ actualRawExecCost: number;
84
+ actualTotalFilled: number;
85
+ avgExecutionPrice: number;
86
+ };
87
+ export declare const resolveActualExecutionEconomics: ({ quoteData, tradeSide, terminalOrderEvents, submittedOrders, }: {
88
+ quoteData: SmartRouteResponse | null | undefined;
89
+ tradeSide: PlaceOrderTab;
90
+ terminalOrderEvents?: PlaceOrderTerminalOrderEvent[];
91
+ submittedOrders?: WsOrderSubmitted[];
92
+ }) => PlaceOrderActualEconomics;
93
+ /**
94
+ * Compute the unfilled remainder of an order from terminal WS events.
95
+ *
96
+ * `originalAmount` is in the same units as the user's input field:
97
+ * - BUY: USD requested → subtract `filledAmountRaw` (USD) per event.
98
+ * - SELL: shares requested → subtract `actualSharesRaw` (shares) per event.
99
+ * For sells we never subtract `filledAmountRaw` because its unit is
100
+ * venue-specific (USD on Polymarket, shares on Kalshi) — mixing
101
+ * units corrupts the "Retry remaining" amount and the auto-skip
102
+ * threshold. `actualSharesRaw` is always shares.
61
103
  */
62
- export declare const getPlaceOrderUnfilledRemaining: ({ originalAmount, terminalOrderEvents, }: {
104
+ export declare const getPlaceOrderUnfilledRemaining: ({ originalAmount, tradeSide, terminalOrderEvents, }: {
63
105
  originalAmount: number;
106
+ tradeSide: PlaceOrderTab;
64
107
  terminalOrderEvents?: PlaceOrderTerminalOrderEvent[];
65
108
  }) => number;
66
109
  export declare const buildPlaceOrderFailureSummary: ({ actionLabel, canRetryRemaining, errorMessage, eventImage, eventSubtitle, eventTitle, labels, orderId, quoteData, submittedOrders, terminalOrderEvents, }: {
@@ -1,5 +1,5 @@
1
1
  import type { WithdrawModalProps } from "./withdraw-modal.types";
2
- export type { WithdrawMethod, WithdrawModalControlledProps, WithdrawModalProps, WithdrawModalSelfDrivenProps, WithdrawFlowData, WithdrawSummary, } from "./withdraw-modal.types";
2
+ export type { WithdrawMethod, WithdrawModalControlledProps, WithdrawModalProps, WithdrawModalSelfDrivenProps, WithdrawFlowData, WithdrawFeeEstimate, WithdrawSummary, } from "./withdraw-modal.types";
3
3
  export declare const WithdrawModal: {
4
4
  (props: WithdrawModalProps): JSX.Element;
5
5
  displayName: string;
@@ -1,5 +1,5 @@
1
1
  import type { WithdrawModalProps } from "./withdraw-modal.types";
2
- export type { WithdrawMethod, WithdrawModalControlledProps, WithdrawModalProps, WithdrawModalSelfDrivenProps, WithdrawFlowData, WithdrawSummary, } from "./withdraw-modal.types";
2
+ export type { WithdrawMethod, WithdrawModalControlledProps, WithdrawModalProps, WithdrawModalSelfDrivenProps, WithdrawFlowData, WithdrawFeeEstimate, WithdrawSummary, } from "./withdraw-modal.types";
3
3
  export declare const WithdrawModal: {
4
4
  (props: WithdrawModalProps): JSX.Element;
5
5
  displayName: string;
@@ -1,14 +1,20 @@
1
+ import type { WithdrawalLifecycleState } from "@agg-build/hooks/withdraw";
1
2
  import type { WithdrawSummary } from "../withdraw-modal.types";
3
+ export type WithdrawResultStatus = "success" | "partial_success" | "failed";
4
+ interface WithdrawLoadingStepProps {
5
+ lifecycleState: WithdrawalLifecycleState;
6
+ onClose: () => void;
7
+ }
2
8
  export interface WithdrawSuccessStepProps {
3
9
  summary: WithdrawSummary;
4
10
  tokenSymbol: string;
5
- /**
6
- * The submitted withdrawal id. When non-null the success step subscribes to
7
- * `withdrawal_lifecycle` WS events and renders live progress; when null it
8
- * falls back to the static "submitted" copy.
9
- */
10
- withdrawalId: string | null;
11
+ requestedWithdrawal: string;
12
+ resultStatus: WithdrawResultStatus;
13
+ errorMessage?: string | null;
11
14
  onDone: () => void;
15
+ onRetry: () => void;
12
16
  onClose: () => void;
13
17
  }
14
- export declare const WithdrawSuccessStep: ({ summary, tokenSymbol, withdrawalId, onDone, onClose, }: WithdrawSuccessStepProps) => JSX.Element;
18
+ export declare const WithdrawLoadingStep: ({ lifecycleState, onClose, }: WithdrawLoadingStepProps) => JSX.Element;
19
+ export declare const WithdrawSuccessStep: ({ summary, tokenSymbol, requestedWithdrawal, resultStatus, errorMessage, onDone, onRetry, onClose, }: WithdrawSuccessStepProps) => JSX.Element;
20
+ export {};
@@ -1,14 +1,20 @@
1
+ import type { WithdrawalLifecycleState } from "@agg-build/hooks/withdraw";
1
2
  import type { WithdrawSummary } from "../withdraw-modal.types";
3
+ export type WithdrawResultStatus = "success" | "partial_success" | "failed";
4
+ interface WithdrawLoadingStepProps {
5
+ lifecycleState: WithdrawalLifecycleState;
6
+ onClose: () => void;
7
+ }
2
8
  export interface WithdrawSuccessStepProps {
3
9
  summary: WithdrawSummary;
4
10
  tokenSymbol: string;
5
- /**
6
- * The submitted withdrawal id. When non-null the success step subscribes to
7
- * `withdrawal_lifecycle` WS events and renders live progress; when null it
8
- * falls back to the static "submitted" copy.
9
- */
10
- withdrawalId: string | null;
11
+ requestedWithdrawal: string;
12
+ resultStatus: WithdrawResultStatus;
13
+ errorMessage?: string | null;
11
14
  onDone: () => void;
15
+ onRetry: () => void;
12
16
  onClose: () => void;
13
17
  }
14
- export declare const WithdrawSuccessStep: ({ summary, tokenSymbol, withdrawalId, onDone, onClose, }: WithdrawSuccessStepProps) => JSX.Element;
18
+ export declare const WithdrawLoadingStep: ({ lifecycleState, onClose, }: WithdrawLoadingStepProps) => JSX.Element;
19
+ export declare const WithdrawSuccessStep: ({ summary, tokenSymbol, requestedWithdrawal, resultStatus, errorMessage, onDone, onRetry, onClose, }: WithdrawSuccessStepProps) => JSX.Element;
20
+ export {};
@@ -9,6 +9,8 @@ export interface WithdrawalLifecycleStep {
9
9
  id: string;
10
10
  label: string;
11
11
  status: WithdrawalLifecycleStepStatus;
12
+ /** Failure reason propagated from `leg.errorMessage`. Only set when `status === "error"`. */
13
+ errorMessage?: string | null;
12
14
  }
13
15
  export type WithdrawalLifecycleStepGroup = WithdrawalLifecycleStep[];
14
16
  export declare const resolveChainLabel: (chainId: number) => string;
@@ -9,6 +9,8 @@ export interface WithdrawalLifecycleStep {
9
9
  id: string;
10
10
  label: string;
11
11
  status: WithdrawalLifecycleStepStatus;
12
+ /** Failure reason propagated from `leg.errorMessage`. Only set when `status === "error"`. */
13
+ errorMessage?: string | null;
12
14
  }
13
15
  export type WithdrawalLifecycleStepGroup = WithdrawalLifecycleStep[];
14
16
  export declare const resolveChainLabel: (chainId: number) => string;
@@ -23,6 +23,11 @@ export interface WithdrawSummary {
23
23
  toWallet: string;
24
24
  fees: string;
25
25
  }
26
+ export interface WithdrawFeeEstimate {
27
+ estimatedFees: string;
28
+ networkReserve: string;
29
+ youReceive: string;
30
+ }
26
31
  export interface WithdrawFlowData {
27
32
  /** Top-level balance shown in the entry step (numeric, e.g. 179.9). */
28
33
  balance: number;
@@ -23,6 +23,11 @@ export interface WithdrawSummary {
23
23
  toWallet: string;
24
24
  fees: string;
25
25
  }
26
+ export interface WithdrawFeeEstimate {
27
+ estimatedFees: string;
28
+ networkReserve: string;
29
+ youReceive: string;
30
+ }
26
31
  export interface WithdrawFlowData {
27
32
  /** Top-level balance shown in the entry step (numeric, e.g. 179.9). */
28
33
  balance: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agg-build/ui",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
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": "^1.2.0",
104
- "@agg-build/sdk": "^1.2.0"
103
+ "@agg-build/hooks": "^1.2.11",
104
+ "@agg-build/sdk": "^1.2.11"
105
105
  },
106
106
  "dependencies": {
107
107
  "@number-flow/react": "^0.6.0",