88from web3 import Web3
99from web3 ._utils .abi import map_abi_data
1010from web3 ._utils .normalizers import BASE_RETURN_NORMALIZERS
11- from web3 .contract import Contract , ContractFunction
11+ from web3 .contract import Contract
12+ from web3 .contract .base_contract import BaseContractFunction
1213from web3 .exceptions import BadFunctionCallOutput , ContractLogicError
1314from web3 .types import (
1415 TxParams ,
1819)
1920from eth_typing .evm import Address , ChecksumAddress
2021from hexbytes import HexBytes
21-
2222from .types import AddressLike
2323from .token import ERC20Token
2424from .exceptions import InvalidToken , InsufficientBalance
@@ -1435,12 +1435,12 @@ def _deadline(self) -> int:
14351435 return int (time .time ()) + 10 * 60
14361436
14371437 def _build_and_send_tx (
1438- self , function : ContractFunction , tx_params : Optional [TxParams ] = None
1438+ self , function : BaseContractFunction , tx_params : Optional [TxParams ] = None
14391439 ) -> HexBytes :
14401440 """Build and send a transaction."""
14411441 if not tx_params :
14421442 tx_params = self ._get_tx_params ()
1443- transaction = function .build_transaction (tx_params )
1443+ transaction = function ._build_transaction (tx_params )
14441444
14451445 if "gas" not in tx_params :
14461446 # `use_estimate_gas` needs to be True for networks like Arbitrum (can't assume 250000 gas),
@@ -1465,7 +1465,9 @@ def _build_and_send_tx(
14651465 logger .debug (f"nonce: { tx_params ['nonce' ]} " )
14661466 self .last_nonce = Nonce (tx_params ["nonce" ] + 1 )
14671467
1468- def _get_tx_params (self , value : Wei = Wei (0 ), gas : Optional [Wei ] = None ) -> TxParams :
1468+ def _get_tx_params (
1469+ self , value : Wei = Wei (0 ), gas : Optional [Wei ] = None
1470+ ) -> TxParams :
14691471 """Get generic transaction parameters."""
14701472 params : TxParams = {
14711473 "from" : _addr_to_str (self .address ),
@@ -1569,7 +1571,7 @@ def multicall(
15691571 block_identifier = "latest"
15701572 )
15711573 decoded_results = [
1572- self .w3 .codec .decode_abi (output_types , multicall_result )
1574+ self .w3 .codec .decode (output_types , multicall_result )
15731575 for multicall_result in results
15741576 ]
15751577 normalized_results = [
@@ -1669,7 +1671,7 @@ def create_pool_instance(
16691671 )
16701672 receipt = self .w3 .eth .wait_for_transaction_receipt (tx )
16711673
1672- event_logs = self .factory_contract .events .PoolCreated ().processReceipt (receipt )
1674+ event_logs = self .factory_contract .events .PoolCreated ().process_receipt (receipt )
16731675 pool_address = event_logs [0 ]["args" ]["pool" ]
16741676 pool_instance = _load_contract (
16751677 self .w3 , abi_name = "uniswap-v3/pool" , address = pool_address
@@ -1823,27 +1825,27 @@ def get_raw_price(
18231825
18241826 if self .version == 2 :
18251827 params : Iterable [Union [ChecksumAddress , Optional [int ]]] = [
1826- self .w3 .toChecksumAddress (token_in ),
1827- self .w3 .toChecksumAddress (token_out ),
1828+ self .w3 .to_checksum_address (token_in ),
1829+ self .w3 .to_checksum_address (token_out ),
18281830 ]
18291831 pair_token = self .factory_contract .functions .getPair (* params ).call ()
18301832 token_in_erc20 = _load_contract_erc20 (
1831- self .w3 , self .w3 .toChecksumAddress (token_in )
1833+ self .w3 , self .w3 .to_checksum_address (token_in )
18321834 )
18331835 token_in_balance = int (
18341836 token_in_erc20 .functions .balanceOf (
1835- self .w3 .toChecksumAddress (pair_token )
1837+ self .w3 .to_checksum_address (pair_token )
18361838 ).call ()
18371839 )
18381840 token_in_decimals = self .get_token (token_in ).decimals
18391841 token_in_balance = token_in_balance / (10 ** token_in_decimals )
18401842
18411843 token_out_erc20 = _load_contract_erc20 (
1842- self .w3 , self .w3 .toChecksumAddress (token_out )
1844+ self .w3 , self .w3 .to_checksum_address (token_out )
18431845 )
18441846 token_out_balance = int (
18451847 token_out_erc20 .functions .balanceOf (
1846- self .w3 .toChecksumAddress (pair_token )
1848+ self .w3 .to_checksum_address (pair_token )
18471849 ).call ()
18481850 )
18491851 token_out_decimals = self .get_token (token_out ).decimals
@@ -1852,15 +1854,15 @@ def get_raw_price(
18521854 raw_price = token_out_balance / token_in_balance
18531855 else :
18541856 params = [
1855- self .w3 .toChecksumAddress (token_in ),
1856- self .w3 .toChecksumAddress (token_out ),
1857+ self .w3 .to_checksum_address (token_in ),
1858+ self .w3 .to_checksum_address (token_out ),
18571859 fee ,
18581860 ]
18591861 pool_address = self .factory_contract .functions .getPool (* params ).call ()
18601862 pool_contract = _load_contract (
18611863 self .w3 , abi_name = "uniswap-v3/pool" , address = pool_address
18621864 )
1863- t0 = pool_contract .functions .token0 ().call ()
1865+ # t0 = pool_contract.functions.token0().call()
18641866 t1 = pool_contract .functions .token1 ().call ()
18651867 if t1 .lower () == token_in .lower ():
18661868 den0 = self .get_token (token_in ).decimals
@@ -1953,7 +1955,9 @@ def _token_address_from_exchange(self, exchange_addr: AddressLike) -> Address:
19531955 @functools .lru_cache ()
19541956 @supports ([1 ])
19551957 def _exchange_contract (
1956- self , token_addr : Optional [AddressLike ] = None , ex_addr : Optional [AddressLike ] = None
1958+ self ,
1959+ token_addr : Optional [AddressLike ] = None ,
1960+ ex_addr : Optional [AddressLike ] = None ,
19571961 ) -> Contract :
19581962 if not ex_addr and token_addr :
19591963 ex_addr = self ._exchange_address_from_token (token_addr )
0 commit comments