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

Appearance settings

Commit 4f15d2e

Browse filesBrowse files
committed
fix: added decode_sqrt_ratioX96 util function
1 parent 7f4d5c7 commit 4f15d2e
Copy full SHA for 4f15d2e

File tree

Expand file treeCollapse file tree

1 file changed

+7
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-0
lines changed

‎uniswap/util.py

Copy file name to clipboardExpand all lines: uniswap/util.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ def encode_sqrt_ratioX96(amount_0: int, amount_1: int) -> int:
9999
return int(math.sqrt(ratioX192))
100100

101101

102+
def decode_sqrt_ratioX96(sqrtPriceX96: int) -> float:
103+
Q96 = 2**96
104+
ratio = sqrtPriceX96 / Q96
105+
price = ratio**2
106+
return price
107+
108+
102109
def get_tick_at_sqrt(sqrtPriceX96: int) -> int:
103110
sqrtPriceX96 = int(sqrtPriceX96)
104111

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.