-
Notifications
You must be signed in to change notification settings - Fork 94
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
Support custom route methods && uniswap v3 multi hop #45
Conversation
liu-zhipeng
commented
Jun 28, 2022
•
edited
Loading
edited
- support custom router abi (For Pangolin and Trader Joe swap on avalanche)
- support custom router method names
- support uniswap v3 multihop
- fix some issues
- Unit tests
- readme
Hi. I am so excited to contribute to such a great project. I found some small problems while using uniswap sdk. For example, some uniswap forked dexs like pangolin swap changed router functions. especially ETH to AVAX. So i added some changes for developers to use custom router abi and router methods. Also I added some code to support uniswap v3 multihop. I would like you to review my changes if you have time. Thank you again for a great sdk! |
Hey @liu-zhipeng firstly thanks so much for this!! Help from others is needed and this looks incredible already. Only scanned on phone but 1 thing which popped out any new things or featured you added to this please add to the readme doc, for example you done some liquidity work and now supporting multihop adding to the docs is the last part missing I think! I will review this tomorrow be great to review with the docs update as well thanks a lot hope this will be your first of many PRs 💪 |
Yep. i will do! Also i am going to add unit tests for new features as well. |
README.md
Outdated
// For multihop swap | ||
// Sequence of Fees | ||
// ex: USDC>USDT>WETH>WBTC => [(USDC-USDT fee), (USDT-WETH fee), (WETH-WBTC fee)] | ||
liquidityProviderFee: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't seem correct here as in v2 it would still be string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in v2 liquidityProviderFee
should be array in this version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liu-zhipeng am i correct?
README.md
Outdated
@@ -437,7 +447,7 @@ export interface TradeContext { | |||
// aka 0.05% = 0.0005 | |||
// 0.3% = 0.003 | |||
// 1% = 0.01 | |||
liquidityProviderFeePercent: number; | |||
liquidityProviderFeePercent: number[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't seem correct here as in v2 it would still be string
README.md
Outdated
@@ -464,7 +474,7 @@ export interface TradeContext { | |||
routeText: string; | |||
routePathArray: string[]; | |||
uniswapVersion: UniswapVersion; | |||
liquidityProviderFee: number; | |||
liquidityProviderFee: number[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't seem correct here as in v2 it would still be string
README.md
Outdated
liquidityProviderFee: '0.030000000000000000', | ||
liquidityProviderFeePercent: 0.003, | ||
liquidityProviderFee: ['0.030000000000000000','0.050000000000000000','0.030000000000000000'], | ||
liquidityProviderFeePercent: [0.003, 0.005, 0.003], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from my memory the liquidity provider fee percent on this level is just 1 percent and if you got many routes with different providers fees it would create repeated objects with the single fee. Then order by the best.
liquidityProviderFee: string; | ||
liquidityProviderFeePercent: number; | ||
liquidityProviderFee: string[]; | ||
liquidityProviderFeePercent: number[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again arrays here v2 wont be an array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above breaking change in the trade context ..
@@ -333,14 +333,13 @@ export class UniswapPairFactory { | |||
? null | |||
: bestRouteQuote.expectedConvertQuoteOrTokenAmountInMaxWithSlippage, | |||
expectedConvertQuote: bestRouteQuote.expectedConvertQuote, | |||
liquidityProviderFee: | |||
liquidityProviderFee: bestRouteQuote.liquidityProviderFee.map((f) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
breaking changes for v2.. if many liquidity provider fees the expected convert quote will be different depending on that no? would not expect a loop here i dont think...
@@ -404,14 +403,13 @@ export class UniswapPairFactory { | |||
? null | |||
: bestRouteQuote.expectedConvertQuoteOrTokenAmountInMaxWithSlippage, | |||
expectedConvertQuote: bestRouteQuote.expectedConvertQuote, | |||
liquidityProviderFee: | |||
liquidityProviderFee: bestRouteQuote.liquidityProviderFee.map((f) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
@@ -470,14 +468,13 @@ export class UniswapPairFactory { | |||
? null | |||
: bestRouteQuote.expectedConvertQuoteOrTokenAmountInMaxWithSlippage, | |||
expectedConvertQuote: bestRouteQuote.expectedConvertQuote, | |||
liquidityProviderFee: | |||
liquidityProviderFee: bestRouteQuote.liquidityProviderFee.map((f) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
@joshstevens19 @liu-zhipeng |
Once @joshstevens19 confirms this, we can release this, cus all features are working properly now. |
So you resolved the backward compatibility? There was a problem about in some points your returned now an array [] could you maybe release in meantime your version on npm? |
That is no problem at all to return |
No PR is good sorry been away I’m going to get to this soon! |
@liu-zhipeng why did you close this unmerged? |
when will you release this? @liu-zhipeng |
@helios8090 the problem is, @liu-zhipeng can not do the merge and the release |
I have no permission to merge. |
@liu-zhipeng I know, for that reason I asked you to fork, merge and release your own repository, just temporally until @joshstevens19 will merge it we are trying to make webcomponents for the community using simple-uniswap to deliver a well working, free, fast, working everywhere solution |
Guys super sorry I’ve been away and it’s super hard for me to see these sometimes. The main problem with the PR is it’s a breaking interface change to the liquidity interface which means if we release it everyones integration will break who use to think that was a string. I’m going to set a note for tomorrow AM before I do anything else to do another PR review on this. I did do a PR review but the things I asked still is missing. We can’t do breaking changes in the interface we can ofc add a new field and depreciate the old one for v1 and v2 use only but if you could make it so v2 interface is NONE breaking then I’m happy to get this in asap @liu-zhipeng |
Remind me set.. tomorrow AM 9:45 BST! will do another review of it and highlight the main issues. Sorry for the delay! |
Yeah that was what I'm saying, there is this breaking change you already told us I Just ask you to maybe integrate this changes also on the swap ui you provide THX a lot! |
Well it is - you just expose the field in a new property in the interface and write docs around it why, it’s a very easy fix in this PR! |
@@ -8,7 +8,7 @@ export interface CurrentTradeContext { | |||
quoteDirection: TradeDirection; | |||
fromToken: Token; | |||
toToken: Token; | |||
liquidityProviderFee: string; | |||
liquidityProviderFee: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This here! This needs to be a new field if it has to be an array so it doesn’t do a breaking change to the interface
liquidityProviderFee: string; | ||
liquidityProviderFeePercent: number; | ||
liquidityProviderFee: string[]; | ||
liquidityProviderFeePercent: number[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above breaking change in the trade context ..
@liu-zhipeng nice! |
this looks better @liu-zhipeng can you just update the readme docs to show the new field and explain it so people understand? |
I have already updated readme. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to run 1 manual test later if good will merge and deploy.. thanks for doing this and sorry it ended up taking longer then we wanted. @liu-zhipeng your a legend!
Thank you for your approval. @joshstevens19 And I am super happy if my work can be helpful for others. |
@liu-zhipeng so done manually tests everything works well, just one thing I spotted is when on a v2 trade the |
I thought that was more consistent. anyway updated finally! |
amazing! Will deploy tomorrow @liu-zhipeng thanks again |
Awesome! |
https://github.com/joshstevens19/simple-uniswap-sdk/releases/tag/3.7.0 - its now deployed |