# Tick

## tickSpacingToMaxLiquidityPerTick

Derives max liquidity per tick from given tick spacing. Executed within the pool constructor.

```javascript
function tickSpacingToMaxLiquidityPerTick(int24 tickSpacing)  internal  pure  returns  (uint128) 
```

**Params:**

| **Name**    | **Type** | **Description**                                                              |
| ----------- | -------- | ---------------------------------------------------------------------------- |
| tickSpacing | int24    | The amount of required tick separation, realized in multiples of tickSpacing |

**Returns:**

| **Type** | **Description**            |
| -------- | -------------------------- |
| uint128  | Maximum liquidity per tick |

## getGrowthInside

Computes growth of fees, collateral, Spear and Shield deltas within a tick boundary.

```javascript
function getGrowthInside(mapping(int24 => TickInfo)  storage self,  int24 tickLower,  int24 tickUpper,  int24 tickCurrent, GrowthX128 memory global)
internal
view
returns  (GrowthX128 memory inside)
```

**Params:**

| **Name**    | **Type**                           | **Description**                                                                                                                                                                     |
| ----------- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| self        | mapping(int24 => struct Tick.Info) | The mapping containing TickInfo. See [Types](https://docs.divergence-protocol.com/technical-reference/core/types#tickinfo)                                                          |
| tickLower   | int24                              | The lower tick boundary of the position                                                                                                                                             |
| tickUpper   | int24                              | The upper tick boundary of the position                                                                                                                                             |
| tickCurrent | int24                              | The current tick                                                                                                                                                                    |
| global      | GrowthX128                         | The [GrowthX128](https://docs.divergence-protocol.com/technical-reference/core/types#growthx128) info struct per unit of liquidity as of the last update to the pool's global state |

**Returns:**

| **Name** | **Type**   | **Description**                                                                                                                                          |
| -------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| inside   | GrowthX128 | The [GrowthX128](https://docs.divergence-protocol.com/technical-reference/core/types#growthx128) info struct per unit of liquidity inside the tick range |

## update

Updates a tick and returns true if the tick was flipped from initialized to uninitialized, or vice versa.

```javascript
function update(mapping(int24 => TickInfo) storage self, int24 tick, int24 tickCurrent, int128 liquidityDelta, GrowthX128 memory global, uint128 maxLiquidity, bool upper) internal returns (bool flipped)
```

**Params:**

| **Name**       | **Type**                           | **Description**                                                                                                                                                                     |
| -------------- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| self           | mapping(int24 => struct Tick.Info) | The mapping containing TickInfo. See [Types](https://docs.divergence-protocol.com/technical-reference/core/types#tickinfo)                                                          |
| tick           | int24                              | The tick that will be updated                                                                                                                                                       |
| tickCurrent    | int24                              | The current tick                                                                                                                                                                    |
| liquidityDelta | int128                             | The change in liquidity                                                                                                                                                             |
| global         | GrowthX128                         | The [GrowthX128](https://docs.divergence-protocol.com/technical-reference/core/types#growthx128) info struct per unit of liquidity as of the last update to the pool's global state |
| maxLiquidity   | uint128                            | The maximum liquidity allocation for a single tick                                                                                                                                  |
| upper          | bool                               | Indicates whether the tick represents the upper boundary                                                                                                                            |

**Returns:**

| **Name** | **Type** | **Description**                                                               |
| -------- | -------- | ----------------------------------------------------------------------------- |
| flipped  | bool     | Whether the tick was flipped from initialized to uninitialized, or vice versa |

## clear

Clears tick data

```javascript
function clear(mapping(int24 => TickInfo)  storage self,  int24 tick)  internal  
```

**Params:**

| **Name** | **Type**                           | **Description**                                                                                                            |
| -------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| self     | mapping(int24 => struct Tick.Info) | The mapping containing TickInfo. See [Types](https://docs.divergence-protocol.com/technical-reference/core/types#tickinfo) |
| tick     | int24                              | The tick that will be cleared                                                                                              |

## cross

Transitions to next tick as needed by price movement

```javascript
function cross(mapping(int24 => TickInfo) storage self, int24 tick, GrowthX128 memory global) internal returns (int128 liquidityNet)
```

**Params:**

| **Name** | **Type**                           | **Description**                                                                                                                                                                     |
| -------- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| self     | mapping(int24 => struct Tick.Info) | The mapping containing TickInfo. See [Types](https://docs.divergence-protocol.com/technical-reference/core/types#tickinfo)                                                          |
| tick     | int24                              | The destination tick of the transition                                                                                                                                              |
| global   | GrowthX128                         | The [GrowthX128](https://docs.divergence-protocol.com/technical-reference/core/types#growthx128) info struct per unit of liquidity as of the last update to the pool's global state |

**Returns:**

| **Name**     | **Type** | **Description**   |
| ------------ | -------- | ----------------- |
| liquidityNet | int128   | The net liquidity |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.divergence-protocol.com/technical-reference/core/libraries/tick.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
