@loafmarkets/ui 0.1.163 → 0.1.165

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/index.d.mts CHANGED
@@ -758,8 +758,12 @@ type PropertyOverviewProps = {
758
758
  volume24h?: number | null;
759
759
  openOrdersValue?: number | null;
760
760
  holderCount?: number | null;
761
+ priceHistory?: {
762
+ time: number;
763
+ close: number;
764
+ }[] | null;
761
765
  };
762
- declare function PropertyOverview({ propertyName, location, midPrice, onTradeClick, onPhotosClick, description: descriptionProp, tradeButtonLabel, images, galleryCategories, videoUrl, tokenName, landSizeSqm: landProp, buildingSizeSqm: buildingProp, features: featuresProp, propertyInfo: propertyInfoProp, overviewData, bedrooms, bathrooms, carSpaces, propertyTypeLabel, tokensIssued: tokensIssuedProp, isLoading, ticker, contractAddress, chain, percentageTokenized, volume24h, openOrdersValue, holderCount, }: PropertyOverviewProps): react_jsx_runtime.JSX.Element;
766
+ declare function PropertyOverview({ propertyName, location, midPrice, onTradeClick, onPhotosClick, description: descriptionProp, tradeButtonLabel, images, galleryCategories, videoUrl, tokenName, landSizeSqm: landProp, buildingSizeSqm: buildingProp, features: featuresProp, propertyInfo: propertyInfoProp, overviewData, bedrooms, bathrooms, carSpaces, propertyTypeLabel, tokensIssued: tokensIssuedProp, isLoading, ticker, contractAddress, chain, percentageTokenized, volume24h, openOrdersValue, holderCount, priceHistory: priceHistoryProp, }: PropertyOverviewProps): react_jsx_runtime.JSX.Element;
763
767
 
764
768
  type OfferStatus = 'active' | 'rejected' | 'expired' | 'historical' | 'pending';
