@agg-build/ui 4.17.2 → 4.17.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.
@@ -3805,6 +3805,24 @@ import { Venue as Venue3 } from "@agg-build/sdk";
3805
3805
  import dayjs from "dayjs";
3806
3806
  import { useCallback as useCallback7, useEffect as useEffect11, useMemo as useMemo8, useRef as useRef10, useState as useState12 } from "react";
3807
3807
 
3808
+ // src/pages/user-profile/cost-basis-display.ts
3809
+ function costBasisDisplay(outcome) {
3810
+ if (outcome.costBasisUnknown === true) {
3811
+ return {
3812
+ averagePriceCents: null,
3813
+ averagePrice: null,
3814
+ totalTradedValue: null,
3815
+ costUnknown: true
3816
+ };
3817
+ }
3818
+ return {
3819
+ averagePriceCents: Math.round(outcome.avgEntryPrice * 100),
3820
+ averagePrice: outcome.avgEntryPrice,
3821
+ totalTradedValue: outcome.avgEntryPrice * outcome.totalSize,
3822
+ costUnknown: false
3823
+ };
3824
+ }
3825
+
3808
3826
  // src/pages/user-profile/components/available-balance-card.tsx
3809
3827
  import { useLabels as useLabels6 } from "@agg-build/hooks";
3810
3828
  import { ACTIVE_VENUES, VENUE_CHAIN_IDS } from "@agg-build/sdk";
