Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect USD price of tokens in menu #5960

Closed
pavel-lens opened this issue Dec 22, 2018 · 7 comments
Closed

Incorrect USD price of tokens in menu #5960

pavel-lens opened this issue Dec 22, 2018 · 7 comments
Assignees

Comments

@pavel-lens
Copy link

Describe the bug
The USD price of tokens in Menu is incorrect. It shows huge amount of USD - around ±100x more as the real value. I'm not sure if it's only a problem of decimal point or the prices are totally wrong. It's obviously connected to where token prices are coming from.

To Reproduce
Steps to reproduce the behavior:

  1. Open Metamask extension
  2. Click on the hamburger menu in top left corner
  3. Scroll down to tokens
  4. Inspect prices

Expected behavior
A correct value in USD should be displayed.

Examples of tokens with invalid USD prices: Crypto20 C20, Gnosis GNO

Screenshots
https://pasteboard.co/HSUIZwg.png

Browser details (please complete the following information):

  • OS: MacOS 10.14 Mojave
  • Browser: Brave Version 0.58.16 Chromium: 71.0.3578.98 (Official Build) (64-bit)
  • MetaMask Version 5.2.2

Additional context
n/a

@tmashuang
Copy link
Contributor

Has it updated after a while to the correct price? We use an external API for token prices/rates, they we have no control over.

@pavel-lens
Copy link
Author

I saw some change in price in few seconds. But the prices I provided screenshot of are after the change. These prices are apparently way off, so I think there is some calculation error on Metamask side. If not, then the API prices are off. If you point me to the right file I can have a look and create a PR with fix.

@tmashuang
Copy link
Contributor

I started here, where the API call starts. token-rates.js.

I just Postman'd the request for the Gnosis contract(0x6810e776880c02933d47db1b9fc05908e5386b96).
Request: https://exchanges.balanc3.net/pie?pairs[]=0x6810e776880c02933d47db1b9fc05908e5386b96/usd&autoConversion=true. But will investigate the calculation as well.

@pavel-lens
Copy link
Author

Okay, the retrieval logic in token-rates.js seems fine.

I looked at how prices are displayed at token-cell.js. It's a bit complicated, but it seems that the problem is that this calculation is being done:

tokenAmount * ethUsdPrice * tokenUsdPrice

In short, multiplication by ethUsdPrice is not necessary since the API already returns price of token in USD. This should be removed / changed
https://github.com/MetaMask/metamask-extension/blob/develop/ui/app/components/token-cell.js#L66

Metamask should only multiply token price stored in state.metamask.conversionRate[address] and token amount in the wallet.

@tmashuang
Copy link
Contributor

Looking deeper we select the native currency selected here
https://github.com/MetaMask/metamask-extension/blob/develop/app/scripts/controllers/token-rates.js#L32

I believe we should still have ethUsdPrice in the calculation.

@tmashuang
Copy link
Contributor

Upon buying GNO tokens, it seems the price for that seems fine with the current calculation.

@aminelarhrib2020
Copy link

hi ,
We have the same issue with CRD token price .
https://ethplorer.io/address/0xcaaa93712bdac37f736c323c93d4d5fdefcc31cc
metamask is displaying the wrong price . could you please help . there is 10X price difference , which is very confusing
many thanks !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants