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

Support trading on custom routes in v2 #379

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ryanpineo
Copy link

No description provided.

@@ -730,10 +740,12 @@ def _token_to_token_swap_input(
function = token_funcs.tokenToTokenTransferInput(*func_params)
return self._build_and_send_tx(function)
elif self.version == 2:
if not route:
route = [input_token, self.get_weth_address(), output_token]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WETH in the middle is an assumption, it doesn't have to be like this. Imagine swapping stable for stable. Probably the most correct approach is just [input_token, output token]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't really say if it's correct or not as i'm not terribly familiar with this stuff but I didn't want to make any breaking changes

@@ -971,7 +984,7 @@ def _token_to_token_swap_output(

# Balance check
input_balance = self.get_token_balance(input_token)
cost = self._get_token_token_output_price(input_token, output_token, qty, fee)
cost = self._get_token_token_output_price(input_token, output_token, qty, fee, route)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_get_token_token_output_price() needs a fix for route=None case as well

@@ -499,6 +505,9 @@ def make_trade_output(
if input_token == output_token:
raise ValueError

if route and (input_token == ETH_ADDRESS or output_token == ETH_ADDRESS):
raise ValueError

if input_token == ETH_ADDRESS:
balance = self.get_eth_balance()
need = self._get_eth_token_output_price(output_token, qty, fee)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom route support should be added here (and similar methods) too imo

Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 61.40%. Comparing base (59fba76) to head (ed2abce).

❗ Current head ed2abce differs from pull request most recent head a4254c3. Consider uploading reports for the commit a4254c3 to get more accurate results

Files Patch % Lines
uniswap/uniswap.py 77.77% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #379       +/-   ##
===========================================
- Coverage   84.20%   61.40%   -22.80%     
===========================================
  Files          11       11               
  Lines        1057     1065        +8     
===========================================
- Hits          890      654      -236     
- Misses        167      411      +244     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@liquid-8
Copy link
Member

liquid-8 commented Apr 7, 2024

Please take a look at recent test results, there are some issues. Just assuming, it could be worth making the route param optional with None as default and then using route = [token_in, token_out].

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

Successfully merging this pull request may close these issues.

None yet

2 participants