Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions uniswap/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,3 @@ class UniswapV4_PathKey:
tickSpacing : int
# The hooks of the pool
hooks : List[Address]

def __repr__(self) -> Tuple[Address, Address, int, int, List[Address]]:
return (self.currency0, self.currency1, self.fee, self.tickSpacing, self.hooks)
6 changes: 4 additions & 2 deletions uniswap/uniswap4.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ def get_quote_exact_input(
:path is a swap route
"""

quote_path = [item.astulpe() for item in path]
quote_params = {
"exactCurrency": currency,
"path": path,
"path": quote_path,
"recipient": self.address,
"exactAmount": qty,
}
Expand All @@ -238,9 +239,10 @@ def get_quote_exact_output(
:path is a swap route
"""

quote_path = [item.astulpe() for item in path]
quote_params = {
"exactCurrency": currency,
"path": path,
"path": quote_path,
"recipient": self.address,
"exactAmount": qty,
}
Expand Down
7 changes: 5 additions & 2 deletions uniswap/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ def _encode_path(token_in: AddressLike, route: List[Tuple[int, AddressLike]]) ->


# Adapted from: https://github.com/Uniswap/v3-sdk/blob/main/src/utils/encodeSqrtRatioX96.ts
def decode_sqrt_ratioX96(amount_0: int, amount_1: int) -> int:
return int(amount_0 * amount_0 * 10**amount_1 >> 192)
def decode_sqrt_ratioX96(sqrtPriceX96: int) -> float:
Q96 = 2**96
ratio = sqrtPriceX96 / Q96
price = ratio**2
return price

# Adapted from: https://github.com/Uniswap/v3-sdk/blob/main/src/utils/encodeSqrtRatioX96.ts
def encode_sqrt_ratioX96(amount_0: int, amount_1: int) -> int:
Expand Down