Skip to content

Commit

Permalink
fix: added decode_sqrt_ratioX96 util function
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed May 23, 2024
1 parent 7f4d5c7 commit 4f15d2e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions uniswap/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ def encode_sqrt_ratioX96(amount_0: int, amount_1: int) -> int:
return int(math.sqrt(ratioX192))


def decode_sqrt_ratioX96(sqrtPriceX96: int) -> float:
Q96 = 2**96
ratio = sqrtPriceX96 / Q96
price = ratio**2
return price


def get_tick_at_sqrt(sqrtPriceX96: int) -> int:
sqrtPriceX96 = int(sqrtPriceX96)

Expand Down

0 comments on commit 4f15d2e

Please sign in to comment.