Skip to content

Replace hardcoded mock prices in the oracle-feeds endpoint with a real price source #41

Description

@priscaenoch

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ADVANCESubstantial, cross-cutting work spanning more than five files. Not a minor fix.GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignenhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions