@agg-build/ui 4.2.0 → 4.4.0
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 +21 -16
- package/dist/{chunk-DNPDXL2D.mjs → chunk-64BBTXFE.mjs} +333 -102
- package/dist/{chunk-WDCH4RRS.mjs → chunk-6STRIKUA.mjs} +1 -1
- package/dist/{chunk-FTL25XKE.mjs → chunk-734VTGCV.mjs} +1 -1
- package/dist/{chunk-QW7VFURU.mjs → chunk-N7UPPT5J.mjs} +53 -3
- package/dist/{chunk-6X6Y4INU.mjs → chunk-UCU2XCV5.mjs} +2 -2
- package/dist/{chunk-GNEFI4SO.mjs → chunk-V5CRUO6S.mjs} +637 -380
- package/dist/{chunk-UDBHAZJJ.mjs → chunk-WW5QKNIM.mjs} +270 -123
- package/dist/events.js +1061 -645
- package/dist/events.mjs +6 -4
- package/dist/index.js +2923 -2251
- package/dist/index.mjs +12 -8
- package/dist/modals.js +9 -2
- package/dist/modals.mjs +3 -3
- package/dist/pages.js +2391 -1721
- package/dist/pages.mjs +8 -6
- package/dist/primitives.js +30 -3
- package/dist/primitives.mjs +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/trading.js +330 -99
- package/dist/trading.mjs +4 -4
- package/dist/types/events/index.d.mts +1 -0
- package/dist/types/events/index.d.ts +1 -0
- package/dist/types/events/item-details/event-list-item-details-market-selector.d.mts +4 -1
- package/dist/types/events/item-details/event-list-item-details-market-selector.d.ts +4 -1
- package/dist/types/events/item-details/event-list-item-details.types.d.mts +25 -1
- package/dist/types/events/item-details/event-list-item-details.types.d.ts +25 -1
- package/dist/types/events/item-details/index.d.mts +1 -1
- package/dist/types/events/item-details/index.d.ts +1 -1
- package/dist/types/events/market-details/index.d.mts +1 -1
- package/dist/types/events/market-details/index.d.ts +1 -1
- package/dist/types/events/market-details/market-details.types.d.mts +4 -0
- package/dist/types/events/market-details/market-details.types.d.ts +4 -0
- package/dist/types/events/shared/format-event-title.d.mts +9 -1
- package/dist/types/events/shared/format-event-title.d.ts +9 -1
- package/dist/types/events/shared/format-sports-event-time.d.mts +2 -0
- package/dist/types/events/shared/format-sports-event-time.d.ts +2 -0
- package/dist/types/events/shared/sports-live-score.d.mts +10 -0
- package/dist/types/events/shared/sports-live-score.d.ts +10 -0
- package/dist/types/pages/event-market/event-market.types.d.mts +4 -0
- package/dist/types/pages/event-market/event-market.types.d.ts +4 -0
- package/dist/types/pages/event-market/index.d.mts +1 -0
- package/dist/types/pages/event-market/index.d.ts +1 -0
- package/dist/types/pages/user-profile/components/available-balance-card.d.mts +5 -0
- package/dist/types/pages/user-profile/components/available-balance-card.d.ts +5 -0
- package/dist/types/pages/user-profile/components/open-order-row.d.mts +1 -0
- package/dist/types/pages/user-profile/components/open-order-row.d.ts +1 -0
- package/dist/types/pages/user-profile/components/positions-activity.d.mts +1 -1
- package/dist/types/pages/user-profile/components/positions-activity.d.ts +1 -1
- package/dist/types/pages/user-profile/user-profile.types.d.mts +1 -1
- package/dist/types/pages/user-profile/user-profile.types.d.ts +1 -1
- 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.execution-steps.d.mts +13 -1
- package/dist/types/trading/place-order/index.place-order.execution-steps.d.ts +13 -1
- package/dist/types/trading/place-order/index.place-order.execution-view.d.mts +2 -1
- package/dist/types/trading/place-order/index.place-order.execution-view.d.ts +2 -1
- package/dist/types/trading/place-order/index.place-order.types.d.mts +9 -0
- package/dist/types/trading/place-order/index.place-order.types.d.ts +9 -0
- package/dist/types/trading/place-order/index.place-order.utils.d.mts +6 -0
- package/dist/types/trading/place-order/index.place-order.utils.d.ts +6 -0
- package/package.json +3 -3
- /package/dist/{chunk-KHHFHXXD.mjs → chunk-JH4B3ZHQ.mjs} +0 -0
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
getTradingVenueLabel,
|
|
10
10
|
prepareSettlementDifferences,
|
|
11
11
|
resolveOrderEligibilityMessage
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-6STRIKUA.mjs";
|
|
13
13
|
import {
|
|
14
14
|
ConnectKalshiModal,
|
|
15
15
|
GeoBlockBanner,
|
|
16
16
|
subscribeAggDepositNotification
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-734VTGCV.mjs";
|
|
18
18
|
import {
|
|
19
19
|
AGG_TERMS_OF_SERVICE_URL,
|
|
20
20
|
Button,
|
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
resolveResolvedOutcomeLabel,
|
|
48
48
|
skeletonViews,
|
|
49
49
|
useOptionalToast
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-N7UPPT5J.mjs";
|
|
51
51
|
|
|
52
52
|
// src/trading/types.ts
|
|
53
53
|
import { Venue, enumGuard, isFiniteNonNeg, safeParse } from "@agg-build/sdk";
|
|
@@ -1994,18 +1994,15 @@ var resolvePlaceOrderFailureActions = ({
|
|
|
1994
1994
|
canRetryRemaining = true,
|
|
1995
1995
|
kind,
|
|
1996
1996
|
labels,
|
|
1997
|
-
terminalEvent
|
|
1997
|
+
terminalEvent: _terminalEvent
|
|
1998
1998
|
}) => {
|
|
1999
|
-
const parsedVenue = parseVenue(terminalEvent == null ? void 0 : terminalEvent.venue);
|
|
2000
|
-
const venue = parsedVenue.success ? parsedVenue.data : void 0;
|
|
2001
|
-
const venueLabel = getTradingVenueLabel(venue);
|
|
2002
1999
|
if (kind === "partial_fill") {
|
|
2003
2000
|
if (!canRetryRemaining) {
|
|
2004
2001
|
return [
|
|
2005
2002
|
{
|
|
2006
|
-
id: "
|
|
2007
|
-
label: labels.
|
|
2008
|
-
variant: "
|
|
2003
|
+
id: "new-trade",
|
|
2004
|
+
label: labels.orderNewTrade,
|
|
2005
|
+
variant: "dismiss"
|
|
2009
2006
|
}
|
|
2010
2007
|
];
|
|
2011
2008
|
}
|
|
@@ -2016,9 +2013,9 @@ var resolvePlaceOrderFailureActions = ({
|
|
|
2016
2013
|
variant: "retry"
|
|
2017
2014
|
},
|
|
2018
2015
|
{
|
|
2019
|
-
id: "
|
|
2020
|
-
label: labels.
|
|
2021
|
-
variant: "
|
|
2016
|
+
id: "new-trade",
|
|
2017
|
+
label: labels.orderNewTrade,
|
|
2018
|
+
variant: "dismiss"
|
|
2022
2019
|
}
|
|
2023
2020
|
];
|
|
2024
2021
|
}
|
|
@@ -2026,12 +2023,12 @@ var resolvePlaceOrderFailureActions = ({
|
|
|
2026
2023
|
return [
|
|
2027
2024
|
{
|
|
2028
2025
|
id: "retry",
|
|
2029
|
-
label: labels.
|
|
2026
|
+
label: labels.orderRetry,
|
|
2030
2027
|
variant: "retry"
|
|
2031
2028
|
},
|
|
2032
2029
|
{
|
|
2033
|
-
id: "
|
|
2034
|
-
label: labels.
|
|
2030
|
+
id: "close",
|
|
2031
|
+
label: labels.orderClose,
|
|
2035
2032
|
variant: "dismiss"
|
|
2036
2033
|
}
|
|
2037
2034
|
];
|
|
@@ -2052,8 +2049,8 @@ var resolvePlaceOrderFailureActions = ({
|
|
|
2052
2049
|
variant: "retry"
|
|
2053
2050
|
},
|
|
2054
2051
|
{
|
|
2055
|
-
id: "
|
|
2056
|
-
label: labels.
|
|
2052
|
+
id: "close",
|
|
2053
|
+
label: labels.orderClose,
|
|
2057
2054
|
variant: "dismiss"
|
|
2058
2055
|
}
|
|
2059
2056
|
];
|
|
@@ -2139,6 +2136,21 @@ var getPlaceOrderUnfilledRemaining = ({
|
|
|
2139
2136
|
}, 0);
|
|
2140
2137
|
return Math.max(0, originalAmount - filled);
|
|
2141
2138
|
};
|
|
2139
|
+
var getCanonicalPlaceOrderUnfilledRemaining = ({
|
|
2140
|
+
originalAmount,
|
|
2141
|
+
tradeSide,
|
|
2142
|
+
terminalOrderEvents
|
|
2143
|
+
}) => {
|
|
2144
|
+
const fillEvents = (terminalOrderEvents != null ? terminalOrderEvents : []).filter(
|
|
2145
|
+
(event) => event.event === "filled" || event.event === "partial_fill"
|
|
2146
|
+
);
|
|
2147
|
+
if (fillEvents.length === 0) return null;
|
|
2148
|
+
const hasCanonicalFillUnits = fillEvents.every(
|
|
2149
|
+
(event) => tradeSide === "buy" ? event.filledAmountRaw != null : event.actualSharesRaw != null
|
|
2150
|
+
);
|
|
2151
|
+
if (!hasCanonicalFillUnits) return null;
|
|
2152
|
+
return getPlaceOrderUnfilledRemaining({ originalAmount, tradeSide, terminalOrderEvents });
|
|
2153
|
+
};
|
|
2142
2154
|
var buildPlaceOrderFailureSummary = ({
|
|
2143
2155
|
actionLabel,
|
|
2144
2156
|
canRetryRemaining,
|
|
@@ -2152,7 +2164,7 @@ var buildPlaceOrderFailureSummary = ({
|
|
|
2152
2164
|
submittedOrders,
|
|
2153
2165
|
terminalOrderEvents
|
|
2154
2166
|
}) => {
|
|
2155
|
-
var _a;
|
|
2167
|
+
var _a, _b;
|
|
2156
2168
|
const normalizedErrorMessage = normalizePlaceOrderErrorMessage({
|
|
2157
2169
|
errorMessage,
|
|
2158
2170
|
fallbackMessage: labels.orderFailed,
|
|
@@ -2198,7 +2210,7 @@ var buildPlaceOrderFailureSummary = ({
|
|
|
2198
2210
|
});
|
|
2199
2211
|
}
|
|
2200
2212
|
const venueSteps = sortedEvents.flatMap((terminalEvent, index) => {
|
|
2201
|
-
var _a2,
|
|
2213
|
+
var _a2, _b2, _c, _d, _e;
|
|
2202
2214
|
const parsedVenue = parseVenue(terminalEvent.venue);
|
|
2203
2215
|
const venue = parsedVenue.success ? parsedVenue.data : void 0;
|
|
2204
2216
|
const venueLabel = getTradingVenueLabel(venue);
|
|
@@ -2206,7 +2218,7 @@ var buildPlaceOrderFailureSummary = ({
|
|
|
2206
2218
|
(candidate) => candidate.orderId === terminalEvent.orderId
|
|
2207
2219
|
);
|
|
2208
2220
|
const fallbackPrice = (_a2 = quoteData == null ? void 0 : quoteData.fills[index]) == null ? void 0 : _a2.avgPrice;
|
|
2209
|
-
const priceLabel = getTradingRoutePriceLabel((_c = (
|
|
2221
|
+
const priceLabel = getTradingRoutePriceLabel((_c = (_b2 = submittedOrder == null ? void 0 : submittedOrder.price) != null ? _b2 : fallbackPrice) != null ? _c : 0);
|
|
2210
2222
|
const filledDollars = parseFilledAmountRawDollars(terminalEvent.filledAmountRaw);
|
|
2211
2223
|
const amountLabel = filledDollars != null ? formatUsd(filledDollars) : null;
|
|
2212
2224
|
const executingStep = {
|
|
@@ -2255,6 +2267,17 @@ var buildPlaceOrderFailureSummary = ({
|
|
|
2255
2267
|
} : null;
|
|
2256
2268
|
const primaryNonFilledEvent = (_a = sortedEvents.find((e) => e.event !== "filled")) != null ? _a : sortedEvents[0];
|
|
2257
2269
|
const parsedRetryVenue = primaryNonFilledEvent ? parseVenue(primaryNonFilledEvent.venue) : null;
|
|
2270
|
+
const failedEventMessage = (_b = sortedEvents.find(
|
|
2271
|
+
(event) => {
|
|
2272
|
+
var _a2;
|
|
2273
|
+
return event.event === "failed" && ((_a2 = event.errorReason) == null ? void 0 : _a2.trim());
|
|
2274
|
+
}
|
|
2275
|
+
)) == null ? void 0 : _b.errorReason;
|
|
2276
|
+
const resolvedErrorMessage = failedEventMessage ? normalizePlaceOrderErrorMessage({
|
|
2277
|
+
errorMessage: failedEventMessage,
|
|
2278
|
+
fallbackMessage: labels.orderFailed,
|
|
2279
|
+
labels
|
|
2280
|
+
}) : overallFailureKind === "partial_fill" ? void 0 : normalizedErrorMessage;
|
|
2258
2281
|
return __spreadProps(__spreadValues({
|
|
2259
2282
|
actionLabel,
|
|
2260
2283
|
actions: resolvePlaceOrderFailureActions({
|
|
@@ -2263,7 +2286,7 @@ var buildPlaceOrderFailureSummary = ({
|
|
|
2263
2286
|
labels,
|
|
2264
2287
|
terminalEvent: primaryNonFilledEvent
|
|
2265
2288
|
}),
|
|
2266
|
-
errorMessage:
|
|
2289
|
+
errorMessage: resolvedErrorMessage,
|
|
2267
2290
|
eventImage,
|
|
2268
2291
|
eventSubtitle,
|
|
2269
2292
|
eventTitle,
|
|
@@ -2489,7 +2512,8 @@ var resolveActualFillPresentation = ({
|
|
|
2489
2512
|
};
|
|
2490
2513
|
var resolveBackendStepStatus = (status) => {
|
|
2491
2514
|
if (status === "completed" || status === "skipped") return "done";
|
|
2492
|
-
if (status === "
|
|
2515
|
+
if (status === "failed") return "failed";
|
|
2516
|
+
if (status === "in_progress") return "loading";
|
|
2493
2517
|
return "not-started";
|
|
2494
2518
|
};
|
|
2495
2519
|
var resolveOrderFallbackFill = (quoteData, order, orderIndex) => {
|
|
@@ -2600,20 +2624,35 @@ var deriveBackendExecutionOrderGroups = ({
|
|
|
2600
2624
|
});
|
|
2601
2625
|
const usesBackendPendingLabel = step.groupStatus === "pending" || step.groupStatus === "in_progress" || step.groupStatus === "failed";
|
|
2602
2626
|
const usesBackendCompletedLabel = step.groupStatus === "completed" || step.groupStatus === "skipped";
|
|
2627
|
+
const isPartialFillStep = step.kind === "fill" && order.event === "partial_fill";
|
|
2628
|
+
const partialFillLabel = labels.orderPartiallyFilledAtPriceWithAmount(
|
|
2629
|
+
presentation.venueLabel,
|
|
2630
|
+
presentation.priceLabel,
|
|
2631
|
+
presentation.amountLabel
|
|
2632
|
+
);
|
|
2603
2633
|
return {
|
|
2604
2634
|
id: `${order.orderId}:${step.groupId}`,
|
|
2605
2635
|
kind: step.kind,
|
|
2606
|
-
pendingLabel: usesBackendPendingLabel ? step.label : fallbackLabels.pendingLabel,
|
|
2607
|
-
completedLabel: usesBackendCompletedLabel ? step.label : fallbackLabels.completedLabel,
|
|
2608
|
-
realStatus: forceCompleted ? "done" : resolveBackendStepStatus(step.groupStatus)
|
|
2636
|
+
pendingLabel: isPartialFillStep ? partialFillLabel : usesBackendPendingLabel ? step.label : fallbackLabels.pendingLabel,
|
|
2637
|
+
completedLabel: isPartialFillStep ? partialFillLabel : usesBackendCompletedLabel ? step.label : fallbackLabels.completedLabel,
|
|
2638
|
+
realStatus: isPartialFillStep ? "warning" : forceCompleted ? "done" : resolveBackendStepStatus(step.groupStatus)
|
|
2609
2639
|
};
|
|
2610
2640
|
});
|
|
2611
2641
|
if (steps.length === 0) return [];
|
|
2612
2642
|
return [__spreadProps(__spreadValues({ id: order.orderId }, presentation), { steps })];
|
|
2613
2643
|
});
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2644
|
+
const allOrdersTerminal = executionOrders.every((order) => order.event !== null);
|
|
2645
|
+
return deriveSequentialDisplayGroups(realGroups, allOrdersTerminal);
|
|
2646
|
+
};
|
|
2647
|
+
var deriveSequentialDisplayGroups = (groups, revealTerminalOutcomes = false) => {
|
|
2648
|
+
if (revealTerminalOutcomes) {
|
|
2649
|
+
return groups.map((group) => __spreadProps(__spreadValues({}, group), {
|
|
2650
|
+
steps: group.steps.map((_a) => {
|
|
2651
|
+
var _b = _a, { realStatus } = _b, step = __objRest(_b, ["realStatus"]);
|
|
2652
|
+
return __spreadProps(__spreadValues({}, step), { status: realStatus });
|
|
2653
|
+
})
|
|
2654
|
+
}));
|
|
2655
|
+
}
|
|
2617
2656
|
let hasUnresolvedPredecessor = false;
|
|
2618
2657
|
return groups.map((group) => __spreadProps(__spreadValues({}, group), {
|
|
2619
2658
|
steps: group.steps.map((_a) => {
|
|
@@ -2679,6 +2718,9 @@ var deriveExecutionOrderGroups = ({
|
|
|
2679
2718
|
const hasSuccessfulTerminalEvent = venueTerminalEvents.some(
|
|
2680
2719
|
(event) => event.event === "filled" || event.event === "partial_fill"
|
|
2681
2720
|
);
|
|
2721
|
+
const hasPartialTerminalEvent = venueTerminalEvents.some(
|
|
2722
|
+
(event) => event.event === "partial_fill"
|
|
2723
|
+
);
|
|
2682
2724
|
const hasVenueExecutionProgress = venueRawSteps.some(isRawStepStarted);
|
|
2683
2725
|
const quotedAmount = fill.venueQty * fill.avgPrice;
|
|
2684
2726
|
const actualFill = resolveActualFillPresentation({
|
|
@@ -2688,6 +2730,11 @@ var deriveExecutionOrderGroups = ({
|
|
|
2688
2730
|
});
|
|
2689
2731
|
const completedAmountLabel = tradeSide === "buy" ? formatUsd(actualFill.amount) : labels.executionShares(formatTokenAmount(fill.venueQty));
|
|
2690
2732
|
const completedPriceLabel = getTradingRoutePriceLabel(actualFill.price);
|
|
2733
|
+
const partialFillLabel = labels.orderPartiallyFilledAtPriceWithAmount(
|
|
2734
|
+
venueLabel,
|
|
2735
|
+
completedPriceLabel,
|
|
2736
|
+
completedAmountLabel
|
|
2737
|
+
);
|
|
2691
2738
|
const setupRawSteps = rawExecutionSteps.filter(
|
|
2692
2739
|
(step) => setupCosts.some((setupCost) => isSetupRawStep(step, setupCost))
|
|
2693
2740
|
);
|
|
@@ -2699,7 +2746,7 @@ var deriveExecutionOrderGroups = ({
|
|
|
2699
2746
|
steps: bridgeRawSteps,
|
|
2700
2747
|
nextPhaseStarted: hasVenueExecutionProgress || hasSuccessfulTerminalEvent
|
|
2701
2748
|
});
|
|
2702
|
-
const executionStatus = forceCompleted || hasSuccessfulTerminalEvent ? "done" : resolveRawPhaseStatus({ steps: venueRawSteps });
|
|
2749
|
+
const executionStatus = hasPartialTerminalEvent ? "warning" : forceCompleted || hasSuccessfulTerminalEvent ? "done" : resolveRawPhaseStatus({ steps: venueRawSteps });
|
|
2703
2750
|
const groupId = `${normalizeIdentity(fill.venue) || "venue"}-${fillIndex}`;
|
|
2704
2751
|
const steps = [
|
|
2705
2752
|
{
|
|
@@ -2731,8 +2778,8 @@ var deriveExecutionOrderGroups = ({
|
|
|
2731
2778
|
{
|
|
2732
2779
|
id: `${groupId}-execute`,
|
|
2733
2780
|
kind: "fill",
|
|
2734
|
-
pendingLabel: labels.fillingOnVenue(venueLabel),
|
|
2735
|
-
completedLabel: labels.venueFilledAtPriceWithAmount(
|
|
2781
|
+
pendingLabel: hasPartialTerminalEvent ? partialFillLabel : labels.fillingOnVenue(venueLabel),
|
|
2782
|
+
completedLabel: hasPartialTerminalEvent ? partialFillLabel : labels.venueFilledAtPriceWithAmount(
|
|
2736
2783
|
venueLabel,
|
|
2737
2784
|
completedAmountLabel,
|
|
2738
2785
|
completedPriceLabel
|
|
@@ -2749,7 +2796,92 @@ var deriveExecutionOrderGroups = ({
|
|
|
2749
2796
|
steps
|
|
2750
2797
|
};
|
|
2751
2798
|
});
|
|
2752
|
-
return deriveSequentialDisplayGroups(
|
|
2799
|
+
return deriveSequentialDisplayGroups(
|
|
2800
|
+
realGroups,
|
|
2801
|
+
terminalOrderEvents.length >= quoteData.fills.length && quoteData.fills.length > 0
|
|
2802
|
+
);
|
|
2803
|
+
};
|
|
2804
|
+
var EXECUTION_MILESTONE_WEIGHTS = {
|
|
2805
|
+
submit: 20,
|
|
2806
|
+
setup: 20,
|
|
2807
|
+
bridge: 20,
|
|
2808
|
+
fill: 40
|
|
2809
|
+
};
|
|
2810
|
+
var COMPLETED_MILESTONE_GROUP_STATUSES = /* @__PURE__ */ new Set([
|
|
2811
|
+
"completed",
|
|
2812
|
+
"skipped"
|
|
2813
|
+
]);
|
|
2814
|
+
var TERMINAL_EXECUTION_GROUP_STATUSES = /* @__PURE__ */ new Set([
|
|
2815
|
+
"completed",
|
|
2816
|
+
"failed",
|
|
2817
|
+
"skipped"
|
|
2818
|
+
]);
|
|
2819
|
+
var uniqueGroupsForOrderAndKind = ({
|
|
2820
|
+
kind,
|
|
2821
|
+
orderId,
|
|
2822
|
+
steps
|
|
2823
|
+
}) => {
|
|
2824
|
+
var _a;
|
|
2825
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2826
|
+
for (const step of steps) {
|
|
2827
|
+
if (step.kind !== kind || !((_a = step.orderIds) == null ? void 0 : _a.includes(orderId)) || groups.has(step.groupId))
|
|
2828
|
+
continue;
|
|
2829
|
+
groups.set(step.groupId, step);
|
|
2830
|
+
}
|
|
2831
|
+
return Array.from(groups.values());
|
|
2832
|
+
};
|
|
2833
|
+
var calculateExecutionProgress = ({
|
|
2834
|
+
orderIds,
|
|
2835
|
+
submittedOrderIds = [],
|
|
2836
|
+
executionSteps = [],
|
|
2837
|
+
executionOrders = [],
|
|
2838
|
+
minimumProgress = 0
|
|
2839
|
+
}) => {
|
|
2840
|
+
const resolvedOrderIds = orderIds.length > 0 ? orderIds : executionOrders.map((order) => order.orderId);
|
|
2841
|
+
if (resolvedOrderIds.length === 0) return 0;
|
|
2842
|
+
const submittedIds = new Set(submittedOrderIds);
|
|
2843
|
+
const orderById = new Map(executionOrders.map((order) => [order.orderId, order]));
|
|
2844
|
+
const hasAuthoritativeTopology = executionSteps.some(
|
|
2845
|
+
(step) => {
|
|
2846
|
+
var _a, _b;
|
|
2847
|
+
return step.kind !== "internal" && step.kind !== "submit" && ((_b = (_a = step.orderIds) == null ? void 0 : _a.length) != null ? _b : 0) > 0;
|
|
2848
|
+
}
|
|
2849
|
+
);
|
|
2850
|
+
let progress = 0;
|
|
2851
|
+
for (const orderId of resolvedOrderIds) {
|
|
2852
|
+
const order = orderById.get(orderId);
|
|
2853
|
+
const isOrderTerminal = (order == null ? void 0 : order.event) !== null && (order == null ? void 0 : order.event) !== void 0;
|
|
2854
|
+
const contributionScale = 1 / resolvedOrderIds.length;
|
|
2855
|
+
const submitGroups = uniqueGroupsForOrderAndKind({
|
|
2856
|
+
kind: "submit",
|
|
2857
|
+
orderId,
|
|
2858
|
+
steps: executionSteps
|
|
2859
|
+
});
|
|
2860
|
+
const setupGroups = uniqueGroupsForOrderAndKind({
|
|
2861
|
+
kind: "setup",
|
|
2862
|
+
orderId,
|
|
2863
|
+
steps: executionSteps
|
|
2864
|
+
});
|
|
2865
|
+
const bridgeGroups = uniqueGroupsForOrderAndKind({
|
|
2866
|
+
kind: "bridge",
|
|
2867
|
+
orderId,
|
|
2868
|
+
steps: executionSteps
|
|
2869
|
+
});
|
|
2870
|
+
const fillGroups = uniqueGroupsForOrderAndKind({
|
|
2871
|
+
kind: "fill",
|
|
2872
|
+
orderId,
|
|
2873
|
+
steps: executionSteps
|
|
2874
|
+
});
|
|
2875
|
+
const submissionComplete = isOrderTerminal || submittedIds.has(orderId) || submitGroups.some((step) => COMPLETED_MILESTONE_GROUP_STATUSES.has(step.groupStatus));
|
|
2876
|
+
const fundingComplete = isOrderTerminal || hasAuthoritativeTopology && (setupGroups.length === 0 || setupGroups.every((step) => COMPLETED_MILESTONE_GROUP_STATUSES.has(step.groupStatus)));
|
|
2877
|
+
const bridgingComplete = isOrderTerminal || hasAuthoritativeTopology && (bridgeGroups.length === 0 || bridgeGroups.every((step) => COMPLETED_MILESTONE_GROUP_STATUSES.has(step.groupStatus)));
|
|
2878
|
+
const executionComplete = isOrderTerminal || fillGroups.length > 0 && fillGroups.every((step) => TERMINAL_EXECUTION_GROUP_STATUSES.has(step.groupStatus));
|
|
2879
|
+
if (submissionComplete) progress += EXECUTION_MILESTONE_WEIGHTS.submit * contributionScale;
|
|
2880
|
+
if (fundingComplete) progress += EXECUTION_MILESTONE_WEIGHTS.setup * contributionScale;
|
|
2881
|
+
if (bridgingComplete) progress += EXECUTION_MILESTONE_WEIGHTS.bridge * contributionScale;
|
|
2882
|
+
if (executionComplete) progress += EXECUTION_MILESTONE_WEIGHTS.fill * contributionScale;
|
|
2883
|
+
}
|
|
2884
|
+
return Math.min(100, Math.max(0, minimumProgress, Math.round(progress)));
|
|
2753
2885
|
};
|
|
2754
2886
|
|
|
2755
2887
|
// src/trading/place-order/index.place-order.execution-view.tsx
|
|
@@ -2801,6 +2933,28 @@ var ExecutionStepIndicator = ({
|
|
|
2801
2933
|
}
|
|
2802
2934
|
) });
|
|
2803
2935
|
}
|
|
2936
|
+
if (step.status === "failed") {
|
|
2937
|
+
return /* @__PURE__ */ jsx4(
|
|
2938
|
+
Icon,
|
|
2939
|
+
{
|
|
2940
|
+
name: "error-filled",
|
|
2941
|
+
size: "xs",
|
|
2942
|
+
className: "h-3 w-3 shrink-0 text-agg-error",
|
|
2943
|
+
"aria-hidden": "true"
|
|
2944
|
+
}
|
|
2945
|
+
);
|
|
2946
|
+
}
|
|
2947
|
+
if (step.status === "warning") {
|
|
2948
|
+
return /* @__PURE__ */ jsx4(
|
|
2949
|
+
Icon,
|
|
2950
|
+
{
|
|
2951
|
+
name: "warning-filled",
|
|
2952
|
+
size: "xs",
|
|
2953
|
+
className: "h-3 w-3 shrink-0 text-agg-warning",
|
|
2954
|
+
"aria-hidden": "true"
|
|
2955
|
+
}
|
|
2956
|
+
);
|
|
2957
|
+
}
|
|
2804
2958
|
return /* @__PURE__ */ jsx4(
|
|
2805
2959
|
"span",
|
|
2806
2960
|
{
|
|
@@ -2864,10 +3018,9 @@ var PlaceOrderExecutionView = ({
|
|
|
2864
3018
|
eventImage,
|
|
2865
3019
|
eventTitle,
|
|
2866
3020
|
groups,
|
|
2867
|
-
labels
|
|
3021
|
+
labels,
|
|
3022
|
+
progress
|
|
2868
3023
|
}) => {
|
|
2869
|
-
const steps = groups.flatMap((group) => group.steps);
|
|
2870
|
-
const completedStepCount = steps.filter((step) => step.status === "done").length;
|
|
2871
3024
|
return /* @__PURE__ */ jsx4(
|
|
2872
3025
|
Card,
|
|
2873
3026
|
{
|
|
@@ -2888,30 +3041,18 @@ var PlaceOrderExecutionView = ({
|
|
|
2888
3041
|
}
|
|
2889
3042
|
),
|
|
2890
3043
|
/* @__PURE__ */ jsxs3("div", { className: cn("flex flex-col gap-5", classNames == null ? void 0 : classNames.content), children: [
|
|
2891
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex
|
|
2892
|
-
/* @__PURE__ */
|
|
3044
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3", children: [
|
|
3045
|
+
/* @__PURE__ */ jsxs3("p", { className: "shrink-0 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: [
|
|
3046
|
+
progress,
|
|
3047
|
+
"%"
|
|
3048
|
+
] }),
|
|
2893
3049
|
/* @__PURE__ */ jsx4(
|
|
2894
|
-
"
|
|
3050
|
+
"progress",
|
|
2895
3051
|
{
|
|
2896
|
-
role: "progressbar",
|
|
2897
3052
|
"aria-label": labels.executingOrder,
|
|
2898
|
-
"
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
className: "flex h-1 w-full gap-0.5",
|
|
2902
|
-
children: steps.map((step) => /* @__PURE__ */ jsx4(
|
|
2903
|
-
"span",
|
|
2904
|
-
{
|
|
2905
|
-
"data-testid": "execution-progress-segment",
|
|
2906
|
-
className: cn(
|
|
2907
|
-
"h-1 min-w-0 flex-1 rounded-agg-full",
|
|
2908
|
-
step.status === "done" ? "bg-agg-primary" : "bg-agg-separator"
|
|
2909
|
-
),
|
|
2910
|
-
"aria-hidden": "true",
|
|
2911
|
-
"data-status": step.status
|
|
2912
|
-
},
|
|
2913
|
-
step.id
|
|
2914
|
-
))
|
|
3053
|
+
className: "h-1 min-w-0 flex-1 overflow-hidden rounded-agg-full bg-agg-separator text-agg-primary accent-agg-primary [&::-moz-progress-bar]:bg-agg-primary [&::-webkit-progress-bar]:bg-agg-separator [&::-webkit-progress-value]:bg-agg-primary",
|
|
3054
|
+
max: 100,
|
|
3055
|
+
value: progress
|
|
2915
3056
|
}
|
|
2916
3057
|
)
|
|
2917
3058
|
] }),
|
|
@@ -2974,7 +3115,7 @@ var PlaceOrderFailureView = ({
|
|
|
2974
3115
|
onDone,
|
|
2975
3116
|
onSkip
|
|
2976
3117
|
}) => {
|
|
2977
|
-
var _a, _b, _c;
|
|
3118
|
+
var _a, _b, _c, _d, _e;
|
|
2978
3119
|
const shouldShowPartialFailureLayout = summary.kind === "partial_fill";
|
|
2979
3120
|
const failureStepGroups = shouldShowPartialFailureLayout ? groupPlaceOrderFailureSteps(summary.steps) : [];
|
|
2980
3121
|
if (shouldShowPartialFailureLayout) {
|
|
@@ -2993,14 +3134,42 @@ var PlaceOrderFailureView = ({
|
|
|
2993
3134
|
] }),
|
|
2994
3135
|
summary.eventSubtitle ? /* @__PURE__ */ jsx5("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
|
|
2995
3136
|
] }),
|
|
2996
|
-
/* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-4", children:
|
|
2997
|
-
|
|
3137
|
+
/* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-4", children: ((_b = summary.executionGroups) == null ? void 0 : _b.length) ? /* @__PURE__ */ jsx5(
|
|
3138
|
+
PlaceOrderExecutionGroups,
|
|
3139
|
+
{
|
|
3140
|
+
enableAnimations: false,
|
|
3141
|
+
groups: summary.executionGroups,
|
|
3142
|
+
labels: tradingLabels
|
|
3143
|
+
}
|
|
3144
|
+
) : failureStepGroups.map((group, groupIndex) => /* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-2", children: group.map((step) => renderPartialFailureStep(step)) }, `failure-group-${groupIndex}`)) }),
|
|
3145
|
+
summary.errorMessage ? /* @__PURE__ */ jsx5(
|
|
3146
|
+
InlineAlert,
|
|
3147
|
+
{
|
|
3148
|
+
tone: "error",
|
|
3149
|
+
variant: "surface",
|
|
3150
|
+
message: tradingLabels.orderFailureDescription(summary.errorMessage)
|
|
3151
|
+
}
|
|
3152
|
+
) : null,
|
|
3153
|
+
summary.result ? /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-4", children: [
|
|
3154
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4", children: [
|
|
3155
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 flex-col", children: [
|
|
3156
|
+
/* @__PURE__ */ jsx5("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.orderPartiallyFilled }),
|
|
3157
|
+
/* @__PURE__ */ jsx5("p", { className: "text-agg-sm leading-agg-5 text-agg-muted-foreground", children: tradingLabels.orderAveragePrice(summary.result.averagePriceLabel) })
|
|
3158
|
+
] }),
|
|
3159
|
+
/* @__PURE__ */ jsx5("p", { className: "shrink-0 text-right text-[30px] font-agg-bold leading-[36px] text-agg-foreground", children: summary.result.filledAmountLabel })
|
|
3160
|
+
] }),
|
|
3161
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4", children: [
|
|
3162
|
+
/* @__PURE__ */ jsx5("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.orderPayout }),
|
|
3163
|
+
/* @__PURE__ */ jsx5("p", { className: "shrink-0 text-right text-[30px] font-agg-bold leading-[36px] text-agg-success", children: summary.result.payoutLabel })
|
|
3164
|
+
] })
|
|
3165
|
+
] }) : null,
|
|
3166
|
+
/* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-4", children: summary.actions.map((action) => /* @__PURE__ */ jsx5(
|
|
2998
3167
|
Button,
|
|
2999
3168
|
{
|
|
3000
|
-
variant: "
|
|
3169
|
+
variant: action.variant === "retry" ? "primary" : "secondary",
|
|
3001
3170
|
size: "medium",
|
|
3002
3171
|
"aria-label": action.label,
|
|
3003
|
-
className: "
|
|
3172
|
+
className: "w-full",
|
|
3004
3173
|
onClick: resolveFailureActionHandler({ action, onDone, onRetry, onSkip }),
|
|
3005
3174
|
children: action.label
|
|
3006
3175
|
},
|
|
@@ -3014,7 +3183,7 @@ var PlaceOrderFailureView = ({
|
|
|
3014
3183
|
/* @__PURE__ */ jsx5(
|
|
3015
3184
|
RemoteImage,
|
|
3016
3185
|
{
|
|
3017
|
-
src: (
|
|
3186
|
+
src: (_c = summary.eventImage) != null ? _c : null,
|
|
3018
3187
|
alt: "",
|
|
3019
3188
|
className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
|
|
3020
3189
|
}
|
|
@@ -3023,21 +3192,29 @@ var PlaceOrderFailureView = ({
|
|
|
3023
3192
|
] }),
|
|
3024
3193
|
summary.eventSubtitle ? /* @__PURE__ */ jsx5("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
|
|
3025
3194
|
] }),
|
|
3195
|
+
((_d = summary.executionGroups) == null ? void 0 : _d.length) ? /* @__PURE__ */ jsx5(
|
|
3196
|
+
PlaceOrderExecutionGroups,
|
|
3197
|
+
{
|
|
3198
|
+
enableAnimations: false,
|
|
3199
|
+
groups: summary.executionGroups,
|
|
3200
|
+
labels: tradingLabels
|
|
3201
|
+
}
|
|
3202
|
+
) : null,
|
|
3026
3203
|
/* @__PURE__ */ jsx5(
|
|
3027
3204
|
InlineAlert,
|
|
3028
3205
|
{
|
|
3029
3206
|
tone: "error",
|
|
3030
3207
|
variant: "surface",
|
|
3031
3208
|
title: tradingLabels.orderFailureTitle,
|
|
3032
|
-
message: tradingLabels.orderFailureDescription((
|
|
3209
|
+
message: tradingLabels.orderFailureDescription((_e = summary.errorMessage) != null ? _e : "")
|
|
3033
3210
|
}
|
|
3034
3211
|
),
|
|
3035
|
-
/* @__PURE__ */ jsx5("div", { className: "agg-order-failure-actions flex
|
|
3212
|
+
/* @__PURE__ */ jsx5("div", { className: "agg-order-failure-actions flex flex-col gap-4", children: summary.actions.map((action) => /* @__PURE__ */ jsx5(
|
|
3036
3213
|
Button,
|
|
3037
3214
|
{
|
|
3038
3215
|
variant: action.variant === "retry" ? "primary" : "secondary",
|
|
3039
3216
|
size: "medium",
|
|
3040
|
-
className: "
|
|
3217
|
+
className: "w-full",
|
|
3041
3218
|
"aria-label": action.label,
|
|
3042
3219
|
onClick: resolveFailureActionHandler({ action, onDone, onRetry, onSkip }),
|
|
3043
3220
|
children: action.label
|
|
@@ -3061,7 +3238,7 @@ var PlaceOrderSuccessView = ({
|
|
|
3061
3238
|
onDone,
|
|
3062
3239
|
onShare: _onShare
|
|
3063
3240
|
}) => {
|
|
3064
|
-
var _a, _b, _c, _d, _e
|
|
3241
|
+
var _a, _b, _c, _d, _e;
|
|
3065
3242
|
const resolvedTradeSide = (_a = summary.tradeSide) != null ? _a : "buy";
|
|
3066
3243
|
const resolvedAmountLabel = (_b = summary.amountLabel) != null ? _b : resolvedTradeSide === "sell" ? summary.shares : summary.estimatedCost;
|
|
3067
3244
|
const resolvedPayoutLabel = (_c = summary.toWinLabel) != null ? _c : resolvedTradeSide === "sell" ? summary.estimatedCost : resolveBuyPayoutLabel(summary.shares);
|
|
@@ -3114,15 +3291,11 @@ var PlaceOrderSuccessView = ({
|
|
|
3114
3291
|
},
|
|
3115
3292
|
step.id
|
|
3116
3293
|
)) }) : null,
|
|
3117
|
-
/* @__PURE__ */ jsxs5("div", { className: "agg-order-success-pill flex h-11 w-full items-center justify-center gap-2 rounded-agg-full bg-agg-success px-6 py-2.5 text-center text-agg-base font-agg-bold leading-agg-6 text-agg-on-primary", children: [
|
|
3118
|
-
/* @__PURE__ */ jsx6(Icon, { name: "success-check", size: "xs", className: "h-3 w-3 shrink-0 text-current" }),
|
|
3119
|
-
/* @__PURE__ */ jsx6("span", { children: (_f = summary.actionLabel) != null ? _f : tradingLabels.orderSuccessTitle })
|
|
3120
|
-
] }),
|
|
3121
3294
|
/* @__PURE__ */ jsxs5("div", { className: "agg-order-success-summary flex flex-col gap-4", children: [
|
|
3122
3295
|
/* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-4", children: [
|
|
3123
3296
|
/* @__PURE__ */ jsxs5("div", { className: "flex min-w-0 flex-col", children: [
|
|
3124
|
-
/* @__PURE__ */ jsx6("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: summary.
|
|
3125
|
-
|
|
3297
|
+
/* @__PURE__ */ jsx6("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: summary.resultState === "partial" ? tradingLabels.orderPartiallyFilled : tradingLabels.orderFullyFilled }),
|
|
3298
|
+
/* @__PURE__ */ jsx6("p", { className: "text-agg-sm leading-agg-5 text-agg-muted-foreground", children: tradingLabels.orderAveragePrice(summary.avgPrice) })
|
|
3126
3299
|
] }),
|
|
3127
3300
|
/* @__PURE__ */ jsx6("p", { className: "shrink-0 text-right text-[30px] font-agg-bold leading-[36px] text-agg-foreground", children: resolvedAmountLabel })
|
|
3128
3301
|
] }),
|
|
@@ -3540,13 +3713,14 @@ var PlaceOrderResolvedView = ({
|
|
|
3540
3713
|
resolutionTimestamp,
|
|
3541
3714
|
resolvedClaim,
|
|
3542
3715
|
className,
|
|
3543
|
-
isSportsEvent = false
|
|
3716
|
+
isSportsEvent = false,
|
|
3717
|
+
showResolvingState = false
|
|
3544
3718
|
}) => {
|
|
3545
3719
|
var _a, _b;
|
|
3546
3720
|
const labels = useLabels2();
|
|
3547
3721
|
const tradingLabels = labels.trading;
|
|
3548
3722
|
const resolvingTimestamp = (_a = resolutionTimestamp != null ? resolutionTimestamp : tradingState.resolvesAt) != null ? _a : tradingState.endsAt;
|
|
3549
|
-
const isResolvingMarket =
|
|
3723
|
+
const isResolvingMarket = showResolvingState && !tradingState.winningOutcome;
|
|
3550
3724
|
const resolvingSubtitle = tradingState.market ? (() => {
|
|
3551
3725
|
const endDateLabel = isSportsEvent ? formatSportsEventTimeEt(resolvingTimestamp != null ? resolvingTimestamp : "") : getTradingDateLabel(resolvingTimestamp != null ? resolvingTimestamp : "");
|
|
3552
3726
|
return endDateLabel ? `${tradingState.market.question} \xB7 ${endDateLabel}` : tradingState.market.question;
|
|
@@ -3826,6 +4000,7 @@ var PlaceOrder = ({
|
|
|
3826
4000
|
onError,
|
|
3827
4001
|
onExecutionStateChange,
|
|
3828
4002
|
resolvedClaim,
|
|
4003
|
+
showResolvingState = false,
|
|
3829
4004
|
midpointsResult
|
|
3830
4005
|
}) => {
|
|
3831
4006
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha;
|
|
@@ -3889,7 +4064,7 @@ var PlaceOrder = ({
|
|
|
3889
4064
|
const resolvedReadOnlyTradingState = useMemo(() => {
|
|
3890
4065
|
return resolveMarketTradingState(resolvedReadOnlyMarket);
|
|
3891
4066
|
}, [resolvedReadOnlyMarket]);
|
|
3892
|
-
const isEndedWithoutKnownWinner =
|
|
4067
|
+
const isEndedWithoutKnownWinner = showResolvingState && !resolvedEventTradingState.winningOutcome && !resolvedReadOnlyTradingState.winningOutcome;
|
|
3893
4068
|
const orderEligibility = useMemo(
|
|
3894
4069
|
() => resolveOrderEligibility({
|
|
3895
4070
|
event: scopedSelectedEvent,
|
|
@@ -4525,6 +4700,10 @@ var PlaceOrder = ({
|
|
|
4525
4700
|
mode: isPaperMode ? "paper" : void 0,
|
|
4526
4701
|
enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((_N = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _N.length)
|
|
4527
4702
|
});
|
|
4703
|
+
const executionProgressFloorRef = useRef2({
|
|
4704
|
+
quoteId: null,
|
|
4705
|
+
value: 0
|
|
4706
|
+
});
|
|
4528
4707
|
const selectedOutcomeLabel = (_Q = (_P = (_O = outcomes.find((outcome) => outcome.id === scopedSelectedOutcomeId)) == null ? void 0 : _O.label) != null ? _P : scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.label) != null ? _Q : "";
|
|
4529
4708
|
const headerImage = (_S = (_R = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.image) != null ? _R : scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.image) != null ? _S : null;
|
|
4530
4709
|
const headerTitle = (_U = (_T = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _T : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _U : "";
|
|
@@ -4555,6 +4734,26 @@ var PlaceOrder = ({
|
|
|
4555
4734
|
(_Z = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _Z.length,
|
|
4556
4735
|
tradingLabels
|
|
4557
4736
|
]);
|
|
4737
|
+
const executionProgressPercent = useMemo(() => {
|
|
4738
|
+
var _a2, _b2, _c2;
|
|
4739
|
+
const quoteId = (_a2 = submissionProgressState == null ? void 0 : submissionProgressState.quoteId) != null ? _a2 : null;
|
|
4740
|
+
const previousProgress = executionProgressFloorRef.current.quoteId === quoteId ? executionProgressFloorRef.current.value : 0;
|
|
4741
|
+
const nextProgress = calculateExecutionProgress({
|
|
4742
|
+
orderIds: (_b2 = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) != null ? _b2 : [],
|
|
4743
|
+
submittedOrderIds: executionProgress.submittedOrders.map((order) => order.orderId),
|
|
4744
|
+
executionSteps: executionProgress.executionSteps,
|
|
4745
|
+
executionOrders: (_c2 = executionProgress.executionOrders) != null ? _c2 : [],
|
|
4746
|
+
minimumProgress: previousProgress
|
|
4747
|
+
});
|
|
4748
|
+
executionProgressFloorRef.current = { quoteId, value: nextProgress };
|
|
4749
|
+
return nextProgress;
|
|
4750
|
+
}, [
|
|
4751
|
+
executionProgress.executionOrders,
|
|
4752
|
+
executionProgress.executionSteps,
|
|
4753
|
+
executionProgress.submittedOrders,
|
|
4754
|
+
submissionProgressState == null ? void 0 : submissionProgressState.orderIds,
|
|
4755
|
+
submissionProgressState == null ? void 0 : submissionProgressState.quoteId
|
|
4756
|
+
]);
|
|
4558
4757
|
const buildExecutionSummary = useCallback2(
|
|
4559
4758
|
(quoteData, executionVenue, orderId, partialFillSummary) => {
|
|
4560
4759
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
|
|
@@ -4583,6 +4782,7 @@ var PlaceOrder = ({
|
|
|
4583
4782
|
const eventTitle = (_f2 = (_e2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _e2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _f2 : "";
|
|
4584
4783
|
const eventDateSource = (_g2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate) != null ? _g2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate;
|
|
4585
4784
|
return {
|
|
4785
|
+
resultState: partialFillSummary ? "partial" : "success",
|
|
4586
4786
|
tradeSide: internalTab,
|
|
4587
4787
|
shares: sharesLabel,
|
|
4588
4788
|
avgPrice: avgPriceLabel,
|
|
@@ -4923,31 +5123,30 @@ var PlaceOrder = ({
|
|
|
4923
5123
|
});
|
|
4924
5124
|
}, [isSell, orderedRouteCards.length, smartRoute.error, tradingLabels, venueSellQuotes.error]);
|
|
4925
5125
|
const progressActionLabel = (internalTab === "buy" ? tradingLabels.buyingOutcome(selectedOutcomeLabel) : tradingLabels.sellingOutcome(selectedOutcomeLabel)).trim();
|
|
4926
|
-
const
|
|
4927
|
-
|
|
5126
|
+
const retryRemainingAmount = useMemo(() => {
|
|
5127
|
+
return getCanonicalPlaceOrderUnfilledRemaining({
|
|
4928
5128
|
originalAmount: internalAmount,
|
|
4929
5129
|
tradeSide: internalTab,
|
|
4930
5130
|
terminalOrderEvents: executionProgress.terminalOrderEvents
|
|
4931
5131
|
});
|
|
5132
|
+
}, [executionProgress.terminalOrderEvents, internalAmount, internalTab]);
|
|
5133
|
+
const canRetryRemaining = useMemo(() => {
|
|
5134
|
+
if (retryRemainingAmount == null) return false;
|
|
4932
5135
|
const minRemainder = isSell ? MIN_SELL_ORDER_SHARES : MIN_BUY_ORDER_AMOUNT;
|
|
4933
|
-
return
|
|
4934
|
-
}, [
|
|
5136
|
+
return retryRemainingAmount >= minRemainder;
|
|
5137
|
+
}, [isSell, retryRemainingAmount]);
|
|
4935
5138
|
const PARTIAL_FILL_AUTO_SUCCESS_THRESHOLD = 0.95;
|
|
4936
5139
|
const shouldAutoSkipPartialFill = useMemo(() => {
|
|
4937
|
-
if (internalAmount <= 0) return false;
|
|
4938
|
-
const
|
|
4939
|
-
originalAmount: internalAmount,
|
|
4940
|
-
tradeSide: internalTab,
|
|
4941
|
-
terminalOrderEvents: executionProgress.terminalOrderEvents
|
|
4942
|
-
});
|
|
4943
|
-
const filled = Math.max(0, internalAmount - remaining);
|
|
5140
|
+
if (internalAmount <= 0 || retryRemainingAmount == null) return false;
|
|
5141
|
+
const filled = Math.max(0, internalAmount - retryRemainingAmount);
|
|
4944
5142
|
const fillRatio = filled / internalAmount;
|
|
4945
5143
|
return fillRatio >= PARTIAL_FILL_AUTO_SUCCESS_THRESHOLD || !canRetryRemaining;
|
|
4946
|
-
}, [canRetryRemaining,
|
|
5144
|
+
}, [canRetryRemaining, internalAmount, retryRemainingAmount]);
|
|
4947
5145
|
const failureSummary = useMemo(() => {
|
|
4948
5146
|
var _a2;
|
|
4949
5147
|
if ((submissionProgressState == null ? void 0 : submissionProgressState.phase) !== "failed") return void 0;
|
|
4950
|
-
|
|
5148
|
+
const quoteData = (_a2 = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _a2 : activeQuoteData;
|
|
5149
|
+
const baseSummary = buildPlaceOrderFailureSummary({
|
|
4951
5150
|
actionLabel: progressActionLabel,
|
|
4952
5151
|
canRetryRemaining,
|
|
4953
5152
|
errorMessage: submissionProgressState.errorMessage,
|
|
@@ -4956,19 +5155,53 @@ var PlaceOrder = ({
|
|
|
4956
5155
|
eventTitle: headerTitle || tradingLabels.orderFailureTitle,
|
|
4957
5156
|
labels: tradingLabels,
|
|
4958
5157
|
orderId: submissionProgressState.orderId,
|
|
4959
|
-
quoteData
|
|
5158
|
+
quoteData,
|
|
4960
5159
|
submittedOrders: executionProgress.submittedOrders,
|
|
4961
5160
|
terminalOrderEvents: executionProgress.terminalOrderEvents
|
|
4962
5161
|
});
|
|
5162
|
+
const summaryWithGroups = __spreadValues(__spreadValues({}, baseSummary), executionOrderGroups.length > 0 ? { executionGroups: executionOrderGroups } : {});
|
|
5163
|
+
if (baseSummary.kind !== "partial_fill") return summaryWithGroups;
|
|
5164
|
+
const actualEconomics = resolveActualExecutionEconomics({
|
|
5165
|
+
quoteData,
|
|
5166
|
+
tradeSide: internalTab,
|
|
5167
|
+
terminalOrderEvents: executionProgress.terminalOrderEvents,
|
|
5168
|
+
submittedOrders: executionProgress.submittedOrders
|
|
5169
|
+
});
|
|
5170
|
+
if (!actualEconomics.hasActualFillData) return summaryWithGroups;
|
|
5171
|
+
if (retryRemainingAmount == null) return summaryWithGroups;
|
|
5172
|
+
const remaining = retryRemainingAmount;
|
|
5173
|
+
const remainingLabel = isSell ? tradingLabels.executionShares(
|
|
5174
|
+
remaining.toLocaleString("en-US", { maximumFractionDigits: 2 })
|
|
5175
|
+
) : formatUsd(remaining);
|
|
5176
|
+
const filledAmountLabel = isSell ? tradingLabels.executionShares(
|
|
5177
|
+
actualEconomics.actualTotalFilled.toLocaleString("en-US", {
|
|
5178
|
+
maximumFractionDigits: 2
|
|
5179
|
+
})
|
|
5180
|
+
) : formatUsd(actualEconomics.actualRawExecCost);
|
|
5181
|
+
const payoutLabel = isSell ? formatUsd(actualEconomics.actualRawExecCost) : formatUsd(actualEconomics.actualTotalFilled);
|
|
5182
|
+
return __spreadProps(__spreadValues({}, summaryWithGroups), {
|
|
5183
|
+
actions: summaryWithGroups.actions.map(
|
|
5184
|
+
(action) => action.variant === "retry" ? __spreadProps(__spreadValues({}, action), { label: tradingLabels.orderTryRemaining(remainingLabel) }) : action
|
|
5185
|
+
),
|
|
5186
|
+
result: {
|
|
5187
|
+
averagePriceLabel: getTradingRoutePriceLabel(actualEconomics.avgExecutionPrice),
|
|
5188
|
+
filledAmountLabel,
|
|
5189
|
+
payoutLabel
|
|
5190
|
+
}
|
|
5191
|
+
});
|
|
4963
5192
|
}, [
|
|
4964
5193
|
activeQuoteData,
|
|
4965
5194
|
canRetryRemaining,
|
|
5195
|
+
executionOrderGroups,
|
|
4966
5196
|
executionProgress.submittedOrders,
|
|
4967
5197
|
executionProgress.terminalOrderEvents,
|
|
4968
5198
|
headerImage,
|
|
4969
5199
|
headerSubtitle,
|
|
4970
5200
|
headerTitle,
|
|
5201
|
+
internalTab,
|
|
5202
|
+
isSell,
|
|
4971
5203
|
progressActionLabel,
|
|
5204
|
+
retryRemainingAmount,
|
|
4972
5205
|
selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData,
|
|
4973
5206
|
submissionProgressState,
|
|
4974
5207
|
tradingLabels
|
|
@@ -5492,7 +5725,7 @@ var PlaceOrder = ({
|
|
|
5492
5725
|
if (!shouldAutoSkipPartialFill) return;
|
|
5493
5726
|
handleSkipToSuccess();
|
|
5494
5727
|
}, [
|
|
5495
|
-
failureSummary
|
|
5728
|
+
failureSummary,
|
|
5496
5729
|
handleSkipToSuccess,
|
|
5497
5730
|
shouldAutoSkipPartialFill,
|
|
5498
5731
|
submissionProgressState == null ? void 0 : submissionProgressState.phase
|
|
@@ -5506,12 +5739,8 @@ var PlaceOrder = ({
|
|
|
5506
5739
|
setSubmissionFeedback(null);
|
|
5507
5740
|
let retryAmount = internalAmount;
|
|
5508
5741
|
let useRemainderRoute = false;
|
|
5509
|
-
if ((failureSummary == null ? void 0 : failureSummary.kind) === "partial_fill" && internalAmount > 0) {
|
|
5510
|
-
const remaining =
|
|
5511
|
-
originalAmount: internalAmount,
|
|
5512
|
-
tradeSide: internalTab,
|
|
5513
|
-
terminalOrderEvents: executionProgress.terminalOrderEvents
|
|
5514
|
-
});
|
|
5742
|
+
if ((failureSummary == null ? void 0 : failureSummary.kind) === "partial_fill" && internalAmount > 0 && retryRemainingAmount != null) {
|
|
5743
|
+
const remaining = retryRemainingAmount;
|
|
5515
5744
|
if (remaining > 0) {
|
|
5516
5745
|
retryAmount = remaining;
|
|
5517
5746
|
useRemainderRoute = true;
|
|
@@ -5631,8 +5860,7 @@ var PlaceOrder = ({
|
|
|
5631
5860
|
}), [
|
|
5632
5861
|
aggClient,
|
|
5633
5862
|
chainBalancesOverride,
|
|
5634
|
-
|
|
5635
|
-
failureSummary == null ? void 0 : failureSummary.kind,
|
|
5863
|
+
failureSummary,
|
|
5636
5864
|
handleExecuteQuote,
|
|
5637
5865
|
handleReturnToOrderForm,
|
|
5638
5866
|
internalAmount,
|
|
@@ -5642,6 +5870,7 @@ var PlaceOrder = ({
|
|
|
5642
5870
|
onAmountChange,
|
|
5643
5871
|
orderEligibility.canPlaceOrder,
|
|
5644
5872
|
orderedRouteCards,
|
|
5873
|
+
retryRemainingAmount,
|
|
5645
5874
|
scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets,
|
|
5646
5875
|
scopedSelectedOutcomeId,
|
|
5647
5876
|
selectedRouteCardId,
|
|
@@ -5697,7 +5926,8 @@ var PlaceOrder = ({
|
|
|
5697
5926
|
eventImage: headerImage,
|
|
5698
5927
|
eventTitle: headerTitle,
|
|
5699
5928
|
groups: executionOrderGroups,
|
|
5700
|
-
labels: tradingLabels
|
|
5929
|
+
labels: tradingLabels,
|
|
5930
|
+
progress: executionProgressPercent
|
|
5701
5931
|
}
|
|
5702
5932
|
);
|
|
5703
5933
|
}
|
|
@@ -5912,7 +6142,8 @@ var PlaceOrder = ({
|
|
|
5912
6142
|
resolvedClaim,
|
|
5913
6143
|
classNames,
|
|
5914
6144
|
className,
|
|
5915
|
-
isSportsEvent: (scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.structureType) === "sport" && !!(scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.sport) && scopedSelectedEvent.sport !== "other_sport"
|
|
6145
|
+
isSportsEvent: (scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.structureType) === "sport" && !!(scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.sport) && scopedSelectedEvent.sport !== "other_sport",
|
|
6146
|
+
showResolvingState
|
|
5916
6147
|
}
|
|
5917
6148
|
);
|
|
5918
6149
|
}
|
|
@@ -6992,7 +7223,7 @@ function useResolvedMarketClaim(options = {}) {
|
|
|
6992
7223
|
});
|
|
6993
7224
|
} : void 0
|
|
6994
7225
|
};
|
|
6995
|
-
}, [claimWinnings, marketId, positions, shouldFetch]);
|
|
7226
|
+
}, [claimWinnings, market, marketId, positions, shouldFetch]);
|
|
6996
7227
|
}
|
|
6997
7228
|
|
|
6998
7229
|
export {
|