Price & Ticks

Tracking Price

Whirlpool tracks price using square-root price. Each pool supports a sqrt-price range between [2642^{-64}, 2642^{64}].

Tick

Users can deposit liquidity on a custom price range in a Whirlpool. The smallest unit of price measurement (tick) is 1bps. Whirlpool represents the price range as a sequence of ticks and stores accounting information in each initialized tick that hosts liquidity.

Sqrt-price maps to a tick with the formula below. Each tick represents 1 basis point of change from the neighboring tick.

p(i)=1.0001i\sqrt{p}(i) = \sqrt{1.0001}^{i} \\

Given the supported price-range of [2642^{-64}, 2642^{64}], the tick range for a Whirlpool is [-443636, 443636].

The Whirlpool account tracks both the current sqrt-price and the current tick-index.

Understanding Tick Spacing

Due to compute cost and rent constraints, it is often not economical for a Whirlpool to allow users to deposit liquidity into every single tick. Whirlpools requires pool owners to define an additional "Tick-Spacing" parameter. This allows them to define the space between "initializable ticks", where liquidity information can be stored.

A tick-spacing of 5 means that liquidity can be deposited into tick-index that are a multiple of 5. (ex. [...-10, -5, 0, 5, 10...]).

Whirlpool supports a tick-spacing between 1 and 256, preferably a value that is a power of 2 for better compute-budget optimization.

As a general rule, the smaller the expected volatility of a pool is, the smaller tick-spacing should be. To help you decide on the best tick-spacing for your whirlpool, consider the following attributes:

1. Granularity of user definable price ranges

The smaller your tick-spacing, the more granular the price users can deposit their liquidity in. For more stable pools, a more granular tick-spacing would let users define a tighter range to maximize their leverage.

Tick Spacing = 1

PriceInitializable Tick Index

1.00012=11.000200011.0001^{-2} = \frac{1}{1.00020001}

-2

1.00011=11.00011.0001^{-1} = \frac{1}{1.0001}

-1

1.00010=11.0001^0 = 1

0

1.00011=1.00011.0001^1 = 1.0001

1

1.00012=1.000200011.0001^2 = 1.00020001

2

Tick Spacing = 100

PriceInitializable Tick Index

1.0001200=11.02020031989393181.0001^{-200} = \frac{1}{1.0202003198939318}

-200

1.0001100=11.01004966209287541.0001^{-100} = \frac{1}{1.0100496620928754}

-100

1.00010=11.0001^0 = 1

0

1.0001100=1.01004966209287541.0001^{100} = 1.0100496620928754

100

1.0001200=1.02020031989393181.0001^{200} = 1.0202003198939318

200

2. Maximum price movement per swap

The size of the tick-spacing defines the maximum price movement a single swap can move the price by for a Whirlpool.

Whirlpool's swap operates by iterating through each ticks with initialized liquidity. The larger the gap between initialized ticks are, the more it can theoretically traverse the price range.

A low tick-spacing pool undergoing a massive price movement may require multiple swap instructions to complete the price movement. Therefore, more volatile pairs that often has large price swings should look at higher tick-spacing to mitigate this pain point for their pool users.

3. Account rent cost for users

On Solana, accounting information requires account space. The more information a program hosts, the more rent is required to store. The larger the tick-spacing, the less ticks it needs for the program to keep track of liquidity across a set price range. Subsequently, the less money it takes to rent space on Solana.

Last updated