fix: use yadio /convert endpoint for accurate fiat-to-sats price#788
fix: use yadio /convert endpoint for accurate fiat-to-sats price#788Matobi98 wants to merge 2 commits intolnp2pBot:mainfrom
Conversation
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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/VESendpoint 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}/BTCendpoint, which is purpose-built for this use case and matches the rate shown on yadio.io.Before:
After:
.envchangeIf you are self-hosting this bot, you must update
FIAT_RATE_EPin your.envfile:Files changed
util/index.ts— updated API call and response parsing.env-sample— updated default valuedocs/INSTALL.mdanddocs/INSTALL.es.md— updated documentation