@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.mjs CHANGED
@@ -8428,32 +8428,36 @@ function truncateAddress(addr) {
8428
8428
  if (addr.length <= 12) return addr;
8429
8429
  return `${addr.slice(0, 6)}...${addr.slice(-4)}`;
8430
8430
  }
8431
- function generateDividendHistory(valuation, totalTokens, tokenPrice) {
8431
+ function generateDividendHistory(valuation, totalTokens, tokenPrice, realPriceHistory) {
8432
8432
  if (valuation <= 0 || !totalTokens || !tokenPrice) return { records: [], priceHistory: [] };
8433
8433
  const annualDiv = valuation * 0.02;
8434
8434
  const monthlyDivPerShare = annualDiv / 12 / totalTokens;
8435
8435
  const records = [];
8436
- const priceHistory = [];
8436
+ const priceHistory = realPriceHistory?.length ? realPriceHistory.map((c) => ({ time: typeof c.time === "number" && c.time < 1e12 ? c.time * 1e3 : c.time, price: c.close })) : (() => {
8437
+ const pts = [];
8438
+ let price = tokenPrice * 0.84;
8439
+ for (let i = 365; i >= 0; i--) {
8440
+ const t = Date.now() - i * 864e5;
8441
+ const progress = (365 - i) / 365;
8442
+ const target = tokenPrice * (0.84 + progress * 0.16);
8443
+ price += (target - price) * 0.03 + (Math.random() - 0.5) * 0.8;
8444
+ price = Math.max(tokenPrice * 0.75, price);
8445
+ pts.push({ time: t, price: Math.round(price * 100) / 100 });
8446
+ }
8447
+ return pts;
8448
+ })();
8437
8449
  const now = /* @__PURE__ */ new Date();
8438
- let price = tokenPrice * 0.84;
8439
- for (let i = 365; i >= 0; i--) {
8440
- const t = Date.now() - i * 864e5;
8441
- const progress = (365 - i) / 365;
8442
- const target = tokenPrice * (0.84 + progress * 0.16);
8443
- price += (target - price) * 0.03 + (Math.random() - 0.5) * 0.8;
8444
- price = Math.max(tokenPrice * 0.75, price);
8445
- priceHistory.push({ time: t, price: Math.round(price * 100) / 100 });
8446
- }
8447
8450
  for (let i = 11; i >= 0; i--) {
8448
8451
  const exDate = new Date(now.getFullYear(), now.getMonth() - i, 1);
8449
8452
  const exTime = exDate.getTime();
8450
8453
  const closest = priceHistory.reduce((best, p) => Math.abs(p.time - exTime) < Math.abs(best.time - exTime) ? p : best);
8451
8454
  const priceAtEx = closest.price;
8455
+ const annualisedYield = priceAtEx > 0 ? monthlyDivPerShare * 12 / priceAtEx * 100 : 2;
8452
8456
  records.push({
8453
8457
  exDate: exDate.toLocaleDateString("en-AU", { day: "2-digit", month: "short", year: "numeric" }),
8454
8458
  payDate: new Date(exDate.getFullYear(), exDate.getMonth(), 15).toLocaleDateString("en-AU", { day: "2-digit", month: "short", year: "numeric" }),
8455
8459
  perShare: monthlyDivPerShare,
8456
- yieldPct: monthlyDivPerShare * 12 / priceAtEx * 100
8460
+ yieldPct: annualisedYield
8457
8461
  });
8458
8462
  }
8459
8463
  return { records, priceHistory };
@@ -8487,7 +8491,8 @@ function PropertyOverview({
8487
8491
  percentageTokenized,
8488
8492
  volume24h,
8489
8493
  openOrdersValue,
8490
- holderCount
8494
+ holderCount,
8495
+ priceHistory: priceHistoryProp
8491
8496
  }) {
8492
8497
  const [isDescExpanded, setDescExpanded] = useState(false);
8493
8498
  const [showDividendHistory, setShowDividendHistory] = useState(false);
@@ -8566,7 +8571,7 @@ function PropertyOverview({
8566
8571
  { label: "Last Valuation", value: isLoading && resolvedValuation == null ? loadingSkeleton : resolvedValuation ? resolvedValuation >= 1e6 ? `$${(resolvedValuation / 1e6).toFixed(2)}M` : `$${resolvedValuation.toLocaleString()}` : "\u2014" },
8567
8572
  { label: "Number of Offers", value: "3" },
8568
8573
  { label: "Growth (Past 5 Years)", value: "+90%" },
8569
- { label: "Last Dividend", value: isLoading && monthlyDivPerShare == null ? loadingSkeleton : monthlyDivPerShare != null ? `${(monthlyDivPerShare * 100).toFixed(1)} cents` : "\u2014" },
8574
+ { label: "Last Dividend", value: isLoading && monthlyDivPerShare == null ? loadingSkeleton : monthlyDivPerShare != null ? `${(monthlyDivPerShare * 100).toFixed(1)}c per Share` : "\u2014" },
8570
8575
  { label: "Upcoming Dividend", value: (() => {
8571
8576
  const now = /* @__PURE__ */ new Date();
8572
8577
  const lastDay = new Date(now.getFullYear(), now.getMonth() + 1, 0);
@@ -8647,6 +8652,7 @@ function PropertyOverview({
8647
8652
  totalTokens: resolvedTokensIssued,
8648
8653
  tokenPrice: tokenPriceValue,
8649
8654
  ticker,
8655
+ priceHistory: priceHistoryProp,
8650
8656
  onClose: () => setShowDividendHistory(false)
8651
8657
  }
8652
8658
  ),
@@ -8779,9 +8785,10 @@ function DividendHistoryPopup({
8779
8785
  totalTokens,
8780
8786
  tokenPrice,
8781
8787
  ticker,
8788
+ priceHistory: realPriceHistory,
8782
8789
  onClose
8783
8790
  }) {
8784
- const { records, priceHistory } = generateDividendHistory(valuation ?? 0, totalTokens ?? 0, tokenPrice ?? 0);
8791
+ const { records, priceHistory } = generateDividendHistory(valuation ?? 0, totalTokens ?? 0, tokenPrice ?? 0, realPriceHistory);
8785
8792
  useEffect(() => {
8786
8793
  const handleEsc = (e) => {
8787
8794
  if (e.key === "Escape") onClose();