Skip to content

fix(rates): wire live XLM/USD price feed with CoinGecko and Horizon DEX fallback (#2) - #109

Open
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/live-exchange-rate-feed-2
Open

fix(rates): wire live XLM/USD price feed with CoinGecko and Horizon DEX fallback (#2)#109
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/live-exchange-rate-feed-2

Conversation

@ghzhost

@ghzhost ghzhost commented Sep 3, 2026

Copy link
Copy Markdown

Description

Resolves #2.

Replaces the hardcoded mock exchange rate { xlmUsd: 0.12 } in useExchangeRate with live rate querying:

  1. Queries CoinGecko public simple price API (/simple/price?ids=stellar&vs_currencies=usd) with timeout protection.
  2. If on Mainnet and external API is unreachable or rate limited, falls back to the native Stellar DEX orderbook (USDC/XLM top bid/ask) via Horizon (horizonUrl(mainnet)).
  3. Gracefully provides a fallback default if offline, and polls for updates every 30 seconds.
  4. Added comprehensive test coverage in src/lib/exchangeRate.test.ts.

Test Plan

  • pnpm test --run passes (116/116 tests passing across all test files).
  • Verified tests handle mock CoinGecko success, Horizon DEX fallback, and network offline graceful fallback.

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.

useExchangeRate hook returns a hardcoded mock price instead of a live rate

1 participant