Price & Ticks

Tracking Price

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.

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

Tick Spacing = 100

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