Skip to content

Historical rate chart for an asset pair #21

Description

@grantfox-oss

Summary

Users interested in the long-term exchange rate between two assets currently have no way to see how the rate has changed over time within this app. This issue adds a historical rate chart to the results section that queries Horizon's trade aggregations endpoint and renders a line chart for the selected asset pair, giving users price context before acting on a route.

Task

  • Create src/lib/trade-aggregations.ts with a fetchRateHistory(network, selling, buying, resolution) function that queries Horizon's /trade_aggregations endpoint and returns an array of { timestamp: number, close: string } objects.
  • Add a src/components/rate-chart.tsx component that accepts the aggregation data and renders a line chart. Use a lightweight charting library such as recharts or chart.js to avoid a large bundle impact.
  • Render RateChart in the results section in src/app/page.tsx when paths.length > 0, between the comparison strip and the table.
  • Fetch 30 days of daily aggregations using the source and destination assets from the last search.
  • Handle the case where no trade history exists for the pair (show a "No historical data available" placeholder).

Acceptance Criteria

  • A line chart appears in the results section after a successful search.
  • The chart shows 30 days of daily close prices for the searched pair.
  • The chart renders correctly on mobile and desktop.
  • Pairs with no trade history show a placeholder message rather than an empty chart or an error.
  • The chart does not appear during loading or when results are empty.

Files in Scope

  • src/lib/trade-aggregations.ts (new file)
  • src/components/rate-chart.tsx (new file)
  • src/app/page.tsx
  • src/types/path.ts

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignenhancementNew feature or requesthelp wantedExtra attention is needed

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions