Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(credits): quote a sub-cent unit price as a real number, and say what a failed fetch means

nirholas0f1ae7873033
diff --git a/src/credits.js b/src/credits.js
index ac3579940..0ee50b4d9 100644
--- a/src/credits.js
+++ b/src/credits.js
@@ -15,6 +15,17 @@ const SOL_MINT = 'So11111111111111111111111111111111111111112';
const $ = (id) => document.getElementById(id);
const fmtUsd = (n) => `$${(Number(n) || 0).toFixed(2)}`;
+
+// Balances round to cents, but a UNIT price does not: $THREE trades well under a
+// cent, and `$0.00` next to a live quote reads as broken. Keep enough decimals to
+// show a real number, capped so the row never turns into scientific noise.
+function fmtUnitPrice(n) {
+ const v = Number(n) || 0;
+ if (v >= 0.01) return `$${v.toFixed(2)}`;
+ if (v <= 0) return '$0.00';
+ const decimals = Math.min(10, Math.max(2, Math.ceil(-Math.log10(v)) + 3));
+ return `$${v.toFixed(decimals).replace(/0+$/, '')}`;
+}
const origin = window.location.origin;
let state = {
@@ -234,7 +245,7 @@ function updateEstimate() {
const fallback = 'Credited at the live USD value when your deposit confirms.';
el.textContent = '';
if (!(amt > 0)) {
- el.textContent = price > 0 ? `1 ${unit} \u2248 ${fmtUsd(price)}` : fallback;
+ el.textContent = price > 0 ? `1 ${unit} \u2248 ${fmtUnitPrice(price)}` : fallback;
return;
}
if (!(price > 0)) {