Description
Invoice amounts are typically denominated in fiat (USD, EUR, GBP), but Stellar payments use XLM or Stellar assets. The SDK has no standardised price oracle adapter, leaving each integrator to implement their own fiat-to-XLM conversion. A pluggable oracle adapter interface should define a standard PriceOracleAdapter contract and ship a default implementation backed by a configurable public price API.
Technical Context
Add src/priceOracle.ts. Define PriceOracleAdapter interface in src/types.ts with getPrice(base: string, quote: string): Promise<number>. Default implementation uses the CoinGecko /simple/price REST endpoint via fetch. Integrates with src/currencyConverter.ts and src/rateCache.ts. Config accepts a custom priceOracle implementation via StellarSplitConfig.
Acceptance Criteria
Description
Invoice amounts are typically denominated in fiat (USD, EUR, GBP), but Stellar payments use XLM or Stellar assets. The SDK has no standardised price oracle adapter, leaving each integrator to implement their own fiat-to-XLM conversion. A pluggable oracle adapter interface should define a standard
PriceOracleAdaptercontract and ship a default implementation backed by a configurable public price API.Technical Context
Add
src/priceOracle.ts. DefinePriceOracleAdapterinterface insrc/types.tswithgetPrice(base: string, quote: string): Promise<number>. Default implementation uses the CoinGecko/simple/priceREST endpoint viafetch. Integrates withsrc/currencyConverter.tsandsrc/rateCache.ts. Config accepts a custompriceOracleimplementation viaStellarSplitConfig.Acceptance Criteria
PriceOracleAdapterinterface is exported fromsrc/index.tsso callers can supply custom implementationsCoinGeckoPriceOraclefetchesXLM/USD,XLM/EUR, and anybase/quotepair dynamicallysrc/currencyConverter.tsuses the oracle adapter when computing fiat-to-asset amountssrc/rateCache.tswith a configurable TTLRateLimitErrorfromsrc/errors.ts