GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Wrong prices for some tokens · Issue #41 · uniswap-python/uniswap-python

Wrong prices for some tokens #41

New issue
Copy link
New issue
Copy link
Closed
Closed
Wrong prices for some tokens#41
Copy link

Description

@liquid-8
liquid-8
opened on Oct 21, 2020
Issue body actions

Hi.

Code is
swapInput=int(volume*10**18)
swapOutput = uniswap_wrapper.get_token_token_input_price(_addr_to_str(token0), _addr_to_str(token1), swapInput)

token0 is ETH
token1 is 0xdf7a06fa60bea43d77c5210c0afb5f244b729e57
Code returns price 0.000000000000542003 but real price is 542003 tokens per ETH

Same here
token0 is ETH
token1 is 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599
Code returns price 0.000000000003088910 but real price is 0.0308901 tokens per ETH

I have no idea what's wrong with it because code works totally fine for other tokens.
Any suggestions?

Activity

  1. ErikBjare commented on Oct 21, 2020

    @ErikBjare
    ErikBjare
    on Oct 21, 2020
    Member
    More actions

    Your code example is not complete (which made it harder to see what you're doing wrong), but you seem to have made a bad assumption about the number of decimals the tokens are denominated in.

    Let's use the WBTC as an example: get_token_token_input_price returns an int which I assume you convert to decimal by dividing by 10**18, this is incorrect since WBTC is denominated with 8 decimals, not 18.

    The first token seems to be denominated with 0 decimals according to Etherscan, so you shouldn't divide it at all.

  2. ErikBjare
    closed this as completedon Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.