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

Commit8fc43e7

Browse files
authored
Merge pull request#370 from liquid-8/dev
fix p.2
2 parentscd1b348 +c5fd61c commit8fc43e7

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

‎uniswap/uniswap4.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
provider:Optional[str]=None,
5151
web3:Optional[Web3]=None,
5252
default_slippage:float=0.01,
53-
poolmanager_contract_addr:Optional[str]=None,
53+
poolmanager_contract_addr:Optional[AddressLike,str]=None,
5454
)->None:
5555
"""
5656
:param address: The public address of the ETH wallet to use.
@@ -155,7 +155,7 @@ def get_price(
155155
try:
156156
price=int(self.w3.eth.call(signed_txn))
157157
exceptContractLogicErrorasrevert:
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])
159159
returnprice
160160

161161
defget_slot0(
@@ -170,7 +170,7 @@ def get_slot0(
170170
:Get the current value in slot0 of the given pool
171171
"""
172172

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)
174174
slot0=UniswapV4_slot0(*self.router.functions.getSlot0(pool_id).call())
175175
returnslot0
176176

@@ -185,7 +185,7 @@ def get_liquidity(
185185
"""
186186
:Get the current value of liquidity of the given pool
187187
"""
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)
189189
liquidity=int(self.router.functions.getLiquidity(pool_id).call())
190190
returnliquidity
191191

@@ -203,7 +203,7 @@ def get_liquidity_for_position(
203203
"""
204204
:Get the current value of liquidity for the specified pool and position
205205
"""
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)
207207
liquidity=int(self.router.functions.getLiquidity(pool_id,owner,tick_lower,tick_upper).call())
208208
returnliquidity
209209

@@ -221,7 +221,7 @@ def get_position(
221221
"""
222222
:Get the current value of liquidity for the specified pool and position
223223
"""
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)
225225
liquidity=UniswapV4_position_info(*self.router.functions.getPosition(pool_id,owner,tick_lower,tick_upper).call())
226226
returnliquidity
227227

@@ -237,7 +237,7 @@ def get_pool_tick_info(
237237
"""
238238
:Get the current value of liquidity for the specified pool and position
239239
"""
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)
241241
tick_info=UniswapV4_tick_info(*self.router.functions.getPoolTickInfo(pool_id,tick).call())
242242
returntick_info
243243

@@ -253,7 +253,7 @@ def get_pool_bitmap_info(
253253
"""
254254
:Get the current value of liquidity for the specified pool and position
255255
"""
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)
257257
bitmap_info=int(self.router.functions.getPoolBitmapInfo(pool_id,word).call())
258258
returnbitmap_info
259259

@@ -515,7 +515,7 @@ def get_token_balance(self, token: AddressLike) -> int:
515515
defapprove(self,token:AddressLike,max_approval:Optional[int]=None)->None:
516516
"""Give an exchange/router max approval of a token."""
517517
max_approval=self.max_approval_intifnotmax_approvalelsemax_approval
518-
contract_addr=poolmanager_contract_addr
518+
contract_addr=self.poolmanager_contract_addr
519519
function=_load_contract_erc20(self.w3,token).functions.approve(
520520
contract_addr,max_approval
521521
)
@@ -537,7 +537,7 @@ def _build_and_send_tx(
537537
"""Build and send a transaction."""
538538
ifnottx_params:
539539
tx_params=self._get_tx_params()
540-
transaction=function.buildTransaction(tx_params)
540+
transaction=function.build_transaction(tx_params)
541541
# Uniswap3 uses 20% margin for transactions
542542
transaction["gas"]=Wei(int(self.w3.eth.estimate_gas(transaction)*1.2))
543543
signed_txn=self.w3.eth.account.sign_transaction(
@@ -570,7 +570,7 @@ def get_token(self, address: AddressLike, abi_name: str = "erc20") -> ERC20Token
570570
# FIXME: This function should always return the same output for the same input
571571
# and would therefore benefit from caching
572572
ifaddress==ETH_ADDRESS:
573-
returnERC20Token("ETH",ETH_ADDRESS,"Ether",18)
573+
returnERC20Token("ETH",address,"Ether",18)
574574
token_contract=_load_contract(self.w3,abi_name,address=address)
575575
try:
576576
_name=token_contract.functions.name().call()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp