@loafmarkets/ui 0.1.148 → 0.1.149

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
@@ -8271,34 +8271,35 @@ function truncateAddress(addr) {
8271
8271
  if (addr.length <= 12) return addr;
8272
8272
  return `${addr.slice(0, 6)}...${addr.slice(-4)}`;
8273
8273
  }
8274
- function generateMockDividendHistory(annualRent, totalTokens, tokenPrice) {
8275
- if (annualRent <= 0 || !totalTokens || !tokenPrice) return [];
8276
- const monthlyDiv = annualRent / 12 / totalTokens;
8274
+ function generateDividendHistory(valuation, totalTokens, tokenPrice) {
8275
+ if (valuation <= 0 || !totalTokens || !tokenPrice) return { records: [], priceHistory: [] };
8276
+ const annualDiv = valuation * 0.02;
8277
+ const monthlyDivPerShare = annualDiv / 12 / totalTokens;
8277
8278
  const records = [];
8279
+ const priceHistory = [];
8278
8280
  const now = /* @__PURE__ */ new Date();
8281
+ let price = tokenPrice * 0.84;
8282
+ for (let i = 365; i >= 0; i--) {
8283
+ const t = Date.now() - i * 864e5;
8284
+ const progress = (365 - i) / 365;
8285
+ const target = tokenPrice * (0.84 + progress * 0.16);
8286
+ price += (target - price) * 0.03 + (Math.random() - 0.5) * 0.8;
8287
+ price = Math.max(tokenPrice * 0.75, price);
8288
+ priceHistory.push({ time: t, price: Math.round(price * 100) / 100 });
8289
+ }
8279
8290
  for (let i = 11; i >= 0; i--) {
8280
- const d = new Date(now.getFullYear(), now.getMonth() - i, 1);
8281
- const priceAtTime = tokenPrice * (0.85 + Math.random() * 0.3);
8291
+ const exDate = new Date(now.getFullYear(), now.getMonth() - i, 1);
8292
+ const exTime = exDate.getTime();
8293
+ const closest = priceHistory.reduce((best, p) => Math.abs(p.time - exTime) < Math.abs(best.time - exTime) ? p : best);
8294
+ const priceAtEx = closest.price;
8282
8295
  records.push({
8283
- exDate: d.toLocaleDateString("en-AU", { day: "2-digit", month: "short", year: "numeric" }),
8284
- payDate: new Date(d.getFullYear(), d.getMonth(), 15).toLocaleDateString("en-AU", { day: "2-digit", month: "short", year: "numeric" }),
8285
- perShare: monthlyDiv,
8286
- yieldPct: monthlyDiv * 12 / priceAtTime * 100
8296
+ exDate: exDate.toLocaleDateString("en-AU", { day: "2-digit", month: "short", year: "numeric" }),
8297
+ payDate: new Date(exDate.getFullYear(), exDate.getMonth(), 15).toLocaleDateString("en-AU", { day: "2-digit", month: "short", year: "numeric" }),
8298
+ perShare: monthlyDivPerShare,
8299
+ yieldPct: monthlyDivPerShare * 12 / priceAtEx * 100
8287
8300
  });
8288
8301
  }
8289
- return records;
8290
- }
8291
- function generateMockPriceHistory() {
8292
- const points = [];
8293
- const now = Date.now();
8294
- let price = 210;
8295
- for (let i = 365; i >= 0; i--) {
8296
- const t = now - i * 864e5;
8297
- price += (Math.random() - 0.47) * 1.2;
8298
- price = Math.max(180, price);
8299
- points.push({ time: t, price: Math.round(price * 100) / 100 });
8300
- }
8301
- return points;
8302
+ return { records, priceHistory };
8302
8303
  }
8303
8304
  function PropertyOverview({
8304
8305
  propertyName,
@@ -8397,13 +8398,14 @@ function PropertyOverview({
8397
8398
  { label: "Open Orders", value: isLoading && openOrdersValue == null ? loadingSkeleton : openOrdersValue != null && openOrdersValue > 0 ? `$${openOrdersValue.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}` : "\u2014" },
8398
8399
  { label: "Holders", value: isLoading && holderCount == null ? loadingSkeleton : holderCount != null ? holderCount.toLocaleString() : "\u2014" }
8399
8400
  ];
8400
- const cashFlowPerShare = annualRent > 0 && resolvedTokensIssued ? annualRent / resolvedTokensIssued : null;
8401
+ const annualDividend = resolvedValuation ? resolvedValuation * 0.02 : null;
8402
+ const monthlyDivPerShare = annualDividend && resolvedTokensIssued ? annualDividend / 12 / resolvedTokensIssued : null;
8401
8403
  const propertyStats = [
8402
8404
  { label: "Last Valuation", value: isLoading && resolvedValuation == null ? loadingSkeleton : resolvedValuation ? resolvedValuation >= 1e6 ? `$${(resolvedValuation / 1e6).toFixed(2)}M` : `$${resolvedValuation.toLocaleString()}` : "\u2014" },
8403
8405
  { label: "Number of Offers", value: "\u2014" },
8404
8406
  { label: "Growth (Past 5 Years)", value: "\u2014" },
8405
8407
  { label: "Security Interest in Asset", value: "Yes, secured to Land Registry" },
8406
- { label: "Cash Flow Per Share", value: isLoading && cashFlowPerShare == null ? loadingSkeleton : cashFlowPerShare != null ? `$${cashFlowPerShare.toFixed(4)}/yr` : "\u2014" }
8408
+ { label: "Dividend Per Share", value: isLoading && monthlyDivPerShare == null ? loadingSkeleton : monthlyDivPerShare != null ? `$${monthlyDivPerShare.toFixed(4)}/mo` : "\u2014" }
8407
8409
  ];
8408
8410
  return /* @__PURE__ */ jsxs(Wrapper, { children: [
8409
8411
  /* @__PURE__ */ jsxs(Section, { children: [
@@ -8474,7 +8476,7 @@ function PropertyOverview({
8474
8476
  showDividendHistory && /* @__PURE__ */ jsx(
8475
8477
  DividendHistoryPopup,
8476
8478
  {
8477
- annualRent,
8479
+ valuation: resolvedValuation,
8478
8480
  totalTokens: resolvedTokensIssued,
8479
8481
  tokenPrice: tokenPriceValue,
8480
8482
  ticker,
@@ -8569,14 +8571,13 @@ function PropertyOverview({
8569
8571
  ] });
8570
8572
  }
8571
8573
  function DividendHistoryPopup({
8572
- annualRent,
8574
+ valuation,
8573
8575
  totalTokens,
8574
8576
  tokenPrice,
8575
8577
  ticker,
8576
8578
  onClose
8577
8579
  }) {
8578
- const records = generateMockDividendHistory(annualRent, totalTokens ?? 0, tokenPrice ?? 0);
8579
- const priceHistory = generateMockPriceHistory();
8580
+ const { records, priceHistory } = generateDividendHistory(valuation ?? 0, totalTokens ?? 0, tokenPrice ?? 0);
8580
8581
  useEffect(() => {
8581
8582
  const handleEsc = (e) => {
8582
8583
  if (e.key === "Escape") onClose();