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..9e60dc67 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) {