Skip to content

Optimize MarketAPI: Consolidate Sources & Add Missing Currencies #129

@Okazakee

Description

@Okazakee

Problem

The current MarketAPI implementation uses 9 different data sources for exchange rates, which adds complexity without clear benefits. Additionally, several major fiat currencies are missing.

Current Sources (9)

  • Kraken (3 currencies)
  • CoinGecko (25 currencies)
  • CoinDesk (15 currencies)
  • Yadio (3 currencies)
  • YadioConvert (2 currencies)
  • Coinbase (1 currency)
  • Coinpaprika (1 currency)
  • Exir (2 currencies)
  • BNR (1 currency)

Issues

  1. No fallback system — if a source fails, the request fails
  2. Too many sources — increases maintenance burden and potential points of failure
  3. Missing major currencies — several countries with large populations/economies are not supported

Proposed Changes

1. Consolidate to 4 Sources

Source Use Case Currencies
Kraken Major fiat pairs (high liquidity) USD, EUR, GBP, CAD, JPY, AUD, CHF
CoinGecko All other standard currencies ~50 currencies
Yadio Parallel/unofficial rates ARS, VES, CLP (countries with capital controls)
Exir Iranian market IRR, IRT

Sources to remove: Coinbase, Coinpaprika, CoinDesk, BNR, YadioConvert, Bitstamp

2. Add Missing Currencies (via CoinGecko)

Asia

  • VND — Vietnamese Dong (100M+ population)
  • PKR — Pakistani Rupee (220M+ population)
  • BDT — Bangladeshi Taka (170M+ population)
  • MMK — Myanmar Kyat

Middle East / Africa

  • EGP — Egyptian Pound (100M+ population)
  • MAD — Moroccan Dirham
  • DZD — Algerian Dinar
  • JOD — Jordanian Dinar

Latin America

  • PEN — Peruvian Sol
  • CRC — Costa Rican Colón
  • DOP — Dominican Peso
  • GTQ — Guatemalan Quetzal
  • BOB — Bolivian Boliviano

Europe / Central Asia

  • BGN — Bulgarian Lev (EU member)
  • GEL — Georgian Lari
  • KZT — Kazakhstani Tenge
  • BYN — Belarusian Ruble

3. Add Fallback System

Implementing fallback logic so if Kraken fails for USD/EUR/GBP, the API falls back to CoinGecko automatically.


Migration Notes

Currencies changing source:

Currency From To
CAD, AUD, CHF, JPY CoinGecko Kraken
CNY Coinbase CoinGecko
INR Coinpaprika CoinGecko
RON BNR CoinGecko
ANG, LBP YadioConvert CoinGecko
AMD, AWG, COP, HRK, ISK, KES, MZN, OMR, PYG, QAR, RSD, TZS, UGX, UYU, XAF, GHS CoinDesk CoinGecko

Benefits

  • ✅ Fewer external dependencies (9 → 4 sources)
  • ✅ Easier maintenance
  • ✅ More currencies supported
  • ✅ Consistent data quality from established providers
  • ✅ Simpler codebase (remove unused Source variants and parsing logic)

Files to Update

  • assets/fiatUnits.json — update source mappings, add new currencies
  • rates/src/lib.rs — remove unused Source variants and their URL/parsing logic

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestratesrates crate

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions