In the uniswap router V2 contract, there is a function called swapExactETHForTokensSupportingFeeOnTransferTokens.
One of the parameters it accepts in the path parameter, which is a list containing two addresses, WBNB and the address of the token i want to buy.
When I use this function to buy tokens, it doesn't buy it if the token I'm trying to buy doesn't have BNB Liquidity Pool.
If the token has a very small BNB LP, say $1, it buys about that much worth and diacards the rest.
It happened to me earlier today. I spent .05BNB on a token that was selling for $.30. I ended up with a total of 24 tokens for my $20.
When I buy that same token via Trust Wallet, the transaction goes like this WBNB -> BUSD -> TOKEN and I get the correct amount.
What must i put in that path parameter to make sure that it correctly routes my transaction ?
Oct 1, 2021, 7:33 PM
Use multi hops to swap tokens
Which doesn't have a liquidity pool
Oct 1, 2021, 7:38 PM
How do I do this?
Oct 1, 2021, 7:39 PM
On specifying the path first swap to bnb then to the token you want to swap for
Oct 1, 2021, 7:40 PM
So in my code, the [spend,contract_id] is where I specify the path.
spend = WBNB
contract_id = Token I'm buying
You're saying that I should make it:
[spend, BNB, contract_id], where BNB would be the address for BNB.
Or, are you saying I should just buy using BNB (not wrapped) and make it:
[BNB,contract_id]
?
spend = WBNB
contract_id = Token I'm buying
You're saying that I should make it:
[spend, BNB, contract_id], where BNB would be the address for BNB.
Or, are you saying I should just buy using BNB (not wrapped) and make it:
[BNB,contract_id]
?
Oct 1, 2021, 7:46 PM
Ill simplyfy
You want to swap from token a to token b
You want to swap from token a to token b
But the liquidity doesn't exist so
First swap token a for bnb then swap that bnb for token b
First swap token a for bnb then swap that bnb for token b
Oct 1, 2021, 7:49 PM
But what if token a is already bnb? Well, wrapped bnb
Oct 1, 2021, 7:53 PM
Then you can swap directly
Oct 1, 2021, 8:00 PM