Skip to content
Merged
Prev Previous commit
Next Next commit
black applied
  • Loading branch information
liquid-8 committed Jul 7, 2021
commit b8788eabec80ce33ab37a58b753186e2ddea6829
32 changes: 22 additions & 10 deletions uniswap/uniswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,13 @@ def make_trade(
)
else:
return self._token_to_token_swap_input(
input_token, output_token, qty, recipient, fee, slippage,fee_on_transfer
input_token,
output_token,
qty,
recipient,
fee,
slippage,
fee_on_transfer,
)

@check_approval
Expand Down Expand Up @@ -462,9 +468,11 @@ def _eth_to_token_swap_input(
(1 - slippage) * self._get_eth_token_input_price(output_token, qty, fee)
)
if fee_on_transfer:
func=self.router.functions.swapExactETHForTokensSupportingFeeOnTransferTokens
func = (
self.router.functions.swapExactETHForTokensSupportingFeeOnTransferTokens
)
else:
func=self.router.functions.swapExactETHForTokens
func = self.router.functions.swapExactETHForTokens
return self._build_and_send_tx(
func(
amount_out_min,
Expand All @@ -476,7 +484,7 @@ def _eth_to_token_swap_input(
)
elif self.version == 3:
if fee_on_transfer:
raise Exception('fee on transfer not supported by Uniswap v3')
raise Exception("fee on transfer not supported by Uniswap v3")
return self._token_to_token_swap_input(
self.get_weth_address(), output_token, qty, recipient, fee, slippage
)
Expand Down Expand Up @@ -514,9 +522,11 @@ def _token_to_eth_swap_input(
(1 - slippage) * self._get_token_eth_input_price(input_token, qty, fee)
)
if fee_on_transfer:
func=self.router.functions.swapExactTokensForETHSupportingFeeOnTransferTokens
func = (
self.router.functions.swapExactTokensForETHSupportingFeeOnTransferTokens
)
else:
func=self.router.functions.swapExactTokensForETH
func = self.router.functions.swapExactTokensForETH
return self._build_and_send_tx(
func(
qty,
Expand All @@ -528,7 +538,7 @@ def _token_to_eth_swap_input(
)
elif self.version == 3:
if fee_on_transfer:
raise Exception('fee on transfer not supported by Uniswap v3')
raise Exception("fee on transfer not supported by Uniswap v3")
return self._token_to_token_swap_input(
input_token, self.get_weth_address(), qty, recipient, fee, slippage
)
Expand Down Expand Up @@ -575,9 +585,11 @@ def _token_to_token_swap_input(
)
)
if fee_on_transfer:
func=self.router.functions.swapExactTokensForTokensSupportingFeeOnTransferTokens
func = (
self.router.functions.swapExactTokensForTokensSupportingFeeOnTransferTokens
)
else:
func=self.router.functions.swapExactTokensForTokens
func = self.router.functions.swapExactTokensForTokens
return self._build_and_send_tx(
func(
qty,
Expand All @@ -589,7 +601,7 @@ def _token_to_token_swap_input(
)
elif self.version == 3:
if fee_on_transfer:
raise Exception('fee on transfer not supported by Uniswap v3')
raise Exception("fee on transfer not supported by Uniswap v3")
min_tokens_bought = int(
(1 - slippage)
* self._get_token_token_input_price(
Expand Down