[英]web3.py getAmountOut() outputs INVALID LIQUIDITY
I'm trying to use the getAmountOut() function from the Uniswap Router-02 which should tell you how much of output token you should receive for a given input token amount.我正在尝试使用 Uniswap Router-02 中的 getAmountOut() function,它应该告诉您对于给定的输入令牌数量,您应该收到多少 output 令牌。
Problem is I am getting the following error:问题是我收到以下错误:
web3.exceptions.ContractLogicError: execution reverted: UniswapV2Library: INSUFFICIENT_LIQUIDITY
. web3.exceptions.ContractLogicError: execution reverted: UniswapV2Library: INSUFFICIENT_LIQUIDITY
。
Now does this function require you to use some ETH because it has to pay gas fees in order to execute or is there an error in my code?现在这个 function 是否需要您使用一些 ETH,因为它必须支付汽油费才能执行,还是我的代码中有错误?
def checkSubTrade(exchange, in_token_address, out_token_address, amount):
# Should be general cross exchange but would have to check if each routers contain the same methods
router_address = w3.toChecksumAddress(router_dict[str(exchange)])
router_abi = abi_dict[str(exchange)]
router_contract = w3.eth.contract(address = router_address, abi = router_abi)
swap_path = [in_token_address, out_token_address]
output = router_contract.functions.getAmountsOut(amount, swap_path).call()
return output
output = checkSubTrade('uniswap', token_dict['WETH'], token_dict['UNI'], 100000000)
print(output())
token_dict
, router_dict
contain the addresses and abi_dict
contains the ABI for the DEX. token_dict
, router_dict
包含地址, abi_dict
包含 DEX 的 ABI。
i think you need to check two things.我认为你需要检查两件事。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.