Skip to content

Q64.96 price range correction #116

@juroberttyb

Description

@juroberttyb

Follow up of issue #49.

At the bottom of page Uniswap V3, price range should be updated from $[2^{-128}, 2^{128}]$ to $(2^{-128}, 2^{128})$.

As $1.0001^{887272}$ is the max price possible to be represented using ticks and Q64.96, where $1.0001^{887272} < 2^{128}$.

Say we would like to represent $2^{128}$.

Let $p(i) = 1.0001^{i}$

$1.0001^{i} = 2^{128}$

$i = log_{1.0001} 2^{128}$

$i ~= 887272.44$

But ticks are integers, $i$ is therefore capped at $887272$, since $1.0001^{887273}$ is clearly larger than $2^{128}$ which causes overflow if stored using Q64.96.

So representing $2^{128}$ is not possible since

$1.0001^{887272} < 1.0001^{887272.44} = 2^{128}$.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions