Problem
src/api/oracle-feeds.ts exposes a price endpoint (GET /oracle-feeds/assets/{assetPair}/price) that returns values from a hardcoded mockPrices object (line 98); the response (line 107) sets price: mockPrices[assetPair], so callers receive fabricated figures presented as live oracle data, and an unknown pair returns undefined. The module has 9 routes built on this mock source. Doing this properly is more than a one-line swap: it means introducing a reusable price-provider layer with caching and configuration, refactoring all nine routes onto it, and covering it with tests.
What needs to be done
- Introduce a price-provider abstraction (interface) so the data source is swappable and testable.
- Implement a real provider (a Stellar/Soroban on-chain oracle or a configured external feed).
- Add a caching layer and rate-limit handling consistent with the other feed routes.
- Refactor all nine oracle-feeds routes to read from the provider, and return a documented
404/typed error for an unknown assetPair instead of undefined.
- Add provider and cache configuration via environment variables, documented in
.env.example and the README.
- Gate any residual mock behind the shared
MOCK_DATA flag (coordinate with the mock-data framework issue).
Files
src/api/oracle-feeds.ts
- new
src/services/pricing/provider.ts (interface) and a real implementation
- a caching module under
src/services/pricing/ (or reuse the existing cache layer)
src/config/ (provider + cache configuration)
.env.example, README.md
- tests under
tests/
Acceptance deliverables
- All nine routes read from the provider; no hardcoded prices remain in the response path.
- Unknown asset pairs return a documented error, not
undefined.
- Any remaining mock is behind an explicit, default-off flag.
- All CI checks pass; the change cannot be merged until CI is green.
Tests to pass
- Test: the endpoint returns provider data (provider mocked) and a typed
404 for an unknown pair.
- Test: responses are served from cache within the configured TTL.
- Test: with
MOCK_DATA unset, no fabricated price is served.
Problem
src/api/oracle-feeds.tsexposes a price endpoint (GET /oracle-feeds/assets/{assetPair}/price) that returns values from a hardcodedmockPricesobject (line 98); the response (line 107) setsprice: mockPrices[assetPair], so callers receive fabricated figures presented as live oracle data, and an unknown pair returnsundefined. The module has 9 routes built on this mock source. Doing this properly is more than a one-line swap: it means introducing a reusable price-provider layer with caching and configuration, refactoring all nine routes onto it, and covering it with tests.What needs to be done
404/typed error for an unknownassetPairinstead ofundefined..env.exampleand the README.MOCK_DATAflag (coordinate with the mock-data framework issue).Files
src/api/oracle-feeds.tssrc/services/pricing/provider.ts(interface) and a real implementationsrc/services/pricing/(or reuse the existing cache layer)src/config/(provider + cache configuration).env.example,README.mdtests/Acceptance deliverables
undefined.Tests to pass
404for an unknown pair.MOCK_DATAunset, no fabricated price is served.