Skip to content

fix: use yadio /convert endpoint for accurate fiat-to-sats price#788

Open
Matobi98 wants to merge 2 commits intolnp2pBot:mainfrom
Matobi98:issue787
Open

fix: use yadio /convert endpoint for accurate fiat-to-sats price#788
Matobi98 wants to merge 2 commits intolnp2pBot:mainfrom
Matobi98:issue787

Conversation

@Matobi98
Copy link
Copy Markdown
Contributor

Fix VES (and low-liquidity currencies) sats calculation

Problem

When creating an order with a fiat amount, the bot was calling https://api.yadio.io/rate/{code} to get the BTC exchange rate. For currencies without a liquid direct BTC trading pair (most notably VES), yadio returns a rate based on a low-liquidity direct pair and includes a warning in the response: "currency pair not specified using default".

This caused incorrect sats calculations. For example, 1212 VES would return ~2,426 sats from the bot, while yadio.io itself shows ~2,492 sats — a ~2.7% discrepancy.

Root Cause

The /rate/VES endpoint returns a direct VES/BTC pair rate that differs from what yadio.io displays on their website. The website derives the rate through a cross-calculation (VES→USD→BTC), which is more accurate for currencies with low BTC liquidity.

Fix

Switch to the /convert/{amount}/{code}/BTC endpoint, which is purpose-built for this use case and matches the rate shown on yadio.io.

Before:

GET https://api.yadio.io/rate/VES
sats = (fiatAmount / response.data.btc) * 1e8

After:

GET https://api.yadio.io/convert/1212/VES/BTC
sats = response.data.result * 1e8

⚠️ Required .env change

If you are self-hosting this bot, you must update FIAT_RATE_EP in your .env file:

- FIAT_RATE_EP='https://api.yadio.io/rate'
+ FIAT_RATE_EP='https://api.yadio.io/convert'

Without this change the bot will stop returning prices for fiat currencies.

Files changed

  • util/index.ts — updated API call and response parsing
  • .env-sample — updated default value
  • docs/INSTALL.md and docs/INSTALL.es.md — updated documentation

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

Warning

Rate limit exceeded

@Matobi98 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 58 minutes and 52 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 58 minutes and 52 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 870e8a07-06e7-411c-b6dd-ec6a72470dad

📥 Commits

Reviewing files that changed from the base of the PR and between 064ded1 and ad95f10.

📒 Files selected for processing (4)
  • .env-sample
  • docs/INSTALL.es.md
  • docs/INSTALL.md
  • util/index.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant