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

fix p1#366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
liquid-8 merged 2 commits intouniswap-python:dev/v4fromliquid-8:dev
Jan 8, 2024
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletionsuniswap/uniswap4.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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,
Expand DownExpand Up@@ -34,6 +34,7 @@
_netid_to_name,
_poolmanager_contract_addresses,
ETH_ADDRESS,
NOHOOK_ADDRESS,
)

logger = logging.getLogger(__name__)
Expand DownExpand Up@@ -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 ------------------------------------------------------------

Expand All@@ -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:
"""
Expand DownExpand Up@@ -285,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:
"""
Expand DownExpand Up@@ -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:
ifint(currency0) >(currency1):
currency0 , currency1 = currency1 , currency0
return self.w3.keccak_solidity(["address", "address", "int24", "int24", "address"], [(currency0, currency1, fee, tickSpacing, hooks)])

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp