@agg-build/ui 4.11.1 → 4.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,7 @@ import {
21
21
  formatChainIdLabel,
22
22
  useClaimWinnings,
23
23
  useResolvedMarketClaim
24
- } from "./chunk-WWIVSROM.mjs";
24
+ } from "./chunk-VHKGW4DB.mjs";
25
25
  import {
26
26
  getDisplayOutcomePrice,
27
27
  resolveHeaderOutcomeItems,
@@ -1412,6 +1412,72 @@ var parseDecimalString = (value) => {
1412
1412
  if (!Number.isFinite(parsed) || parsed <= 0) return null;
1413
1413
  return parsed;
1414
1414
  };
1415
+ var getPlaceOrderBuyPayout = (quoteData) => {
1416
+ var _a;
1417
+ return (_a = quoteData.estimatedPayout) != null ? _a : quoteData.totalFilled;
1418
+ };
1419
+ var getPlaceOrderSellProceeds = (quoteData) => Math.max(
1420
+ 0,
1421
+ quoteData.rawExecCost - quoteData.fills.reduce((sum, fill) => {
1422
+ var _a, _b;
1423
+ return sum + ((_a = fill.venueFee) != null ? _a : 0) + ((_b = fill.builderFee) != null ? _b : 0);
1424
+ }, 0)
1425
+ );
1426
+ var getPlaceOrderQuoteValue = (quoteData, tradeSide) => tradeSide === "sell" ? getPlaceOrderSellProceeds(quoteData) : getPlaceOrderBuyPayout(quoteData);
1427
+ var resolvePlaceOrderNetResult = ({
1428
+ quoteData,
1429
+ tradeSide,
1430
+ shares,
1431
+ usd,
1432
+ terminalOrderEvents,
1433
+ submittedOrders
1434
+ }) => {
1435
+ if (!quoteData) return tradeSide === "sell" ? usd : shares;
1436
+ const actualEvents = (terminalOrderEvents != null ? terminalOrderEvents : []).filter(
1437
+ (event) => (event.event === "filled" || event.event === "partial_fill") && (tradeSide === "buy" ? event.filledAmountRaw != null : event.actualSharesRaw != null)
1438
+ );
1439
+ if (actualEvents.length) {
1440
+ return actualEvents.reduce((sum, event) => {
1441
+ var _a;
1442
+ const outcomeId = (_a = submittedOrders == null ? void 0 : submittedOrders.find(
1443
+ (order) => order.orderId === event.orderId
1444
+ )) == null ? void 0 : _a.outcomeId;
1445
+ const venueFills = quoteData.fills.filter((fill) => fill.venue === event.venue);
1446
+ const exactFill = venueFills.find((fill) => fill.venueMarketOutcomeId === outcomeId);
1447
+ const fills = exactFill ? [exactFill] : venueFills;
1448
+ const legQuote = fills.length ? __spreadProps(__spreadValues({}, quoteData), {
1449
+ fills,
1450
+ totalFilled: fills.reduce((total, fill) => total + fill.venueQty, 0),
1451
+ rawExecCost: fills.reduce((total, fill) => total + fill.avgPrice * fill.venueQty, 0),
1452
+ estimatedPayout: fills.reduce(
1453
+ (total, fill) => {
1454
+ var _a2;
1455
+ return total + fill.venueQty - ((_a2 = fill.settlementFee) != null ? _a2 : 0);
1456
+ },
1457
+ 0
1458
+ )
1459
+ }) : quoteData;
1460
+ const actual = resolveActualExecutionEconomics({
1461
+ quoteData: legQuote,
1462
+ tradeSide,
1463
+ terminalOrderEvents: [event],
1464
+ submittedOrders
1465
+ });
1466
+ return sum + resolvePlaceOrderNetResult({
1467
+ quoteData: legQuote,
1468
+ tradeSide,
1469
+ shares: actual.actualTotalFilled,
1470
+ usd: actual.actualRawExecCost
1471
+ });
1472
+ }, 0);
1473
+ }
1474
+ if (tradeSide === "sell") {
1475
+ const gross = quoteData.rawExecCost;
1476
+ return gross > 0 ? usd * (getPlaceOrderSellProceeds(quoteData) / gross) : usd;
1477
+ }
1478
+ const filled = quoteData.totalFilled;
1479
+ return filled > 0 ? shares * (getPlaceOrderBuyPayout(quoteData) / filled) : shares;
1480
+ };
1415
1481
  var resolvePlaceOrderQuoteResult = ({
1416
1482
  labels,
1417
1483
  quoteData,
@@ -1420,7 +1486,7 @@ var resolvePlaceOrderQuoteResult = ({
1420
1486
  if (!quoteData || quoteData.totalFilled <= 0) return null;
1421
1487
  const avgPrice = getPlaceOrderAverageExecutionPrice(quoteData);
1422
1488
  if (avgPrice == null) return null;
1423
- const quoteValue = tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled;
1489
+ const quoteValue = getPlaceOrderQuoteValue(quoteData, tradeSide);
1424
1490
  return {
1425
1491
  hint: labels.averagePrice(avgPrice),
1426
1492
  value: getTradingValueLabel({
@@ -1538,7 +1604,7 @@ var buildLiveRouteCards = ({
1538
1604
  eventVenues = [],
1539
1605
  geoBlockedVenues: inheritedGeoBlockedVenues
1540
1606
  }) => {
1541
- var _a, _b, _c, _d;
1607
+ var _a, _b, _c, _d, _e;
1542
1608
  const geoBlockedVenues = extractGeoBlockedVenues(quoteData.warnings);
1543
1609
  for (const venue of inheritedGeoBlockedVenues != null ? inheritedGeoBlockedVenues : []) {
1544
1610
  geoBlockedVenues.add(venue);
@@ -1553,6 +1619,7 @@ var buildLiveRouteCards = ({
1553
1619
  );
1554
1620
  const averageExecutionPrice = (_b = getPlaceOrderAverageExecutionPrice(quoteData)) != null ? _b : void 0;
1555
1621
  const primaryWinnerVenue = quoteData.fills.length === 1 ? primaryVenue : void 0;
1622
+ const primaryWinnerOutcomeId = quoteData.fills.length === 1 ? (_c = quoteData.fills[0]) == null ? void 0 : _c.venueMarketOutcomeId : void 0;
1556
1623
  const isPrimaryRouteGeoBlocked = quoteData.fills.length > 0 && quoteData.fills.some((f) => geoBlockedVenues.has(f.venue));
1557
1624
  const primaryCard = primaryResult ? isPrimaryRouteGeoBlocked ? isSplit ? null : {
1558
1625
  id: "live-route",
@@ -1562,7 +1629,7 @@ var buildLiveRouteCards = ({
1562
1629
  parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
1563
1630
  ),
1564
1631
  executionPrice: averageExecutionPrice,
1565
- numericValue: tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled,
1632
+ numericValue: getPlaceOrderQuoteValue(quoteData, tradeSide),
1566
1633
  quoteData,
1567
1634
  value: primaryResult.value,
1568
1635
  venue: parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0,
@@ -1575,7 +1642,7 @@ var buildLiveRouteCards = ({
1575
1642
  label: isSplit ? labels.orderSplitting : getTradingVenueLabel(
1576
1643
  parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
1577
1644
  ),
1578
- numericValue: tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled,
1645
+ numericValue: getPlaceOrderQuoteValue(quoteData, tradeSide),
1579
1646
  quoteData,
1580
1647
  rows: mapQuoteDataToRoutingRows(quoteData, tradeSide),
1581
1648
  description: labels.splitOrderDescription,
@@ -1585,7 +1652,7 @@ var buildLiveRouteCards = ({
1585
1652
  requiresSharedKyc: primaryRequiresSharedKyc
1586
1653
  } : null;
1587
1654
  const soloCardId = (prefix, sq) => `${prefix}-${sq.venue}${sq.venueMarketOutcomeId ? `-${sq.venueMarketOutcomeId}` : ""}`;
1588
- const soloCards = ((_c = quoteData.venueSoloQuotes) != null ? _c : []).filter(
1655
+ const soloCards = ((_d = quoteData.venueSoloQuotes) != null ? _d : []).filter(
1589
1656
  (sq) => sq.status === "ok" && sq.unavailableReason !== "venue_unavailable" && sq.avgPrice !== null && sq.filledQty > 0 && // No `sq.quoteId` requirement: a solo is preview-only whenever its own
1590
1657
  // funding lane is short (API nulls the quoteId), which is NOT always the
1591
1658
  // whole-quote `insufficient_balance` case — an off-chain winner (Kalshi
@@ -1593,9 +1660,9 @@ var buildLiveRouteCards = ({
1593
1660
  // stays unfunded. Gating on the quoteId silently hid that venue from the
1594
1661
  // comparison list entirely. The panel's Deposit CTA fires off the same
1595
1662
  // balance condition, and `handleExecuteQuote` rejects an empty quoteId.
1596
- sq.venue !== primaryWinnerVenue
1663
+ (primaryWinnerOutcomeId && sq.venueMarketOutcomeId ? sq.venueMarketOutcomeId !== primaryWinnerOutcomeId : sq.venue !== primaryWinnerVenue)
1597
1664
  ).map((sq) => {
1598
- var _a2, _b2;
1665
+ var _a2, _b2, _c2, _d2, _e2, _f;
1599
1666
  const parsedVenue = parseVenue(sq.venue);
1600
1667
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
1601
1668
  if (geoBlockedVenues.has(sq.venue)) {
@@ -1605,10 +1672,10 @@ var buildLiveRouteCards = ({
1605
1672
  hint: labels.venueUnavailableInRegion,
1606
1673
  kind: "venue",
1607
1674
  label: getTradingVenueLabel(venue),
1608
- numericValue: sq.filledQty,
1675
+ numericValue: (_a2 = sq.estimatedPayout) != null ? _a2 : sq.filledQty,
1609
1676
  quoteData,
1610
1677
  value: getTradingValueLabel({
1611
- amount: sq.filledQty,
1678
+ amount: (_b2 = sq.estimatedPayout) != null ? _b2 : sq.filledQty,
1612
1679
  minimumFractionDigits: 2,
1613
1680
  maximumFractionDigits: 2
1614
1681
  }),
@@ -1622,7 +1689,7 @@ var buildLiveRouteCards = ({
1622
1689
  // Preview-only solos intentionally carry no executable quoteId; the card
1623
1690
  // should still render for comparison, while the CTA stays disabled until
1624
1691
  // the user is funded and requotes.
1625
- quoteId: (_a2 = sq.quoteId) != null ? _a2 : "",
1692
+ quoteId: (_c2 = sq.quoteId) != null ? _c2 : "",
1626
1693
  fills: sq.fills.map((f) => __spreadValues({}, f)),
1627
1694
  totalFilled: sq.filledQty,
1628
1695
  rawExecCost: sq.rawExecCost,
@@ -1635,7 +1702,7 @@ var buildLiveRouteCards = ({
1635
1702
  // primary route's breakdown in place, so selecting a bridge-free venue
1636
1703
  // still showed the primary's bridging charge. Falls back to the
1637
1704
  // primary only when the router omitted one (non-"ok" solos).
1638
- feeBreakdown: (_b2 = sq.feeBreakdown) != null ? _b2 : quoteData.feeBreakdown
1705
+ feeBreakdown: (_d2 = sq.feeBreakdown) != null ? _d2 : quoteData.feeBreakdown
1639
1706
  }), sq.quoteId ? { status: "ok", error: void 0 } : null);
1640
1707
  return {
1641
1708
  id: soloCardId("live-solo", sq),
@@ -1644,10 +1711,10 @@ var buildLiveRouteCards = ({
1644
1711
  kind: "venue",
1645
1712
  label: getTradingVenueLabel(venue),
1646
1713
  executionPrice: avgPrice,
1647
- numericValue: sq.filledQty,
1714
+ numericValue: (_e2 = sq.estimatedPayout) != null ? _e2 : sq.filledQty,
1648
1715
  quoteData: soloQuoteData,
1649
1716
  value: getTradingValueLabel({
1650
- amount: sq.filledQty,
1717
+ amount: (_f = sq.estimatedPayout) != null ? _f : sq.filledQty,
1651
1718
  minimumFractionDigits: 2,
1652
1719
  maximumFractionDigits: 2
1653
1720
  }),
@@ -1655,7 +1722,8 @@ var buildLiveRouteCards = ({
1655
1722
  requiresSharedKyc: venueRequiresSharedKyc({ venue: sq.venue })
1656
1723
  };
1657
1724
  });
1658
- const unavailableCards = ((_d = quoteData.venueSoloQuotes) != null ? _d : []).filter((sq) => sq.status === "unavailable" || sq.unavailableReason === "venue_unavailable").map((sq) => {
1725
+ const unavailableCards = ((_e = quoteData.venueSoloQuotes) != null ? _e : []).filter((sq) => sq.status === "unavailable" || sq.unavailableReason === "venue_unavailable").map((sq) => {
1726
+ var _a2, _b2;
1659
1727
  const parsedVenue = parseVenue(sq.venue);
1660
1728
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
1661
1729
  const temporarilyUnavailable = sq.unavailableReason === "venue_unavailable";
@@ -1666,10 +1734,10 @@ var buildLiveRouteCards = ({
1666
1734
  hint: temporarilyUnavailable ? labels.venueTemporarilyUnavailable : labels.venueUnavailableInRegion,
1667
1735
  kind: "venue",
1668
1736
  label: getTradingVenueLabel(venue),
1669
- numericValue: hasPreview ? sq.filledQty : 0,
1737
+ numericValue: hasPreview ? (_a2 = sq.estimatedPayout) != null ? _a2 : sq.filledQty : 0,
1670
1738
  quoteData: __spreadProps(__spreadValues({}, quoteData), { quoteId: "" }),
1671
1739
  value: hasPreview ? getTradingValueLabel({
1672
- amount: sq.filledQty,
1740
+ amount: (_b2 = sq.estimatedPayout) != null ? _b2 : sq.filledQty,
1673
1741
  minimumFractionDigits: 2,
1674
1742
  maximumFractionDigits: 2
1675
1743
  }) : ""
@@ -1883,10 +1951,13 @@ var getPlaceOrderPotentialReturn = (quoteData) => {
1883
1951
  if (!((_a = quoteData == null ? void 0 : quoteData.fills) == null ? void 0 : _a.length) || quoteData.fills.length < 2) return 0;
1884
1952
  const bestSoloVenueFill = Math.max(
1885
1953
  0,
1886
- ...((_b = quoteData.venueSoloQuotes) != null ? _b : []).filter((quote) => quote.status === "ok" && quote.filledQty > 0).map((quote) => quote.filledQty)
1954
+ ...((_b = quoteData.venueSoloQuotes) != null ? _b : []).filter((quote) => quote.status === "ok" && quote.filledQty > 0).map((quote) => {
1955
+ var _a2;
1956
+ return (_a2 = quote.estimatedPayout) != null ? _a2 : quote.filledQty;
1957
+ })
1887
1958
  );
1888
1959
  if (bestSoloVenueFill <= 0) return 0;
1889
- return Math.max(0, quoteData.totalFilled - bestSoloVenueFill);
1960
+ return Math.max(0, getPlaceOrderBuyPayout(quoteData) - bestSoloVenueFill);
1890
1961
  };
1891
1962
  var resolvePrimarySubmittedOrderId = ({
1892
1963
  allowOrderIdFallback = true,
@@ -5072,7 +5143,16 @@ var PlaceOrder = ({
5072
5143
  });
5073
5144
  const payoutLabel = formatUsd(usdSide);
5074
5145
  const amountLabel = internalTab === "sell" ? sharesLabel : payoutLabel;
5075
- const toWinLabel = internalTab === "sell" ? payoutLabel : formatUsd(sharesSide);
5146
+ const toWinLabel = formatUsd(
5147
+ resolvePlaceOrderNetResult({
5148
+ quoteData,
5149
+ tradeSide: internalTab,
5150
+ shares: sharesSide,
5151
+ usd: usdSide,
5152
+ terminalOrderEvents: executionProgress.terminalOrderEvents,
5153
+ submittedOrders: executionProgress.submittedOrders
5154
+ })
5155
+ );
5076
5156
  const potentialReturnValue = getPlaceOrderPotentialReturn(quoteData);
5077
5157
  const potentialReturnLabel = potentialReturnValue > 0 ? formatUsd(potentialReturnValue) : void 0;
5078
5158
  const eventTitle = (_f2 = (_e2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _e2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _f2 : "";
@@ -5476,7 +5556,16 @@ var PlaceOrder = ({
5476
5556
  maximumFractionDigits: 2
5477
5557
  })
5478
5558
  ) : formatUsd(actualEconomics.actualRawExecCost);
5479
- const payoutLabel = isSell ? formatUsd(actualEconomics.actualRawExecCost) : formatUsd(actualEconomics.actualTotalFilled);
5559
+ const payoutLabel = formatUsd(
5560
+ resolvePlaceOrderNetResult({
5561
+ quoteData,
5562
+ tradeSide: internalTab,
5563
+ shares: actualEconomics.actualTotalFilled,
5564
+ usd: actualEconomics.actualRawExecCost,
5565
+ terminalOrderEvents: executionProgress.terminalOrderEvents,
5566
+ submittedOrders: executionProgress.submittedOrders
5567
+ })
5568
+ );
5480
5569
  return __spreadProps(__spreadValues({}, summaryWithGroups), {
5481
5570
  actions: summaryWithGroups.actions.map(
5482
5571
  (action) => action.variant === "retry" ? __spreadProps(__spreadValues({}, action), { label: tradingLabels.orderTryRemaining(remainingLabel) }) : action
package/dist/index.js CHANGED
@@ -21818,6 +21818,72 @@ var parseDecimalString = (value) => {
21818
21818
  if (!Number.isFinite(parsed) || parsed <= 0) return null;
21819
21819
  return parsed;
21820
21820
  };
21821
+ var getPlaceOrderBuyPayout = (quoteData) => {
21822
+ var _a;
21823
+ return (_a = quoteData.estimatedPayout) != null ? _a : quoteData.totalFilled;
21824
+ };
21825
+ var getPlaceOrderSellProceeds = (quoteData) => Math.max(
21826
+ 0,
21827
+ quoteData.rawExecCost - quoteData.fills.reduce((sum, fill) => {
21828
+ var _a, _b;
21829
+ return sum + ((_a = fill.venueFee) != null ? _a : 0) + ((_b = fill.builderFee) != null ? _b : 0);
21830
+ }, 0)
21831
+ );
21832
+ var getPlaceOrderQuoteValue = (quoteData, tradeSide) => tradeSide === "sell" ? getPlaceOrderSellProceeds(quoteData) : getPlaceOrderBuyPayout(quoteData);
21833
+ var resolvePlaceOrderNetResult = ({
21834
+ quoteData,
21835
+ tradeSide,
21836
+ shares,
21837
+ usd,
21838
+ terminalOrderEvents,
21839
+ submittedOrders
21840
+ }) => {
21841
+ if (!quoteData) return tradeSide === "sell" ? usd : shares;
21842
+ const actualEvents = (terminalOrderEvents != null ? terminalOrderEvents : []).filter(
21843
+ (event) => (event.event === "filled" || event.event === "partial_fill") && (tradeSide === "buy" ? event.filledAmountRaw != null : event.actualSharesRaw != null)
21844
+ );
21845
+ if (actualEvents.length) {
21846
+ return actualEvents.reduce((sum, event) => {
21847
+ var _a;
21848
+ const outcomeId = (_a = submittedOrders == null ? void 0 : submittedOrders.find(
21849
+ (order) => order.orderId === event.orderId
21850
+ )) == null ? void 0 : _a.outcomeId;
21851
+ const venueFills = quoteData.fills.filter((fill) => fill.venue === event.venue);
21852
+ const exactFill = venueFills.find((fill) => fill.venueMarketOutcomeId === outcomeId);
21853
+ const fills = exactFill ? [exactFill] : venueFills;
21854
+ const legQuote = fills.length ? __spreadProps(__spreadValues({}, quoteData), {
21855
+ fills,
21856
+ totalFilled: fills.reduce((total, fill) => total + fill.venueQty, 0),
21857
+ rawExecCost: fills.reduce((total, fill) => total + fill.avgPrice * fill.venueQty, 0),
21858
+ estimatedPayout: fills.reduce(
21859
+ (total, fill) => {
21860
+ var _a2;
21861
+ return total + fill.venueQty - ((_a2 = fill.settlementFee) != null ? _a2 : 0);
21862
+ },
21863
+ 0
21864
+ )
21865
+ }) : quoteData;
21866
+ const actual = resolveActualExecutionEconomics({
21867
+ quoteData: legQuote,
21868
+ tradeSide,
21869
+ terminalOrderEvents: [event],
21870
+ submittedOrders
21871
+ });
21872
+ return sum + resolvePlaceOrderNetResult({
21873
+ quoteData: legQuote,
21874
+ tradeSide,
21875
+ shares: actual.actualTotalFilled,
21876
+ usd: actual.actualRawExecCost
21877
+ });
21878
+ }, 0);
21879
+ }
21880
+ if (tradeSide === "sell") {
21881
+ const gross = quoteData.rawExecCost;
21882
+ return gross > 0 ? usd * (getPlaceOrderSellProceeds(quoteData) / gross) : usd;
21883
+ }
21884
+ const filled = quoteData.totalFilled;
21885
+ return filled > 0 ? shares * (getPlaceOrderBuyPayout(quoteData) / filled) : shares;
21886
+ };
21821
21887
  var resolvePlaceOrderQuoteResult = ({
21822
21888
  labels,
21823
21889
  quoteData,
@@ -21826,7 +21892,7 @@ var resolvePlaceOrderQuoteResult = ({
21826
21892
  if (!quoteData || quoteData.totalFilled <= 0) return null;
21827
21893
  const avgPrice = getPlaceOrderAverageExecutionPrice(quoteData);
21828
21894
  if (avgPrice == null) return null;
21829
- const quoteValue = tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled;
21895
+ const quoteValue = getPlaceOrderQuoteValue(quoteData, tradeSide);
21830
21896
  return {
21831
21897
  hint: labels.averagePrice(avgPrice),
21832
21898
  value: getTradingValueLabel({
@@ -21944,7 +22010,7 @@ var buildLiveRouteCards = ({
21944
22010
  eventVenues = [],
21945
22011
  geoBlockedVenues: inheritedGeoBlockedVenues
21946
22012
  }) => {
21947
- var _a, _b, _c, _d;
22013
+ var _a, _b, _c, _d, _e;
21948
22014
  const geoBlockedVenues = extractGeoBlockedVenues(quoteData.warnings);
21949
22015
  for (const venue of inheritedGeoBlockedVenues != null ? inheritedGeoBlockedVenues : []) {
21950
22016
  geoBlockedVenues.add(venue);
@@ -21959,6 +22025,7 @@ var buildLiveRouteCards = ({
21959
22025
  );
21960
22026
  const averageExecutionPrice = (_b = getPlaceOrderAverageExecutionPrice(quoteData)) != null ? _b : void 0;
21961
22027
  const primaryWinnerVenue = quoteData.fills.length === 1 ? primaryVenue : void 0;
22028
+ const primaryWinnerOutcomeId = quoteData.fills.length === 1 ? (_c = quoteData.fills[0]) == null ? void 0 : _c.venueMarketOutcomeId : void 0;
21962
22029
  const isPrimaryRouteGeoBlocked = quoteData.fills.length > 0 && quoteData.fills.some((f) => geoBlockedVenues.has(f.venue));
21963
22030
  const primaryCard = primaryResult ? isPrimaryRouteGeoBlocked ? isSplit ? null : {
21964
22031
  id: "live-route",
@@ -21968,7 +22035,7 @@ var buildLiveRouteCards = ({
21968
22035
  parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
21969
22036
  ),
21970
22037
  executionPrice: averageExecutionPrice,
21971
- numericValue: tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled,
22038
+ numericValue: getPlaceOrderQuoteValue(quoteData, tradeSide),
21972
22039
  quoteData,
21973
22040
  value: primaryResult.value,
21974
22041
  venue: parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0,
@@ -21981,7 +22048,7 @@ var buildLiveRouteCards = ({
21981
22048
  label: isSplit ? labels.orderSplitting : getTradingVenueLabel(
21982
22049
  parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
21983
22050
  ),
21984
- numericValue: tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled,
22051
+ numericValue: getPlaceOrderQuoteValue(quoteData, tradeSide),
21985
22052
  quoteData,
21986
22053
  rows: mapQuoteDataToRoutingRows(quoteData, tradeSide),
21987
22054
  description: labels.splitOrderDescription,
@@ -21991,7 +22058,7 @@ var buildLiveRouteCards = ({
21991
22058
  requiresSharedKyc: primaryRequiresSharedKyc
21992
22059
  } : null;
21993
22060
  const soloCardId = (prefix, sq) => `${prefix}-${sq.venue}${sq.venueMarketOutcomeId ? `-${sq.venueMarketOutcomeId}` : ""}`;
21994
- const soloCards = ((_c = quoteData.venueSoloQuotes) != null ? _c : []).filter(
22061
+ const soloCards = ((_d = quoteData.venueSoloQuotes) != null ? _d : []).filter(
21995
22062
  (sq) => sq.status === "ok" && sq.unavailableReason !== "venue_unavailable" && sq.avgPrice !== null && sq.filledQty > 0 && // No `sq.quoteId` requirement: a solo is preview-only whenever its own
21996
22063
  // funding lane is short (API nulls the quoteId), which is NOT always the
21997
22064
  // whole-quote `insufficient_balance` case — an off-chain winner (Kalshi
@@ -21999,9 +22066,9 @@ var buildLiveRouteCards = ({
21999
22066
  // stays unfunded. Gating on the quoteId silently hid that venue from the
22000
22067
  // comparison list entirely. The panel's Deposit CTA fires off the same
22001
22068
  // balance condition, and `handleExecuteQuote` rejects an empty quoteId.
22002
- sq.venue !== primaryWinnerVenue
22069
+ (primaryWinnerOutcomeId && sq.venueMarketOutcomeId ? sq.venueMarketOutcomeId !== primaryWinnerOutcomeId : sq.venue !== primaryWinnerVenue)
22003
22070
  ).map((sq) => {
22004
- var _a2, _b2;
22071
+ var _a2, _b2, _c2, _d2, _e2, _f;
22005
22072
  const parsedVenue = parseVenue(sq.venue);
22006
22073
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
22007
22074
  if (geoBlockedVenues.has(sq.venue)) {
@@ -22011,10 +22078,10 @@ var buildLiveRouteCards = ({
22011
22078
  hint: labels.venueUnavailableInRegion,
22012
22079
  kind: "venue",
22013
22080
  label: getTradingVenueLabel(venue),
22014
- numericValue: sq.filledQty,
22081
+ numericValue: (_a2 = sq.estimatedPayout) != null ? _a2 : sq.filledQty,
22015
22082
  quoteData,
22016
22083
  value: getTradingValueLabel({
22017
- amount: sq.filledQty,
22084
+ amount: (_b2 = sq.estimatedPayout) != null ? _b2 : sq.filledQty,
22018
22085
  minimumFractionDigits: 2,
22019
22086
  maximumFractionDigits: 2
22020
22087
  }),
@@ -22028,7 +22095,7 @@ var buildLiveRouteCards = ({
22028
22095
  // Preview-only solos intentionally carry no executable quoteId; the card
22029
22096
  // should still render for comparison, while the CTA stays disabled until
22030
22097
  // the user is funded and requotes.
22031
- quoteId: (_a2 = sq.quoteId) != null ? _a2 : "",
22098
+ quoteId: (_c2 = sq.quoteId) != null ? _c2 : "",
22032
22099
  fills: sq.fills.map((f) => __spreadValues({}, f)),
22033
22100
  totalFilled: sq.filledQty,
22034
22101
  rawExecCost: sq.rawExecCost,
@@ -22041,7 +22108,7 @@ var buildLiveRouteCards = ({
22041
22108
  // primary route's breakdown in place, so selecting a bridge-free venue
22042
22109
  // still showed the primary's bridging charge. Falls back to the
22043
22110
  // primary only when the router omitted one (non-"ok" solos).
22044
- feeBreakdown: (_b2 = sq.feeBreakdown) != null ? _b2 : quoteData.feeBreakdown
22111
+ feeBreakdown: (_d2 = sq.feeBreakdown) != null ? _d2 : quoteData.feeBreakdown
22045
22112
  }), sq.quoteId ? { status: "ok", error: void 0 } : null);
22046
22113
  return {
22047
22114
  id: soloCardId("live-solo", sq),
@@ -22050,10 +22117,10 @@ var buildLiveRouteCards = ({
22050
22117
  kind: "venue",
22051
22118
  label: getTradingVenueLabel(venue),
22052
22119
  executionPrice: avgPrice,
22053
- numericValue: sq.filledQty,
22120
+ numericValue: (_e2 = sq.estimatedPayout) != null ? _e2 : sq.filledQty,
22054
22121
  quoteData: soloQuoteData,
22055
22122
  value: getTradingValueLabel({
22056
- amount: sq.filledQty,
22123
+ amount: (_f = sq.estimatedPayout) != null ? _f : sq.filledQty,
22057
22124
  minimumFractionDigits: 2,
22058
22125
  maximumFractionDigits: 2
22059
22126
  }),
@@ -22061,7 +22128,8 @@ var buildLiveRouteCards = ({
22061
22128
  requiresSharedKyc: venueRequiresSharedKyc({ venue: sq.venue })
22062
22129
  };
22063
22130
  });
22064
- const unavailableCards = ((_d = quoteData.venueSoloQuotes) != null ? _d : []).filter((sq) => sq.status === "unavailable" || sq.unavailableReason === "venue_unavailable").map((sq) => {
22131
+ const unavailableCards = ((_e = quoteData.venueSoloQuotes) != null ? _e : []).filter((sq) => sq.status === "unavailable" || sq.unavailableReason === "venue_unavailable").map((sq) => {
22132
+ var _a2, _b2;
22065
22133
  const parsedVenue = parseVenue(sq.venue);
22066
22134
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
22067
22135
  const temporarilyUnavailable = sq.unavailableReason === "venue_unavailable";
@@ -22072,10 +22140,10 @@ var buildLiveRouteCards = ({
22072
22140
  hint: temporarilyUnavailable ? labels.venueTemporarilyUnavailable : labels.venueUnavailableInRegion,
22073
22141
  kind: "venue",
22074
22142
  label: getTradingVenueLabel(venue),
22075
- numericValue: hasPreview ? sq.filledQty : 0,
22143
+ numericValue: hasPreview ? (_a2 = sq.estimatedPayout) != null ? _a2 : sq.filledQty : 0,
22076
22144
  quoteData: __spreadProps(__spreadValues({}, quoteData), { quoteId: "" }),
22077
22145
  value: hasPreview ? getTradingValueLabel({
22078
- amount: sq.filledQty,
22146
+ amount: (_b2 = sq.estimatedPayout) != null ? _b2 : sq.filledQty,
22079
22147
  minimumFractionDigits: 2,
22080
22148
  maximumFractionDigits: 2
22081
22149
  }) : ""
@@ -22289,10 +22357,13 @@ var getPlaceOrderPotentialReturn = (quoteData) => {
22289
22357
  if (!((_a = quoteData == null ? void 0 : quoteData.fills) == null ? void 0 : _a.length) || quoteData.fills.length < 2) return 0;
22290
22358
  const bestSoloVenueFill = Math.max(
22291
22359
  0,
22292
- ...((_b = quoteData.venueSoloQuotes) != null ? _b : []).filter((quote) => quote.status === "ok" && quote.filledQty > 0).map((quote) => quote.filledQty)
22360
+ ...((_b = quoteData.venueSoloQuotes) != null ? _b : []).filter((quote) => quote.status === "ok" && quote.filledQty > 0).map((quote) => {
22361
+ var _a2;
22362
+ return (_a2 = quote.estimatedPayout) != null ? _a2 : quote.filledQty;
22363
+ })
22293
22364
  );
22294
22365
  if (bestSoloVenueFill <= 0) return 0;
22295
- return Math.max(0, quoteData.totalFilled - bestSoloVenueFill);
22366
+ return Math.max(0, getPlaceOrderBuyPayout(quoteData) - bestSoloVenueFill);
22296
22367
  };
22297
22368
  var resolvePrimarySubmittedOrderId = ({
22298
22369
  allowOrderIdFallback = true,
@@ -25478,7 +25549,16 @@ var PlaceOrder = ({
25478
25549
  });
25479
25550
  const payoutLabel = formatUsd(usdSide);
25480
25551
  const amountLabel = internalTab === "sell" ? sharesLabel : payoutLabel;
25481
- const toWinLabel = internalTab === "sell" ? payoutLabel : formatUsd(sharesSide);
25552
+ const toWinLabel = formatUsd(
25553
+ resolvePlaceOrderNetResult({
25554
+ quoteData,
25555
+ tradeSide: internalTab,
25556
+ shares: sharesSide,
25557
+ usd: usdSide,
25558
+ terminalOrderEvents: executionProgress.terminalOrderEvents,
25559
+ submittedOrders: executionProgress.submittedOrders
25560
+ })
25561
+ );
25482
25562
  const potentialReturnValue = getPlaceOrderPotentialReturn(quoteData);
25483
25563
  const potentialReturnLabel = potentialReturnValue > 0 ? formatUsd(potentialReturnValue) : void 0;
25484
25564
  const eventTitle = (_f2 = (_e2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _e2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _f2 : "";
@@ -25882,7 +25962,16 @@ var PlaceOrder = ({
25882
25962
  maximumFractionDigits: 2
25883
25963
  })
25884
25964
  ) : formatUsd(actualEconomics.actualRawExecCost);
25885
- const payoutLabel = isSell ? formatUsd(actualEconomics.actualRawExecCost) : formatUsd(actualEconomics.actualTotalFilled);
25965
+ const payoutLabel = formatUsd(
25966
+ resolvePlaceOrderNetResult({
25967
+ quoteData,
25968
+ tradeSide: internalTab,
25969
+ shares: actualEconomics.actualTotalFilled,
25970
+ usd: actualEconomics.actualRawExecCost,
25971
+ terminalOrderEvents: executionProgress.terminalOrderEvents,
25972
+ submittedOrders: executionProgress.submittedOrders
25973
+ })
25974
+ );
25886
25975
  return __spreadProps(__spreadValues({}, summaryWithGroups), {
25887
25976
  actions: summaryWithGroups.actions.map(
25888
25977
  (action) => action.variant === "retry" ? __spreadProps(__spreadValues({}, action), { label: tradingLabels.orderTryRemaining(remainingLabel) }) : action
package/dist/index.mjs CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  formatRecurringCountdown,
15
15
  formatShareAmount,
16
16
  useHomePageModals
17
- } from "./chunk-VMG6BUHI.mjs";
17
+ } from "./chunk-5D36HPOG.mjs";
18
18
  import {
19
19
  EventList,
20
20
  EventListItem,
@@ -67,7 +67,7 @@ import {
67
67
  useResolvedMarketClaim,
68
68
  useSharedKycFlow,
69
69
  venueRequiresSharedKyc
70
- } from "./chunk-WWIVSROM.mjs";
70
+ } from "./chunk-VHKGW4DB.mjs";
71
71
  import {
72
72
  SETTLEMENT_SECTION_ID,
73
73
  Settlement,
package/dist/pages.js CHANGED
@@ -19493,6 +19493,72 @@ var parseDecimalString = (value) => {
19493
19493
  if (!Number.isFinite(parsed) || parsed <= 0) return null;
19494
19494
  return parsed;
19495
19495
  };
19496
+ var getPlaceOrderBuyPayout = (quoteData) => {
19497
+ var _a;
19498
+ return (_a = quoteData.estimatedPayout) != null ? _a : quoteData.totalFilled;
19499
+ };
19500
+ var getPlaceOrderSellProceeds = (quoteData) => Math.max(
19501
+ 0,
19502
+ quoteData.rawExecCost - quoteData.fills.reduce((sum, fill) => {
19503
+ var _a, _b;
19504
+ return sum + ((_a = fill.venueFee) != null ? _a : 0) + ((_b = fill.builderFee) != null ? _b : 0);
19505
+ }, 0)
19506
+ );
19507
+ var getPlaceOrderQuoteValue = (quoteData, tradeSide) => tradeSide === "sell" ? getPlaceOrderSellProceeds(quoteData) : getPlaceOrderBuyPayout(quoteData);
19508
+ var resolvePlaceOrderNetResult = ({
19509
+ quoteData,
19510
+ tradeSide,
19511
+ shares,
19512
+ usd,
19513
+ terminalOrderEvents,
19514
+ submittedOrders
19515
+ }) => {
19516
+ if (!quoteData) return tradeSide === "sell" ? usd : shares;
19517
+ const actualEvents = (terminalOrderEvents != null ? terminalOrderEvents : []).filter(
19518
+ (event) => (event.event === "filled" || event.event === "partial_fill") && (tradeSide === "buy" ? event.filledAmountRaw != null : event.actualSharesRaw != null)
19519
+ );
19520
+ if (actualEvents.length) {
19521
+ return actualEvents.reduce((sum, event) => {
19522
+ var _a;
19523
+ const outcomeId = (_a = submittedOrders == null ? void 0 : submittedOrders.find(
19524
+ (order) => order.orderId === event.orderId
19525
+ )) == null ? void 0 : _a.outcomeId;
19526
+ const venueFills = quoteData.fills.filter((fill) => fill.venue === event.venue);
19527
+ const exactFill = venueFills.find((fill) => fill.venueMarketOutcomeId === outcomeId);
19528
+ const fills = exactFill ? [exactFill] : venueFills;
19529
+ const legQuote = fills.length ? __spreadProps(__spreadValues({}, quoteData), {
19530
+ fills,
19531
+ totalFilled: fills.reduce((total, fill) => total + fill.venueQty, 0),
19532
+ rawExecCost: fills.reduce((total, fill) => total + fill.avgPrice * fill.venueQty, 0),
19533
+ estimatedPayout: fills.reduce(
19534
+ (total, fill) => {
19535
+ var _a2;
19536
+ return total + fill.venueQty - ((_a2 = fill.settlementFee) != null ? _a2 : 0);
19537
+ },
19538
+ 0
19539
+ )
19540
+ }) : quoteData;
19541
+ const actual = resolveActualExecutionEconomics({
19542
+ quoteData: legQuote,
19543
+ tradeSide,
19544
+ terminalOrderEvents: [event],
19545
+ submittedOrders
19546
+ });
19547
+ return sum + resolvePlaceOrderNetResult({
19548
+ quoteData: legQuote,
19549
+ tradeSide,
19550
+ shares: actual.actualTotalFilled,
19551
+ usd: actual.actualRawExecCost
19552
+ });
19553
+ }, 0);
19554
+ }
19555
+ if (tradeSide === "sell") {
19556
+ const gross = quoteData.rawExecCost;
19557
+ return gross > 0 ? usd * (getPlaceOrderSellProceeds(quoteData) / gross) : usd;
19558
+ }
19559
+ const filled = quoteData.totalFilled;
19560
+ return filled > 0 ? shares * (getPlaceOrderBuyPayout(quoteData) / filled) : shares;
19561
+ };
19496
19562
  var resolvePlaceOrderQuoteResult = ({
19497
19563
  labels,
19498
19564
  quoteData,
@@ -19501,7 +19567,7 @@ var resolvePlaceOrderQuoteResult = ({
19501
19567
  if (!quoteData || quoteData.totalFilled <= 0) return null;
19502
19568
  const avgPrice = getPlaceOrderAverageExecutionPrice(quoteData);
19503
19569
  if (avgPrice == null) return null;
19504
- const quoteValue = tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled;
19570
+ const quoteValue = getPlaceOrderQuoteValue(quoteData, tradeSide);
19505
19571
  return {
19506
19572
  hint: labels.averagePrice(avgPrice),
19507
19573
  value: getTradingValueLabel({
@@ -19619,7 +19685,7 @@ var buildLiveRouteCards = ({
19619
19685
  eventVenues = [],
19620
19686
  geoBlockedVenues: inheritedGeoBlockedVenues
19621
19687
  }) => {
19622
- var _a, _b, _c, _d;
19688
+ var _a, _b, _c, _d, _e;
19623
19689
  const geoBlockedVenues = extractGeoBlockedVenues(quoteData.warnings);
19624
19690
  for (const venue of inheritedGeoBlockedVenues != null ? inheritedGeoBlockedVenues : []) {
19625
19691
  geoBlockedVenues.add(venue);
@@ -19634,6 +19700,7 @@ var buildLiveRouteCards = ({
19634
19700
  );
19635
19701
  const averageExecutionPrice = (_b = getPlaceOrderAverageExecutionPrice(quoteData)) != null ? _b : void 0;
19636
19702
  const primaryWinnerVenue = quoteData.fills.length === 1 ? primaryVenue : void 0;
19703
+ const primaryWinnerOutcomeId = quoteData.fills.length === 1 ? (_c = quoteData.fills[0]) == null ? void 0 : _c.venueMarketOutcomeId : void 0;
19637
19704
  const isPrimaryRouteGeoBlocked = quoteData.fills.length > 0 && quoteData.fills.some((f) => geoBlockedVenues.has(f.venue));
19638
19705
  const primaryCard = primaryResult ? isPrimaryRouteGeoBlocked ? isSplit ? null : {
19639
19706
  id: "live-route",
@@ -19643,7 +19710,7 @@ var buildLiveRouteCards = ({
19643
19710
  parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
19644
19711
  ),
19645
19712
  executionPrice: averageExecutionPrice,
19646
- numericValue: tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled,
19713
+ numericValue: getPlaceOrderQuoteValue(quoteData, tradeSide),
19647
19714
  quoteData,
19648
19715
  value: primaryResult.value,
19649
19716
  venue: parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0,
@@ -19656,7 +19723,7 @@ var buildLiveRouteCards = ({
19656
19723
  label: isSplit ? labels.orderSplitting : getTradingVenueLabel(
19657
19724
  parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
19658
19725
  ),
19659
- numericValue: tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled,
19726
+ numericValue: getPlaceOrderQuoteValue(quoteData, tradeSide),
19660
19727
  quoteData,
19661
19728
  rows: mapQuoteDataToRoutingRows(quoteData, tradeSide),
19662
19729
  description: labels.splitOrderDescription,
@@ -19666,7 +19733,7 @@ var buildLiveRouteCards = ({
19666
19733
  requiresSharedKyc: primaryRequiresSharedKyc
19667
19734
  } : null;
19668
19735
  const soloCardId = (prefix, sq) => `${prefix}-${sq.venue}${sq.venueMarketOutcomeId ? `-${sq.venueMarketOutcomeId}` : ""}`;
19669
- const soloCards = ((_c = quoteData.venueSoloQuotes) != null ? _c : []).filter(
19736
+ const soloCards = ((_d = quoteData.venueSoloQuotes) != null ? _d : []).filter(
19670
19737
  (sq) => sq.status === "ok" && sq.unavailableReason !== "venue_unavailable" && sq.avgPrice !== null && sq.filledQty > 0 && // No `sq.quoteId` requirement: a solo is preview-only whenever its own
19671
19738
  // funding lane is short (API nulls the quoteId), which is NOT always the
19672
19739
  // whole-quote `insufficient_balance` case — an off-chain winner (Kalshi
@@ -19674,9 +19741,9 @@ var buildLiveRouteCards = ({
19674
19741
  // stays unfunded. Gating on the quoteId silently hid that venue from the
19675
19742
  // comparison list entirely. The panel's Deposit CTA fires off the same
19676
19743
  // balance condition, and `handleExecuteQuote` rejects an empty quoteId.
19677
- sq.venue !== primaryWinnerVenue
19744
+ (primaryWinnerOutcomeId && sq.venueMarketOutcomeId ? sq.venueMarketOutcomeId !== primaryWinnerOutcomeId : sq.venue !== primaryWinnerVenue)
19678
19745
  ).map((sq) => {
19679
- var _a2, _b2;
19746
+ var _a2, _b2, _c2, _d2, _e2, _f;
19680
19747
  const parsedVenue = parseVenue(sq.venue);
19681
19748
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
19682
19749
  if (geoBlockedVenues.has(sq.venue)) {
@@ -19686,10 +19753,10 @@ var buildLiveRouteCards = ({
19686
19753
  hint: labels.venueUnavailableInRegion,
19687
19754
  kind: "venue",
19688
19755
  label: getTradingVenueLabel(venue),
19689
- numericValue: sq.filledQty,
19756
+ numericValue: (_a2 = sq.estimatedPayout) != null ? _a2 : sq.filledQty,
19690
19757
  quoteData,
19691
19758
  value: getTradingValueLabel({
19692
- amount: sq.filledQty,
19759
+ amount: (_b2 = sq.estimatedPayout) != null ? _b2 : sq.filledQty,
19693
19760
  minimumFractionDigits: 2,
19694
19761
  maximumFractionDigits: 2
19695
19762
  }),
@@ -19703,7 +19770,7 @@ var buildLiveRouteCards = ({
19703
19770
  // Preview-only solos intentionally carry no executable quoteId; the card
19704
19771
  // should still render for comparison, while the CTA stays disabled until
19705
19772
  // the user is funded and requotes.
19706
- quoteId: (_a2 = sq.quoteId) != null ? _a2 : "",
19773
+ quoteId: (_c2 = sq.quoteId) != null ? _c2 : "",
19707
19774
  fills: sq.fills.map((f) => __spreadValues({}, f)),
19708
19775
  totalFilled: sq.filledQty,
19709
19776
  rawExecCost: sq.rawExecCost,
@@ -19716,7 +19783,7 @@ var buildLiveRouteCards = ({
19716
19783
  // primary route's breakdown in place, so selecting a bridge-free venue
19717
19784
  // still showed the primary's bridging charge. Falls back to the
19718
19785
  // primary only when the router omitted one (non-"ok" solos).
19719
- feeBreakdown: (_b2 = sq.feeBreakdown) != null ? _b2 : quoteData.feeBreakdown
19786
+ feeBreakdown: (_d2 = sq.feeBreakdown) != null ? _d2 : quoteData.feeBreakdown
19720
19787
  }), sq.quoteId ? { status: "ok", error: void 0 } : null);
19721
19788
  return {
19722
19789
  id: soloCardId("live-solo", sq),
@@ -19725,10 +19792,10 @@ var buildLiveRouteCards = ({
19725
19792
  kind: "venue",
19726
19793
  label: getTradingVenueLabel(venue),
19727
19794
  executionPrice: avgPrice,
19728
- numericValue: sq.filledQty,
19795
+ numericValue: (_e2 = sq.estimatedPayout) != null ? _e2 : sq.filledQty,
19729
19796
  quoteData: soloQuoteData,
19730
19797
  value: getTradingValueLabel({
19731
- amount: sq.filledQty,
19798
+ amount: (_f = sq.estimatedPayout) != null ? _f : sq.filledQty,
19732
19799
  minimumFractionDigits: 2,
19733
19800
  maximumFractionDigits: 2
19734
19801
  }),
@@ -19736,7 +19803,8 @@ var buildLiveRouteCards = ({
19736
19803
  requiresSharedKyc: venueRequiresSharedKyc({ venue: sq.venue })
19737
19804
  };
19738
19805
  });
19739
- const unavailableCards = ((_d = quoteData.venueSoloQuotes) != null ? _d : []).filter((sq) => sq.status === "unavailable" || sq.unavailableReason === "venue_unavailable").map((sq) => {
19806
+ const unavailableCards = ((_e = quoteData.venueSoloQuotes) != null ? _e : []).filter((sq) => sq.status === "unavailable" || sq.unavailableReason === "venue_unavailable").map((sq) => {
19807
+ var _a2, _b2;
19740
19808
  const parsedVenue = parseVenue(sq.venue);
19741
19809
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
19742
19810
  const temporarilyUnavailable = sq.unavailableReason === "venue_unavailable";
@@ -19747,10 +19815,10 @@ var buildLiveRouteCards = ({
19747
19815
  hint: temporarilyUnavailable ? labels.venueTemporarilyUnavailable : labels.venueUnavailableInRegion,
19748
19816
  kind: "venue",
19749
19817
  label: getTradingVenueLabel(venue),
19750
- numericValue: hasPreview ? sq.filledQty : 0,
19818
+ numericValue: hasPreview ? (_a2 = sq.estimatedPayout) != null ? _a2 : sq.filledQty : 0,
19751
19819
  quoteData: __spreadProps(__spreadValues({}, quoteData), { quoteId: "" }),
19752
19820
  value: hasPreview ? getTradingValueLabel({
19753
- amount: sq.filledQty,
19821
+ amount: (_b2 = sq.estimatedPayout) != null ? _b2 : sq.filledQty,
19754
19822
  minimumFractionDigits: 2,
19755
19823
  maximumFractionDigits: 2
19756
19824
  }) : ""
@@ -19964,10 +20032,13 @@ var getPlaceOrderPotentialReturn = (quoteData) => {
19964
20032
  if (!((_a = quoteData == null ? void 0 : quoteData.fills) == null ? void 0 : _a.length) || quoteData.fills.length < 2) return 0;
19965
20033
  const bestSoloVenueFill = Math.max(
19966
20034
  0,
19967
- ...((_b = quoteData.venueSoloQuotes) != null ? _b : []).filter((quote) => quote.status === "ok" && quote.filledQty > 0).map((quote) => quote.filledQty)
20035
+ ...((_b = quoteData.venueSoloQuotes) != null ? _b : []).filter((quote) => quote.status === "ok" && quote.filledQty > 0).map((quote) => {
20036
+ var _a2;
20037
+ return (_a2 = quote.estimatedPayout) != null ? _a2 : quote.filledQty;
20038
+ })
19968
20039
  );
19969
20040
  if (bestSoloVenueFill <= 0) return 0;
19970
- return Math.max(0, quoteData.totalFilled - bestSoloVenueFill);
20041
+ return Math.max(0, getPlaceOrderBuyPayout(quoteData) - bestSoloVenueFill);
19971
20042
  };
19972
20043
  var resolvePrimarySubmittedOrderId = ({
19973
20044
  allowOrderIdFallback = true,
@@ -23153,7 +23224,16 @@ var PlaceOrder = ({
23153
23224
  });
23154
23225
  const payoutLabel = formatUsd(usdSide);
23155
23226
  const amountLabel = internalTab === "sell" ? sharesLabel : payoutLabel;
23156
- const toWinLabel = internalTab === "sell" ? payoutLabel : formatUsd(sharesSide);
23227
+ const toWinLabel = formatUsd(
23228
+ resolvePlaceOrderNetResult({
23229
+ quoteData,
23230
+ tradeSide: internalTab,
23231
+ shares: sharesSide,
23232
+ usd: usdSide,
23233
+ terminalOrderEvents: executionProgress.terminalOrderEvents,
23234
+ submittedOrders: executionProgress.submittedOrders
23235
+ })
23236
+ );
23157
23237
  const potentialReturnValue = getPlaceOrderPotentialReturn(quoteData);
23158
23238
  const potentialReturnLabel = potentialReturnValue > 0 ? formatUsd(potentialReturnValue) : void 0;
23159
23239
  const eventTitle = (_f2 = (_e2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _e2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _f2 : "";
@@ -23557,7 +23637,16 @@ var PlaceOrder = ({
23557
23637
  maximumFractionDigits: 2
23558
23638
  })
23559
23639
  ) : formatUsd(actualEconomics.actualRawExecCost);
23560
- const payoutLabel = isSell ? formatUsd(actualEconomics.actualRawExecCost) : formatUsd(actualEconomics.actualTotalFilled);
23640
+ const payoutLabel = formatUsd(
23641
+ resolvePlaceOrderNetResult({
23642
+ quoteData,
23643
+ tradeSide: internalTab,
23644
+ shares: actualEconomics.actualTotalFilled,
23645
+ usd: actualEconomics.actualRawExecCost,
23646
+ terminalOrderEvents: executionProgress.terminalOrderEvents,
23647
+ submittedOrders: executionProgress.submittedOrders
23648
+ })
23649
+ );
23561
23650
  return __spreadProps(__spreadValues({}, summaryWithGroups), {
23562
23651
  actions: summaryWithGroups.actions.map(
23563
23652
  (action) => action.variant === "retry" ? __spreadProps(__spreadValues({}, action), { label: tradingLabels.orderTryRemaining(remainingLabel) }) : action
package/dist/pages.mjs CHANGED
@@ -11,14 +11,14 @@ import {
11
11
  formatRecurringCountdown,
12
12
  formatShareAmount,
13
13
  useHomePageModals
14
- } from "./chunk-VMG6BUHI.mjs";
14
+ } from "./chunk-5D36HPOG.mjs";
15
15
  import "./chunk-EYJS45RP.mjs";
16
16
  import {
17
17
  DEPOSIT_MODAL_OPEN_EVENT,
18
18
  WITHDRAW_MODAL_OPEN_EVENT,
19
19
  requestAggDepositModalOpen,
20
20
  requestAggWithdrawModalOpen
21
- } from "./chunk-WWIVSROM.mjs";
21
+ } from "./chunk-VHKGW4DB.mjs";
22
22
  import "./chunk-6EHT5OFU.mjs";
23
23
  import "./chunk-TXQJUVRW.mjs";
24
24
  import "./chunk-W7HQVQ22.mjs";
package/dist/trading.js CHANGED
@@ -9315,6 +9315,72 @@ var parseDecimalString = (value) => {
9315
9315
  if (!Number.isFinite(parsed) || parsed <= 0) return null;
9316
9316
  return parsed;
9317
9317
  };
9318
+ var getPlaceOrderBuyPayout = (quoteData) => {
9319
+ var _a;
9320
+ return (_a = quoteData.estimatedPayout) != null ? _a : quoteData.totalFilled;
9321
+ };
9322
+ var getPlaceOrderSellProceeds = (quoteData) => Math.max(
9323
+ 0,
9324
+ quoteData.rawExecCost - quoteData.fills.reduce((sum, fill) => {
9325
+ var _a, _b;
9326
+ return sum + ((_a = fill.venueFee) != null ? _a : 0) + ((_b = fill.builderFee) != null ? _b : 0);
9327
+ }, 0)
9328
+ );
9329
+ var getPlaceOrderQuoteValue = (quoteData, tradeSide) => tradeSide === "sell" ? getPlaceOrderSellProceeds(quoteData) : getPlaceOrderBuyPayout(quoteData);
9330
+ var resolvePlaceOrderNetResult = ({
9331
+ quoteData,
9332
+ tradeSide,
9333
+ shares,
9334
+ usd,
9335
+ terminalOrderEvents,
9336
+ submittedOrders
9337
+ }) => {
9338
+ if (!quoteData) return tradeSide === "sell" ? usd : shares;
9339
+ const actualEvents = (terminalOrderEvents != null ? terminalOrderEvents : []).filter(
9340
+ (event) => (event.event === "filled" || event.event === "partial_fill") && (tradeSide === "buy" ? event.filledAmountRaw != null : event.actualSharesRaw != null)
9341
+ );
9342
+ if (actualEvents.length) {
9343
+ return actualEvents.reduce((sum, event) => {
9344
+ var _a;
9345
+ const outcomeId = (_a = submittedOrders == null ? void 0 : submittedOrders.find(
9346
+ (order) => order.orderId === event.orderId
9347
+ )) == null ? void 0 : _a.outcomeId;
9348
+ const venueFills = quoteData.fills.filter((fill) => fill.venue === event.venue);
9349
+ const exactFill = venueFills.find((fill) => fill.venueMarketOutcomeId === outcomeId);
9350
+ const fills = exactFill ? [exactFill] : venueFills;
9351
+ const legQuote = fills.length ? __spreadProps(__spreadValues({}, quoteData), {
9352
+ fills,
9353
+ totalFilled: fills.reduce((total, fill) => total + fill.venueQty, 0),
9354
+ rawExecCost: fills.reduce((total, fill) => total + fill.avgPrice * fill.venueQty, 0),
9355
+ estimatedPayout: fills.reduce(
9356
+ (total, fill) => {
9357
+ var _a2;
9358
+ return total + fill.venueQty - ((_a2 = fill.settlementFee) != null ? _a2 : 0);
9359
+ },
9360
+ 0
9361
+ )
9362
+ }) : quoteData;
9363
+ const actual = resolveActualExecutionEconomics({
9364
+ quoteData: legQuote,
9365
+ tradeSide,
9366
+ terminalOrderEvents: [event],
9367
+ submittedOrders
9368
+ });
9369
+ return sum + resolvePlaceOrderNetResult({
9370
+ quoteData: legQuote,
9371
+ tradeSide,
9372
+ shares: actual.actualTotalFilled,
9373
+ usd: actual.actualRawExecCost
9374
+ });
9375
+ }, 0);
9376
+ }
9377
+ if (tradeSide === "sell") {
9378
+ const gross = quoteData.rawExecCost;
9379
+ return gross > 0 ? usd * (getPlaceOrderSellProceeds(quoteData) / gross) : usd;
9380
+ }
9381
+ const filled = quoteData.totalFilled;
9382
+ return filled > 0 ? shares * (getPlaceOrderBuyPayout(quoteData) / filled) : shares;
9383
+ };
9318
9384
  var resolvePlaceOrderQuoteResult = ({
9319
9385
  labels,
9320
9386
  quoteData,
@@ -9323,7 +9389,7 @@ var resolvePlaceOrderQuoteResult = ({
9323
9389
  if (!quoteData || quoteData.totalFilled <= 0) return null;
9324
9390
  const avgPrice = getPlaceOrderAverageExecutionPrice(quoteData);
9325
9391
  if (avgPrice == null) return null;
9326
- const quoteValue = tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled;
9392
+ const quoteValue = getPlaceOrderQuoteValue(quoteData, tradeSide);
9327
9393
  return {
9328
9394
  hint: labels.averagePrice(avgPrice),
9329
9395
  value: getTradingValueLabel({
@@ -9441,7 +9507,7 @@ var buildLiveRouteCards = ({
9441
9507
  eventVenues = [],
9442
9508
  geoBlockedVenues: inheritedGeoBlockedVenues
9443
9509
  }) => {
9444
- var _a, _b, _c, _d;
9510
+ var _a, _b, _c, _d, _e;
9445
9511
  const geoBlockedVenues = extractGeoBlockedVenues(quoteData.warnings);
9446
9512
  for (const venue of inheritedGeoBlockedVenues != null ? inheritedGeoBlockedVenues : []) {
9447
9513
  geoBlockedVenues.add(venue);
@@ -9456,6 +9522,7 @@ var buildLiveRouteCards = ({
9456
9522
  );
9457
9523
  const averageExecutionPrice = (_b = getPlaceOrderAverageExecutionPrice(quoteData)) != null ? _b : void 0;
9458
9524
  const primaryWinnerVenue = quoteData.fills.length === 1 ? primaryVenue : void 0;
9525
+ const primaryWinnerOutcomeId = quoteData.fills.length === 1 ? (_c = quoteData.fills[0]) == null ? void 0 : _c.venueMarketOutcomeId : void 0;
9459
9526
  const isPrimaryRouteGeoBlocked = quoteData.fills.length > 0 && quoteData.fills.some((f) => geoBlockedVenues.has(f.venue));
9460
9527
  const primaryCard = primaryResult ? isPrimaryRouteGeoBlocked ? isSplit ? null : {
9461
9528
  id: "live-route",
@@ -9465,7 +9532,7 @@ var buildLiveRouteCards = ({
9465
9532
  parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
9466
9533
  ),
9467
9534
  executionPrice: averageExecutionPrice,
9468
- numericValue: tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled,
9535
+ numericValue: getPlaceOrderQuoteValue(quoteData, tradeSide),
9469
9536
  quoteData,
9470
9537
  value: primaryResult.value,
9471
9538
  venue: parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0,
@@ -9478,7 +9545,7 @@ var buildLiveRouteCards = ({
9478
9545
  label: isSplit ? labels.orderSplitting : getTradingVenueLabel(
9479
9546
  parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
9480
9547
  ),
9481
- numericValue: tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled,
9548
+ numericValue: getPlaceOrderQuoteValue(quoteData, tradeSide),
9482
9549
  quoteData,
9483
9550
  rows: mapQuoteDataToRoutingRows(quoteData, tradeSide),
9484
9551
  description: labels.splitOrderDescription,
@@ -9488,7 +9555,7 @@ var buildLiveRouteCards = ({
9488
9555
  requiresSharedKyc: primaryRequiresSharedKyc
9489
9556
  } : null;
9490
9557
  const soloCardId = (prefix, sq) => `${prefix}-${sq.venue}${sq.venueMarketOutcomeId ? `-${sq.venueMarketOutcomeId}` : ""}`;
9491
- const soloCards = ((_c = quoteData.venueSoloQuotes) != null ? _c : []).filter(
9558
+ const soloCards = ((_d = quoteData.venueSoloQuotes) != null ? _d : []).filter(
9492
9559
  (sq) => sq.status === "ok" && sq.unavailableReason !== "venue_unavailable" && sq.avgPrice !== null && sq.filledQty > 0 && // No `sq.quoteId` requirement: a solo is preview-only whenever its own
9493
9560
  // funding lane is short (API nulls the quoteId), which is NOT always the
9494
9561
  // whole-quote `insufficient_balance` case — an off-chain winner (Kalshi
@@ -9496,9 +9563,9 @@ var buildLiveRouteCards = ({
9496
9563
  // stays unfunded. Gating on the quoteId silently hid that venue from the
9497
9564
  // comparison list entirely. The panel's Deposit CTA fires off the same
9498
9565
  // balance condition, and `handleExecuteQuote` rejects an empty quoteId.
9499
- sq.venue !== primaryWinnerVenue
9566
+ (primaryWinnerOutcomeId && sq.venueMarketOutcomeId ? sq.venueMarketOutcomeId !== primaryWinnerOutcomeId : sq.venue !== primaryWinnerVenue)
9500
9567
  ).map((sq) => {
9501
- var _a2, _b2;
9568
+ var _a2, _b2, _c2, _d2, _e2, _f;
9502
9569
  const parsedVenue = parseVenue(sq.venue);
9503
9570
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
9504
9571
  if (geoBlockedVenues.has(sq.venue)) {
@@ -9508,10 +9575,10 @@ var buildLiveRouteCards = ({
9508
9575
  hint: labels.venueUnavailableInRegion,
9509
9576
  kind: "venue",
9510
9577
  label: getTradingVenueLabel(venue),
9511
- numericValue: sq.filledQty,
9578
+ numericValue: (_a2 = sq.estimatedPayout) != null ? _a2 : sq.filledQty,
9512
9579
  quoteData,
9513
9580
  value: getTradingValueLabel({
9514
- amount: sq.filledQty,
9581
+ amount: (_b2 = sq.estimatedPayout) != null ? _b2 : sq.filledQty,
9515
9582
  minimumFractionDigits: 2,
9516
9583
  maximumFractionDigits: 2
9517
9584
  }),
@@ -9525,7 +9592,7 @@ var buildLiveRouteCards = ({
9525
9592
  // Preview-only solos intentionally carry no executable quoteId; the card
9526
9593
  // should still render for comparison, while the CTA stays disabled until
9527
9594
  // the user is funded and requotes.
9528
- quoteId: (_a2 = sq.quoteId) != null ? _a2 : "",
9595
+ quoteId: (_c2 = sq.quoteId) != null ? _c2 : "",
9529
9596
  fills: sq.fills.map((f) => __spreadValues({}, f)),
9530
9597
  totalFilled: sq.filledQty,
9531
9598
  rawExecCost: sq.rawExecCost,
@@ -9538,7 +9605,7 @@ var buildLiveRouteCards = ({
9538
9605
  // primary route's breakdown in place, so selecting a bridge-free venue
9539
9606
  // still showed the primary's bridging charge. Falls back to the
9540
9607
  // primary only when the router omitted one (non-"ok" solos).
9541
- feeBreakdown: (_b2 = sq.feeBreakdown) != null ? _b2 : quoteData.feeBreakdown
9608
+ feeBreakdown: (_d2 = sq.feeBreakdown) != null ? _d2 : quoteData.feeBreakdown
9542
9609
  }), sq.quoteId ? { status: "ok", error: void 0 } : null);
9543
9610
  return {
9544
9611
  id: soloCardId("live-solo", sq),
@@ -9547,10 +9614,10 @@ var buildLiveRouteCards = ({
9547
9614
  kind: "venue",
9548
9615
  label: getTradingVenueLabel(venue),
9549
9616
  executionPrice: avgPrice,
9550
- numericValue: sq.filledQty,
9617
+ numericValue: (_e2 = sq.estimatedPayout) != null ? _e2 : sq.filledQty,
9551
9618
  quoteData: soloQuoteData,
9552
9619
  value: getTradingValueLabel({
9553
- amount: sq.filledQty,
9620
+ amount: (_f = sq.estimatedPayout) != null ? _f : sq.filledQty,
9554
9621
  minimumFractionDigits: 2,
9555
9622
  maximumFractionDigits: 2
9556
9623
  }),
@@ -9558,7 +9625,8 @@ var buildLiveRouteCards = ({
9558
9625
  requiresSharedKyc: venueRequiresSharedKyc({ venue: sq.venue })
9559
9626
  };
9560
9627
  });
9561
- const unavailableCards = ((_d = quoteData.venueSoloQuotes) != null ? _d : []).filter((sq) => sq.status === "unavailable" || sq.unavailableReason === "venue_unavailable").map((sq) => {
9628
+ const unavailableCards = ((_e = quoteData.venueSoloQuotes) != null ? _e : []).filter((sq) => sq.status === "unavailable" || sq.unavailableReason === "venue_unavailable").map((sq) => {
9629
+ var _a2, _b2;
9562
9630
  const parsedVenue = parseVenue(sq.venue);
9563
9631
  const venue = parsedVenue.success ? parsedVenue.data : void 0;
9564
9632
  const temporarilyUnavailable = sq.unavailableReason === "venue_unavailable";
@@ -9569,10 +9637,10 @@ var buildLiveRouteCards = ({
9569
9637
  hint: temporarilyUnavailable ? labels.venueTemporarilyUnavailable : labels.venueUnavailableInRegion,
9570
9638
  kind: "venue",
9571
9639
  label: getTradingVenueLabel(venue),
9572
- numericValue: hasPreview ? sq.filledQty : 0,
9640
+ numericValue: hasPreview ? (_a2 = sq.estimatedPayout) != null ? _a2 : sq.filledQty : 0,
9573
9641
  quoteData: __spreadProps(__spreadValues({}, quoteData), { quoteId: "" }),
9574
9642
  value: hasPreview ? getTradingValueLabel({
9575
- amount: sq.filledQty,
9643
+ amount: (_b2 = sq.estimatedPayout) != null ? _b2 : sq.filledQty,
9576
9644
  minimumFractionDigits: 2,
9577
9645
  maximumFractionDigits: 2
9578
9646
  }) : ""
@@ -9786,10 +9854,13 @@ var getPlaceOrderPotentialReturn = (quoteData) => {
9786
9854
  if (!((_a = quoteData == null ? void 0 : quoteData.fills) == null ? void 0 : _a.length) || quoteData.fills.length < 2) return 0;
9787
9855
  const bestSoloVenueFill = Math.max(
9788
9856
  0,
9789
- ...((_b = quoteData.venueSoloQuotes) != null ? _b : []).filter((quote) => quote.status === "ok" && quote.filledQty > 0).map((quote) => quote.filledQty)
9857
+ ...((_b = quoteData.venueSoloQuotes) != null ? _b : []).filter((quote) => quote.status === "ok" && quote.filledQty > 0).map((quote) => {
9858
+ var _a2;
9859
+ return (_a2 = quote.estimatedPayout) != null ? _a2 : quote.filledQty;
9860
+ })
9790
9861
  );
9791
9862
  if (bestSoloVenueFill <= 0) return 0;
9792
- return Math.max(0, quoteData.totalFilled - bestSoloVenueFill);
9863
+ return Math.max(0, getPlaceOrderBuyPayout(quoteData) - bestSoloVenueFill);
9793
9864
  };
9794
9865
  var resolvePrimarySubmittedOrderId = ({
9795
9866
  allowOrderIdFallback = true,
@@ -12975,7 +13046,16 @@ var PlaceOrder = ({
12975
13046
  });
12976
13047
  const payoutLabel = formatUsd(usdSide);
12977
13048
  const amountLabel = internalTab === "sell" ? sharesLabel : payoutLabel;
12978
- const toWinLabel = internalTab === "sell" ? payoutLabel : formatUsd(sharesSide);
13049
+ const toWinLabel = formatUsd(
13050
+ resolvePlaceOrderNetResult({
13051
+ quoteData,
13052
+ tradeSide: internalTab,
13053
+ shares: sharesSide,
13054
+ usd: usdSide,
13055
+ terminalOrderEvents: executionProgress.terminalOrderEvents,
13056
+ submittedOrders: executionProgress.submittedOrders
13057
+ })
13058
+ );
12979
13059
  const potentialReturnValue = getPlaceOrderPotentialReturn(quoteData);
12980
13060
  const potentialReturnLabel = potentialReturnValue > 0 ? formatUsd(potentialReturnValue) : void 0;
12981
13061
  const eventTitle = (_f2 = (_e2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _e2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _f2 : "";
@@ -13379,7 +13459,16 @@ var PlaceOrder = ({
13379
13459
  maximumFractionDigits: 2
13380
13460
  })
13381
13461
  ) : formatUsd(actualEconomics.actualRawExecCost);
13382
- const payoutLabel = isSell ? formatUsd(actualEconomics.actualRawExecCost) : formatUsd(actualEconomics.actualTotalFilled);
13462
+ const payoutLabel = formatUsd(
13463
+ resolvePlaceOrderNetResult({
13464
+ quoteData,
13465
+ tradeSide: internalTab,
13466
+ shares: actualEconomics.actualTotalFilled,
13467
+ usd: actualEconomics.actualRawExecCost,
13468
+ terminalOrderEvents: executionProgress.terminalOrderEvents,
13469
+ submittedOrders: executionProgress.submittedOrders
13470
+ })
13471
+ );
13383
13472
  return __spreadProps(__spreadValues({}, summaryWithGroups), {
13384
13473
  actions: summaryWithGroups.actions.map(
13385
13474
  (action) => action.variant === "retry" ? __spreadProps(__spreadValues({}, action), { label: tradingLabels.orderTryRemaining(remainingLabel) }) : action
package/dist/trading.mjs CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  useClaimWinnings,
15
15
  useResolvedMarketClaim,
16
16
  venueRequiresSharedKyc
17
- } from "./chunk-WWIVSROM.mjs";
17
+ } from "./chunk-VHKGW4DB.mjs";
18
18
  import {
19
19
  SETTLEMENT_SECTION_ID,
20
20
  Settlement,
@@ -73,6 +73,34 @@ export type PlaceOrderAggregateOrderStatus = "pending" | "full_success" | "parti
73
73
  * corresponding terminal event so the UI never transitions prematurely.
74
74
  */
75
75
  export declare const deriveAggregateOrderStatus: (orderIds: string[], terminalEvents: PlaceOrderTerminalOrderEvent[]) => PlaceOrderAggregateOrderStatus;
76
+ /**
77
+ * Dollars a BUY quote pays if the outcome wins. One dollar per share, less what
78
+ * the venue takes from that payout (Hyperliquid HIP-4's close fee), which the
79
+ * API reports as `estimatedPayout`. Older responses omit it — fall back to
80
+ * shares, which is exactly right for every venue that charges nothing at win.
81
+ */
82
+ export declare const getPlaceOrderBuyPayout: (quoteData: Pick<SmartRouteResponse, "estimatedPayout" | "totalFilled">) => number;
83
+ /**
84
+ * Dollars a SELL quote returns after the fees charged at fill. `rawExecCost` is
85
+ * gross proceeds on a sell (redeem legs at $1 plus router revenue), so subtract
86
+ * each fill's venue and builder fee. Sell fills carry no execution reserve.
87
+ */
88
+ export declare const getPlaceOrderSellProceeds: (quoteData: Pick<SmartRouteResponse, "rawExecCost" | "fills">) => number;
89
+ /** The dollar figure a route card shows and is ranked by. */
90
+ export declare const getPlaceOrderQuoteValue: (quoteData: SmartRouteResponse, tradeSide: PlaceOrderTab) => number;
91
+ /**
92
+ * The same net figure for realized fills: scale the actual shares (buy) or
93
+ * actual gross proceeds (sell) by each executed leg's quoted net-to-gross
94
+ * ratio. Without execution events, use the overall quote ratio.
95
+ */
96
+ export declare const resolvePlaceOrderNetResult: ({ quoteData, tradeSide, shares, usd, terminalOrderEvents, submittedOrders, }: {
97
+ quoteData: SmartRouteResponse | null | undefined;
98
+ tradeSide: PlaceOrderTab;
99
+ shares: number;
100
+ usd: number;
101
+ terminalOrderEvents?: PlaceOrderTerminalOrderEvent[];
102
+ submittedOrders?: WsOrderSubmitted[];
103
+ }) => number;
76
104
  export declare const resolvePlaceOrderQuoteResult: ({ labels, quoteData, tradeSide, }: ResolvePlaceOrderQuoteResultParams) => PlaceOrderQuoteResult | null;
77
105
  export declare const sanitizePlaceOrderAmount: (value: number) => number;
78
106
  export declare const getTradingRoutePriceLabel: (value: number) => string;
@@ -73,6 +73,34 @@ export type PlaceOrderAggregateOrderStatus = "pending" | "full_success" | "parti
73
73
  * corresponding terminal event so the UI never transitions prematurely.
74
74
  */
75
75
  export declare const deriveAggregateOrderStatus: (orderIds: string[], terminalEvents: PlaceOrderTerminalOrderEvent[]) => PlaceOrderAggregateOrderStatus;
76
+ /**
77
+ * Dollars a BUY quote pays if the outcome wins. One dollar per share, less what
78
+ * the venue takes from that payout (Hyperliquid HIP-4's close fee), which the
79
+ * API reports as `estimatedPayout`. Older responses omit it — fall back to
80
+ * shares, which is exactly right for every venue that charges nothing at win.
81
+ */
82
+ export declare const getPlaceOrderBuyPayout: (quoteData: Pick<SmartRouteResponse, "estimatedPayout" | "totalFilled">) => number;
83
+ /**
84
+ * Dollars a SELL quote returns after the fees charged at fill. `rawExecCost` is
85
+ * gross proceeds on a sell (redeem legs at $1 plus router revenue), so subtract
86
+ * each fill's venue and builder fee. Sell fills carry no execution reserve.
87
+ */
88
+ export declare const getPlaceOrderSellProceeds: (quoteData: Pick<SmartRouteResponse, "rawExecCost" | "fills">) => number;
89
+ /** The dollar figure a route card shows and is ranked by. */
90
+ export declare const getPlaceOrderQuoteValue: (quoteData: SmartRouteResponse, tradeSide: PlaceOrderTab) => number;
91
+ /**
92
+ * The same net figure for realized fills: scale the actual shares (buy) or
93
+ * actual gross proceeds (sell) by each executed leg's quoted net-to-gross
94
+ * ratio. Without execution events, use the overall quote ratio.
95
+ */
96
+ export declare const resolvePlaceOrderNetResult: ({ quoteData, tradeSide, shares, usd, terminalOrderEvents, submittedOrders, }: {
97
+ quoteData: SmartRouteResponse | null | undefined;
98
+ tradeSide: PlaceOrderTab;
99
+ shares: number;
100
+ usd: number;
101
+ terminalOrderEvents?: PlaceOrderTerminalOrderEvent[];
102
+ submittedOrders?: WsOrderSubmitted[];
103
+ }) => number;
76
104
  export declare const resolvePlaceOrderQuoteResult: ({ labels, quoteData, tradeSide, }: ResolvePlaceOrderQuoteResultParams) => PlaceOrderQuoteResult | null;
77
105
  export declare const sanitizePlaceOrderAmount: (value: number) => number;
78
106
  export declare const getTradingRoutePriceLabel: (value: number) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agg-build/ui",
3
- "version": "4.11.1",
3
+ "version": "4.11.3",
4
4
  "description": "Pre-built React component library for the AGG prediction market aggregator. Tailwind-based, themeable, with primitives, event surfaces, trading flows, full pages, and modals.",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -101,7 +101,7 @@
101
101
  "react": "^18.0.0 || ^19.0.0",
102
102
  "react-dom": "^18.0.0 || ^19.0.0",
103
103
  "@agg-build/hooks": "^4.11.0",
104
- "@agg-build/sdk": "^4.11.0"
104
+ "@agg-build/sdk": "^4.11.3"
105
105
  },
106
106
  "dependencies": {
107
107
  "@number-flow/react": "^0.6.0",