Skip to content

Question, why [input_token, weth, output_token] #405

Description

@weestack

Hello not a bug, but however a question from a newbie in dex swapping.

[input_token, self.get_weth_address(), output_token],

There on line 1011:
[input_token, self.get_weth_address(), output_token],

why are the default for v2 a 3 way path, I debugged the code yesterday, because I already had some WETH in my meta account, so naturally I set the input to weth, and output to what I wanted to swap i for, which kept failing with "SAME ADDRESS" error.

Are there any perks of using a 3-way route over a 2-way route on Uniswap V2, in my own clumsy and logic (VERY new to defi) it should be faster and cheaper with a 2-way router rather than a 3-way route, right?

Can someone explain the implementation reason to me, as I cant find it in the documentation and neither that it defaults to weth as middle route, perhaps i just used it wrong.... but it would be great to get some perspective on the matter

uniswap = Uniswap(address=address, default_slippage=0.5, private_key=private_key, version=version, provider=provider)

web3 = Web3(Web3.HTTPProvider(mainnet_url))
token_meta = uniswap.get_token(token, 'erc20')
spend_eth = '0.001'
spend = web3.to_wei(spend_eth, 'ether')
Amount = uniswap.get_price_input(WETH_PAIR_ADDRESS, token, spend)
uniswap.make_trade(WETH_PAIR_ADDRESS, token, spend, fee_on_transfer=True)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions