@loafmarkets/ui 0.1.148 → 0.1.150

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.js CHANGED
@@ -8297,34 +8297,35 @@ function truncateAddress(addr) {
8297
8297
  if (addr.length <= 12) return addr;
8298
8298
  return `${addr.slice(0, 6)}...${addr.slice(-4)}`;
8299
8299
  }
8300
- function generateMockDividendHistory(annualRent, totalTokens, tokenPrice) {
8301
- if (annualRent <= 0 || !totalTokens || !tokenPrice) return [];
8302
- const monthlyDiv = annualRent / 12 / totalTokens;
8300
+ function generateDividendHistory(valuation, totalTokens, tokenPrice) {
8301
+ if (valuation <= 0 || !totalTokens || !tokenPrice) return { records: [], priceHistory: [] };
8302
+ const annualDiv = valuation * 0.02;
8303
+ const monthlyDivPerShare = annualDiv / 12 / totalTokens;
8303
8304
  const records = [];
8305
+ const priceHistory = [];
8304
8306
  const now = /* @__PURE__ */ new Date();
8307
+ let price = tokenPrice * 0.84;
8308
+ for (let i = 365; i >= 0; i--) {
8309
+ const t = Date.now() - i * 864e5;
8310
+ const progress = (365 - i) / 365;
8311
+ const target = tokenPrice * (0.84 + progress * 0.16);
8312
+ price += (target - price) * 0.03 + (Math.random() - 0.5) * 0.8;
8313
+ price = Math.max(tokenPrice * 0.75, price);
8314
+ priceHistory.push({ time: t, price: Math.round(price * 100) / 100 });
8315
+ }
8305
8316
  for (let i = 11; i >= 0; i--) {
8306
- const d = new Date(now.getFullYear(), now.getMonth() - i, 1);
8307
- const priceAtTime = tokenPrice * (0.85 + Math.random() * 0.3);
8317
+ const exDate = new Date(now.getFullYear(), now.getMonth() - i, 1);
8318
+ const exTime = exDate.getTime();
8319
+ const closest = priceHistory.reduce((best, p) => Math.abs(p.time - exTime) < Math.abs(best.time - exTime) ? p : best);
8320
+ const priceAtEx = closest.price;
8308
8321
  records.push({
8309
- exDate: d.toLocaleDateString("en-AU", { day: "2-digit", month: "short", year: "numeric" }),
8310
- payDate: new Date(d.getFullYear(), d.getMonth(), 15).toLocaleDateString("en-AU", { day: "2-digit", month: "short", year: "numeric" }),
8311
- perShare: monthlyDiv,
8312
- yieldPct: monthlyDiv * 12 / priceAtTime * 100
8322
+ exDate: exDate.toLocaleDateString("en-AU", { day: "2-digit", month: "short", year: "numeric" }),
8323
+ payDate: new Date(exDate.getFullYear(), exDate.getMonth(), 15).toLocaleDateString("en-AU", { day: "2-digit", month: "short", year: "numeric" }),
8324
+ perShare: monthlyDivPerShare,
8325
+ yieldPct: monthlyDivPerShare * 12 / priceAtEx * 100
8313
8326
  });
8314
8327
  }
8315
- return records;
8316
- }
8317
- function generateMockPriceHistory() {
8318
- const points = [];
8319
- const now = Date.now();
8320
- let price = 210;
8321
- for (let i = 365; i >= 0; i--) {
8322
- const t = now - i * 864e5;
8323
- price += (Math.random() - 0.47) * 1.2;
8324
- price = Math.max(180, price);
8325
- points.push({ time: t, price: Math.round(price * 100) / 100 });
8326
- }
8327
- return points;
8328
+ return { records, priceHistory };
8328
8329
  }
8329
8330
  function PropertyOverview({
8330
8331
  propertyName,
@@ -8421,15 +8422,16 @@ function PropertyOverview({
8421
8422
  { label: "24h Volume", value: isLoading && vol24hDollar == null ? loadingSkeleton : vol24hDollar != null && vol24hDollar > 0 ? `$${vol24hDollar.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}` : "\u2014" },
8422
8423
  { label: "Current Dividend Yield", value: isLoading && currentDividendYield == null ? loadingSkeleton : currentDividendYield ? `${currentDividendYield}%` : "\u2014" },
8423
8424
  { label: "Open Orders", value: isLoading && openOrdersValue == null ? loadingSkeleton : openOrdersValue != null && openOrdersValue > 0 ? `$${openOrdersValue.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}` : "\u2014" },
8424
- { label: "Holders", value: isLoading && holderCount == null ? loadingSkeleton : holderCount != null ? holderCount.toLocaleString() : "\u2014" }
8425
+ { label: "Token Holders", value: isLoading && holderCount == null ? loadingSkeleton : holderCount != null ? holderCount.toLocaleString() : "\u2014" }
8425
8426
  ];
8426
- const cashFlowPerShare = annualRent > 0 && resolvedTokensIssued ? annualRent / resolvedTokensIssued : null;
8427
+ const annualDividend = resolvedValuation ? resolvedValuation * 0.02 : null;
8428
+ const monthlyDivPerShare = annualDividend && resolvedTokensIssued ? annualDividend / 12 / resolvedTokensIssued : null;
8427
8429
  const propertyStats = [
8428
8430
  { label: "Last Valuation", value: isLoading && resolvedValuation == null ? loadingSkeleton : resolvedValuation ? resolvedValuation >= 1e6 ? `$${(resolvedValuation / 1e6).toFixed(2)}M` : `$${resolvedValuation.toLocaleString()}` : "\u2014" },
8429
8431
  { label: "Number of Offers", value: "\u2014" },
8430
8432
  { label: "Growth (Past 5 Years)", value: "\u2014" },
8431
8433
  { label: "Security Interest in Asset", value: "Yes, secured to Land Registry" },
8432
- { label: "Cash Flow Per Share", value: isLoading && cashFlowPerShare == null ? loadingSkeleton : cashFlowPerShare != null ? `$${cashFlowPerShare.toFixed(4)}/yr` : "\u2014" }
8434
+ { label: "Dividend Per Share", value: isLoading && monthlyDivPerShare == null ? loadingSkeleton : monthlyDivPerShare != null ? `$${monthlyDivPerShare.toFixed(4)}/mo` : "\u2014" }
8433
8435
  ];
8434
8436
  return /* @__PURE__ */ jsxRuntime.jsxs(Wrapper, { children: [
8435
8437
  /* @__PURE__ */ jsxRuntime.jsxs(Section, { children: [
@@ -8500,7 +8502,7 @@ function PropertyOverview({
8500
8502
  showDividendHistory && /* @__PURE__ */ jsxRuntime.jsx(
8501
8503
  DividendHistoryPopup,
8502
8504
  {
8503
- annualRent,
8505
+ valuation: resolvedValuation,
8504
8506
  totalTokens: resolvedTokensIssued,
8505
8507
  tokenPrice: tokenPriceValue,
8506
8508
  ticker,
@@ -8595,14 +8597,13 @@ function PropertyOverview({
8595
8597
  ] });
8596
8598
  }
8597
8599
  function DividendHistoryPopup({
8598
- annualRent,
8600
+ valuation,
8599
8601
  totalTokens,
8600
8602
  tokenPrice,
8601
8603
  ticker,
8602
8604
  onClose
8603
8605
  }) {
8604
- const records = generateMockDividendHistory(annualRent, totalTokens ?? 0, tokenPrice ?? 0);
8605
- const priceHistory = generateMockPriceHistory();
8606
+ const { records, priceHistory } = generateDividendHistory(valuation ?? 0, totalTokens ?? 0, tokenPrice ?? 0);
8606
8607
  React5.useEffect(() => {
8607
8608
  const handleEsc = (e) => {
8608
8609
  if (e.key === "Escape") onClose();