You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
Activity
ErikBjare commentedon Oct 21, 2020
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_pricereturns an int which I assume you convert to decimal by dividing by10**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.