Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plotlink",
"version": "0.1.20",
"version": "0.1.21",
"private": true,
"workspaces": [
"packages/*"
Expand Down
18 changes: 18 additions & 0 deletions src/components/PriceChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<PriceMode>("usd");
const currentPrice = Number(formatUnits(currentPriceRaw, 18));
Expand Down
Loading