I'm currently using web3.py to try to buy tokens using a script, but I'm currently having some issues. Question 1. If the LP pair of token is USDT https://poocoin.app/tokens/0x2f0D30A46CAc1197F93679e39c7B1D1652Bad6bf, and I use WBNB to buy, call the swapExactETHForTokens method, then Route: WBNB→USDT→token[ex: YES DAO], this is after 2 router exchanges.
pancakeswap_txn = contract.functions.swapExactETHForTokens(
amountOutMin,
[spend,usdt,buyToken], #WBNB → USDT → token
senderAddress,
(int(start) + 10000)
).buildTransaction({
'from':senderAddress,
'value':web3.toWei(0.0001,'ether'),
'gas':500000,
'gasPrice': web3.toWei('5', 'gwei'),
'nonce':nonce
})
But if the LP pair of the token only has the WBNB transaction pair, for example: https://poocoin.app/tokens/0xffad7f9f704a5fdc6265e24b436b4b35ed52def2, then if the swapExactETHForTokens method is used, then the router conversion of WBNB→USDT→token cannot be used, it must be WBNB →token
pancakeswap_txn = contract.functions.swapExactETHForTokens(
amountOutMin,
[spend,buyToken], # WBNB→ token
senderAddress,
(int(start) + 10000)
).buildTransaction({
'from':senderAddress,
'value':web3.toWei(0.0001,'ether'),
'gas':500000,
'gasPrice': web3.toWei('5', 'gwei'),
'nonce':nonce
})
If you use swapExactTokensForTokens method,How should I get the value of amountIn and amountOutMin similar。
Question 2: Now a token has two trading pairs, that is, two LP Pair addresses such as: https://poocoin.app/tokens/0x84DFDb5F025011572D7167201D89573e3fF6A7e3, its largest LP is USDT LP, and its BNB LP is only 0.02B , if I use the python script to purchase using swapExactETHForTokens, then I will definitely buy the BNB LP pool, so I will lose my money, then how to get the largest LP pair address in the smart contract, and then execute the purchase before the steps Judge the size of the pool, so as not to buy the wrong one.