From 185e81683fc0f0a3c571ddcff29f02d580aa98a9 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 4 Jul 2026 09:44:50 -0700 Subject: rates: fix Iranian IRR/IRT feed after nobitex API host move The nobitex endpoint host changed (old host now NXDOMAIN) and the fetch was swallowed by an empty catch, silently blanking Iranian rates. Point at the current host, and since the API quotes in Rial despite the IRT pair name, set IRR from lastTradePrice and IRT = Rial/10. Log fetch failures instead of ignoring them. Co-Authored-By: Claude Opus 4.8 (1M context) --- lib/rates.ts | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/rates.ts b/lib/rates.ts index f9ef9f3c..03a3dcea 100644 --- a/lib/rates.ts +++ b/lib/rates.ts @@ -26,12 +26,25 @@ const connect = async () => { }); try { - rates.IRT = ( - (await got( - "https://api.nobitex.ir/v2/orderbook/BTCIRT", - ).json()) as any - ).lastTradePrice; - } catch (e) {} + // Nobitex is the real Iranian market rate (fixer's IRR is the + // official peg, which undervalues by ~20%). Its API quotes in RIAL + // despite the IRT pair name, so IRR = lastTradePrice and Toman = + // Rial / 10. (Host moved from api. to apiv2.; the old one is now + // NXDOMAIN, which silently blanked both currencies.) + const irr = Number( + ( + (await got( + "https://apiv2.nobitex.ir/v2/orderbook/BTCIRT", + ).json()) as any + ).lastTradePrice, + ); + if (irr > 0) { + rates.IRR = irr; + rates.IRT = irr / 10; + } + } catch (e) { + err("nobitex IRR/IRT rate fetch failed", e.message); + } rate = msg.c; s("rate", rate); -- cgit v1.2.3