aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-07-04 09:44:50 -0700
committerAdam Soltys <[email protected]>2026-07-04 09:44:50 -0700
commit185e81683fc0f0a3c571ddcff29f02d580aa98a9 (patch)
tree14ab77d68eb2c129cedfee9b8938342313da35db /lib
parent9c4c7060560f21246a4e4ce6feb83fd07e4aa481 (diff)
downloadcoinos-server-185e81683fc0f0a3c571ddcff29f02d580aa98a9.tar.gz
coinos-server-185e81683fc0f0a3c571ddcff29f02d580aa98a9.zip
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) <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/rates.ts25
1 files changed, 19 insertions, 6 deletions
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);