繁体   English   中英

getAmountsOut function 与交易所价格之间的差异

[英]Discrepancy between the getAmountsOut function and the prices on the exchange

我正在制作一个应用程序以从不同的交易所获取代币的实时价格。 为此,我使用 web3.py 访问 DEX 智能合约并调用 getAmountsOut function。它应该是最准确的,因为它直接来自 dex 路由器,但我经常看到我得到的数字与实际交换中的数字,甚至使用 dexscreener。

难道我做错了什么? 我应该尝试包括滑点以使其更接近交易所吗? 请注意,我从 getAmountsOut function 检索到的价格通常是准确的。

这是我在python中使用的function的代码。

routerContract = web3.eth.contract(address=uniswapV2Router, abi=uniswapV2ABI)
oneToken = web3.toWei(1, 'Ether')                                                           
price = routerContract.functions.getAmountsOut(oneToken, [tokenAddress, DAI]).call()        
readablePrice = web3.fromWei(price[1], 'Ether')    

                                    

此处未显示与节点的连接,可能是端点的限制吗? 谢谢!

在 getAmountsOut 的计算中考虑了 0.3% 的 uniswap 费用,因此像 dexscreener 这样的价格会有所不同

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM