From 7740a77943ccaa86f0dcbc6d661cfe6b345144b1 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Sun, 12 Apr 2026 03:56:02 +0100 Subject: [PATCH] [#852] Document historical USD conversion approach in PriceChart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add doc comment explaining the USD pricing formula, data accuracy tiers (live/backfill_exact/backfill_approx), and chart fallback behavior. Implementation was already complete — this closes the documentation gap from #776. Co-Authored-By: Claude Opus 4.6 (1M context) --- package.json | 2 +- src/components/PriceChart.tsx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 671f8478..da22803c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plotlink", - "version": "0.1.20", + "version": "0.1.21", "private": true, "workspaces": [ "packages/*" diff --git a/src/components/PriceChart.tsx b/src/components/PriceChart.tsx index e4bfa58d..c0b6840a 100644 --- a/src/components/PriceChart.tsx +++ b/src/components/PriceChart.tsx @@ -53,6 +53,24 @@ function formatUsdPrice(v: number): string { return `$${v.toExponential(2)}`; } +/** + * Price chart with historical USD conversion (resolves #776 / #852). + * + * USD pricing approach: + * USD price = price_per_token (in PLOT) × reserve_usd_rate + * where reserve_usd_rate = priceForNextMint(PLOT→HUNT) × HUNT/USD (1inch oracle) + * + * Data accuracy tiers (stored in trade_history.rate_source): + * - "live" — rate captured at indexing time, within ~200 blocks of head + * - "backfill_exact" — both PLOT/HUNT and HUNT/USD read from archive RPC at trade block + * - "backfill_approx" — current PLOT/HUNT × historical HUNT/USD (less accurate for older trades) + * + * Chart behavior: + * - USD/PLOT toggle shown only when at least one trade has a rate + * - In USD mode, only points with a rate are plotted (gaps are acceptable) + * - Approximate data rendered as dashed lines to signal lower confidence + * - Falls back to PLOT-only view if no USD data exists + */ export function PriceChart({ tokenAddress, currentPriceRaw }: PriceChartProps) { const [mode, setMode] = useState("usd"); const currentPrice = Number(formatUnits(currentPriceRaw, 18));