Skip to content

Disparity in prices between uniswap and wrapper #152

@Marsh-James

Description

@Marsh-James

Been testing a few coins to get a sense of the accuracy of the wrapper. I've noticed a difference across a few coins and am curious for others to give it a test. On average I'm seeing a 0%<x<0.5% delta.

Here's my code, please do comment if I've implemented it poorly or give it a test.

# Addresses sourced from: https://info.uniswap.org/#/tokens
ETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
USDT = '0xdAC17F958D2ee523a2206206994597C13D831ec7'
DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F'

# CONFIGURE UNISWAP
# uniswap_keys = get_keys('../bin/uniswap.secret')
uniswap_exchange = uniswap.Uniswap(
    address='', #uniswap_keys['key'],
    private_key='', #uniswap_keys['secret'],
    provider='', #'https://mainnet.infura.io/v3/<PROJECT>',
    version=3,
    default_slippage=0.01
)

DAI_SWAP = uniswap_exchange.get_price_output(token0=DAI,  token1=ETH, qty=1)

print(DAI_SWAP)

EDIT: I wonder if it's a gas fee? Can we calculate this/extract this value?

EDIT 2: Looking at another issue I've seen this as a possible solution, could someone explain the exponent work (10** etc) and where these values are obtained from?

decimals_usdt = uniswap_exchange.get_token(USDT).decimals
decimals_eth = uniswap_exchange.get_token(ETH).decimals

quantity = 10 ** decimals_eth
price = uniswap_exchange.get_price_input(ETH, USDT, qty=quantity)
price = price / 10 ** decimals_usdt
print(price)

Thoughts @ErikBjare?

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