rainbow icon indicating copy to clipboard operation
rainbow copied to clipboard

Price labels on chart are showing in the wrong currency

Open normanzb opened this issue 1 year ago • 1 comments

Reproduce steps:

  1. Set app currency to GBP British Pounds.
  2. Then click eth chart on dashboard.

Please see screenshot below:

image

Expected result:

All labels showing in GBP with correct values.

Actual result:

The labels for highest and lowest value althrough they are showing with £ Pounds symbol, the values are actually the corresponding USD value.

Proposed fix:

There are 2 way to draw the chart in the selected currency:

  1. Display the token prices in historical GBP (selected currency) prices, this requires storage of historical GBP price somewhere, not sure if there are data available.
  2. Display the token prices in historical USD prices but convert the label price to GBP using exchange rate at the point of rendering.

Searching around it seems most services simply use the latter, e.g. search "eth price in USD" vs "eth price in GBP" in Google:

image image

The valleys and peaks look pretty much the same, meaning it is the 2nd solution.

Assuming we also go for 2nd solution as it is quickest.

By looking into the code, the chart data is pulled by usePriceChart()(in usePriceInfo.ts, wrong name?) from metadataClient.priceChart(), however the endpoint lack of a currency parameter. So the chart data is always returned in USD.

The metadata graphql endpoint is hosted on https://metadata.p.rainbow.me/v1/graph.

The issue can be fixed by adding a currency parameter to the endpoint, but I can't find where the source is.

Alternative solution: we can pull the token USD price and GBP price via metadataClient.externalToken({ address, chainId, currency }), then generate a exchange rate from it, then use the exchange rate in ExtremeLabel to show the price in GBP.

Alternative solution 2: use a 3rd party service to retrieve exchange rate, any recommandation?

Any other idea for fixing it?

I am happy to give it a try to fix the issue since i use rainbow a lot and I don't have a day job right now, but please let me know what's the best way that I can help.

Cheers

normanzb avatar Aug 22 '24 14:08 normanzb

Will raise this in stand up tomorrow, but the proper solution would be adding a currency query param to our metadata endpoint. We'll ticket this out and get to it asap 🥇

walmat avatar Aug 28 '24 00:08 walmat