@@ -50,7 +50,7 @@ def __init__(
50
50
provider :Optional [str ]= None ,
51
51
web3 :Optional [Web3 ]= None ,
52
52
default_slippage :float = 0.01 ,
53
- poolmanager_contract_addr :Optional [str ]= None ,
53
+ poolmanager_contract_addr :Optional [AddressLike , str ]= None ,
54
54
)-> None :
55
55
"""
56
56
:param address: The public address of the ETH wallet to use.
@@ -155,7 +155,7 @@ def get_price(
155
155
try :
156
156
price = int (self .w3 .eth .call (signed_txn ))
157
157
except ContractLogicError as revert :
158
- price = int (self .w3 .codec .decode_abi (["int128[]" ,"uint160" ,"uint32" ],revert . data )[1 ])
158
+ price = int (self .w3 .codec .decode (["int128[]" ,"uint160" ,"uint32" ],bytes ( revert ) )[1 ])
159
159
return price
160
160
161
161
def get_slot0 (
@@ -170,7 +170,7 @@ def get_slot0(
170
170
:Get the current value in slot0 of the given pool
171
171
"""
172
172
173
- pool_id = get_pool_id (currency0 ,currency1 ,fee ,tick_spacing ,hooks )
173
+ pool_id = self . get_pool_id (currency0 ,currency1 ,fee ,tick_spacing ,hooks )
174
174
slot0 = UniswapV4_slot0 (* self .router .functions .getSlot0 (pool_id ).call ())
175
175
return slot0
176
176
@@ -185,7 +185,7 @@ def get_liquidity(
185
185
"""
186
186
:Get the current value of liquidity of the given pool
187
187
"""
188
- pool_id = get_pool_id (currency0 ,currency1 ,fee ,tick_spacing ,hooks )
188
+ pool_id = self . get_pool_id (currency0 ,currency1 ,fee ,tick_spacing ,hooks )
189
189
liquidity = int (self .router .functions .getLiquidity (pool_id ).call ())
190
190
return liquidity
191
191
@@ -203,7 +203,7 @@ def get_liquidity_for_position(
203
203
"""
204
204
:Get the current value of liquidity for the specified pool and position
205
205
"""
206
- pool_id = get_pool_id (currency0 ,currency1 ,fee ,tick_spacing ,hooks )
206
+ pool_id = self . get_pool_id (currency0 ,currency1 ,fee ,tick_spacing ,hooks )
207
207
liquidity = int (self .router .functions .getLiquidity (pool_id ,owner ,tick_lower ,tick_upper ).call ())
208
208
return liquidity
209
209
@@ -221,7 +221,7 @@ def get_position(
221
221
"""
222
222
:Get the current value of liquidity for the specified pool and position
223
223
"""
224
- pool_id = get_pool_id (currency0 ,currency1 ,fee ,tick_spacing ,hooks )
224
+ pool_id = self . get_pool_id (currency0 ,currency1 ,fee ,tick_spacing ,hooks )
225
225
liquidity = UniswapV4_position_info (* self .router .functions .getPosition (pool_id ,owner ,tick_lower ,tick_upper ).call ())
226
226
return liquidity
227
227
@@ -237,7 +237,7 @@ def get_pool_tick_info(
237
237
"""
238
238
:Get the current value of liquidity for the specified pool and position
239
239
"""
240
- pool_id = get_pool_id (currency0 ,currency1 ,fee ,tick_spacing ,hooks )
240
+ pool_id = self . get_pool_id (currency0 ,currency1 ,fee ,tick_spacing ,hooks )
241
241
tick_info = UniswapV4_tick_info (* self .router .functions .getPoolTickInfo (pool_id ,tick ).call ())
242
242
return tick_info
243
243
@@ -253,7 +253,7 @@ def get_pool_bitmap_info(
253
253
"""
254
254
:Get the current value of liquidity for the specified pool and position
255
255
"""
256
- pool_id = get_pool_id (currency0 ,currency1 ,fee ,tick_spacing ,hooks )
256
+ pool_id = self . get_pool_id (currency0 ,currency1 ,fee ,tick_spacing ,hooks )
257
257
bitmap_info = int (self .router .functions .getPoolBitmapInfo (pool_id ,word ).call ())
258
258
return bitmap_info
259
259
@@ -515,7 +515,7 @@ def get_token_balance(self, token: AddressLike) -> int:
515
515
def approve (self ,token :AddressLike ,max_approval :Optional [int ]= None )-> None :
516
516
"""Give an exchange/router max approval of a token."""
517
517
max_approval = self .max_approval_int if not max_approval else max_approval
518
- contract_addr = poolmanager_contract_addr
518
+ contract_addr = self . poolmanager_contract_addr
519
519
function = _load_contract_erc20 (self .w3 ,token ).functions .approve (
520
520
contract_addr ,max_approval
521
521
)
@@ -537,7 +537,7 @@ def _build_and_send_tx(
537
537
"""Build and send a transaction."""
538
538
if not tx_params :
539
539
tx_params = self ._get_tx_params ()
540
- transaction = function .buildTransaction (tx_params )
540
+ transaction = function .build_transaction (tx_params )
541
541
# Uniswap3 uses 20% margin for transactions
542
542
transaction ["gas" ]= Wei (int (self .w3 .eth .estimate_gas (transaction )* 1.2 ))
543
543
signed_txn = self .w3 .eth .account .sign_transaction (
@@ -570,7 +570,7 @@ def get_token(self, address: AddressLike, abi_name: str = "erc20") -> ERC20Token
570
570
# FIXME: This function should always return the same output for the same input
571
571
# and would therefore benefit from caching
572
572
if address == ETH_ADDRESS :
573
- return ERC20Token ("ETH" ,ETH_ADDRESS ,"Ether" ,18 )
573
+ return ERC20Token ("ETH" ,address ,"Ether" ,18 )
574
574
token_contract = _load_contract (self .w3 ,abi_name ,address = address )
575
575
try :
576
576
_name = token_contract .functions .name ().call ()