Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap route via WETH #205

Open
romanbsd opened this issue Nov 24, 2021 · 8 comments
Open

Swap route via WETH #205

romanbsd opened this issue Nov 24, 2021 · 8 comments

Comments

@romanbsd
Copy link
Contributor

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?

@liquid-8
Copy link
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

@romanbsd
Copy link
Contributor Author

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

@liquid-8
Copy link
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.

@romanbsd
Copy link
Contributor Author

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.

@ErikBjare
Copy link
Member

ErikBjare commented Dec 21, 2021

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).

@ErikBjare
Copy link
Member

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

@romanbsd
Copy link
Contributor Author

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

@starascendin
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@romanbsd @ErikBjare @liquid-8 @starascendin and others