Skip to content

Swap route via WETH #205

Open
Open

Description

@romanbsd

The make_trade (as well as get price methods) have a route of [token1, WETH, token2]
https://github.com/uniswap-python/uniswap-python/blob/master/uniswap/uniswap.py#L686

Does it mean that the swaps incur 0.6% fee?

Activity

  1. liquid-8 commented on Nov 24, 2021

    @liquid-8
    Member

    The make_trade (as well as get price methods) have a route of [token1, WETH, token2]

    By default. You can specify the route parameter (for univ2 at least). Mentioned route causes two swaps: token1->weth; weth->token2. Taker's fee is applied twice, so total fee = 1-0.997^2=0.005991

  2. romanbsd commented on Nov 24, 2021

    @romanbsd
    ContributorAuthor

    I don't think you can do that using this library.

  3. liquid-8 commented on Nov 25, 2021

    @liquid-8
    Member

    I've checked this. Well, it is possible for get_price methods, but make_swap methods don't have such an option actually, which is surprising. However, it is relatively easy to add it.

  4. romanbsd commented on Dec 14, 2021

    @romanbsd
    ContributorAuthor

    When I come to think about it, the default should be [t0,t1] (and a boolean for going through [t0,weth,t1] route) and in case such pair doesn't exist an exception thrown suggesting to set the boolean parameter to true. Because incurring double fee breaks the principle of least surprise.

  5. ErikBjare commented on Dec 21, 2021

    @ErikBjare
    Member

    Well, it is possible for get_price methods, but make_swap methods don't have such an option actually, which is surprising. However, it is relatively easy to add it.

    @liquid-8 Yeah, I might look into that.

    When I come to think about it, the default should be [t0,t1] (and a boolean for going through [t0,weth,t1] route) and in case such pair doesn't exist an exception thrown suggesting to set the boolean parameter to true.

    @romanbsd The issue is that [t0, t1] is often a much less liquid pair than [t0, weth, t1], so chances are high that such a trade might have significant price impact and therefore a bad execution price.

    Swaps are actually made using [t0, t1] right now though (no multi-hop swaps yet), so yeah...

    Because incurring double fee breaks the principle of least surprise.

    I agree, but in this case ensuring that the pair assumed has liquidity takes precedence imo (I'd be more surprised if I made a terrible trade, as in #198, then if I incurred an additional 0.3% fee).

  6. ErikBjare commented on Dec 21, 2021

    @ErikBjare
    Member

    @liquid-8 Apparently I had already been working on that in #221, feel free to continue the work! (I might not have time)

  7. romanbsd commented on Dec 21, 2021

    @romanbsd
    ContributorAuthor

    Insufficient liquidity is caveat emptor. But maybe some safeguard is needed indeed...

  8. starascendin commented on Mar 7, 2022

    @starascendin

    Hey all, so i've been running into this issue because sometimes my clients have LP as [t0, stablecoin] instead of [t0, bnb/eth/base_token], and not being able to customize route in make_trade is not ideal.

    Should we add an optional param route= to make_trade? I have a working solution; i'd be happy to contribute

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