Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaf83aa3

Browse files
authored
Merge pull request#366 from liquid-8/dev
fix p1
2 parents3087004 +5a3e35b commitaf83aa3

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

‎uniswap/uniswap4.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
fromtypingimportList,Any,Optional,Union,Tuple,Dict
66

77
fromweb3importWeb3
8-
fromweb3.ethimportContract
9-
fromweb3.contractimportContractFunction
8+
fromweb3.contractimportContract
9+
fromweb3.contract.contractimportContractFunction
1010
fromweb3.exceptionsimportBadFunctionCallOutput,ContractLogicError
1111
fromweb3.typesimport (
1212
TxParams,
@@ -34,6 +34,7 @@
3434
_netid_to_name,
3535
_poolmanager_contract_addresses,
3636
ETH_ADDRESS,
37+
NOHOOK_ADDRESS,
3738
)
3839

3940
logger=logging.getLogger(__name__)
@@ -86,17 +87,22 @@ def __init__(
8687

8788
self.last_nonce:Nonce=self.w3.eth.get_transaction_count(self.address)
8889

90+
max_approval_hex=f"0x{64*'f'}"
91+
self.max_approval_int=int(max_approval_hex,16)
92+
max_approval_check_hex=f"0x{15*'0'}{49*'f'}"
93+
self.max_approval_check_int=int(max_approval_check_hex,16)
94+
8995
ifpoolmanager_contract_addrisNone:
9096
poolmanager_contract_addr=_poolmanager_contract_addresses[self.network]
9197

92-
self.poolmanager_contract=_load_contract(
98+
self.router=_load_contract(
9399
self.w3,
94100
abi_name="uniswap-v4/poolmanager",
95101
address=_str_to_addr(poolmanager_contract_addr),
96102
)
97103

98104
ifhasattr(self,"poolmanager_contract"):
99-
logger.info(f"Using pool manager contract:{self.poolmanager_contract}")
105+
logger.info(f"Using pool manager contract:{self.router}")
100106

101107
# ------ Contract calls ------------------------------------------------------------
102108

@@ -109,9 +115,8 @@ def get_price(
109115
qty:int,
110116
fee:int,
111117
tick_spacing:int,
112-
zero_to_one:bool=true,
113118
sqrt_price_limit_x96:int=0,
114-
zero_for_one:bool=true,
119+
zero_for_one:bool=True,
115120
hooks:AddressLike=NOHOOK_ADDRESS,
116121
)->int:
117122
"""
@@ -285,7 +290,7 @@ def swap(
285290
fee:int,
286291
tick_spacing:int,
287292
sqrt_price_limit_x96:int=0,
288-
zero_for_one:bool=true,
293+
zero_for_one:bool=True,
289294
hooks:AddressLike=NOHOOK_ADDRESS,
290295
)->HexBytes:
291296
"""
@@ -593,7 +598,7 @@ def get_token(self, address: AddressLike, abi_name: str = "erc20") -> ERC20Token
593598
returnERC20Token(symbol,address,name,decimals)
594599

595600
defget_pool_id(self,currency0:AddressLike,currency1:AddressLike,fee :int,tickSpacing :int,hooks :AddressLike=ETH)->bytes:
596-
ifcurrency0>currency1:
601+
ifint(currency0)>(currency1):
597602
currency0 ,currency1=currency1 ,currency0
598603
returnself.w3.keccak_solidity(["address","address","int24","int24","address"], [(currency0,currency1,fee,tickSpacing,hooks)])
599604

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp