Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions uniswap/uniswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,11 +742,17 @@ def _token_to_token_swap_input(
)
else:
func = self.router.functions.swapExactTokensForTokens
weth_address = self.get_weth_address()
if is_same_address(input_token, weth_address) or is_same_address(output_token, weth_address):
path = [input_token, output_token]
else:
path = [input_token, weth_address, output_token]

return self._build_and_send_tx(
func(
qty,
min_tokens_bought,
[input_token, self.get_weth_address(), output_token],
path,
recipient,
self._deadline(),
),
Expand Down Expand Up @@ -1004,11 +1010,17 @@ def _token_to_token_swap_output(
input_token, output_token, qty, fee=fee
)
amount_in_max = int((1 + slippage) * cost)
weth = self.get_weth_address()
path = (
[input_token, output_token]
if is_same_address(input_token, weth) or is_same_address(output_token, weth)
else [input_token, weth, output_token]
)
Comment thread
liquid-8 marked this conversation as resolved.
return self._build_and_send_tx(
self.router.functions.swapTokensForExactTokens(
qty,
amount_in_max,
[input_token, self.get_weth_address(), output_token],
path,
recipient,
self._deadline(),
),
Expand Down
Loading