Files
dark-lord/lib/shopFx.ts
drjones 78a071ba02 Harden onion boot flow and deepen site surfaces
Add persistent onion key backup and restore, improve startup resilience, and flesh out the major site verticals with richer navigation, search coverage, and operator documentation.

Made-with: Cursor
2026-04-07 21:35:52 -07:00

27 lines
752 B
TypeScript

import type { ShopCurrency } from "@/lib/shopCatalog";
/**
* Rough USD notional for cart/checkout when only BTC spot is loaded from API.
* ETH/XMR are pegged off BTC for display totals (sim storefront).
*/
export function estimateUsdForCryptoAmount(
amount: number,
currency: ShopCurrency,
btcUsd: number,
): number {
if (currency === "USD") return Math.round(amount * 100) / 100;
if (!(btcUsd > 0)) return 0;
const ethUsd = btcUsd / 28;
const xmrUsd = btcUsd / 520;
switch (currency) {
case "BTC":
return Math.round(amount * btcUsd * 100) / 100;
case "ETH":
return Math.round(amount * ethUsd * 100) / 100;
case "XMR":
return Math.round(amount * xmrUsd * 100) / 100;
default:
return 0;
}
}