Skip to content

Wrong prices for some tokens #41

Closed

Description

@liquid-8

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
    Member

    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.

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