# Tick

Contains functions for managing tick processes and relevant calculations

### Functions[​](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#functions) <a href="#functions" id="functions"></a>

#### tickSpacingToMaxLiquidityPerTick[​](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#tickspacingtomaxliquiditypertick) <a href="#tickspacingtomaxliquiditypertick" id="tickspacingtomaxliquiditypertick"></a>

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

Derives max liquidity per tick from given tick spacing

Executed within the pool constructor

**Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#parameters)

| Name          | Type  | Description                                                                                                                                                                             |
| ------------- | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tickSpacing` | int24 | The amount of required tick separation, realized in multiples of `tickSpacing` e.g., a tickSpacing of 3 requires ticks to be initialized every 3rd tick i.e., ..., -6, -3, 0, 3, 6, ... |

**Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#return-values)

| Type    | Description            |
| ------- | ---------------------- |
| uint128 | max liquidity per tick |

#### getFeeGrowthInside[​](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#getfeegrowthinside) <a href="#getfeegrowthinside" id="getfeegrowthinside"></a>

```solidity
  function getFeeGrowthInside(
    mapping(int24 => struct Tick.Info) self,
    int24 tickLower,
    int24 tickUpper,
    int24 tickCurrent,
    uint256 feeGrowthGlobal0X128,
    uint256 feeGrowthGlobal1X128
  ) internal view returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128)
```

Retrieves fee growth data

**Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#parameters-1)

| Name                   | Type                               | Description                                                       |
| ---------------------- | ---------------------------------- | ----------------------------------------------------------------- |
| `self`                 | mapping(int24 => struct Tick.Info) | The mapping containing all tick information for initialized ticks |
| `tickLower`            | int24                              | The lower tick boundary of the position                           |
| `tickUpper`            | int24                              | The upper tick boundary of the position                           |
| `tickCurrent`          | int24                              | The current tick                                                  |
| `feeGrowthGlobal0X128` | uint256                            | The all-time global fee growth, per unit of liquidity, in token0  |
| `feeGrowthGlobal1X128` | uint256                            | The all-time global fee growth, per unit of liquidity, in token1  |

**Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#return-values-1)

| Name                   | Type    | Description                                                                                     |
| ---------------------- | ------- | ----------------------------------------------------------------------------------------------- |
| `feeGrowthInside0X128` | uint256 | The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries |
| `feeGrowthInside1X128` | uint256 | The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries |

#### update[​](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#update) <a href="#update" id="update"></a>

```solidity
  function update(
    mapping(int24 => struct Tick.Info) self,
    int24 tick,
    int24 tickCurrent,
    int128 liquidityDelta,
    uint256 feeGrowthGlobal0X128,
    uint256 feeGrowthGlobal1X128,
    bool upper,
    uint128 maxLiquidity
  ) internal returns (bool flipped)
```

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

**Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#parameters-2)

| Name                   | Type                               | Description                                                                                                |
| ---------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `self`                 | mapping(int24 => struct Tick.Info) | The mapping containing all tick information for initialized ticks                                          |
| `tick`                 | int24                              | The tick that will be updated                                                                              |
| `tickCurrent`          | int24                              | The current tick                                                                                           |
| `liquidityDelta`       | int128                             | A new amount of liquidity to be added (subtracted) when tick is crossed from left to right (right to left) |
| `feeGrowthGlobal0X128` | uint256                            | The all-time global fee growth, per unit of liquidity, in token0                                           |
| `feeGrowthGlobal1X128` | uint256                            | The all-time global fee growth, per unit of liquidity, in token1                                           |
| `upper`                | bool                               | true for updating a position's upper tick, or false for updating a position's lower tick                   |
| `maxLiquidity`         | uint128                            | The maximum liquidity allocation for a single tick                                                         |

**Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#return-values-2)

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

#### clear[​](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#clear) <a href="#clear" id="clear"></a>

```solidity
  function clear(
    mapping(int24 => struct Tick.Info) self,
    int24 tick
  ) internal
```

Clears tick data

**Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#parameters-3)

| Name   | Type                               | Description                                                                   |
| ------ | ---------------------------------- | ----------------------------------------------------------------------------- |
| `self` | mapping(int24 => struct Tick.Info) | The mapping containing all initialized tick information for initialized ticks |
| `tick` | int24                              | The tick that will be cleared                                                 |

#### cross[​](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#cross) <a href="#cross" id="cross"></a>

```solidity
  function cross(
    mapping(int24 => struct Tick.Info) self,
    int24 tick,
    uint256 feeGrowthGlobal0X128,
    uint256 feeGrowthGlobal1X128
  ) internal returns (int128 liquidityNet)
```

Transitions to next tick as needed by price movement

**Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#parameters-4)

| Name                   | Type                               | Description                                                       |
| ---------------------- | ---------------------------------- | ----------------------------------------------------------------- |
| `self`                 | mapping(int24 => struct Tick.Info) | The mapping containing all tick information for initialized ticks |
| `tick`                 | int24                              | The destination tick of the transition                            |
| `feeGrowthGlobal0X128` | uint256                            | The all-time global fee growth, per unit of liquidity, in token0  |
| `feeGrowthGlobal1X128` | uint256                            | The all-time global fee growth, per unit of liquidity, in token1  |

**Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick#return-values-3)

| Name           | Type   | Description                                                                                        |
| -------------- | ------ | -------------------------------------------------------------------------------------------------- |
| `liquidityNet` | int128 | The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left) |
