@@ -86,6 +86,10 @@ def __init__(
86
86
)
87
87
88
88
self .version = version
89
+ if self .version not in [1 , 2 , 3 ]:
90
+ raise Exception (
91
+ f"Invalid version '{ self .version } ', only 1, 2 or 3 supported"
92
+ ) # pragma: no cover
89
93
90
94
# TODO: Write tests for slippage
91
95
self .default_slippage = default_slippage
@@ -104,7 +108,7 @@ def __init__(
104
108
if self .netid in _netid_to_name :
105
109
self .netname = _netid_to_name [self .netid ]
106
110
else :
107
- raise Exception (f"Unknown netid: { self .netid } " )
111
+ raise Exception (f"Unknown netid: { self .netid } " ) # pragma: no cover
108
112
logger .info (f"Using { self .w3 } ('{ self .netname } ', netid: { self .netid } )" )
109
113
110
114
self .last_nonce : Nonce = self .w3 .eth .get_transaction_count (self .address )
@@ -164,10 +168,6 @@ def __init__(
164
168
self .router = _load_contract (
165
169
self .w3 , abi_name = "uniswap-v3/router" , address = self .router_address
166
170
)
167
- else :
168
- raise Exception (
169
- f"Invalid version '{ self .version } ', only 1, 2 or 3 supported"
170
- )
171
171
172
172
if hasattr (self , "factory_contract" ):
173
173
logger .info (f"Using factory contract: { self .factory_contract } " )
@@ -234,6 +234,8 @@ def _get_eth_token_input_price(
234
234
price = self ._get_token_token_input_price (
235
235
self .get_weth_address (), token , qty , fee = fee
236
236
) # type: ignore
237
+ else :
238
+ raise ValueError # pragma: no cover
237
239
return price
238
240
239
241
def _get_token_eth_input_price (
@@ -254,6 +256,8 @@ def _get_token_eth_input_price(
254
256
price = self ._get_token_token_input_price (
255
257
token , self .get_weth_address (), qty , fee = fee
256
258
)
259
+ else :
260
+ raise ValueError # pragma: no cover
257
261
return price
258
262
259
263
def _get_token_token_input_price (
@@ -320,6 +324,8 @@ def _get_eth_token_output_price(
320
324
self .get_weth_address (), token , qty , fee = fee
321
325
)
322
326
)
327
+ else :
328
+ raise ValueError # pragma: no cover
323
329
return price
324
330
325
331
def _get_token_eth_output_price (
@@ -339,8 +345,11 @@ def _get_token_eth_output_price(
339
345
price = self ._get_token_token_output_price (
340
346
token , self .get_weth_address (), qty , fee = fee
341
347
)
348
+ else :
349
+ raise ValueError # pragma: no cover
342
350
return price
343
351
352
+ @supports ([2 , 3 ])
344
353
def _get_token_token_output_price (
345
354
self ,
346
355
token0 : AddressLike , # input token
@@ -385,7 +394,7 @@ def _get_token_token_output_price(
385
394
token0 , token1 , fee , qty , sqrtPriceLimitX96
386
395
).call ()
387
396
else :
388
- raise ValueError ( "function not supported for this version of Uniswap" )
397
+ raise ValueError # pragma: no cover
389
398
return price
390
399
391
400
# ------ Make Trade ----------------------------------------------------------------
@@ -548,7 +557,7 @@ def _eth_to_token_swap_input(
548
557
self ._get_tx_params (value = qty ),
549
558
)
550
559
else :
551
- raise ValueError
560
+ raise ValueError # pragma: no cover
552
561
553
562
def _token_to_eth_swap_input (
554
563
self ,
@@ -637,9 +646,8 @@ def _token_to_eth_swap_input(
637
646
self .router .functions .multicall ([swap_data , unwrap_data ]),
638
647
self ._get_tx_params (),
639
648
)
640
-
641
649
else :
642
- raise ValueError
650
+ raise ValueError # pragma: no cover
643
651
644
652
def _token_to_token_swap_input (
645
653
self ,
@@ -734,7 +742,7 @@ def _token_to_token_swap_input(
734
742
self ._get_tx_params (),
735
743
)
736
744
else :
737
- raise ValueError
745
+ raise ValueError # pragma: no cover
738
746
739
747
def _eth_to_token_swap_output (
740
748
self ,
0 commit comments