@agg-build/ui 2.7.3 → 3.0.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/dist/{chunk-EDQ64EKO.mjs → chunk-JTSLZARU.mjs} +6 -5
- package/dist/{chunk-FMYYPNZZ.mjs → chunk-KO6VTRV6.mjs} +101 -27
- package/dist/{chunk-AHQA3B7D.mjs → chunk-KX3TQ7WC.mjs} +1 -1
- package/dist/{chunk-7DM45TMO.mjs → chunk-MKU5Q6PN.mjs} +21 -13
- package/dist/{chunk-MZBYIXYA.mjs → chunk-R362GNI2.mjs} +1310 -500
- package/dist/{chunk-JQKJDSTW.mjs → chunk-VR5ZRDQT.mjs} +3 -2
- package/dist/{chunk-O27JUYCF.mjs → chunk-XIDQ2A6W.mjs} +645 -346
- package/dist/events.js +168 -91
- package/dist/events.mjs +3 -3
- package/dist/index.js +2784 -1606
- package/dist/index.mjs +9 -7
- package/dist/modals.js +98 -29
- package/dist/modals.mjs +3 -3
- package/dist/pages.js +2510 -1333
- package/dist/pages.mjs +8 -6
- package/dist/primitives.js +94 -26
- package/dist/primitives.mjs +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/trading.js +1739 -1143
- package/dist/trading.mjs +4 -4
- package/dist/types/events/orderbook/orderbook.utils.d.mts +1 -1
- package/dist/types/events/orderbook/orderbook.utils.d.ts +1 -1
- package/dist/types/pages/user-profile/components/available-balance-card.d.mts +5 -1
- package/dist/types/pages/user-profile/components/available-balance-card.d.ts +5 -1
- package/dist/types/pages/user-profile/components/manage-balances-modal.d.mts +8 -0
- package/dist/types/pages/user-profile/components/manage-balances-modal.d.ts +8 -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/index.d.mts +1 -0
- package/dist/types/pages/user-profile/index.d.ts +1 -0
- package/dist/types/pages/user-profile/position-view-model.d.mts +15 -4
- package/dist/types/pages/user-profile/position-view-model.d.ts +15 -4
- package/dist/types/primitives/select/index.d.mts +1 -1
- package/dist/types/primitives/select/index.d.ts +1 -1
- package/dist/types/primitives/select/select.types.d.mts +8 -0
- package/dist/types/primitives/select/select.types.d.ts +8 -0
- package/dist/types/profile/profile-modal.constants.d.mts +1 -1
- package/dist/types/profile/profile-modal.constants.d.ts +1 -1
- package/dist/types/trading/place-order/index.place-order.constants.d.mts +3 -1
- package/dist/types/trading/place-order/index.place-order.constants.d.ts +3 -1
- package/dist/types/trading/place-order/index.place-order.types.d.mts +10 -0
- package/dist/types/trading/place-order/index.place-order.types.d.ts +10 -0
- package/dist/types/trading/place-order/index.place-order.utils.d.mts +17 -5
- package/dist/types/trading/place-order/index.place-order.utils.d.ts +17 -5
- package/package.json +3 -3
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
getTradingVenueLabel,
|
|
10
10
|
prepareSettlementDifferences,
|
|
11
11
|
resolveOrderEligibilityMessage
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-VR5ZRDQT.mjs";
|
|
13
13
|
import {
|
|
14
14
|
ConnectKalshiModal,
|
|
15
15
|
GeoBlockBanner,
|
|
16
16
|
subscribeAggDepositNotification
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-KX3TQ7WC.mjs";
|
|
18
18
|
import {
|
|
19
19
|
AGG_TERMS_OF_SERVICE_URL,
|
|
20
20
|
Button,
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
Modal,
|
|
29
29
|
PlaceOrderRouteCardSkeleton,
|
|
30
30
|
RemoteImage,
|
|
31
|
+
Select,
|
|
31
32
|
Skeleton,
|
|
32
33
|
Tooltip,
|
|
33
34
|
Typography,
|
|
@@ -46,7 +47,7 @@ import {
|
|
|
46
47
|
resolveResolvedOutcomeLabel,
|
|
47
48
|
skeletonViews,
|
|
48
49
|
useOptionalToast
|
|
49
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-KO6VTRV6.mjs";
|
|
50
51
|
|
|
51
52
|
// src/trading/types.ts
|
|
52
53
|
import { Venue, enumGuard, isFiniteNonNeg, safeParse } from "@agg-build/sdk";
|
|
@@ -147,6 +148,7 @@ import {
|
|
|
147
148
|
useExecutionProgress,
|
|
148
149
|
useGeoBlock,
|
|
149
150
|
useLabels as useLabels2,
|
|
151
|
+
useLimitOrderVenueQuotes,
|
|
150
152
|
useLiveBestPrices,
|
|
151
153
|
useLiveOutcomePrices,
|
|
152
154
|
useManagedBalances,
|
|
@@ -160,7 +162,6 @@ import {
|
|
|
160
162
|
} from "@agg-build/hooks";
|
|
161
163
|
import { Venue as Venue4 } from "@agg-build/sdk";
|
|
162
164
|
import NumberFlow from "@number-flow/react";
|
|
163
|
-
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
|
164
165
|
import * as Popover from "@radix-ui/react-popover";
|
|
165
166
|
import dayjs from "dayjs";
|
|
166
167
|
import timezone from "dayjs/plugin/timezone";
|
|
@@ -612,11 +613,13 @@ var MIN_SELL_ORDER_SHARES = 1;
|
|
|
612
613
|
var DEFAULT_SLIPPAGE_VALUE = "0.5";
|
|
613
614
|
var HIGH_SLIPPAGE_THRESHOLD = 10;
|
|
614
615
|
var PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT = 3;
|
|
616
|
+
var PLACE_ORDER_MAXIMIZE_PAYOUT_ROUTE_ID = "live-maximize-payout";
|
|
617
|
+
var PLACE_ORDER_NUMERIC_INPUT_CLASS_NAME = "bg-transparent text-right text-agg-3xl font-agg-bold leading-agg-9 tracking-agg-normal text-agg-foreground outline-none";
|
|
615
618
|
var PLACE_ORDER_CONTAINER_CLASS_NAME = "w-full overflow-hidden rounded-agg-xl border border-agg-separator bg-agg-secondary shadow-none hover:shadow-none";
|
|
616
619
|
var PLACE_ORDER_OUTCOME_BUTTON_CLASS_NAMES = {
|
|
617
620
|
activeNegative: "border-agg-error/50 bg-agg-error/15 font-agg-bold text-agg-error",
|
|
618
621
|
activePositive: "border-agg-success/50 bg-agg-success/15 font-agg-bold text-agg-success",
|
|
619
|
-
base: "flex h-
|
|
622
|
+
base: "flex h-11 flex-1 items-center justify-center rounded-agg-full border px-6 text-agg-base leading-agg-6",
|
|
620
623
|
inactive: "border-transparent bg-agg-secondary-hover font-agg-normal text-agg-foreground hover:bg-agg-tertiary"
|
|
621
624
|
};
|
|
622
625
|
|
|
@@ -1085,6 +1088,116 @@ var routePriceLabelFormatter = new Intl.NumberFormat("en-US", {
|
|
|
1085
1088
|
maximumFractionDigits: 1
|
|
1086
1089
|
});
|
|
1087
1090
|
var GEO_BLOCK_WARNING_PREFIX = "Venue not available in your region";
|
|
1091
|
+
var floorToDecimals = (value, decimals) => {
|
|
1092
|
+
if (!Number.isFinite(value) || value <= 0) return 0;
|
|
1093
|
+
const [coefficient = "0", exponentText = "0"] = value.toString().toLowerCase().split("e");
|
|
1094
|
+
const [whole = "0", fraction = ""] = coefficient.split(".");
|
|
1095
|
+
const exponent = Number(exponentText);
|
|
1096
|
+
const digits = `${whole}${fraction}`;
|
|
1097
|
+
const decimalIndex = whole.length + exponent;
|
|
1098
|
+
const normalized = decimalIndex <= 0 ? `0.${"0".repeat(-decimalIndex)}${digits}` : decimalIndex >= digits.length ? `${digits}${"0".repeat(decimalIndex - digits.length)}` : `${digits.slice(0, decimalIndex)}.${digits.slice(decimalIndex)}`;
|
|
1099
|
+
const [normalizedWhole = "0", normalizedFraction = ""] = normalized.split(".");
|
|
1100
|
+
const truncatedFraction = normalizedFraction.slice(0, decimals);
|
|
1101
|
+
return Number(
|
|
1102
|
+
truncatedFraction.length > 0 ? `${normalizedWhole}.${truncatedFraction}` : normalizedWhole
|
|
1103
|
+
);
|
|
1104
|
+
};
|
|
1105
|
+
var formatFlooredShareAmount = (value, decimals) => {
|
|
1106
|
+
const flooredValue = floorToDecimals(value, decimals);
|
|
1107
|
+
if (flooredValue <= 0) return "0";
|
|
1108
|
+
const formattedValue = flooredValue.toLocaleString("en-US", {
|
|
1109
|
+
minimumFractionDigits: 0,
|
|
1110
|
+
maximumFractionDigits: decimals
|
|
1111
|
+
});
|
|
1112
|
+
return formattedValue.replace(/(\.\d*?[1-9])0+$/u, "$1").replace(/\.0+$/u, "");
|
|
1113
|
+
};
|
|
1114
|
+
var normalizeOutcomeName = (value) => {
|
|
1115
|
+
var _a;
|
|
1116
|
+
return (_a = value == null ? void 0 : value.trim().toLowerCase()) != null ? _a : "";
|
|
1117
|
+
};
|
|
1118
|
+
var findMatchingVenueOutcome = (market, selectedOutcome) => {
|
|
1119
|
+
var _a, _b;
|
|
1120
|
+
const selectedNames = new Set(
|
|
1121
|
+
[selectedOutcome.label, selectedOutcome.title].map(normalizeOutcomeName).filter(Boolean)
|
|
1122
|
+
);
|
|
1123
|
+
return (_b = (_a = market.venueMarketOutcomes) == null ? void 0 : _a.find((outcome) => {
|
|
1124
|
+
const normalizedLabel = normalizeOutcomeName(outcome.label);
|
|
1125
|
+
return normalizedLabel !== "" && selectedNames.has(normalizedLabel);
|
|
1126
|
+
})) != null ? _b : null;
|
|
1127
|
+
};
|
|
1128
|
+
var buildLimitOrderVenueOptions = ({
|
|
1129
|
+
currentPrices,
|
|
1130
|
+
livePrices,
|
|
1131
|
+
market,
|
|
1132
|
+
selectedOutcomeId
|
|
1133
|
+
}) => {
|
|
1134
|
+
var _a, _b, _c, _d;
|
|
1135
|
+
if (!market || !selectedOutcomeId) return [];
|
|
1136
|
+
const selectedOutcome = market.venueMarketOutcomes.find(
|
|
1137
|
+
(outcome) => outcome.id === selectedOutcomeId
|
|
1138
|
+
);
|
|
1139
|
+
if (!selectedOutcome) return [];
|
|
1140
|
+
const options = /* @__PURE__ */ new Map();
|
|
1141
|
+
const addOption = ({
|
|
1142
|
+
outcomeId,
|
|
1143
|
+
venue,
|
|
1144
|
+
venueMarketId
|
|
1145
|
+
}) => {
|
|
1146
|
+
var _a2;
|
|
1147
|
+
const parsedVenue = parseVenue(venue);
|
|
1148
|
+
if (!parsedVenue.success || options.has(parsedVenue.data)) return;
|
|
1149
|
+
options.set(parsedVenue.data, {
|
|
1150
|
+
currentPrice: (_a2 = livePrices == null ? void 0 : livePrices.get(outcomeId)) != null ? _a2 : currentPrices.get(outcomeId),
|
|
1151
|
+
venue: parsedVenue.data,
|
|
1152
|
+
venueMarketId,
|
|
1153
|
+
venueMarketOutcomeId: outcomeId
|
|
1154
|
+
});
|
|
1155
|
+
};
|
|
1156
|
+
addOption({
|
|
1157
|
+
outcomeId: selectedOutcome.id,
|
|
1158
|
+
venue: market.venue,
|
|
1159
|
+
venueMarketId: market.id
|
|
1160
|
+
});
|
|
1161
|
+
const matchedMarketsById = new Map(
|
|
1162
|
+
((_a = market.matchedVenueMarkets) != null ? _a : []).map((matchedMarket) => [matchedMarket.id, matchedMarket])
|
|
1163
|
+
);
|
|
1164
|
+
const matchedOutcomeRefs = (_b = selectedOutcome.matchedVenueMarketOutcomes) != null ? _b : [];
|
|
1165
|
+
for (const ref of matchedOutcomeRefs) {
|
|
1166
|
+
const matchedMarket = matchedMarketsById.get(ref.venueMarketId);
|
|
1167
|
+
const matchedOutcome = (_c = matchedMarket == null ? void 0 : matchedMarket.venueMarketOutcomes) == null ? void 0 : _c.find(
|
|
1168
|
+
(outcome) => outcome.id === ref.venueMarketOutcomeId
|
|
1169
|
+
);
|
|
1170
|
+
if (!matchedMarket || !matchedOutcome) continue;
|
|
1171
|
+
addOption({
|
|
1172
|
+
outcomeId: matchedOutcome.id,
|
|
1173
|
+
venue: matchedMarket.venue,
|
|
1174
|
+
venueMarketId: matchedMarket.id
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
if (matchedOutcomeRefs.length === 0) {
|
|
1178
|
+
for (const matchedMarket of (_d = market.matchedVenueMarkets) != null ? _d : []) {
|
|
1179
|
+
const matchedOutcome = findMatchingVenueOutcome(matchedMarket, selectedOutcome);
|
|
1180
|
+
if (!matchedOutcome) continue;
|
|
1181
|
+
addOption({
|
|
1182
|
+
outcomeId: matchedOutcome.id,
|
|
1183
|
+
venue: matchedMarket.venue,
|
|
1184
|
+
venueMarketId: matchedMarket.id
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
return [...options.values()];
|
|
1189
|
+
};
|
|
1190
|
+
var resolveAutomaticLimitOrderVenueOption = (options, side) => {
|
|
1191
|
+
if (options.length === 0) return null;
|
|
1192
|
+
return [...options].sort((left, right) => {
|
|
1193
|
+
if (left.currentPrice == null && right.currentPrice == null) {
|
|
1194
|
+
return left.venue.localeCompare(right.venue);
|
|
1195
|
+
}
|
|
1196
|
+
if (left.currentPrice == null) return 1;
|
|
1197
|
+
if (right.currentPrice == null) return -1;
|
|
1198
|
+
return side === "buy" ? left.currentPrice - right.currentPrice : right.currentPrice - left.currentPrice;
|
|
1199
|
+
})[0];
|
|
1200
|
+
};
|
|
1088
1201
|
var isGeoBlockWarningReason = (reason) => reason.startsWith(GEO_BLOCK_WARNING_PREFIX);
|
|
1089
1202
|
var extractGeoBlockedVenues = (warnings) => {
|
|
1090
1203
|
if (!(warnings == null ? void 0 : warnings.length)) return /* @__PURE__ */ new Set();
|
|
@@ -1092,6 +1205,12 @@ var extractGeoBlockedVenues = (warnings) => {
|
|
|
1092
1205
|
warnings.filter((w) => w.venue && isGeoBlockWarningReason(w.reason)).map((w) => w.venue)
|
|
1093
1206
|
);
|
|
1094
1207
|
};
|
|
1208
|
+
var getSmartRouteTotalFees = (feeBreakdown) => {
|
|
1209
|
+
if (!feeBreakdown) return null;
|
|
1210
|
+
const feeParts = [feeBreakdown.venueFees, feeBreakdown.bridgeFees, feeBreakdown.executionGas];
|
|
1211
|
+
if (!feeParts.every(Number.isFinite)) return null;
|
|
1212
|
+
return feeParts.reduce((total, fee) => total + fee, 0);
|
|
1213
|
+
};
|
|
1095
1214
|
var hasLowLiquidityWarning = (warnings) => {
|
|
1096
1215
|
if (!(warnings == null ? void 0 : warnings.length)) return false;
|
|
1097
1216
|
return warnings.some((warning) => (warning == null ? void 0 : warning.reason) === "low_liquidity");
|
|
@@ -1141,18 +1260,24 @@ var mapVenueMarketOutcomesToPlaceOrderOutcomes = (venueMarketOutcomes) => {
|
|
|
1141
1260
|
};
|
|
1142
1261
|
});
|
|
1143
1262
|
};
|
|
1144
|
-
var mapQuoteDataToRoutingRows = (quoteData) => {
|
|
1263
|
+
var mapQuoteDataToRoutingRows = (quoteData, tradeSide = "buy") => {
|
|
1145
1264
|
if (!(quoteData == null ? void 0 : quoteData.fills.length)) return [];
|
|
1146
|
-
return quoteData.fills.map((fill) =>
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1265
|
+
return quoteData.fills.map((fill) => {
|
|
1266
|
+
const allocationValueLabel = getTradingValueLabel(__spreadValues({
|
|
1267
|
+
amount: fill.venueQty * fill.avgPrice
|
|
1268
|
+
}, tradeSide === "sell" ? { minimumFractionDigits: 2, maximumFractionDigits: 2 } : {}));
|
|
1269
|
+
const allocationSharesLabel = `${formatFlooredShareAmount(fill.venueQty, 2)} shares`;
|
|
1270
|
+
return {
|
|
1271
|
+
venue: fill.venue,
|
|
1272
|
+
label: tradeSide === "sell" ? allocationSharesLabel : allocationValueLabel,
|
|
1273
|
+
priceLabel: getTradingRoutePriceLabel(fill.avgPrice),
|
|
1274
|
+
resultLabel: tradeSide === "sell" ? allocationValueLabel : getTradingValueLabel({
|
|
1275
|
+
amount: fill.venueQty,
|
|
1276
|
+
minimumFractionDigits: 2,
|
|
1277
|
+
maximumFractionDigits: 2
|
|
1278
|
+
})
|
|
1279
|
+
};
|
|
1280
|
+
});
|
|
1156
1281
|
};
|
|
1157
1282
|
var deriveAggregateOrderStatus = (orderIds, terminalEvents) => {
|
|
1158
1283
|
if (!orderIds.length) return "pending";
|
|
@@ -1331,7 +1456,8 @@ var buildLiveRouteCards = ({
|
|
|
1331
1456
|
),
|
|
1332
1457
|
numericValue: tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled,
|
|
1333
1458
|
quoteData,
|
|
1334
|
-
rows: mapQuoteDataToRoutingRows(quoteData),
|
|
1459
|
+
rows: mapQuoteDataToRoutingRows(quoteData, tradeSide),
|
|
1460
|
+
description: labels.splitOrderDescription,
|
|
1335
1461
|
value: primaryResult.value,
|
|
1336
1462
|
venue: isSplit ? void 0 : parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
|
|
1337
1463
|
} : null;
|
|
@@ -1465,6 +1591,9 @@ var clampSellSharesToAvailability = (requestedSellShares, availableShares) => {
|
|
|
1465
1591
|
requestedAtomicShares < availableAtomicShares ? requestedAtomicShares : availableAtomicShares
|
|
1466
1592
|
);
|
|
1467
1593
|
};
|
|
1594
|
+
var hasInsufficientVenueInventory = (requestedSellShares, availableShares) => {
|
|
1595
|
+
return sellSharesToAtomicUnits(requestedSellShares) > sellSharesToAtomicUnits(availableShares);
|
|
1596
|
+
};
|
|
1468
1597
|
var getRemainingVenueSellShares = (availableShares, filledShares) => {
|
|
1469
1598
|
const availableAtomicShares = sellSharesToAtomicUnits(availableShares);
|
|
1470
1599
|
const filledAtomicShares = sellSharesToAtomicUnits(filledShares);
|
|
@@ -1501,12 +1630,37 @@ var buildVenueSellQuoteRequests = ({
|
|
|
1501
1630
|
};
|
|
1502
1631
|
var buildLiveSellRouteCards = ({
|
|
1503
1632
|
labels,
|
|
1633
|
+
requestedSellShares,
|
|
1504
1634
|
smartQuoteData,
|
|
1505
1635
|
venueQuotes,
|
|
1506
1636
|
eventVenues = [],
|
|
1507
1637
|
geoBlockedVenues
|
|
1508
1638
|
}) => {
|
|
1509
1639
|
var _a;
|
|
1640
|
+
const availabilityRequests = buildVenueSellQuoteRequests({
|
|
1641
|
+
quoteData: smartQuoteData,
|
|
1642
|
+
requestedSellShares
|
|
1643
|
+
});
|
|
1644
|
+
const availabilityRequestByVenue = new Map(
|
|
1645
|
+
availabilityRequests.map((request) => [request.venue, request])
|
|
1646
|
+
);
|
|
1647
|
+
const decorateVenueCard = (card, request) => {
|
|
1648
|
+
if (card.kind !== "venue" || !card.venue || !request) return card;
|
|
1649
|
+
const executionPrice = card.quoteData.totalFilled > 0 ? card.quoteData.rawExecCost / card.quoteData.totalFilled : void 0;
|
|
1650
|
+
const insufficientInventory = hasInsufficientVenueInventory(
|
|
1651
|
+
requestedSellShares,
|
|
1652
|
+
request.availableShares
|
|
1653
|
+
);
|
|
1654
|
+
const sharesLabel = labels.shares(floorToDecimals(request.availableShares, 2));
|
|
1655
|
+
const priceLabel = executionPrice == null ? "\u2014" : getTradingRoutePriceLabel(executionPrice);
|
|
1656
|
+
return __spreadProps(__spreadValues({}, card), {
|
|
1657
|
+
availableShares: request.availableShares,
|
|
1658
|
+
executionPrice,
|
|
1659
|
+
hint: card.isUnavailable ? card.hint : insufficientInventory ? labels.insufficientVenueInventory(sharesLabel, priceLabel) : labels.venueInventory(sharesLabel, priceLabel),
|
|
1660
|
+
id: `live-solo-${card.venue}`,
|
|
1661
|
+
insufficientInventory
|
|
1662
|
+
});
|
|
1663
|
+
};
|
|
1510
1664
|
const smartRouteCards = smartQuoteData ? buildLiveRouteCards({
|
|
1511
1665
|
labels,
|
|
1512
1666
|
quoteData: __spreadProps(__spreadValues({}, smartQuoteData), {
|
|
@@ -1515,12 +1669,25 @@ var buildLiveSellRouteCards = ({
|
|
|
1515
1669
|
tradeSide: "sell",
|
|
1516
1670
|
eventVenues,
|
|
1517
1671
|
geoBlockedVenues
|
|
1672
|
+
}).map((card) => {
|
|
1673
|
+
if (card.kind === "split") {
|
|
1674
|
+
return __spreadProps(__spreadValues({}, card), {
|
|
1675
|
+
description: labels.maximizePayoutDescription,
|
|
1676
|
+
id: PLACE_ORDER_MAXIMIZE_PAYOUT_ROUTE_ID,
|
|
1677
|
+
label: labels.maximizePayout
|
|
1678
|
+
});
|
|
1679
|
+
}
|
|
1680
|
+
return decorateVenueCard(
|
|
1681
|
+
card,
|
|
1682
|
+
card.venue ? availabilityRequestByVenue.get(card.venue) : void 0
|
|
1683
|
+
);
|
|
1518
1684
|
}) : [];
|
|
1519
1685
|
const smartRouteVenue = (smartQuoteData == null ? void 0 : smartQuoteData.status) === "ok" && smartQuoteData.fills.length === 1 ? parseVenue((_a = smartQuoteData.fills[0]) == null ? void 0 : _a.venue) : null;
|
|
1520
1686
|
const independentVenueCards = /* @__PURE__ */ new Map();
|
|
1521
1687
|
for (const venueQuote of venueQuotes) {
|
|
1522
1688
|
const quoteData = venueQuote.quoteData;
|
|
1523
|
-
|
|
1689
|
+
const { venue } = venueQuote.request;
|
|
1690
|
+
if (!(quoteData == null ? void 0 : quoteData.quoteId) || quoteData.status !== "ok" || quoteData.fills.length === 0 || quoteData.fills.some((fill) => fill.venue !== venue) || (smartRouteVenue == null ? void 0 : smartRouteVenue.success) && smartRouteVenue.data === venue) {
|
|
1524
1691
|
continue;
|
|
1525
1692
|
}
|
|
1526
1693
|
const [venueCard] = buildLiveRouteCards({
|
|
@@ -1531,17 +1698,17 @@ var buildLiveSellRouteCards = ({
|
|
|
1531
1698
|
tradeSide: "sell",
|
|
1532
1699
|
geoBlockedVenues
|
|
1533
1700
|
});
|
|
1534
|
-
if (!venueCard || venueCard.kind !== "venue" || venueCard.venue !==
|
|
1701
|
+
if (!venueCard || venueCard.kind !== "venue" || venueCard.venue !== venue) {
|
|
1535
1702
|
continue;
|
|
1536
1703
|
}
|
|
1537
|
-
independentVenueCards.set(
|
|
1538
|
-
id: `live-solo-${venueQuote.venue}`
|
|
1539
|
-
}));
|
|
1704
|
+
independentVenueCards.set(venue, decorateVenueCard(venueCard, venueQuote.request));
|
|
1540
1705
|
}
|
|
1541
1706
|
const deduplicatedSmartRouteCards = smartRouteCards.filter(
|
|
1542
1707
|
(card) => !card.venue || !independentVenueCards.has(card.venue)
|
|
1543
1708
|
);
|
|
1544
1709
|
return [...deduplicatedSmartRouteCards, ...independentVenueCards.values()].sort((left, right) => {
|
|
1710
|
+
if (left.id === PLACE_ORDER_MAXIMIZE_PAYOUT_ROUTE_ID) return -1;
|
|
1711
|
+
if (right.id === PLACE_ORDER_MAXIMIZE_PAYOUT_ROUTE_ID) return 1;
|
|
1545
1712
|
if (!!left.isUnavailable !== !!right.isUnavailable) {
|
|
1546
1713
|
return left.isUnavailable ? 1 : -1;
|
|
1547
1714
|
}
|
|
@@ -2602,29 +2769,6 @@ PlaceOrderSuccessView.displayName = "PlaceOrderSuccessView";
|
|
|
2602
2769
|
import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2603
2770
|
var SELL_SHARE_INPUT_DECIMALS = 6;
|
|
2604
2771
|
var SELL_SHARE_DISPLAY_DECIMALS = 2;
|
|
2605
|
-
var floorToDecimals = (value, decimals) => {
|
|
2606
|
-
if (!Number.isFinite(value) || value <= 0) return 0;
|
|
2607
|
-
const [coefficient = "0", exponentText = "0"] = value.toString().toLowerCase().split("e");
|
|
2608
|
-
const [whole = "0", fraction = ""] = coefficient.split(".");
|
|
2609
|
-
const exponent = Number(exponentText);
|
|
2610
|
-
const digits = `${whole}${fraction}`;
|
|
2611
|
-
const decimalIndex = whole.length + exponent;
|
|
2612
|
-
const normalized = decimalIndex <= 0 ? `0.${"0".repeat(-decimalIndex)}${digits}` : decimalIndex >= digits.length ? `${digits}${"0".repeat(decimalIndex - digits.length)}` : `${digits.slice(0, decimalIndex)}.${digits.slice(decimalIndex)}`;
|
|
2613
|
-
const [normalizedWhole = "0", normalizedFraction = ""] = normalized.split(".");
|
|
2614
|
-
const truncatedFraction = normalizedFraction.slice(0, decimals);
|
|
2615
|
-
return Number(
|
|
2616
|
-
truncatedFraction.length > 0 ? `${normalizedWhole}.${truncatedFraction}` : normalizedWhole
|
|
2617
|
-
);
|
|
2618
|
-
};
|
|
2619
|
-
var formatFlooredShareAmount = (value, decimals) => {
|
|
2620
|
-
const flooredValue = floorToDecimals(value, decimals);
|
|
2621
|
-
if (flooredValue <= 0) return "0";
|
|
2622
|
-
const formattedValue = flooredValue.toLocaleString("en-US", {
|
|
2623
|
-
minimumFractionDigits: 0,
|
|
2624
|
-
maximumFractionDigits: decimals
|
|
2625
|
-
});
|
|
2626
|
-
return formattedValue.replace(/(\.\d*?[1-9])0+$/u, "$1").replace(/\.0+$/u, "");
|
|
2627
|
-
};
|
|
2628
2772
|
var resolvePlaceOrderPortalContainer = (triggerElement) => {
|
|
2629
2773
|
var _a;
|
|
2630
2774
|
return (_a = triggerElement == null ? void 0 : triggerElement.closest(".agg-modal-center")) != null ? _a : void 0;
|
|
@@ -3182,7 +3326,7 @@ var renderRouteCard = ({
|
|
|
3182
3326
|
onSelect,
|
|
3183
3327
|
tradingLabels
|
|
3184
3328
|
}) => {
|
|
3185
|
-
var _a, _b;
|
|
3329
|
+
var _a, _b, _c;
|
|
3186
3330
|
const showSplitDetails = isSelected && isExpanded && card.kind === "split" && !!((_a = card.rows) == null ? void 0 : _a.length);
|
|
3187
3331
|
const ariaLabel = [card.label, card.hint, card.value].filter(Boolean).join(" ");
|
|
3188
3332
|
return /* @__PURE__ */ jsx6(
|
|
@@ -3237,6 +3381,14 @@ var renderRouteCard = ({
|
|
|
3237
3381
|
className: "shrink-0 text-agg-muted-foreground",
|
|
3238
3382
|
"aria-hidden": "true"
|
|
3239
3383
|
}
|
|
3384
|
+
) : card.insufficientInventory ? /* @__PURE__ */ jsx6(
|
|
3385
|
+
Icon,
|
|
3386
|
+
{
|
|
3387
|
+
name: "warning",
|
|
3388
|
+
size: "xs",
|
|
3389
|
+
className: "shrink-0 text-agg-muted-foreground",
|
|
3390
|
+
"aria-hidden": "true"
|
|
3391
|
+
}
|
|
3240
3392
|
) : card.kind === "split" && isSelected ? /* @__PURE__ */ jsx6(
|
|
3241
3393
|
Icon,
|
|
3242
3394
|
{
|
|
@@ -3263,8 +3415,8 @@ var renderRouteCard = ({
|
|
|
3263
3415
|
)
|
|
3264
3416
|
] }),
|
|
3265
3417
|
showSplitDetails ? /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
3266
|
-
/* @__PURE__ */ jsx6("p", { className: "agg-route-card-description text-agg-xs leading-agg-4 text-agg-foreground", children: tradingLabels.splitOrderDescription }),
|
|
3267
|
-
/* @__PURE__ */ jsx6("div", { className: "agg-route-breakdown flex flex-col gap-3", children: (
|
|
3418
|
+
/* @__PURE__ */ jsx6("p", { className: "agg-route-card-description text-agg-xs leading-agg-4 text-agg-foreground", children: (_b = card.description) != null ? _b : tradingLabels.splitOrderDescription }),
|
|
3419
|
+
/* @__PURE__ */ jsx6("div", { className: "agg-route-breakdown flex flex-col gap-3", children: (_c = card.rows) == null ? void 0 : _c.map((row) => renderRouteBreakdownRow(row)) })
|
|
3268
3420
|
] }) : null
|
|
3269
3421
|
] })
|
|
3270
3422
|
}
|
|
@@ -3380,10 +3532,11 @@ var PlaceOrder = ({
|
|
|
3380
3532
|
resolvedClaim,
|
|
3381
3533
|
midpointsResult
|
|
3382
3534
|
}) => {
|
|
3383
|
-
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
|
|
3535
|
+
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, __, _$;
|
|
3384
3536
|
const {
|
|
3385
3537
|
enableDebug: isExecutionDebugEnabled,
|
|
3386
3538
|
features: { enableAnimations, showFeesBreakdown, showLimitOrders },
|
|
3539
|
+
formatting: { formatPrice },
|
|
3387
3540
|
general: { locale },
|
|
3388
3541
|
trading: { executionMode: configuredExecutionMode = "live" } = { executionMode: "live" }
|
|
3389
3542
|
} = useSdkUiConfig();
|
|
@@ -3503,7 +3656,7 @@ var PlaceOrder = ({
|
|
|
3503
3656
|
);
|
|
3504
3657
|
const [internalTab, setInternalTab] = useState2("buy");
|
|
3505
3658
|
const [executionType, setExecutionType] = useState2("market");
|
|
3506
|
-
const [
|
|
3659
|
+
const [selectedLimitVenue, setSelectedLimitVenue] = useState2(null);
|
|
3507
3660
|
const [limitPrice, setLimitPrice] = useState2(0.5);
|
|
3508
3661
|
const [limitPriceInputValue, setLimitPriceInputValue] = useState2(formatLimitPriceInputValue(0.5));
|
|
3509
3662
|
const [limitPriceInputError, setLimitPriceInputError] = useState2(null);
|
|
@@ -3553,7 +3706,6 @@ var PlaceOrder = ({
|
|
|
3553
3706
|
]);
|
|
3554
3707
|
const buyTabRef = useRef2(null);
|
|
3555
3708
|
const sellTabRef = useRef2(null);
|
|
3556
|
-
const executionTypeTriggerRef = useRef2(null);
|
|
3557
3709
|
const expirationTriggerRef = useRef2(null);
|
|
3558
3710
|
const limitPriceInitializedForOutcomeRef = useRef2(void 0);
|
|
3559
3711
|
const expirationOptionRefs = useRef2([]);
|
|
@@ -3593,6 +3745,27 @@ var PlaceOrder = ({
|
|
|
3593
3745
|
const isQuoteInputEditing = internalAmount !== debouncedAmount;
|
|
3594
3746
|
const isLimitOrder = showLimitOrders && executionType === "limit";
|
|
3595
3747
|
const isSell = useMemo(() => internalTab === "sell", [internalTab]);
|
|
3748
|
+
const limitVenueOptions = useMemo(
|
|
3749
|
+
() => {
|
|
3750
|
+
var _a2;
|
|
3751
|
+
return buildLimitOrderVenueOptions({
|
|
3752
|
+
currentPrices: (_a2 = clusterMidpointResult.currentMidpointsByOutcomeId) != null ? _a2 : clusterMidpointResult.prices,
|
|
3753
|
+
livePrices,
|
|
3754
|
+
market: scopedSelectedMarket,
|
|
3755
|
+
selectedOutcomeId: scopedSelectedOutcomeId
|
|
3756
|
+
});
|
|
3757
|
+
},
|
|
3758
|
+
[clusterMidpointResult, livePrices, scopedSelectedMarket, scopedSelectedOutcomeId]
|
|
3759
|
+
);
|
|
3760
|
+
const visibleLimitVenueOptions = useMemo(() => {
|
|
3761
|
+
return limitVenueOptions.filter((option) => {
|
|
3762
|
+
return getVenueAvailabilityState({
|
|
3763
|
+
venueId: option.venue,
|
|
3764
|
+
disabledVenues,
|
|
3765
|
+
isConfigLoading: isAppConfigLoading
|
|
3766
|
+
}) !== "hidden";
|
|
3767
|
+
});
|
|
3768
|
+
}, [disabledVenues, isAppConfigLoading, limitVenueOptions]);
|
|
3596
3769
|
const {
|
|
3597
3770
|
positions: executionPositions,
|
|
3598
3771
|
dataUpdatedAt: executionPositionsUpdatedAt,
|
|
@@ -3613,8 +3786,69 @@ var PlaceOrder = ({
|
|
|
3613
3786
|
isEditing: isQuoteInputEditing,
|
|
3614
3787
|
isMarketOpen: resolvedTradingState.kind === "open" && !isEndedWithoutKnownWinner,
|
|
3615
3788
|
isPanelActive: isQuotePanelActive,
|
|
3616
|
-
isSubmitting: submissionProgressState != null || isBeforeActionPending || executeManaged.isPending
|
|
3789
|
+
isSubmitting: submissionProgressState != null || isBeforeActionPending || executeManaged.isPending || placeLimitOrder.isPending
|
|
3617
3790
|
};
|
|
3791
|
+
const limitVenueQuoteRequests = useMemo(
|
|
3792
|
+
() => visibleLimitVenueOptions.map((option) => ({
|
|
3793
|
+
venue: option.venue,
|
|
3794
|
+
venueMarketOutcomeId: option.venueMarketOutcomeId
|
|
3795
|
+
})),
|
|
3796
|
+
[visibleLimitVenueOptions]
|
|
3797
|
+
);
|
|
3798
|
+
const hasValidLimitVenueQuoteAmount = debouncedAmount > 0;
|
|
3799
|
+
const isLimitVenueQuoteEnabled = isLimitOrder && isQuotePanelActive && !isEndedWithoutKnownWinner && !submissionProgressState && !isBeforeActionPending && !placeLimitOrder.isPending && hasValidLimitVenueQuoteAmount && orderEligibility.canPlaceOrder && (!isSell || sellFilledForOutcomeId === scopedSelectedOutcomeId && !isQuoteInputEditing);
|
|
3800
|
+
const limitVenueQuotes = useLimitOrderVenueQuotes({
|
|
3801
|
+
requests: limitVenueQuoteRequests,
|
|
3802
|
+
tradeSide: internalTab,
|
|
3803
|
+
amount: debouncedAmount,
|
|
3804
|
+
marketId: scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id,
|
|
3805
|
+
accountId: (_k = user == null ? void 0 : user.id) != null ? _k : null,
|
|
3806
|
+
chainBalances: chainBalancesOverride,
|
|
3807
|
+
mode: isPaperMode ? "paper" : void 0,
|
|
3808
|
+
slipCapBps: 1e6,
|
|
3809
|
+
enabled: isLimitVenueQuoteEnabled,
|
|
3810
|
+
refreshContext: smartRouteRefreshContext
|
|
3811
|
+
});
|
|
3812
|
+
const limitVenueQuoteByVenue = useMemo(
|
|
3813
|
+
() => new Map(limitVenueQuotes.quotes.map((quote) => [quote.request.venue, quote])),
|
|
3814
|
+
[limitVenueQuotes.quotes]
|
|
3815
|
+
);
|
|
3816
|
+
const geoBlockedLimitVenues = useMemo(() => {
|
|
3817
|
+
var _a2;
|
|
3818
|
+
const venues = /* @__PURE__ */ new Set();
|
|
3819
|
+
for (const quote of limitVenueQuotes.quotes) {
|
|
3820
|
+
if (extractGeoBlockedVenues((_a2 = quote.data) == null ? void 0 : _a2.warnings).has(quote.request.venue)) {
|
|
3821
|
+
venues.add(quote.request.venue);
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
return venues;
|
|
3825
|
+
}, [limitVenueQuotes.quotes]);
|
|
3826
|
+
const availableLimitVenueOptions = useMemo(() => {
|
|
3827
|
+
return visibleLimitVenueOptions.filter((option) => {
|
|
3828
|
+
return !geoBlockedLimitVenues.has(option.venue) && getVenueAvailabilityState({
|
|
3829
|
+
venueId: option.venue,
|
|
3830
|
+
disabledVenues,
|
|
3831
|
+
isConfigLoading: isAppConfigLoading
|
|
3832
|
+
}) === "available";
|
|
3833
|
+
});
|
|
3834
|
+
}, [disabledVenues, geoBlockedLimitVenues, isAppConfigLoading, visibleLimitVenueOptions]);
|
|
3835
|
+
const automaticLimitVenueOption = useMemo(
|
|
3836
|
+
() => resolveAutomaticLimitOrderVenueOption(availableLimitVenueOptions, internalTab),
|
|
3837
|
+
[availableLimitVenueOptions, internalTab]
|
|
3838
|
+
);
|
|
3839
|
+
const selectedLimitVenueOption = useMemo(() => {
|
|
3840
|
+
if (selectedLimitVenue) {
|
|
3841
|
+
const selectedOption = availableLimitVenueOptions.find(
|
|
3842
|
+
(option) => option.venue === selectedLimitVenue
|
|
3843
|
+
);
|
|
3844
|
+
if (selectedOption) return selectedOption;
|
|
3845
|
+
}
|
|
3846
|
+
return automaticLimitVenueOption;
|
|
3847
|
+
}, [automaticLimitVenueOption, availableLimitVenueOptions, selectedLimitVenue]);
|
|
3848
|
+
useEffect2(() => {
|
|
3849
|
+
if (!selectedLimitVenue || !geoBlockedLimitVenues.has(selectedLimitVenue)) return;
|
|
3850
|
+
setSelectedLimitVenue(null);
|
|
3851
|
+
}, [geoBlockedLimitVenues, selectedLimitVenue]);
|
|
3618
3852
|
const smartRoute = useSmartRoute(__spreadProps(__spreadValues({
|
|
3619
3853
|
venueMarketOutcomeId: scopedSelectedOutcomeId,
|
|
3620
3854
|
maxSpend: isSell ? void 0 : debouncedAmount,
|
|
@@ -3630,7 +3864,7 @@ var PlaceOrder = ({
|
|
|
3630
3864
|
enabled: isSmartRouteEnabled
|
|
3631
3865
|
}, isSell ? {
|
|
3632
3866
|
sellCacheScope: {
|
|
3633
|
-
accountId: (
|
|
3867
|
+
accountId: (_l = user == null ? void 0 : user.id) != null ? _l : null,
|
|
3634
3868
|
positionVersion: executionPositionsUpdatedAt
|
|
3635
3869
|
}
|
|
3636
3870
|
} : {}), {
|
|
@@ -3686,12 +3920,12 @@ var PlaceOrder = ({
|
|
|
3686
3920
|
);
|
|
3687
3921
|
const venueSellQuotes = useVenueSellQuotes({
|
|
3688
3922
|
venueMarketOutcomeId: scopedSelectedOutcomeId,
|
|
3689
|
-
accountId: (
|
|
3923
|
+
accountId: (_m = user == null ? void 0 : user.id) != null ? _m : null,
|
|
3690
3924
|
positionVersion: executionPositionsUpdatedAt,
|
|
3691
3925
|
requests: venueSellQuoteRequests,
|
|
3692
3926
|
mode: isPaperMode ? "paper" : void 0,
|
|
3693
3927
|
slipCapBps: 1e6,
|
|
3694
|
-
enabled: isSell && isSmartRouteEnabled && !smartRoute.isLoading && ((
|
|
3928
|
+
enabled: isSell && isSmartRouteEnabled && !smartRoute.isLoading && ((_n = smartRoute.data) == null ? void 0 : _n.venueMarketOutcomeId) === scopedSelectedOutcomeId,
|
|
3695
3929
|
refreshContext: smartRouteRefreshContext
|
|
3696
3930
|
});
|
|
3697
3931
|
const currentSellableShares = useMemo(() => {
|
|
@@ -3726,13 +3960,13 @@ var PlaceOrder = ({
|
|
|
3726
3960
|
isSell,
|
|
3727
3961
|
scopedSelectedMarket,
|
|
3728
3962
|
scopedSelectedOutcome,
|
|
3729
|
-
(
|
|
3963
|
+
(_p = (_o = smartRoute.data) == null ? void 0 : _o.positionAvailability) == null ? void 0 : _p.totalSellableShares
|
|
3730
3964
|
]);
|
|
3731
3965
|
const maxSellableShares = useMemo(
|
|
3732
3966
|
() => floorToDecimals(currentSellableShares, SELL_SHARE_INPUT_DECIMALS),
|
|
3733
3967
|
[currentSellableShares]
|
|
3734
3968
|
);
|
|
3735
|
-
const isCurrentSellableSharesLoading = isSell && isAuthenticated && !(typeof ((
|
|
3969
|
+
const isCurrentSellableSharesLoading = isSell && isAuthenticated && !(typeof ((_r = (_q = smartRoute.data) == null ? void 0 : _q.positionAvailability) == null ? void 0 : _r.totalSellableShares) === "number") && (isExecutionPositionsLoading || isExecutionPositionsFetching);
|
|
3736
3970
|
const displayedCurrentSellableShares = useMemo(() => {
|
|
3737
3971
|
if (!Number.isFinite(currentSellableShares) || currentSellableShares <= 0) return 0;
|
|
3738
3972
|
return floorToDecimals(currentSellableShares, SELL_SHARE_DISPLAY_DECIMALS);
|
|
@@ -3742,7 +3976,7 @@ var PlaceOrder = ({
|
|
|
3742
3976
|
[maxSellableShares]
|
|
3743
3977
|
);
|
|
3744
3978
|
const isAtMaxSellableShares = isSell && maxSellableShares > 0 && Math.abs(internalAmount - maxSellableShares) < 1e-9;
|
|
3745
|
-
const isSellAmountAboveAvailability = isSell && ((
|
|
3979
|
+
const isSellAmountAboveAvailability = isSell && ((_s = smartRoute.data) == null ? void 0 : _s.venueMarketOutcomeId) === scopedSelectedOutcomeId && typeof ((_t = smartRoute.data.positionAvailability) == null ? void 0 : _t.totalSellableShares) === "number" && internalAmount > maxSellableShares;
|
|
3746
3980
|
useEffect2(() => {
|
|
3747
3981
|
if (submissionProgressState != null) return;
|
|
3748
3982
|
if (!isSell || isCurrentSellableSharesLoading) return;
|
|
@@ -3778,8 +4012,8 @@ var PlaceOrder = ({
|
|
|
3778
4012
|
isSell,
|
|
3779
4013
|
onAmountChange,
|
|
3780
4014
|
scopedSelectedOutcomeId,
|
|
3781
|
-
(
|
|
3782
|
-
(
|
|
4015
|
+
(_v = (_u = smartRoute.data) == null ? void 0 : _u.positionAvailability) == null ? void 0 : _v.totalSellableShares,
|
|
4016
|
+
(_w = smartRoute.data) == null ? void 0 : _w.venueMarketOutcomeId,
|
|
3783
4017
|
submissionProgressState
|
|
3784
4018
|
]);
|
|
3785
4019
|
const routeCards = useMemo(() => {
|
|
@@ -3789,9 +4023,10 @@ var PlaceOrder = ({
|
|
|
3789
4023
|
eventVenues,
|
|
3790
4024
|
geoBlockedVenues: inheritedBuyGeoBlockedVenues,
|
|
3791
4025
|
labels: tradingLabels,
|
|
4026
|
+
requestedSellShares: debouncedAmount,
|
|
3792
4027
|
smartQuoteData: smartRoute.data,
|
|
3793
4028
|
venueQuotes: venueSellQuotes.quotes.map((venueQuote) => ({
|
|
3794
|
-
|
|
4029
|
+
request: venueQuote.request,
|
|
3795
4030
|
quoteData: venueQuote.data
|
|
3796
4031
|
}))
|
|
3797
4032
|
});
|
|
@@ -3803,6 +4038,7 @@ var PlaceOrder = ({
|
|
|
3803
4038
|
tradeSide: "buy"
|
|
3804
4039
|
}) : [];
|
|
3805
4040
|
}, [
|
|
4041
|
+
debouncedAmount,
|
|
3806
4042
|
smartRoute.data,
|
|
3807
4043
|
tradingLabels,
|
|
3808
4044
|
inheritedBuyGeoBlockedVenues,
|
|
@@ -3810,16 +4046,19 @@ var PlaceOrder = ({
|
|
|
3810
4046
|
scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets,
|
|
3811
4047
|
venueSellQuotes.quotes
|
|
3812
4048
|
]);
|
|
4049
|
+
const isSellQuoteTransitioning = isSell && (isQuoteInputEditing || smartRoute.isLoading || smartRoute.isFetching || venueSellQuotes.isLoading || venueSellQuotes.isFetching);
|
|
3813
4050
|
const resolvedSelectedRouteCardId = useMemo(() => {
|
|
3814
4051
|
var _a2;
|
|
3815
|
-
if (routeCards.length === 0) return null;
|
|
3816
4052
|
if (selectedRouteCardId && routeCards.some((card) => card.id === selectedRouteCardId && !card.isUnavailable)) {
|
|
3817
4053
|
return selectedRouteCardId;
|
|
3818
4054
|
}
|
|
4055
|
+
if (selectedRouteCardId && isSellQuoteTransitioning) return selectedRouteCardId;
|
|
4056
|
+
if (routeCards.length === 0) return null;
|
|
3819
4057
|
return resolveDefaultRouteCardId(routeCards, isSell ? void 0 : (_a2 = smartRoute.data) == null ? void 0 : _a2.status);
|
|
3820
|
-
}, [routeCards, selectedRouteCardId,
|
|
4058
|
+
}, [isSell, isSellQuoteTransitioning, routeCards, selectedRouteCardId, (_x = smartRoute.data) == null ? void 0 : _x.status]);
|
|
3821
4059
|
useEffect2(() => {
|
|
3822
4060
|
if (routeCards.length === 0) {
|
|
4061
|
+
if (isSellQuoteTransitioning) return;
|
|
3823
4062
|
setSelectedRouteCardId(null);
|
|
3824
4063
|
setIsRoutesExpanded(false);
|
|
3825
4064
|
setIsSplitDetailOpen(false);
|
|
@@ -3828,7 +4067,12 @@ var PlaceOrder = ({
|
|
|
3828
4067
|
if (resolvedSelectedRouteCardId !== selectedRouteCardId) {
|
|
3829
4068
|
setSelectedRouteCardId(resolvedSelectedRouteCardId);
|
|
3830
4069
|
}
|
|
3831
|
-
}, [
|
|
4070
|
+
}, [
|
|
4071
|
+
isSellQuoteTransitioning,
|
|
4072
|
+
resolvedSelectedRouteCardId,
|
|
4073
|
+
routeCards.length,
|
|
4074
|
+
selectedRouteCardId
|
|
4075
|
+
]);
|
|
3832
4076
|
const isSubmissionLocked = submissionProgressState != null;
|
|
3833
4077
|
const isSubmissionLockedRef = useRef2(isSubmissionLocked);
|
|
3834
4078
|
isSubmissionLockedRef.current = isSubmissionLocked;
|
|
@@ -3840,7 +4084,6 @@ var PlaceOrder = ({
|
|
|
3840
4084
|
useEffect2(() => {
|
|
3841
4085
|
if (showLimitOrders || executionType !== "limit") return;
|
|
3842
4086
|
setExecutionType("market");
|
|
3843
|
-
setIsExecutionTypeMenuOpen(false);
|
|
3844
4087
|
setIsLimitExpirationPickerOpen(false);
|
|
3845
4088
|
}, [executionType, showLimitOrders]);
|
|
3846
4089
|
useEffect2(() => {
|
|
@@ -3856,15 +4099,24 @@ var PlaceOrder = ({
|
|
|
3856
4099
|
setLimitPriceInputValue(formatLimitPriceInputValue(nextLimitPrice));
|
|
3857
4100
|
setLimitPriceInputError(null);
|
|
3858
4101
|
}, [executionType, scopedSelectedOutcomeId, selectedOutcomeDisplayPrice]);
|
|
4102
|
+
useEffect2(() => {
|
|
4103
|
+
setSelectedLimitVenue(null);
|
|
4104
|
+
}, [scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id, scopedSelectedOutcomeId]);
|
|
4105
|
+
useEffect2(() => {
|
|
4106
|
+
setSelectedRouteCardId(null);
|
|
4107
|
+
setIsRoutesExpanded(false);
|
|
4108
|
+
setIsSplitDetailOpen(false);
|
|
4109
|
+
}, [executionType, internalTab, scopedSelectedOutcomeId]);
|
|
3859
4110
|
const orderedRouteCards = routeCards;
|
|
3860
|
-
const selectedRouteCard = (
|
|
4111
|
+
const selectedRouteCard = (_z = (_y = orderedRouteCards.find((card) => card.id === resolvedSelectedRouteCardId)) != null ? _y : orderedRouteCards[0]) != null ? _z : null;
|
|
3861
4112
|
const isKalshiRoute = useMemo(() => {
|
|
4113
|
+
if (isLimitOrder) return (selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue) === Venue4.kalshi;
|
|
3862
4114
|
if (selectedRouteCard) {
|
|
3863
4115
|
return selectedRouteCard.venue === "kalshi" || selectedRouteCard.quoteData.fills.some((f) => f.venue === "kalshi");
|
|
3864
4116
|
}
|
|
3865
4117
|
return (scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venue) === "kalshi";
|
|
3866
|
-
}, [selectedRouteCard, scopedSelectedMarket]);
|
|
3867
|
-
const displayedBalance = isPaperMode ? paperTotalBalance : isKalshiRoute ? (
|
|
4118
|
+
}, [isLimitOrder, selectedLimitVenueOption == null ? void 0 : selectedLimitVenueOption.venue, selectedRouteCard, scopedSelectedMarket]);
|
|
4119
|
+
const displayedBalance = isPaperMode ? paperTotalBalance : isKalshiRoute ? (_A = liveBalanceState.kalshiBalance) != null ? _A : 0 : liveAvailableBalance;
|
|
3868
4120
|
const legacyKalshiAccount = useMemo(
|
|
3869
4121
|
() => {
|
|
3870
4122
|
var _a2;
|
|
@@ -3872,8 +4124,8 @@ var PlaceOrder = ({
|
|
|
3872
4124
|
},
|
|
3873
4125
|
[user == null ? void 0 : user.venueAccounts]
|
|
3874
4126
|
);
|
|
3875
|
-
const isKalshiAccountActive = (
|
|
3876
|
-
const isKalshiVerified = ((
|
|
4127
|
+
const isKalshiAccountActive = (_B = kalshiKeyStatus == null ? void 0 : kalshiKeyStatus.connected) != null ? _B : (legacyKalshiAccount == null ? void 0 : legacyKalshiAccount.status) === "active";
|
|
4128
|
+
const isKalshiVerified = ((_C = kalshiKeyStatus == null ? void 0 : kalshiKeyStatus.kycStatus) != null ? _C : legacyKalshiAccount == null ? void 0 : legacyKalshiAccount.kycStatus) === "verified";
|
|
3877
4129
|
const hasKalshiConnectionState = kalshiKeyStatus !== void 0 || (user == null ? void 0 : user.venueAccounts) != null;
|
|
3878
4130
|
const isKalshiAvailable = getVenueAvailabilityState({
|
|
3879
4131
|
venueId: "kalshi",
|
|
@@ -3900,30 +4152,47 @@ var PlaceOrder = ({
|
|
|
3900
4152
|
[aggClient, onConnectKalshi, refetchKalshiKeyStatus]
|
|
3901
4153
|
);
|
|
3902
4154
|
const needsKycVerification = isAuthenticated && hasKalshiConnectionState && isKalshiRoute && isKalshiAccountActive && !isKalshiVerified;
|
|
3903
|
-
const verifyKalshiConnectionLabel = (
|
|
4155
|
+
const verifyKalshiConnectionLabel = (_G = (_F = (_E = (_D = labels.onboarding) == null ? void 0 : _D.connectKalshiModal) == null ? void 0 : _E.actions) == null ? void 0 : _F.verifyConnection) != null ? _G : tradingLabels.kycRequired;
|
|
3904
4156
|
const handleRouteCardSelect = useCallback2(
|
|
3905
4157
|
(cardId) => {
|
|
4158
|
+
const card = routeCards.find((routeCard) => routeCard.id === cardId);
|
|
4159
|
+
if (!card || card.isUnavailable) return;
|
|
3906
4160
|
if (cardId === resolvedSelectedRouteCardId) {
|
|
3907
|
-
const card = routeCards.find((c) => c.id === cardId);
|
|
3908
4161
|
if ((card == null ? void 0 : card.kind) === "split") {
|
|
3909
4162
|
setIsSplitDetailOpen((prev) => !prev);
|
|
3910
4163
|
return;
|
|
3911
4164
|
}
|
|
3912
4165
|
}
|
|
3913
4166
|
setSelectedRouteCardId(cardId);
|
|
4167
|
+
setIsSplitDetailOpen(false);
|
|
4168
|
+
if (!isSell || card.kind !== "venue" || !card.insufficientInventory || card.availableShares == null) {
|
|
4169
|
+
return;
|
|
4170
|
+
}
|
|
4171
|
+
const clampedAmount = clampSellSharesToAvailability(internalAmount, card.availableShares);
|
|
4172
|
+
if (clampedAmount === internalAmount) return;
|
|
4173
|
+
setInternalAmount(clampedAmount);
|
|
4174
|
+
setSellFilledForOutcomeId(scopedSelectedOutcomeId != null ? scopedSelectedOutcomeId : null);
|
|
4175
|
+
onAmountChange == null ? void 0 : onAmountChange(clampedAmount);
|
|
3914
4176
|
},
|
|
3915
|
-
[
|
|
4177
|
+
[
|
|
4178
|
+
internalAmount,
|
|
4179
|
+
isSell,
|
|
4180
|
+
onAmountChange,
|
|
4181
|
+
resolvedSelectedRouteCardId,
|
|
4182
|
+
routeCards,
|
|
4183
|
+
scopedSelectedOutcomeId
|
|
4184
|
+
]
|
|
3916
4185
|
);
|
|
3917
4186
|
const executionProgress = useExecutionProgress({
|
|
3918
|
-
orderIds: (
|
|
3919
|
-
quoteId: (
|
|
4187
|
+
orderIds: (_H = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) != null ? _H : null,
|
|
4188
|
+
quoteId: (_I = submissionProgressState == null ? void 0 : submissionProgressState.quoteId) != null ? _I : null,
|
|
3920
4189
|
mode: isPaperMode ? "paper" : void 0,
|
|
3921
|
-
enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((
|
|
4190
|
+
enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((_J = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _J.length)
|
|
3922
4191
|
});
|
|
3923
|
-
const selectedOutcomeLabel = (
|
|
3924
|
-
const headerImage = (
|
|
3925
|
-
const headerTitle = (
|
|
3926
|
-
const headerSubtitle = (
|
|
4192
|
+
const selectedOutcomeLabel = (_M = (_L = (_K = outcomes.find((outcome) => outcome.id === scopedSelectedOutcomeId)) == null ? void 0 : _K.label) != null ? _L : scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.label) != null ? _M : "";
|
|
4193
|
+
const headerImage = (_O = (_N = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.image) != null ? _N : scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.image) != null ? _O : null;
|
|
4194
|
+
const headerTitle = (_Q = (_P = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _P : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _Q : "";
|
|
4195
|
+
const headerSubtitle = (_R = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _R : "";
|
|
3927
4196
|
const buildExecutionSummary = useCallback2(
|
|
3928
4197
|
(quoteData, executionVenue, orderId, partialFillSummary) => {
|
|
3929
4198
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
|
|
@@ -4221,23 +4490,24 @@ var PlaceOrder = ({
|
|
|
4221
4490
|
queryClient,
|
|
4222
4491
|
submissionProgressState
|
|
4223
4492
|
]);
|
|
4224
|
-
const activeQuoteData = (
|
|
4225
|
-
const
|
|
4493
|
+
const activeQuoteData = isLimitOrder ? null : (_T = (_S = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _S : smartRoute.data) != null ? _T : null;
|
|
4494
|
+
const visibleMarketRouteCards = orderedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT && !isRoutesExpanded ? orderedRouteCards.slice(0, PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT) : orderedRouteCards;
|
|
4226
4495
|
const hasEnteredAmount = internalAmount > 0;
|
|
4227
|
-
const isQuoteLoading = !isLimitOrder && hasEnteredAmount && (
|
|
4496
|
+
const isQuoteLoading = !isLimitOrder && hasEnteredAmount && (isSell && isQuoteInputEditing || smartRoute.isLoading || !isSell && smartRoute.isFetching || isSell && venueSellQuotes.isLoading);
|
|
4228
4497
|
const routeLoadingMessage = isQuoteLoading ? smartRoute.loadingReason === "updating-route" ? tradingLabels.updatingRoute : smartRoute.loadingReason === "refreshing-quotes" ? tradingLabels.refreshingQuotes : tradingLabels.findingBestOdds : null;
|
|
4229
|
-
const selectedRouteFills = (
|
|
4498
|
+
const selectedRouteFills = (_U = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData.fills) != null ? _U : [];
|
|
4230
4499
|
const isKalshiOnlyRoute = isKalshiRoute && ((selectedRouteCard == null ? void 0 : selectedRouteCard.venue) === Venue4.kalshi || selectedRouteFills.length > 0 && selectedRouteFills.every((fill) => fill.venue === Venue4.kalshi));
|
|
4231
4500
|
const isOnchainOnlyRoute = !isKalshiRoute || selectedRouteFills.length > 0 && selectedRouteFills.every((fill) => fill.venue !== Venue4.kalshi);
|
|
4232
4501
|
const kalshiRequiredAmount = isSell ? 0 : selectedRouteFills.filter((fill) => fill.venue === Venue4.kalshi).reduce((total, fill) => total + fill.venueQty * fill.avgPrice, 0);
|
|
4233
4502
|
const onchainRequiredAmount = isSell ? 0 : selectedRouteFills.filter((fill) => fill.venue !== Venue4.kalshi).reduce((total, fill) => total + fill.venueQty * fill.avgPrice, 0);
|
|
4234
4503
|
const resolvedKalshiRequiredAmount = isKalshiOnlyRoute || isKalshiRoute && selectedRouteFills.length === 0 ? internalAmount : kalshiRequiredAmount;
|
|
4235
4504
|
const resolvedOnchainRequiredAmount = isOnchainOnlyRoute || !isKalshiRoute && selectedRouteFills.length === 0 ? internalAmount : onchainRequiredAmount;
|
|
4236
|
-
const isKalshiBalanceInsufficient = !isPaperMode && isKalshiRoute && resolvedKalshiRequiredAmount > ((
|
|
4505
|
+
const isKalshiBalanceInsufficient = !isPaperMode && isKalshiRoute && resolvedKalshiRequiredAmount > ((_V = liveBalanceState.kalshiBalance) != null ? _V : 0);
|
|
4237
4506
|
const isOnchainBalanceInsufficient = resolvedOnchainRequiredAmount > liveAvailableBalance;
|
|
4238
4507
|
const isInsufficientBalance = !isSell && isAuthenticated && hasEnteredAmount && !isBalanceLoading && (isLimitOrder ? internalAmount > totalBalance : isPaperMode ? internalAmount > paperTotalBalance : isKalshiBalanceInsufficient || isOnchainBalanceInsufficient);
|
|
4239
4508
|
const isQuoteInsufficientBalance = !isLimitOrder && (activeQuoteData == null ? void 0 : activeQuoteData.status) === "insufficient_balance";
|
|
4240
4509
|
const shouldShowInsufficientBalanceAlert = isInsufficientBalance || isQuoteInsufficientBalance;
|
|
4510
|
+
const isSelectedVenueInventoryInsufficient = isSell && (selectedRouteCard == null ? void 0 : selectedRouteCard.kind) === "venue" && selectedRouteCard.insufficientInventory === true;
|
|
4241
4511
|
const isBelowClientMinimum = !isSell && hasEnteredAmount && internalAmount < MIN_BUY_ORDER_AMOUNT;
|
|
4242
4512
|
const isBelowVenueMinimumFromQuote = isQuoteBelowVenueMinimum(activeQuoteData);
|
|
4243
4513
|
const isBelowMinimum = isBelowClientMinimum || isBelowVenueMinimumFromQuote;
|
|
@@ -4319,17 +4589,14 @@ var PlaceOrder = ({
|
|
|
4319
4589
|
tradingLabels
|
|
4320
4590
|
]);
|
|
4321
4591
|
const displayedToWinHint = useMemo(() => {
|
|
4322
|
-
var _a2
|
|
4592
|
+
var _a2;
|
|
4323
4593
|
if (!selectedRouteCard) return "";
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
return avgPrice != null ? tradingLabels.averagePrice(avgPrice) : "";
|
|
4327
|
-
}
|
|
4328
|
-
return (_d2 = selectedRouteCard.hint) != null ? _d2 : "";
|
|
4594
|
+
const averagePrice = selectedRouteCard.quoteData.totalFilled > 0 ? selectedRouteCard.quoteData.rawExecCost / selectedRouteCard.quoteData.totalFilled : (_a2 = selectedRouteCard.quoteData.fills[0]) == null ? void 0 : _a2.avgPrice;
|
|
4595
|
+
return averagePrice == null ? "" : tradingLabels.averagePrice(averagePrice);
|
|
4329
4596
|
}, [selectedRouteCard, tradingLabels]);
|
|
4330
|
-
const displayedToWinValue = (
|
|
4597
|
+
const displayedToWinValue = (_W = selectedRouteCard == null ? void 0 : selectedRouteCard.numericValue) != null ? _W : 0;
|
|
4331
4598
|
const limitOrderPayload = useMemo(() => {
|
|
4332
|
-
if (!
|
|
4599
|
+
if (!selectedLimitVenueOption || internalAmount <= 0) return null;
|
|
4333
4600
|
if (limitPriceInputError) return null;
|
|
4334
4601
|
const expirationDate = resolveLimitExpirationDate({
|
|
4335
4602
|
expirationType: limitExpirationType,
|
|
@@ -4345,8 +4612,8 @@ var PlaceOrder = ({
|
|
|
4345
4612
|
});
|
|
4346
4613
|
const expiresAt = expirationDate ? serializeLimitOrderExpiration(expirationDate) : void 0;
|
|
4347
4614
|
return __spreadValues({
|
|
4348
|
-
venue:
|
|
4349
|
-
venueMarketOutcomeId:
|
|
4615
|
+
venue: selectedLimitVenueOption.venue,
|
|
4616
|
+
venueMarketOutcomeId: selectedLimitVenueOption.venueMarketOutcomeId,
|
|
4350
4617
|
side: internalTab,
|
|
4351
4618
|
limitPriceRaw,
|
|
4352
4619
|
sizeRaw,
|
|
@@ -4360,8 +4627,7 @@ var PlaceOrder = ({
|
|
|
4360
4627
|
limitExpirationType,
|
|
4361
4628
|
limitPrice,
|
|
4362
4629
|
limitPriceInputError,
|
|
4363
|
-
|
|
4364
|
-
scopedSelectedOutcomeId
|
|
4630
|
+
selectedLimitVenueOption
|
|
4365
4631
|
]);
|
|
4366
4632
|
const resolvedLimitExpirationDraftDate = useMemo(() => {
|
|
4367
4633
|
return resolveLimitExpirationDate({
|
|
@@ -4404,11 +4670,70 @@ var PlaceOrder = ({
|
|
|
4404
4670
|
)
|
|
4405
4671
|
) / Number(LIMIT_ORDER_RAW_SCALE);
|
|
4406
4672
|
}, [internalTab, limitOrderPayload]);
|
|
4673
|
+
const limitRouteCards = useMemo(() => {
|
|
4674
|
+
return visibleLimitVenueOptions.map((option) => {
|
|
4675
|
+
var _a2, _b2;
|
|
4676
|
+
const availabilityState = getVenueAvailabilityState({
|
|
4677
|
+
venueId: option.venue,
|
|
4678
|
+
disabledVenues,
|
|
4679
|
+
isConfigLoading: isAppConfigLoading
|
|
4680
|
+
});
|
|
4681
|
+
const isGeoBlocked = geoBlockedLimitVenues.has(option.venue);
|
|
4682
|
+
const isUnavailable = isTradingBlocked || isGeoBlocked || availabilityState !== "available";
|
|
4683
|
+
const currentPriceLabel = option.currentPrice == null ? "\u2014" : formatProbabilityCents(option.currentPrice, formatPrice);
|
|
4684
|
+
const totalFees = getSmartRouteTotalFees(
|
|
4685
|
+
(_b2 = (_a2 = limitVenueQuoteByVenue.get(option.venue)) == null ? void 0 : _a2.data) == null ? void 0 : _b2.feeBreakdown
|
|
4686
|
+
);
|
|
4687
|
+
const feeLabel = totalFees == null ? void 0 : formatUsd(totalFees, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
4688
|
+
return {
|
|
4689
|
+
id: `limit-venue-${option.venue}-${option.venueMarketOutcomeId}`,
|
|
4690
|
+
hint: isGeoBlocked ? tradingLabels.venueUnavailableInRegion : tradingLabels.limitRoutingCurrentPrice(currentPriceLabel, feeLabel),
|
|
4691
|
+
isUnavailable,
|
|
4692
|
+
kind: "venue",
|
|
4693
|
+
label: getTradingVenueLabel(option.venue),
|
|
4694
|
+
numericValue: displayedLimitToWinValue,
|
|
4695
|
+
value: formatUsd(displayedLimitToWinValue, {
|
|
4696
|
+
maximumFractionDigits: 2,
|
|
4697
|
+
minimumFractionDigits: 2
|
|
4698
|
+
}),
|
|
4699
|
+
venue: option.venue
|
|
4700
|
+
};
|
|
4701
|
+
});
|
|
4702
|
+
}, [
|
|
4703
|
+
disabledVenues,
|
|
4704
|
+
displayedLimitToWinValue,
|
|
4705
|
+
formatPrice,
|
|
4706
|
+
geoBlockedLimitVenues,
|
|
4707
|
+
isAppConfigLoading,
|
|
4708
|
+
isTradingBlocked,
|
|
4709
|
+
limitVenueQuoteByVenue,
|
|
4710
|
+
tradingLabels,
|
|
4711
|
+
visibleLimitVenueOptions
|
|
4712
|
+
]);
|
|
4713
|
+
const limitVenueOptionByCardId = useMemo(() => {
|
|
4714
|
+
return new Map(
|
|
4715
|
+
visibleLimitVenueOptions.map((option) => [
|
|
4716
|
+
`limit-venue-${option.venue}-${option.venueMarketOutcomeId}`,
|
|
4717
|
+
option
|
|
4718
|
+
])
|
|
4719
|
+
);
|
|
4720
|
+
}, [visibleLimitVenueOptions]);
|
|
4721
|
+
const activeRouteCards = isLimitOrder ? limitRouteCards : visibleMarketRouteCards;
|
|
4722
|
+
const activeRouteCardCount = isLimitOrder ? limitRouteCards.length : orderedRouteCards.length;
|
|
4723
|
+
const handleActiveRouteCardSelect = (cardId) => {
|
|
4724
|
+
if (!isLimitOrder) {
|
|
4725
|
+
handleRouteCardSelect(cardId);
|
|
4726
|
+
return;
|
|
4727
|
+
}
|
|
4728
|
+
const option = limitVenueOptionByCardId.get(cardId);
|
|
4729
|
+
if (!option) return;
|
|
4730
|
+
setSelectedLimitVenue(option.venue);
|
|
4731
|
+
};
|
|
4407
4732
|
const displayedLimitToWinHint = formatLimitPriceLabel(limitPrice);
|
|
4408
4733
|
const activeFeeBreakdown = activeQuoteData == null ? void 0 : activeQuoteData.feeBreakdown;
|
|
4409
4734
|
const estimatedFeesValue = useMemo(() => {
|
|
4410
|
-
|
|
4411
|
-
|
|
4735
|
+
const totalFees = getSmartRouteTotalFees(activeFeeBreakdown);
|
|
4736
|
+
if (totalFees == null) return null;
|
|
4412
4737
|
return formatUsd(totalFees, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
4413
4738
|
}, [activeFeeBreakdown]);
|
|
4414
4739
|
const feeBreakdownRows = useMemo(() => {
|
|
@@ -4446,13 +4771,15 @@ var PlaceOrder = ({
|
|
|
4446
4771
|
];
|
|
4447
4772
|
}, [activeFeeBreakdown, tradingLabels]);
|
|
4448
4773
|
const isActionLoading = isPrimaryActionLoading || executeManaged.isPending || placeLimitOrder.isPending || isBeforeActionPending;
|
|
4449
|
-
const
|
|
4774
|
+
const selectedLimitRouteCardId = selectedLimitVenueOption ? `limit-venue-${selectedLimitVenueOption.venue}-${selectedLimitVenueOption.venueMarketOutcomeId}` : null;
|
|
4775
|
+
const selectedLimitRouteCard = selectedLimitRouteCardId ? (_X = limitRouteCards.find((card) => card.id === selectedLimitRouteCardId)) != null ? _X : null : null;
|
|
4776
|
+
const selectedRouteGeoBlocked = isLimitOrder ? (_Y = selectedLimitRouteCard == null ? void 0 : selectedLimitRouteCard.isUnavailable) != null ? _Y : false : (_Z = selectedRouteCard == null ? void 0 : selectedRouteCard.isUnavailable) != null ? _Z : false;
|
|
4450
4777
|
const geoBlockedVenuesFromWarnings = useMemo(
|
|
4451
4778
|
() => {
|
|
4452
4779
|
var _a2;
|
|
4453
4780
|
return extractGeoBlockedVenues((_a2 = smartRoute.data) == null ? void 0 : _a2.warnings);
|
|
4454
4781
|
},
|
|
4455
|
-
[(
|
|
4782
|
+
[(__ = smartRoute.data) == null ? void 0 : __.warnings]
|
|
4456
4783
|
);
|
|
4457
4784
|
const isPrimaryVenueGeoBlocked = useMemo(() => {
|
|
4458
4785
|
var _a2, _b2;
|
|
@@ -4460,12 +4787,12 @@ var PlaceOrder = ({
|
|
|
4460
4787
|
const fills = (_b2 = (_a2 = selectedRouteCard.quoteData) == null ? void 0 : _a2.fills) != null ? _b2 : [];
|
|
4461
4788
|
return fills.length > 0 && fills.every((f) => geoBlockedVenuesFromWarnings.has(f.venue));
|
|
4462
4789
|
}, [selectedRouteCard, geoBlockedVenuesFromWarnings]);
|
|
4463
|
-
const shouldShowGeoBlockBanner = isTradingBlocked || selectedRouteGeoBlocked || isPrimaryVenueGeoBlocked;
|
|
4790
|
+
const shouldShowGeoBlockBanner = isTradingBlocked || selectedRouteGeoBlocked || isPrimaryVenueGeoBlocked || isLimitOrder && limitRouteCards.length > 0 && limitRouteCards.every((card) => card.isUnavailable);
|
|
4464
4791
|
const shouldShowLowLiquidityWarning = !isQuoteInputEditing && !isQuoteLoading && (activeQuoteData == null ? void 0 : activeQuoteData.venueMarketOutcomeId) === scopedSelectedOutcomeId && hasLowLiquidityWarning(activeQuoteData.warnings);
|
|
4465
4792
|
const actionLabel = `${internalTab === "buy" ? tradingLabels.buy : tradingLabels.sell} ${selectedOutcomeLabel}`.trim();
|
|
4466
|
-
const isActionDisabled = isPrimaryActionDisabled || !orderEligibility.canPlaceOrder || isActionLoading || !hasEnteredAmount || !scopedSelectedMarket || isInsufficientBalance || isQuoteInsufficientBalance || isSell && isQuoteInputEditing || isSellAmountAboveAvailability || isBelowMinimum || !isLimitOrder && isQuoteLoading || (isLimitOrder ? !limitOrderPayload : !selectedRouteCard || !selectedRouteCard.quoteData.quoteId) || selectedRouteGeoBlocked || !isAuthenticated || !isLimitOrder && quoteStatus !== void 0;
|
|
4467
|
-
const shouldShowSmartRouting =
|
|
4468
|
-
const shouldShowRouteToggle = !isQuoteLoading && orderedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT;
|
|
4793
|
+
const isActionDisabled = isPrimaryActionDisabled || !orderEligibility.canPlaceOrder || isActionLoading || !hasEnteredAmount || !scopedSelectedMarket || isInsufficientBalance || isQuoteInsufficientBalance || isSell && isQuoteInputEditing || isSellAmountAboveAvailability || isBelowMinimum || !isLimitOrder && isQuoteLoading || isSelectedVenueInventoryInsufficient || (isLimitOrder ? !limitOrderPayload : !selectedRouteCard || !selectedRouteCard.quoteData.quoteId) || selectedRouteGeoBlocked || !isAuthenticated || !isLimitOrder && quoteStatus !== void 0;
|
|
4794
|
+
const shouldShowSmartRouting = orderEligibility.canPlaceOrder && hasEnteredAmount && !isBelowMinimum && (isLimitOrder ? limitRouteCards.length > 0 : orderedRouteCards.length > 0 || smartRoute.isFetching || smartRoute.isLoading || isSell && (venueSellQuotes.isFetching || venueSellQuotes.isLoading));
|
|
4795
|
+
const shouldShowRouteToggle = !isLimitOrder && !isQuoteLoading && orderedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT;
|
|
4469
4796
|
const handleReturnToOrderForm = useCallback2(() => {
|
|
4470
4797
|
const submittedSelection = submittedSelectionRef.current;
|
|
4471
4798
|
submittedSelectionRef.current = null;
|
|
@@ -4803,16 +5130,20 @@ var PlaceOrder = ({
|
|
|
4803
5130
|
}
|
|
4804
5131
|
const refreshedCards = selectedVenueQuote ? buildLiveSellRouteCards({
|
|
4805
5132
|
labels: tradingLabels,
|
|
5133
|
+
requestedSellShares: retryAmount,
|
|
4806
5134
|
smartQuoteData: null,
|
|
4807
5135
|
venueQuotes: [
|
|
4808
5136
|
{
|
|
4809
|
-
|
|
5137
|
+
request: __spreadProps(__spreadValues({}, selectedVenueQuote.request), {
|
|
5138
|
+
sellShares: retryAmount
|
|
5139
|
+
}),
|
|
4810
5140
|
quoteData: refetchedQuoteData
|
|
4811
5141
|
}
|
|
4812
5142
|
]
|
|
4813
5143
|
}) : isSell ? buildLiveSellRouteCards({
|
|
4814
5144
|
eventVenues: scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.venueMarkets.map((market) => market.venue),
|
|
4815
5145
|
labels: tradingLabels,
|
|
5146
|
+
requestedSellShares: retryAmount,
|
|
4816
5147
|
smartQuoteData: refetchedQuoteData,
|
|
4817
5148
|
venueQuotes: []
|
|
4818
5149
|
}) : buildLiveRouteCards({
|
|
@@ -4945,6 +5276,8 @@ var PlaceOrder = ({
|
|
|
4945
5276
|
const handleFillSellableShares = () => {
|
|
4946
5277
|
if (!isSell) return;
|
|
4947
5278
|
if (maxSellableShares <= 0) return;
|
|
5279
|
+
setSelectedRouteCardId(PLACE_ORDER_MAXIMIZE_PAYOUT_ROUTE_ID);
|
|
5280
|
+
setIsSplitDetailOpen(false);
|
|
4948
5281
|
handleAmountChange(maxSellableShares);
|
|
4949
5282
|
};
|
|
4950
5283
|
const handleExecutionTypeChange = (nextType) => {
|
|
@@ -5110,7 +5443,7 @@ var PlaceOrder = ({
|
|
|
5110
5443
|
PlaceOrderResolvedView,
|
|
5111
5444
|
{
|
|
5112
5445
|
tradingState: resolvedReadOnlyTradingState,
|
|
5113
|
-
resolutionTimestamp: (
|
|
5446
|
+
resolutionTimestamp: (_$ = resolvedEventTradingState.resolvesAt) != null ? _$ : resolvedReadOnlyTradingState.resolvesAt,
|
|
5114
5447
|
resolvedClaim,
|
|
5115
5448
|
classNames,
|
|
5116
5449
|
className,
|
|
@@ -5193,261 +5526,228 @@ var PlaceOrder = ({
|
|
|
5193
5526
|
tabItem.value
|
|
5194
5527
|
);
|
|
5195
5528
|
}) }),
|
|
5196
|
-
showLimitOrders ? /* @__PURE__ */
|
|
5197
|
-
|
|
5529
|
+
showLimitOrders ? /* @__PURE__ */ jsx6(
|
|
5530
|
+
Select,
|
|
5198
5531
|
{
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
children: [
|
|
5213
|
-
/* @__PURE__ */ jsx6("span", { children: isLimitOrder ? tradingLabels.orderTypeLimit : tradingLabels.orderTypeMarket }),
|
|
5214
|
-
/* @__PURE__ */ jsx6(Icon, { name: "chevron-down", size: "small", className: "h-4 w-4", "aria-hidden": true })
|
|
5215
|
-
]
|
|
5216
|
-
}
|
|
5217
|
-
) }),
|
|
5218
|
-
/* @__PURE__ */ jsx6(
|
|
5219
|
-
DropdownMenu.Portal,
|
|
5220
|
-
{
|
|
5221
|
-
container: resolvePlaceOrderPortalContainer(executionTypeTriggerRef.current),
|
|
5222
|
-
children: /* @__PURE__ */ jsx6(
|
|
5223
|
-
DropdownMenu.Content,
|
|
5224
|
-
{
|
|
5225
|
-
align: "end",
|
|
5226
|
-
sideOffset: 8,
|
|
5227
|
-
className: "z-50 min-w-[140px] rounded-agg-lg border border-agg-separator bg-agg-secondary p-1 shadow-[0_8px_16px_rgba(0,0,0,0.12)]",
|
|
5228
|
-
children: [
|
|
5229
|
-
{ value: "market", label: tradingLabels.orderTypeMarket },
|
|
5230
|
-
{ value: "limit", label: tradingLabels.orderTypeLimit }
|
|
5231
|
-
].map((item) => /* @__PURE__ */ jsx6(
|
|
5232
|
-
DropdownMenu.Item,
|
|
5233
|
-
{
|
|
5234
|
-
className: cn(
|
|
5235
|
-
"cursor-pointer rounded-agg-sm px-3 py-2 text-agg-sm leading-agg-5 text-agg-foreground outline-none hover:bg-agg-secondary-hover focus:bg-agg-secondary-hover",
|
|
5236
|
-
executionType === item.value && "font-agg-bold text-agg-primary"
|
|
5237
|
-
),
|
|
5238
|
-
onSelect: () => handleExecutionTypeChange(item.value),
|
|
5239
|
-
children: item.label
|
|
5240
|
-
},
|
|
5241
|
-
item.value
|
|
5242
|
-
))
|
|
5243
|
-
}
|
|
5244
|
-
)
|
|
5245
|
-
}
|
|
5246
|
-
)
|
|
5247
|
-
]
|
|
5532
|
+
ariaLabel: tradingLabels.orderTypeAria,
|
|
5533
|
+
className: "mb-2",
|
|
5534
|
+
triggerClassName: "agg-order-type-trigger",
|
|
5535
|
+
items: [
|
|
5536
|
+
{ value: "market", label: tradingLabels.orderTypeMarket },
|
|
5537
|
+
{ value: "limit", label: tradingLabels.orderTypeLimit }
|
|
5538
|
+
],
|
|
5539
|
+
value: executionType,
|
|
5540
|
+
onChange: handleExecutionTypeChange,
|
|
5541
|
+
variant: "inline",
|
|
5542
|
+
openOnHover: true,
|
|
5543
|
+
contentAlign: "end",
|
|
5544
|
+
contentSideOffset: 4
|
|
5248
5545
|
}
|
|
5249
5546
|
) : null
|
|
5250
5547
|
]
|
|
5251
5548
|
}
|
|
5252
5549
|
),
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5550
|
+
/* @__PURE__ */ jsxs5("div", { className: "agg-order-entry-section flex flex-col gap-4", children: [
|
|
5551
|
+
outcomes.length >= 2 ? /* @__PURE__ */ jsx6("div", { className: "agg-outcomes flex w-full max-w-full gap-2", children: outcomes.map((outcome, index) => {
|
|
5552
|
+
var _a2, _b2, _c2;
|
|
5553
|
+
const price = getDisplayOutcomePrice({
|
|
5554
|
+
outcomeId: outcome.id,
|
|
5555
|
+
outcomeLabel: outcome.label,
|
|
5556
|
+
selection: (_a2 = tradingContext == null ? void 0 : tradingContext.tradeSide) != null ? _a2 : isSell ? "sell" : "buy",
|
|
5557
|
+
bestPrices: clusterBestPrices,
|
|
5558
|
+
bestMidpoint: clusterBestMidpoint,
|
|
5559
|
+
bestMidpointsByOutcomeId: clusterBestMidpointsByOutcomeId,
|
|
5560
|
+
livePrices
|
|
5561
|
+
});
|
|
5562
|
+
const isActive = outcome.id === scopedSelectedOutcomeId;
|
|
5563
|
+
const isPositive = resolveIsPositiveOutcome(outcome, index);
|
|
5564
|
+
const isPriceLoading = clusterMidpointResult.isLoading && price == null;
|
|
5565
|
+
return /* @__PURE__ */ jsxs5(
|
|
5566
|
+
"button",
|
|
5567
|
+
{
|
|
5568
|
+
"data-id": outcome.id,
|
|
5569
|
+
type: "button",
|
|
5570
|
+
className: cn(
|
|
5571
|
+
"agg-outcome-button",
|
|
5572
|
+
getOutcomeButtonClassName({
|
|
5573
|
+
enableAnimations,
|
|
5574
|
+
isActive,
|
|
5575
|
+
isPositive
|
|
5576
|
+
}),
|
|
5577
|
+
"disabled:cursor-not-allowed disabled:opacity-60",
|
|
5578
|
+
"leading-agg-5! flex-1 min-w-0 gap-1 md:gap-2"
|
|
5579
|
+
),
|
|
5580
|
+
"aria-pressed": isActive,
|
|
5581
|
+
"aria-label": `${(_b2 = outcome.title) != null ? _b2 : outcome.label} ${formatProbabilityCents(price, formatPrice)}`,
|
|
5582
|
+
disabled: !orderEligibility.canPlaceOrder || isResolvedOutcomeCtaLocked,
|
|
5583
|
+
onClick: () => handleOutcomeChange(outcome.id),
|
|
5584
|
+
children: [
|
|
5585
|
+
/* @__PURE__ */ jsx6(
|
|
5586
|
+
Typography,
|
|
5587
|
+
{
|
|
5588
|
+
as: "span",
|
|
5589
|
+
variant: isActive ? "body-strong" : "body",
|
|
5590
|
+
className: cn("whitespace-nowrap truncate"),
|
|
5591
|
+
children: (_c2 = outcome.title) != null ? _c2 : outcome.label
|
|
5592
|
+
}
|
|
5593
|
+
),
|
|
5594
|
+
isPriceLoading ? /* @__PURE__ */ jsx6(
|
|
5595
|
+
"span",
|
|
5596
|
+
{
|
|
5597
|
+
"aria-hidden": "true",
|
|
5598
|
+
className: cn(
|
|
5599
|
+
"agg-place-order-outcome-price-loading",
|
|
5600
|
+
"h-4 w-10 shrink-0 rounded-agg-sm bg-agg-separator animate-pulse"
|
|
5601
|
+
)
|
|
5602
|
+
}
|
|
5603
|
+
) : /* @__PURE__ */ jsx6(Typography, { as: "span", variant: isActive ? "body-strong" : "body", children: formatProbabilityCents(price, formatPrice) })
|
|
5604
|
+
]
|
|
5605
|
+
},
|
|
5606
|
+
outcome.id
|
|
5607
|
+
);
|
|
5608
|
+
}) }) : null,
|
|
5609
|
+
isLimitOrder ? /* @__PURE__ */ jsxs5("div", { className: "agg-limit-price-section flex items-center justify-between gap-4", children: [
|
|
5610
|
+
/* @__PURE__ */ jsx6("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.limitPrice }),
|
|
5611
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex min-w-0 flex-col items-end gap-1", children: [
|
|
5612
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
|
|
5613
|
+
/* @__PURE__ */ jsxs5("label", { className: "relative flex items-center", children: [
|
|
5614
|
+
/* @__PURE__ */ jsx6(
|
|
5615
|
+
"input",
|
|
5616
|
+
{
|
|
5617
|
+
type: "text",
|
|
5618
|
+
inputMode: "decimal",
|
|
5619
|
+
"aria-label": tradingLabels.limitPriceInputAria,
|
|
5620
|
+
"aria-invalid": Boolean(limitPriceInputError),
|
|
5621
|
+
value: limitPriceInputValue,
|
|
5622
|
+
onChange: handleLimitPriceInputChange,
|
|
5623
|
+
onBlur: handleLimitPriceInputBlur,
|
|
5624
|
+
className: cn(
|
|
5625
|
+
PLACE_ORDER_NUMERIC_INPUT_CLASS_NAME,
|
|
5626
|
+
"h-9 w-[108px] pr-5",
|
|
5627
|
+
limitPriceInputError && "text-agg-error focus-visible:text-agg-error"
|
|
5628
|
+
)
|
|
5629
|
+
}
|
|
5630
|
+
),
|
|
5631
|
+
/* @__PURE__ */ jsx6("span", { className: "pointer-events-none absolute right-1 text-agg-3xl font-agg-bold leading-agg-9 text-agg-foreground", children: "\xA2" })
|
|
5632
|
+
] }),
|
|
5287
5633
|
/* @__PURE__ */ jsx6(
|
|
5288
|
-
|
|
5634
|
+
"button",
|
|
5289
5635
|
{
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5636
|
+
type: "button",
|
|
5637
|
+
className: "flex size-8 cursor-pointer items-center justify-center rounded-agg-lg bg-agg-secondary-hover text-agg-foreground hover:bg-agg-tertiary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary",
|
|
5638
|
+
"aria-label": tradingLabels.limitPriceDecreaseAria,
|
|
5639
|
+
onClick: () => handleLimitPriceStep("decrease"),
|
|
5640
|
+
children: /* @__PURE__ */ jsx6(Icon, { name: "minus", size: "small", className: "h-4 w-4", "aria-hidden": true })
|
|
5294
5641
|
}
|
|
5295
5642
|
),
|
|
5296
|
-
|
|
5297
|
-
"
|
|
5643
|
+
/* @__PURE__ */ jsx6(
|
|
5644
|
+
"button",
|
|
5298
5645
|
{
|
|
5299
|
-
|
|
5300
|
-
className:
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
)
|
|
5646
|
+
type: "button",
|
|
5647
|
+
className: "flex size-8 cursor-pointer items-center justify-center rounded-agg-lg bg-agg-secondary-hover text-agg-foreground hover:bg-agg-tertiary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary",
|
|
5648
|
+
"aria-label": tradingLabels.limitPriceIncreaseAria,
|
|
5649
|
+
onClick: () => handleLimitPriceStep("increase"),
|
|
5650
|
+
children: /* @__PURE__ */ jsx6(Icon, { name: "plus", size: "small", className: "h-4 w-4", "aria-hidden": true })
|
|
5304
5651
|
}
|
|
5305
|
-
)
|
|
5306
|
-
]
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
)
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
"input",
|
|
5652
|
+
)
|
|
5653
|
+
] }),
|
|
5654
|
+
limitPriceInputError ? /* @__PURE__ */ jsx6("p", { className: "max-w-[220px] text-right text-agg-xs leading-agg-4 text-agg-error", children: limitPriceInputError }) : null
|
|
5655
|
+
] })
|
|
5656
|
+
] }) : null,
|
|
5657
|
+
/* @__PURE__ */ jsxs5("div", { className: "agg-order-amount-section flex items-start justify-between gap-4", children: [
|
|
5658
|
+
/* @__PURE__ */ jsxs5("div", { className: "agg-order-amount-meta flex flex-col", children: [
|
|
5659
|
+
/* @__PURE__ */ jsx6("p", { className: "agg-order-amount-label text-agg-base font-agg-bold leading-agg-6 text-agg-foreground whitespace-nowrap", children: tradingLabels.amount(internalTab) }),
|
|
5660
|
+
isAuthenticated ? isSell ? /* @__PURE__ */ jsx6("div", { className: "agg-balance-value flex items-baseline gap-1.5 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: isCurrentSellableSharesLoading ? /* @__PURE__ */ jsx6(LoadingIcon, { size: "small" }) : /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
5661
|
+
/* @__PURE__ */ jsx6("span", { className: "whitespace-pre", children: displayedCurrentSellableSharesLabel }),
|
|
5662
|
+
displayedCurrentSellableShares > 0 ? /* @__PURE__ */ jsx6(
|
|
5663
|
+
"button",
|
|
5318
5664
|
{
|
|
5319
|
-
type: "
|
|
5320
|
-
inputMode: "decimal",
|
|
5321
|
-
"aria-label": tradingLabels.limitPriceInputAria,
|
|
5322
|
-
"aria-invalid": Boolean(limitPriceInputError),
|
|
5323
|
-
value: limitPriceInputValue,
|
|
5324
|
-
onChange: handleLimitPriceInputChange,
|
|
5325
|
-
onBlur: handleLimitPriceInputBlur,
|
|
5665
|
+
type: "button",
|
|
5326
5666
|
className: cn(
|
|
5327
|
-
"
|
|
5328
|
-
"
|
|
5329
|
-
|
|
5330
|
-
|
|
5667
|
+
"agg-max-shares-button",
|
|
5668
|
+
"cursor-pointer disabled:cursor-not-allowed",
|
|
5669
|
+
"bg-transparent p-0 text-agg-sm font-agg-bold leading-agg-5 text-agg-primary disabled:text-agg-muted-foreground",
|
|
5670
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary"
|
|
5671
|
+
),
|
|
5672
|
+
"aria-label": tradingLabels.maxShares,
|
|
5673
|
+
disabled: !orderEligibility.canPlaceOrder || isAtMaxSellableShares,
|
|
5674
|
+
onClick: handleFillSellableShares,
|
|
5675
|
+
children: tradingLabels.maxShares
|
|
5331
5676
|
}
|
|
5332
|
-
)
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5677
|
+
) : null
|
|
5678
|
+
] }) }) : /* @__PURE__ */ jsx6("p", { className: "agg-balance-value flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: isBalanceLoading ? /* @__PURE__ */ jsx6(LoadingIcon, { size: "small" }) : tradingLabels.balance(formatUsd(displayedBalance)) }) : null
|
|
5679
|
+
] }),
|
|
5680
|
+
/* @__PURE__ */ jsx6(
|
|
5681
|
+
CurrencyInput,
|
|
5682
|
+
{
|
|
5683
|
+
value: internalAmount,
|
|
5684
|
+
onChange: handleAmountChange,
|
|
5685
|
+
ariaLabel: tradingLabels.amount(internalTab),
|
|
5686
|
+
max: isLimitOrder && !isSell && isAuthenticated && !isBalanceLoading ? totalBalance : void 0,
|
|
5687
|
+
isInvalid: isInsufficientBalance || isBelowMinimum,
|
|
5688
|
+
disabled: !orderEligibility.canPlaceOrder,
|
|
5689
|
+
prefix: internalTab === "buy" ? "$" : "",
|
|
5690
|
+
decimalPlaces: isSell ? SELL_SHARE_INPUT_DECIMALS : 2,
|
|
5691
|
+
classNames: {
|
|
5692
|
+
input: cn(
|
|
5693
|
+
"agg-order-amount-input",
|
|
5694
|
+
PLACE_ORDER_NUMERIC_INPUT_CLASS_NAME,
|
|
5695
|
+
"w-full max-w-[168px]",
|
|
5696
|
+
hasEnteredAmount ? "text-agg-foreground" : "text-agg-separator caret-agg-foreground"
|
|
5697
|
+
)
|
|
5343
5698
|
}
|
|
5344
|
-
|
|
5699
|
+
}
|
|
5700
|
+
)
|
|
5701
|
+
] }),
|
|
5702
|
+
showFeesBreakdown && hasEnteredAmount && !isBelowMinimum && estimatedFeesValue ? /* @__PURE__ */ jsxs5("div", { className: "agg-order-fees-section flex items-center justify-between gap-4", children: [
|
|
5703
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1.5", children: [
|
|
5345
5704
|
/* @__PURE__ */ jsx6(
|
|
5346
|
-
|
|
5705
|
+
Typography,
|
|
5347
5706
|
{
|
|
5348
|
-
|
|
5349
|
-
className: "
|
|
5350
|
-
|
|
5351
|
-
onClick: () => handleLimitPriceStep("increase"),
|
|
5352
|
-
children: /* @__PURE__ */ jsx6(Icon, { name: "plus", size: "small", className: "h-4 w-4", "aria-hidden": true })
|
|
5707
|
+
variant: "text-sm",
|
|
5708
|
+
className: "text-agg-sm leading-agg-5 text-agg-muted-foreground",
|
|
5709
|
+
children: tradingLabels.estimatedFees
|
|
5353
5710
|
}
|
|
5354
|
-
)
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
] })
|
|
5358
|
-
] }) : null,
|
|
5359
|
-
/* @__PURE__ */ jsxs5("div", { className: "agg-order-amount-section flex items-start justify-between gap-4", children: [
|
|
5360
|
-
/* @__PURE__ */ jsxs5("div", { className: "agg-order-amount-meta flex flex-col", children: [
|
|
5361
|
-
/* @__PURE__ */ jsx6("p", { className: "agg-order-amount-label text-agg-base font-agg-bold leading-agg-6 text-agg-foreground whitespace-nowrap", children: tradingLabels.amount(internalTab) }),
|
|
5362
|
-
isAuthenticated ? isSell ? /* @__PURE__ */ jsx6("div", { className: "agg-balance-value flex items-baseline gap-1.5 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: isCurrentSellableSharesLoading ? /* @__PURE__ */ jsx6(LoadingIcon, { size: "small" }) : /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
5363
|
-
/* @__PURE__ */ jsx6("span", { className: "whitespace-pre", children: displayedCurrentSellableSharesLabel }),
|
|
5364
|
-
displayedCurrentSellableShares > 0 ? /* @__PURE__ */ jsx6(
|
|
5365
|
-
"button",
|
|
5711
|
+
),
|
|
5712
|
+
feeBreakdownRows.length > 0 ? /* @__PURE__ */ jsx6(
|
|
5713
|
+
Tooltip,
|
|
5366
5714
|
{
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5715
|
+
"aria-label": tradingLabels.estimatedFeesTooltipAria,
|
|
5716
|
+
classNames: {
|
|
5717
|
+
content: cn(
|
|
5718
|
+
"min-w-[220px] max-w-[320px] rounded-[10px] px-5 py-4",
|
|
5719
|
+
"shadow-[0_12px_12px_rgba(0,0,0,0.10)]"
|
|
5720
|
+
),
|
|
5721
|
+
icon: "h-3 w-3 text-agg-muted-foreground",
|
|
5722
|
+
trigger: "h-3 w-3 text-agg-muted-foreground"
|
|
5723
|
+
},
|
|
5724
|
+
content: /* @__PURE__ */ jsx6("div", { className: "flex w-full flex-col gap-2", children: feeBreakdownRows.map((row) => /* @__PURE__ */ jsxs5(
|
|
5725
|
+
"div",
|
|
5726
|
+
{
|
|
5727
|
+
className: "flex items-center justify-between gap-3 text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground",
|
|
5728
|
+
children: [
|
|
5729
|
+
/* @__PURE__ */ jsx6("span", { children: row.label }),
|
|
5730
|
+
row.kind === "badge" ? /* @__PURE__ */ jsx6(
|
|
5731
|
+
"span",
|
|
5732
|
+
{
|
|
5733
|
+
className: cn(
|
|
5734
|
+
"agg-fee-badge inline-flex items-center justify-center rounded-agg-sm border border-agg-primary/50",
|
|
5735
|
+
"bg-linear-to-b from-agg-primary/8 to-agg-primary/15 px-1.5 py-1",
|
|
5736
|
+
"text-agg-xs font-agg-bold leading-agg-4 text-agg-primary uppercase whitespace-nowrap"
|
|
5737
|
+
),
|
|
5738
|
+
children: row.badgeLabel
|
|
5739
|
+
}
|
|
5740
|
+
) : /* @__PURE__ */ jsx6("span", { className: "text-right", children: row.value })
|
|
5741
|
+
]
|
|
5742
|
+
},
|
|
5743
|
+
row.label
|
|
5744
|
+
)) })
|
|
5378
5745
|
}
|
|
5379
5746
|
) : null
|
|
5380
|
-
] })
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
CurrencyInput,
|
|
5384
|
-
{
|
|
5385
|
-
value: internalAmount,
|
|
5386
|
-
onChange: handleAmountChange,
|
|
5387
|
-
ariaLabel: tradingLabels.amount(internalTab),
|
|
5388
|
-
max: isLimitOrder && !isSell && isAuthenticated && !isBalanceLoading ? totalBalance : void 0,
|
|
5389
|
-
isInvalid: isInsufficientBalance || isBelowMinimum,
|
|
5390
|
-
disabled: !orderEligibility.canPlaceOrder,
|
|
5391
|
-
prefix: internalTab === "buy" ? "$" : "",
|
|
5392
|
-
decimalPlaces: isSell ? SELL_SHARE_INPUT_DECIMALS : 2,
|
|
5393
|
-
classNames: {
|
|
5394
|
-
input: cn(
|
|
5395
|
-
"agg-order-amount-input",
|
|
5396
|
-
"w-full max-w-[168px] text-right text-agg-3xl font-agg-bold leading-agg-9 tracking-agg-normal",
|
|
5397
|
-
hasEnteredAmount ? "text-agg-foreground" : "text-agg-separator caret-agg-foreground"
|
|
5398
|
-
)
|
|
5399
|
-
}
|
|
5400
|
-
}
|
|
5401
|
-
)
|
|
5747
|
+
] }),
|
|
5748
|
+
/* @__PURE__ */ jsx6("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: estimatedFeesValue })
|
|
5749
|
+
] }) : null
|
|
5402
5750
|
] }),
|
|
5403
|
-
showFeesBreakdown && hasEnteredAmount && !isBelowMinimum && estimatedFeesValue ? /* @__PURE__ */ jsxs5("div", { className: "agg-order-fees-section flex items-center justify-between gap-4", children: [
|
|
5404
|
-
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1.5", children: [
|
|
5405
|
-
/* @__PURE__ */ jsx6(
|
|
5406
|
-
Typography,
|
|
5407
|
-
{
|
|
5408
|
-
variant: "text-sm",
|
|
5409
|
-
className: "text-agg-sm leading-agg-5 text-agg-muted-foreground",
|
|
5410
|
-
children: tradingLabels.estimatedFees
|
|
5411
|
-
}
|
|
5412
|
-
),
|
|
5413
|
-
feeBreakdownRows.length > 0 ? /* @__PURE__ */ jsx6(
|
|
5414
|
-
Tooltip,
|
|
5415
|
-
{
|
|
5416
|
-
"aria-label": tradingLabels.estimatedFeesTooltipAria,
|
|
5417
|
-
classNames: {
|
|
5418
|
-
content: cn(
|
|
5419
|
-
"min-w-[220px] max-w-[320px] rounded-[10px] px-5 py-4",
|
|
5420
|
-
"shadow-[0_12px_12px_rgba(0,0,0,0.10)]"
|
|
5421
|
-
),
|
|
5422
|
-
icon: "h-3 w-3 text-agg-muted-foreground",
|
|
5423
|
-
trigger: "h-3 w-3 text-agg-muted-foreground"
|
|
5424
|
-
},
|
|
5425
|
-
content: /* @__PURE__ */ jsx6("div", { className: "flex w-full flex-col gap-2", children: feeBreakdownRows.map((row) => /* @__PURE__ */ jsxs5(
|
|
5426
|
-
"div",
|
|
5427
|
-
{
|
|
5428
|
-
className: "flex items-center justify-between gap-3 text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground",
|
|
5429
|
-
children: [
|
|
5430
|
-
/* @__PURE__ */ jsx6("span", { children: row.label }),
|
|
5431
|
-
row.kind === "badge" ? /* @__PURE__ */ jsx6(
|
|
5432
|
-
"span",
|
|
5433
|
-
{
|
|
5434
|
-
className: cn(
|
|
5435
|
-
"agg-fee-badge inline-flex items-center justify-center rounded-agg-sm border border-agg-primary/50",
|
|
5436
|
-
"bg-linear-to-b from-agg-primary/8 to-agg-primary/15 px-1.5 py-1",
|
|
5437
|
-
"text-agg-xs font-agg-bold leading-agg-4 text-agg-primary uppercase whitespace-nowrap"
|
|
5438
|
-
),
|
|
5439
|
-
children: row.badgeLabel
|
|
5440
|
-
}
|
|
5441
|
-
) : /* @__PURE__ */ jsx6("span", { className: "text-right", children: row.value })
|
|
5442
|
-
]
|
|
5443
|
-
},
|
|
5444
|
-
row.label
|
|
5445
|
-
)) })
|
|
5446
|
-
}
|
|
5447
|
-
) : null
|
|
5448
|
-
] }),
|
|
5449
|
-
/* @__PURE__ */ jsx6("p", { className: "text-agg-sm leading-agg-5 text-agg-foreground", children: estimatedFeesValue })
|
|
5450
|
-
] }) : null,
|
|
5451
5751
|
shouldShowSmartRouting ? /* @__PURE__ */ jsxs5("div", { className: "agg-route-panel flex flex-col gap-3", children: [
|
|
5452
5752
|
/* @__PURE__ */ jsxs5("div", { className: "agg-route-panel-header flex items-center justify-between gap-4", children: [
|
|
5453
5753
|
/* @__PURE__ */ jsx6("p", { className: "agg-route-panel-title text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.smartRouting }),
|
|
@@ -5456,10 +5756,10 @@ var PlaceOrder = ({
|
|
|
5456
5756
|
{
|
|
5457
5757
|
type: "button",
|
|
5458
5758
|
className: "agg-route-toggle flex cursor-pointer items-center gap-1.5 text-agg-sm leading-agg-5 text-agg-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary",
|
|
5459
|
-
"aria-label": tradingLabels.viewAllRoutes(
|
|
5759
|
+
"aria-label": tradingLabels.viewAllRoutes(activeRouteCardCount),
|
|
5460
5760
|
onClick: () => setIsRoutesExpanded((currentValue) => !currentValue),
|
|
5461
5761
|
children: [
|
|
5462
|
-
/* @__PURE__ */ jsx6("span", { children: tradingLabels.viewAllRoutes(
|
|
5762
|
+
/* @__PURE__ */ jsx6("span", { children: tradingLabels.viewAllRoutes(activeRouteCardCount) }),
|
|
5463
5763
|
/* @__PURE__ */ jsx6(
|
|
5464
5764
|
Icon,
|
|
5465
5765
|
{
|
|
@@ -5473,16 +5773,16 @@ var PlaceOrder = ({
|
|
|
5473
5773
|
}
|
|
5474
5774
|
) : null
|
|
5475
5775
|
] }),
|
|
5476
|
-
/* @__PURE__ */ jsx6("div", { className: "agg-route-list flex flex-col gap-2", children: isQuoteLoading ? /* @__PURE__ */ jsxs5("div", { className: "agg-route-loading flex flex-col gap-2", "aria-hidden": "true", children: [
|
|
5776
|
+
/* @__PURE__ */ jsx6("div", { className: "agg-route-list flex flex-col gap-2", children: !isLimitOrder && isQuoteLoading ? /* @__PURE__ */ jsxs5("div", { className: "agg-route-loading flex flex-col gap-2", "aria-hidden": "true", children: [
|
|
5477
5777
|
/* @__PURE__ */ jsx6(PlaceOrderRouteCardSkeleton, {}),
|
|
5478
5778
|
/* @__PURE__ */ jsx6(PlaceOrderRouteCardSkeleton, {})
|
|
5479
|
-
] }) :
|
|
5779
|
+
] }) : activeRouteCards.length > 0 ? activeRouteCards.map((card) => {
|
|
5480
5780
|
return /* @__PURE__ */ jsx6(Fragment2, { children: renderRouteCard({
|
|
5481
5781
|
card,
|
|
5482
5782
|
enableAnimations,
|
|
5483
5783
|
isExpanded: card.kind === "split" ? isSplitDetailOpen : isRoutesExpanded,
|
|
5484
|
-
isSelected: !card.isUnavailable && card.id === resolvedSelectedRouteCardId,
|
|
5485
|
-
onSelect:
|
|
5784
|
+
isSelected: !card.isUnavailable && card.id === (isLimitOrder ? selectedLimitRouteCardId : resolvedSelectedRouteCardId),
|
|
5785
|
+
onSelect: handleActiveRouteCardSelect,
|
|
5486
5786
|
tradingLabels
|
|
5487
5787
|
}) }, card.id);
|
|
5488
5788
|
}) : null })
|
|
@@ -5503,7 +5803,6 @@ var PlaceOrder = ({
|
|
|
5503
5803
|
className: "flex min-w-0 cursor-pointer items-center justify-end gap-2 text-right text-agg-base leading-agg-6 text-agg-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary",
|
|
5504
5804
|
"aria-label": tradingLabels.expirationMenuAria,
|
|
5505
5805
|
children: [
|
|
5506
|
-
/* @__PURE__ */ jsx6(Icon, { name: "calendar", size: "small", className: "h-4 w-4 shrink-0", "aria-hidden": true }),
|
|
5507
5806
|
/* @__PURE__ */ jsx6("span", { className: "min-w-0 truncate", children: limitExpirationType === "GTC" ? tradingLabels.expirationGoodTilCanceled : limitExpirationType === "FIVE_MINUTES" ? tradingLabels.expirationFiveMinutes : limitExpirationType === "ONE_HOUR" ? tradingLabels.expirationOneHour : limitExpirationType === "END_OF_DAY" ? tradingLabels.expirationEndOfDay : resolvedCustomExpirationDate ? dayjs(resolvedCustomExpirationDate).format(
|
|
5508
5807
|
"MMM D, YYYY [at] HH:mm"
|
|
5509
5808
|
) : tradingLabels.expirationCustom }),
|