765
769
  type PropertyOffer = {
package/dist/index.d.ts CHANGED
@@ -758,8 +758,12 @@ type PropertyOverviewProps = {
758
758
  volume24h?: number | null;
759
759
  openOrdersValue?: number | null;
760
760
  holderCount?: number | null;
761
+ priceHistory?: {
762
+ time: number;
763
+ close: number;
764
+ }[] | null;
761
765
  };
762
- declare function PropertyOverview({ propertyName, location, midPrice, onTradeClick, onPhotosClick, description: descriptionProp, tradeButtonLabel, images, galleryCategories, videoUrl, tokenName, landSizeSqm: landProp, buildingSizeSqm: buildingProp, features: featuresProp, propertyInfo: propertyInfoProp, overviewData, bedrooms, bathrooms, carSpaces, propertyTypeLabel, tokensIssued: tokensIssuedProp, isLoading, ticker, contractAddress, chain, percentageTokenized, volume24h, openOrdersValue, holderCount, }: PropertyOverviewProps): react_jsx_runtime.JSX.Element;
766
+ declare function PropertyOverview({ propertyName, location, midPrice, onTradeClick, onPhotosClick, description: descriptionProp, tradeButtonLabel, images, galleryCategories, videoUrl, tokenName, landSizeSqm: landProp, buildingSizeSqm: buildingProp, features: featuresProp, propertyInfo: propertyInfoProp, overviewData, bedrooms, bathrooms, carSpaces, propertyTypeLabel, tokensIssued: tokensIssuedProp, isLoading, ticker, contractAddress, chain, percentageTokenized, volume24h, openOrdersValue, holderCount, priceHistory: priceHistoryProp, }: PropertyOverviewProps): react_jsx_runtime.JSX.Element;
763
767
 
764
768
  type OfferStatus = 'active' | 'rejected' | 'expired' | 'historical' | 'pending';
765
769
  type PropertyOffer = {
package/dist/index.js CHANGED
@@ -8454,32 +8454,36 @@ function truncateAddress(addr) {
8454
8454
  if (addr.length <= 12) return addr;
8455
8455
  return `${addr.slice(0, 6)}...${addr.slice(-4)}`;
8456
8456
  }
8457
- function generateDividendHistory(valuation, totalTokens, tokenPrice) {
8457
+ function generateDividendHistory(valuation, totalTokens, tokenPrice, realPriceHistory) {
8458
8458
  if (valuation <= 0 || !totalTokens || !tokenPrice) return { records: [], priceHistory: [] };
8459
8459
  const annualDiv = valuation * 0.02;
8460
8460
  const monthlyDivPerShare = annualDiv / 12 / totalTokens;
8461
8461
  const records = [];
8462
- const priceHistory = [];
8462
+ const priceHistory = realPriceHistory?.length ? realPriceHistory.map((c) => ({ time: typeof c.time === "number" && c.time < 1e12 ? c.time * 1e3 : c.time, price: c.close })) : (() => {
8463
+ const pts = [];
8464
+ let price = tokenPrice * 0.84;
8465
+ for (let i = 365; i >= 0; i--) {
8466
+ const t = Date.now() - i * 864e5;
8467
+ const progress = (365 - i) / 365;
8468
+ const target = tokenPrice * (0.84 + progress * 0.16);
8469
+ price += (target - price) * 0.03 + (Math.random() - 0.5) * 0.8;
8470
+ price = Math.max(tokenPrice * 0.75, price);
8471
+ pts.push({ time: t, price: Math.round(price * 100) / 100 });
8472
+ }
8473
+ return pts;
8474
+ })();
8463
8475
  const now = /* @__PURE__ */ new Date();
8464
- let price = tokenPrice * 0.84;
8465
- for (let i = 365; i >= 0; i--) {
8466
- const t = Date.now() - i * 864e5;
8467
- const progress = (365 - i) / 365;
8468
- const target = tokenPrice * (0.84 + progress * 0.16);
8469
- price += (target - price) * 0.03 + (Math.random() - 0.5) * 0.8;
8470
- price = Math.max(tokenPrice * 0.75, price);
8471
- priceHistory.push({ time: t, price: Math.round(price * 100) / 100 });
8472
- }
8473
8476
  for (let i = 11; i >= 0; i--) {
8474
8477
  const exDate = new Date(now.getFullYear(), now.getMonth() - i, 1);
8475
8478
  const exTime = exDate.getTime();
8476
8479
  const closest = priceHistory.reduce((best, p) => Math.abs(p.time - exTime) < Math.abs(best.time - exTime) ? p : best);
8477
8480
  const priceAtEx = closest.price;
8481
+ const annualisedYield = priceAtEx > 0 ? monthlyDivPerShare * 12 / priceAtEx * 100 : 2;
8478
8482
  records.push({
8479
8483
  exDate: exDate.toLocaleDateString("en-AU", { day: "2-digit", month: "short", year: "numeric" }),
8480
8484
  payDate: new Date(exDate.getFullYear(), exDate.getMonth(), 15).toLocaleDateString("en-AU", { day: "2-digit", month: "short", year: "numeric" }),
8481
8485
  perShare: monthlyDivPerShare,
8482
- yieldPct: monthlyDivPerShare * 12 / priceAtEx * 100
8486
+ yieldPct: annualisedYield
8483
8487
  });
8484
8488
  }
8485
8489
  return { records, priceHistory };
@@ -8513,7 +8517,8 @@ function PropertyOverview({
8513
8517
  percentageTokenized,
8514
8518
  volume24h,
8515
8519
  openOrdersValue,
8516
- holderCount
8520
+ holderCount,
8521
+ priceHistory: priceHistoryProp
8517
8522
  }) {
8518
8523
  const [isDescExpanded, setDescExpanded] = React5.useState(false);
8519
8524
  const [showDividendHistory, setShowDividendHistory] = React5.useState(false);
@@ -8592,7 +8597,7 @@ function PropertyOverview({
8592
8597
  { label: "Last Valuation", value: isLoading && resolvedValuation == null ? loadingSkeleton : resolvedValuation ? resolvedValuation >= 1e6 ? `$${(resolvedValuation / 1e6).toFixed(2)}M` : `$${resolvedValuation.toLocaleString()}` : "\u2014" },
8593
8598
  { label: "Number of Offers", value: "3" },
8594
8599
  { label: "Growth (Past 5 Years)", value: "+90%" },
8595
- { label: "Last Dividend", value: isLoading && monthlyDivPerShare == null ? loadingSkeleton : monthlyDivPerShare != null ? `${(monthlyDivPerShare * 100).toFixed(1)} cents` : "\u2014" },
8600
+ { label: "Last Dividend", value: isLoading && monthlyDivPerShare == null ? loadingSkeleton : monthlyDivPerShare != null ? `${(monthlyDivPerShare * 100).toFixed(1)}c per Share` : "\u2014" },
8596
8601
  { label: "Upcoming Dividend", value: (() => {
8597
8602
  const now = /* @__PURE__ */ new Date();
8598
8603
  const lastDay = new Date(now.getFullYear(), now.getMonth() + 1, 0);
@@ -8673,6 +8678,7 @@ function PropertyOverview({
8673
8678
  totalTokens: resolvedTokensIssued,
8674
8679
  tokenPrice: tokenPriceValue,
8675
8680
  ticker,
8681
+ priceHistory: priceHistoryProp,
8676
8682
  onClose: () => setShowDividendHistory(false)
8677
8683
  }
8678
8684
  ),
@@ -8805,9 +8811,10 @@ function DividendHistoryPopup({
8805
8811
  totalTokens,
8806
8812
  tokenPrice,
8807
8813
  ticker,
8814
+ priceHistory: realPriceHistory,
8808
8815
  onClose
8809
8816
  }) {
8810
- const { records, priceHistory } = generateDividendHistory(valuation ?? 0, totalTokens ?? 0, tokenPrice ?? 0);
8817
+ const { records, priceHistory } = generateDividendHistory(valuation ?? 0, totalTokens ?? 0, tokenPrice ?? 0, realPriceHistory);
8811
8818
  React5.useEffect(() => {
8812
8819
  const handleEsc = (e) => {
8813
8820
  if (e.key === "Escape") onClose();