Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Disparity in prices between uniswap and wrapper#182

Unanswered
Marsh-James asked this question inQ&A
Discussion options

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/#/tokensETH = '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).decimalsdecimals_eth = uniswap_exchange.get_token(ETH).decimalsquantity = 10 ** decimals_ethprice = uniswap_exchange.get_price_input(ETH, USDT, qty=quantity)price = price / 10 ** decimals_usdtprint(price)

Thoughts@ErikBjare?

You must be logged in to vote

Replies: 3 comments

Comment options

You may not be getting the best route from the pair by default. Try specifyingroute toget_price_input. See#93 and related discussion for discussion about automating how to find the ~best pair.

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

You can get the current gas price from theuniswap_exchange.web3 instance. Check the Web3.py docs.

Note that neither this wrapper nor the Uniswap interface takes gas costs into account when quoted.

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?

The decimals are retrieved from the ERC20 contracts, they are needed to scale the traded amount into their base (non-decimal) unit (1 ETH = 10**18 WEI).

You must be logged in to vote
0 replies
Comment options

You may not be getting the best route from the pair by default. Try specifyingroute toget_price_input. See#93 and related discussion for discussion about automating how to find the ~best pair.

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

You can get the current gas price from theuniswap_exchange.web3 instance. Check the Web3.py docs.

Note that neither this wrapper nor the Uniswap interface takes gas costs into account when quoted.

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?

The decimals are retrieved from the ERC20 contracts, they are needed to scale the traded amount into their base (non-decimal) unit (1 ETH = 10**18 WEI).

Thanks for getting back to me. Comparing with uniswap v3, with multihops disabled, so we're looking at TOKEN->TOKEN directly there's still this discrepancy. Does uniswap do anything off chain perhaps or could the infrua node be lagging in some capacity?

You must be logged in to vote
0 replies
Comment options

could the infrua node be lagging

Yes. Just set up the local node; you can use light-mode for syncing so it requires like 700Mb of the disc space.

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
3 participants
@Marsh-James@ErikBjare@liquid-8
Converted from issue

This discussion was converted from issue #152 on October 19, 2021 10:13.


[8]ページ先頭

©2009-2025 Movatter.jp