@@ -8121,16 +8139,15 @@ var UserProfilePage = ({
8121
8139
  const outcomeId = (_b3 = (_a3 = outcome.venueBreakdown.find((row) => row.venueMarketOutcomeId)) == null ? void 0 : _a3.venueMarketOutcomeId) != null ? _b3 : void 0;
8122
8140
  const isResolved = group.venueMarket.status === "resolved";
8123
8141
  const isUnpriced = outcome.priceSource === "entry";
8124
- const averagePriceCents = Math.round(outcome.avgEntryPrice * 100);
8125
- const totalTradedValue = outcome.avgEntryPrice * outcome.totalSize;
8142
+ const { averagePriceCents, averagePrice, totalTradedValue, costUnknown } = costBasisDisplay(outcome);
8126
8143
  const finalPayoutValue = isResolved ? outcome.winner === true ? outcome.totalValue : 0 : outcome.totalValue;
8127
8144
  const finalPrice = isResolved ? outcome.winner === true ? 1 : 0 : outcome.currentPrice;
8128
- const finalPnlValue = finalPayoutValue - totalTradedValue;
8129
- const finalPnlPercent = totalTradedValue === 0 ? 0 : finalPnlValue / Math.abs(totalTradedValue) * 100;
8145
+ const finalPnlValue = totalTradedValue == null ? null : finalPayoutValue - totalTradedValue;
8146
+ const finalPnlPercent = totalTradedValue == null || totalTradedValue === 0 || finalPnlValue == null ? null : finalPnlValue / Math.abs(totalTradedValue) * 100;
8130
8147
  const displayCurrentPrice = isResolved ? finalPrice : isUnpriced ? null : outcome.currentPrice;
8131
8148
  const displayCurrentValue = isResolved ? finalPayoutValue : isUnpriced ? null : outcome.totalValue;
8132
- const displayPnlValue = isResolved ? finalPnlValue : isUnpriced ? null : outcome.unrealizedPnl;
8133
- const displayPnlPercent = isResolved ? finalPnlPercent : isUnpriced ? null : outcome.unrealizedPnlPercent;
8149
+ const displayPnlValue = costUnknown ? null : isResolved ? finalPnlValue : isUnpriced ? null : outcome.unrealizedPnl;
8150
+ const displayPnlPercent = costUnknown ? null : isResolved ? finalPnlPercent : isUnpriced ? null : outcome.unrealizedPnlPercent;
8134
8151
  const currentPriceCents = typeof displayCurrentPrice === "number" ? Math.round(displayCurrentPrice * 100) : null;
8135
8152
  const pnlPrefix = (displayPnlValue != null ? displayPnlValue : 0) >= 0 ? "+" : "";
8136
8153
  const pnlPercent = displayPnlPercent == null ? null : displayPnlPercent.toFixed(2);
@@ -8146,8 +8163,8 @@ var UserProfilePage = ({
8146
8163
  resolutionLabel: winningOutcomeLabel,
8147
8164
  venueShareBreakdown: buildVenueShareBreakdown(outcome),
8148
8165
  totalShares: outcome.totalSize,
8149
- averageLabel: `${averagePriceCents}\xA2`,
8150
- averagePrice: outcome.avgEntryPrice,
8166
+ averageLabel: averagePriceCents == null ? "\u2014" : `${averagePriceCents}\xA2`,
8167
+ averagePrice,
8151
8168
  currentLabel: currentPriceCents == null ? "\u2014" : `${currentPriceCents}\xA2`,
8152
8169
  currentPrice: displayCurrentPrice,
8153
8170
  valueLabel: displayCurrentValue == null ? "\u2014" : formatUsd2(displayCurrentValue),
@@ -8160,14 +8177,14 @@ var UserProfilePage = ({
8160
8177
  marketStatus: group.venueMarket.status,
8161
8178
  winner: (_f = outcome.winner) != null ? _f : null,
8162
8179
  resolutionDate: group.resolutionDate,
8163
- closedTotalTradedLabel: formatUsd2(totalTradedValue),
8180
+ closedTotalTradedLabel: totalTradedValue == null ? "\u2014" : formatUsd2(totalTradedValue),
8164
8181
  totalTradedValue,
8165
8182
  closedAmountWonLabel: formatUsd2(finalPayoutValue),
8166
8183
  finalPayoutValue,
8167
8184
  finalPnlValue,
8168
8185
  finalPnlPercent,
8169
8186
  finalPrice,
8170
- closedReturnLabel: formatSignedPercentLabel(finalPnlPercent / 100),
8187
+ closedReturnLabel: finalPnlPercent == null ? "\u2014" : formatSignedPercentLabel(finalPnlPercent / 100),
8171
8188
  closedClaimStatus: group.redeemStatus,
8172
8189
  winningOutcomeIds: winningOutcomeIds.length > 0 ? winningOutcomeIds : closedTotals.winningOutcomeIds
8173
8190
  };
package/dist/index.js CHANGED
@@ -31828,6 +31828,24 @@ var import_sdk29 = require("@agg-build/sdk");
31828
31828
  var import_dayjs9 = __toESM(require("dayjs"));
31829
31829
  var import_react55 = require("react");
31830
31830
 
31831
+ // src/pages/user-profile/cost-basis-display.ts
31832
+ function costBasisDisplay(outcome) {
31833
+ if (outcome.costBasisUnknown === true) {
31834
+ return {
31835
+ averagePriceCents: null,
31836
+ averagePrice: null,
31837
+ totalTradedValue: null,
31838
+ costUnknown: true
31839
+ };
31840
+ }
31841
+ return {
31842
+ averagePriceCents: Math.round(outcome.avgEntryPrice * 100),
31843
+ averagePrice: outcome.avgEntryPrice,
31844
+ totalTradedValue: outcome.avgEntryPrice * outcome.totalSize,
31845
+ costUnknown: false
31846
+ };
31847
+ }
31848
+
31831
31849
  // src/pages/user-profile/components/available-balance-card.tsx
31832
31850
  var import_hooks80 = require("@agg-build/hooks");
31833
31851
  var import_sdk26 = require("@agg-build/sdk");
@@ -36078,16 +36096,15 @@ var UserProfilePage = ({
36078
36096
  const outcomeId = (_b3 = (_a3 = outcome.venueBreakdown.find((row) => row.venueMarketOutcomeId)) == null ? void 0 : _a3.venueMarketOutcomeId) != null ? _b3 : void 0;
36079
36097
  const isResolved = group.venueMarket.status === "resolved";
36080
36098
  const isUnpriced = outcome.priceSource === "entry";
36081
- const averagePriceCents = Math.round(outcome.avgEntryPrice * 100);
36082
- const totalTradedValue = outcome.avgEntryPrice * outcome.totalSize;
36099
+ const { averagePriceCents, averagePrice, totalTradedValue, costUnknown } = costBasisDisplay(outcome);
36083
36100
  const finalPayoutValue = isResolved ? outcome.winner === true ? outcome.totalValue : 0 : outcome.totalValue;
36084
36101
  const finalPrice = isResolved ? outcome.winner === true ? 1 : 0 : outcome.currentPrice;
36085
- const finalPnlValue = finalPayoutValue - totalTradedValue;
36086
- const finalPnlPercent = totalTradedValue === 0 ? 0 : finalPnlValue / Math.abs(totalTradedValue) * 100;
36102
+ const finalPnlValue = totalTradedValue == null ? null : finalPayoutValue - totalTradedValue;
36103
+ const finalPnlPercent = totalTradedValue == null || totalTradedValue === 0 || finalPnlValue == null ? null : finalPnlValue / Math.abs(totalTradedValue) * 100;
36087
36104
  const displayCurrentPrice = isResolved ? finalPrice : isUnpriced ? null : outcome.currentPrice;
36088
36105
  const displayCurrentValue = isResolved ? finalPayoutValue : isUnpriced ? null : outcome.totalValue;
36089
- const displayPnlValue = isResolved ? finalPnlValue : isUnpriced ? null : outcome.unrealizedPnl;
36090
- const displayPnlPercent = isResolved ? finalPnlPercent : isUnpriced ? null : outcome.unrealizedPnlPercent;
36106
+ const displayPnlValue = costUnknown ? null : isResolved ? finalPnlValue : isUnpriced ? null : outcome.unrealizedPnl;
36107
+ const displayPnlPercent = costUnknown ? null : isResolved ? finalPnlPercent : isUnpriced ? null : outcome.unrealizedPnlPercent;
36091
36108
  const currentPriceCents = typeof displayCurrentPrice === "number" ? Math.round(displayCurrentPrice * 100) : null;
36092
36109
  const pnlPrefix = (displayPnlValue != null ? displayPnlValue : 0) >= 0 ? "+" : "";
36093
36110
  const pnlPercent = displayPnlPercent == null ? null : displayPnlPercent.toFixed(2);
@@ -36103,8 +36120,8 @@ var UserProfilePage = ({
36103
36120
  resolutionLabel: winningOutcomeLabel,
36104
36121
  venueShareBreakdown: buildVenueShareBreakdown(outcome),
36105
36122
  totalShares: outcome.totalSize,
36106
- averageLabel: `${averagePriceCents}\xA2`,
36107
- averagePrice: outcome.avgEntryPrice,
36123
+ averageLabel: averagePriceCents == null ? "\u2014" : `${averagePriceCents}\xA2`,
36124
+ averagePrice,
36108
36125
  currentLabel: currentPriceCents == null ? "\u2014" : `${currentPriceCents}\xA2`,
36109
36126
  currentPrice: displayCurrentPrice,
36110
36127
  valueLabel: displayCurrentValue == null ? "\u2014" : formatUsd2(displayCurrentValue),
@@ -36117,14 +36134,14 @@ var UserProfilePage = ({
36117
36134
  marketStatus: group.venueMarket.status,
36118
36135
  winner: (_f = outcome.winner) != null ? _f : null,
36119
36136
  resolutionDate: group.resolutionDate,
36120
- closedTotalTradedLabel: formatUsd2(totalTradedValue),
36137
+ closedTotalTradedLabel: totalTradedValue == null ? "\u2014" : formatUsd2(totalTradedValue),
36121
36138
  totalTradedValue,
36122
36139
  closedAmountWonLabel: formatUsd2(finalPayoutValue),
36123
36140
  finalPayoutValue,
36124
36141
  finalPnlValue,
36125
36142
  finalPnlPercent,
36126
36143
  finalPrice,
36127
- closedReturnLabel: formatSignedPercentLabel(finalPnlPercent / 100),
36144
+ closedReturnLabel: finalPnlPercent == null ? "\u2014" : formatSignedPercentLabel(finalPnlPercent / 100),
36128
36145
  closedClaimStatus: group.redeemStatus,
36129
36146
  winningOutcomeIds: winningOutcomeIds.length > 0 ? winningOutcomeIds : closedTotals.winningOutcomeIds
36130
36147
  };
package/dist/index.mjs CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  formatRecurringCountdown,
15
15
  formatShareAmount,
16
16
  useHomePageModals
17
- } from "./chunk-3Y2GCNVL.mjs";
17
+ } from "./chunk-DSQSQ4RG.mjs";
18
18
  import {
19
19
  EventList,
20
20
  EventListItem,
package/dist/pages.js CHANGED
@@ -29526,6 +29526,24 @@ var import_sdk29 = require("@agg-build/sdk");
29526
29526
  var import_dayjs9 = __toESM(require("dayjs"));
29527
29527
  var import_react52 = require("react");
29528
29528
 
29529
+ // src/pages/user-profile/cost-basis-display.ts
29530
+ function costBasisDisplay(outcome) {
29531
+ if (outcome.costBasisUnknown === true) {
29532
+ return {
29533
+ averagePriceCents: null,
29534
+ averagePrice: null,
29535
+ totalTradedValue: null,
29536
+ costUnknown: true
29537
+ };
29538
+ }
29539
+ return {
29540
+ averagePriceCents: Math.round(outcome.avgEntryPrice * 100),
29541
+ averagePrice: outcome.avgEntryPrice,
29542
+ totalTradedValue: outcome.avgEntryPrice * outcome.totalSize,
29543
+ costUnknown: false
29544
+ };
29545
+ }
29546
+
29529
29547
  // src/pages/user-profile/components/available-balance-card.tsx
29530
29548
  var import_hooks76 = require("@agg-build/hooks");
29531
29549
  var import_sdk26 = require("@agg-build/sdk");
@@ -33832,16 +33850,15 @@ var UserProfilePage = ({
33832
33850
  const outcomeId = (_b3 = (_a3 = outcome.venueBreakdown.find((row) => row.venueMarketOutcomeId)) == null ? void 0 : _a3.venueMarketOutcomeId) != null ? _b3 : void 0;
33833
33851
  const isResolved = group.venueMarket.status === "resolved";
33834
33852
  const isUnpriced = outcome.priceSource === "entry";
33835
- const averagePriceCents = Math.round(outcome.avgEntryPrice * 100);
33836
- const totalTradedValue = outcome.avgEntryPrice * outcome.totalSize;
33853
+ const { averagePriceCents, averagePrice, totalTradedValue, costUnknown } = costBasisDisplay(outcome);
33837
33854
  const finalPayoutValue = isResolved ? outcome.winner === true ? outcome.totalValue : 0 : outcome.totalValue;
33838
33855
  const finalPrice = isResolved ? outcome.winner === true ? 1 : 0 : outcome.currentPrice;
33839
- const finalPnlValue = finalPayoutValue - totalTradedValue;
33840
- const finalPnlPercent = totalTradedValue === 0 ? 0 : finalPnlValue / Math.abs(totalTradedValue) * 100;
33856
+ const finalPnlValue = totalTradedValue == null ? null : finalPayoutValue - totalTradedValue;
33857
+ const finalPnlPercent = totalTradedValue == null || totalTradedValue === 0 || finalPnlValue == null ? null : finalPnlValue / Math.abs(totalTradedValue) * 100;
33841
33858
  const displayCurrentPrice = isResolved ? finalPrice : isUnpriced ? null : outcome.currentPrice;
33842
33859
  const displayCurrentValue = isResolved ? finalPayoutValue : isUnpriced ? null : outcome.totalValue;
33843
- const displayPnlValue = isResolved ? finalPnlValue : isUnpriced ? null : outcome.unrealizedPnl;
33844
- const displayPnlPercent = isResolved ? finalPnlPercent : isUnpriced ? null : outcome.unrealizedPnlPercent;
33860
+ const displayPnlValue = costUnknown ? null : isResolved ? finalPnlValue : isUnpriced ? null : outcome.unrealizedPnl;
33861
+ const displayPnlPercent = costUnknown ? null : isResolved ? finalPnlPercent : isUnpriced ? null : outcome.unrealizedPnlPercent;
33845
33862
  const currentPriceCents = typeof displayCurrentPrice === "number" ? Math.round(displayCurrentPrice * 100) : null;
33846
33863
  const pnlPrefix = (displayPnlValue != null ? displayPnlValue : 0) >= 0 ? "+" : "";
33847
33864
  const pnlPercent = displayPnlPercent == null ? null : displayPnlPercent.toFixed(2);
@@ -33857,8 +33874,8 @@ var UserProfilePage = ({
33857
33874
  resolutionLabel: winningOutcomeLabel,
33858
33875
  venueShareBreakdown: buildVenueShareBreakdown(outcome),
33859
33876
  totalShares: outcome.totalSize,
33860
- averageLabel: `${averagePriceCents}\xA2`,
33861
- averagePrice: outcome.avgEntryPrice,
33877
+ averageLabel: averagePriceCents == null ? "\u2014" : `${averagePriceCents}\xA2`,
33878
+ averagePrice,
33862
33879
  currentLabel: currentPriceCents == null ? "\u2014" : `${currentPriceCents}\xA2`,
33863
33880
  currentPrice: displayCurrentPrice,
33864
33881
  valueLabel: displayCurrentValue == null ? "\u2014" : formatUsd2(displayCurrentValue),
@@ -33871,14 +33888,14 @@ var UserProfilePage = ({
33871
33888
  marketStatus: group.venueMarket.status,
33872
33889
  winner: (_f = outcome.winner) != null ? _f : null,
33873
33890
  resolutionDate: group.resolutionDate,
33874
- closedTotalTradedLabel: formatUsd2(totalTradedValue),
33891
+ closedTotalTradedLabel: totalTradedValue == null ? "\u2014" : formatUsd2(totalTradedValue),
33875
33892
  totalTradedValue,
33876
33893
  closedAmountWonLabel: formatUsd2(finalPayoutValue),
33877
33894
  finalPayoutValue,
33878
33895
  finalPnlValue,
33879
33896
  finalPnlPercent,
33880
33897
  finalPrice,
33881
- closedReturnLabel: formatSignedPercentLabel(finalPnlPercent / 100),
33898
+ closedReturnLabel: finalPnlPercent == null ? "\u2014" : formatSignedPercentLabel(finalPnlPercent / 100),
33882
33899
  closedClaimStatus: group.redeemStatus,
33883
33900
  winningOutcomeIds: winningOutcomeIds.length > 0 ? winningOutcomeIds : closedTotals.winningOutcomeIds
33884
33901
  };
package/dist/pages.mjs CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  formatRecurringCountdown,
12
12
  formatShareAmount,
13
13
  useHomePageModals
14
- } from "./chunk-3Y2GCNVL.mjs";
14
+ } from "./chunk-DSQSQ4RG.mjs";
15
15
  import "./chunk-RZLM3M5R.mjs";
16
16
  import {
17
17
  DEPOSIT_MODAL_OPEN_EVENT,
@@ -0,0 +1,29 @@
1
+ /**
2
+ * What a position row may say about what its shares cost.
3
+ *
4
+ * Shares can reach a user's wallet without Agg ever recording a purchase —
5
+ * bought on the venue directly, or transferred in — and when the venue has no
6
+ * acquisition price we can reconcile either, the API sends `costBasisUnknown`
7
+ * with `avgEntryPrice: 0`. That 0 is a column default, not a price: rendered as
8
+ * one it claims a free acquisition, and every figure derived from it (amount
9
+ * traded, P&L, return %) becomes a 100% gain the user never made.
10
+ *
11
+ * So the cost-derived fields are withheld rather than computed. Quantity and
12
+ * current value are known and stay visible — this hides the claim, not the
13
+ * position.
14
+ */
15
+ export interface CostBasisDisplayInput {
16
+ avgEntryPrice: number;
17
+ totalSize: number;
18
+ costBasisUnknown?: boolean;
19
+ }
20
+ export interface CostBasisDisplay {
21
+ /** `null` when unknown — callers render "—". */
22
+ averagePriceCents: number | null;
23
+ averagePrice: number | null;
24
+ /** Size × entry price. `null` when there is no entry price. */
25
+ totalTradedValue: number | null;
26
+ /** True when every cost-derived figure on this row must be suppressed. */
27
+ costUnknown: boolean;
28
+ }
29
+ export declare function costBasisDisplay(outcome: CostBasisDisplayInput): CostBasisDisplay;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * What a position row may say about what its shares cost.
3
+ *
4
+ * Shares can reach a user's wallet without Agg ever recording a purchase —
5
+ * bought on the venue directly, or transferred in — and when the venue has no
6
+ * acquisition price we can reconcile either, the API sends `costBasisUnknown`
7
+ * with `avgEntryPrice: 0`. That 0 is a column default, not a price: rendered as
8
+ * one it claims a free acquisition, and every figure derived from it (amount
9
+ * traded, P&L, return %) becomes a 100% gain the user never made.
10
+ *
11
+ * So the cost-derived fields are withheld rather than computed. Quantity and
12
+ * current value are known and stay visible — this hides the claim, not the
13
+ * position.
14
+ */
15
+ export interface CostBasisDisplayInput {
16
+ avgEntryPrice: number;
17
+ totalSize: number;
18
+ costBasisUnknown?: boolean;
19
+ }
20
+ export interface CostBasisDisplay {
21
+ /** `null` when unknown — callers render "—". */
22
+ averagePriceCents: number | null;
23
+ averagePrice: number | null;
24
+ /** Size × entry price. `null` when there is no entry price. */
25
+ totalTradedValue: number | null;
26
+ /** True when every cost-derived figure on this row must be suppressed. */
27
+ costUnknown: boolean;
28
+ }
29
+ export declare function costBasisDisplay(outcome: CostBasisDisplayInput): CostBasisDisplay;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agg-build/ui",
3
- "version": "4.17.2",
3
+ "version": "4.17.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",