From 442771dc3e12b5d65539650b75f0c6a75091a70e Mon Sep 17 00:00:00 2001 From: liquid-8 Date: Tue, 9 Jan 2024 01:45:42 +0200 Subject: [PATCH 1/2] fix p.1 --- uniswap/uniswap4.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/uniswap/uniswap4.py b/uniswap/uniswap4.py index 60a1f2e..ee23367 100644 --- a/uniswap/uniswap4.py +++ b/uniswap/uniswap4.py @@ -5,8 +5,8 @@ from typing import List, Any, Optional, Union, Tuple, Dict from web3 import Web3 -from web3.eth import Contract -from web3.contract import ContractFunction +from web3.contract import Contract +from web3.contract.contract import ContractFunction from web3.exceptions import BadFunctionCallOutput, ContractLogicError from web3.types import ( TxParams, @@ -34,6 +34,7 @@ _netid_to_name, _poolmanager_contract_addresses, ETH_ADDRESS, + NOHOOK_ADDRESS, ) logger = logging.getLogger(__name__) @@ -86,17 +87,22 @@ def __init__( self.last_nonce: Nonce = self.w3.eth.get_transaction_count(self.address) + max_approval_hex = f"0x{64 * 'f'}" + self.max_approval_int = int(max_approval_hex, 16) + max_approval_check_hex = f"0x{15 * '0'}{49 * 'f'}" + self.max_approval_check_int = int(max_approval_check_hex, 16) + if poolmanager_contract_addr is None: poolmanager_contract_addr = _poolmanager_contract_addresses[self.network] - self.poolmanager_contract = _load_contract( + self.router = _load_contract( self.w3, abi_name="uniswap-v4/poolmanager", address=_str_to_addr(poolmanager_contract_addr), ) if hasattr(self, "poolmanager_contract"): - logger.info(f"Using pool manager contract: {self.poolmanager_contract}") + logger.info(f"Using pool manager contract: {self.router}") # ------ Contract calls ------------------------------------------------------------ @@ -109,9 +115,8 @@ def get_price( qty: int, fee: int, tick_spacing: int, - zero_to_one: bool = true, sqrt_price_limit_x96: int = 0, - zero_for_one: bool = true, + zero_for_one: bool = True, hooks: AddressLike = NOHOOK_ADDRESS, ) -> int: """ @@ -593,7 +598,7 @@ def get_token(self, address: AddressLike, abi_name: str = "erc20") -> ERC20Token return ERC20Token(symbol, address, name, decimals) def get_pool_id(self, currency0: AddressLike, currency1: AddressLike, fee : int, tickSpacing : int, hooks : AddressLike = ETH) -> bytes: - if currency0 > currency1: + if int(currency0) > (currency1): currency0 , currency1 = currency1 , currency0 return self.w3.keccak_solidity(["address", "address", "int24", "int24", "address"], [(currency0, currency1, fee, tickSpacing, hooks)]) From 5a3e35bd4363aa08c5c44f95da1d406022e9b1a0 Mon Sep 17 00:00:00 2001 From: liquid-8 Date: Tue, 9 Jan 2024 01:50:15 +0200 Subject: [PATCH 2/2] and more --- uniswap/uniswap4.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uniswap/uniswap4.py b/uniswap/uniswap4.py index ee23367..455cf9e 100644 --- a/uniswap/uniswap4.py +++ b/uniswap/uniswap4.py @@ -290,7 +290,7 @@ def swap( fee: int, tick_spacing: int, sqrt_price_limit_x96: int = 0, - zero_for_one: bool = true, + zero_for_one: bool = True, hooks: AddressLike = NOHOOK_ADDRESS, ) -> HexBytes: """ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy