From 8ec3cba012d3dc7de695389928ff82cbd0d4192a Mon Sep 17 00:00:00 2001 From: Maxi Vila Date: Fri, 24 Apr 2026 07:39:39 -0300 Subject: [PATCH 1/2] fix: use yadio /convert endpoint for accurate fiat-to-sats price --- .env-sample | 2 +- docs/INSTALL.es.md | 2 +- docs/INSTALL.md | 2 +- util/index.ts | 6 ++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.env-sample b/.env-sample index 5351191c..b0b27ae4 100644 --- a/.env-sample +++ b/.env-sample @@ -43,7 +43,7 @@ PENDING_PAYMENT_WINDOW=5 # Fiat currency rate API FIAT_RATE_NAME='' -FIAT_RATE_EP='' +FIAT_RATE_EP='https://api.yadio.io/convert' NODE_ENV='development' # Expiration time for published order in seconds diff --git a/docs/INSTALL.es.md b/docs/INSTALL.es.md index 2c63853a..5110effb 100644 --- a/docs/INSTALL.es.md +++ b/docs/INSTALL.es.md @@ -144,7 +144,7 @@ CHANNEL='@tu-canal-de-ofertas' ADMIN_CHANNEL='-10*****46' HELP_GROUP='@tu-grupo-de-soporte' -FIAT_RATE_EP='https://api.yadio.io/rate' +FIAT_RATE_EP='https://api.yadio.io/convert' DISPUTE_CHANNEL='@tu-canal-de-disputas' diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 0dcbaf51..350ffa5e 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -143,7 +143,7 @@ CHANNEL='@your-offers-channel' ADMIN_CHANNEL='-10*****46' HELP_GROUP='@your-support-group' -FIAT_RATE_EP='https://api.yadio.io/rate' +FIAT_RATE_EP='https://api.yadio.io/convert' DISPUTE_CHANNEL='@your-dispute-channel' diff --git a/util/index.ts b/util/index.ts index dc00c832..66548e00 100644 --- a/util/index.ts +++ b/util/index.ts @@ -155,11 +155,13 @@ const getBtcFiatPrice = async (fiatCode: string, fiatAmount: number) => { if (!currency.price) return; // Before hit the endpoint we make sure the code have only 3 chars const code = currency.code.substring(0, 3); - const response = await axios.get(`${process.env.FIAT_RATE_EP}/${code}`); + const response = await axios.get( + `${process.env.FIAT_RATE_EP}/${fiatAmount}/${code}/BTC` + ); if (response.data.error) { return 0; } - const sats = (fiatAmount / response.data.btc) * 100000000; + const sats = response.data.result * 100000000; return Number(sats); } catch (error) { From ad95f10bc48dfd0ea197092fc5b488f38bc14e71 Mon Sep 17 00:00:00 2001 From: Maxi Vila Date: Fri, 24 Apr 2026 07:57:31 -0300 Subject: [PATCH 2/2] formatting --- util/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/index.ts b/util/index.ts index 66548e00..9e60dc67 100644 --- a/util/index.ts +++ b/util/index.ts @@ -156,7 +156,7 @@ const getBtcFiatPrice = async (fiatCode: string, fiatAmount: number) => { // Before hit the endpoint we make sure the code have only 3 chars const code = currency.code.substring(0, 3); const response = await axios.get( - `${process.env.FIAT_RATE_EP}/${fiatAmount}/${code}/BTC` + `${process.env.FIAT_RATE_EP}/${fiatAmount}/${code}/BTC`, ); if (response.data.error) { return 0;