# TickBitmap

Stores a packed mapping of tick index to its initialized state

The mapping uses int16 for keys since ticks are represented as int24 and there are 256 (2^8) values per word.

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

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

```solidity
  function flipTick(
    mapping(int16 => uint256) self,
    int24 tick,
    int24 tickSpacing
  ) internal
```

Flips the initialized state for a given tick from false to true, or vice versa

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

| Name          | Type                      | Description                           |
| ------------- | ------------------------- | ------------------------------------- |
| `self`        | mapping(int16 => uint256) | The mapping in which to flip the tick |
| `tick`        | int24                     | The tick to flip                      |
| `tickSpacing` | int24                     | The spacing between usable ticks      |

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

```solidity
  function nextInitializedTickWithinOneWord(
    mapping(int16 => uint256) self,
    int24 tick,
    int24 tickSpacing,
    bool lte
  ) internal view returns (int24 next, bool initialized)
```

Returns the next initialized tick contained in the same word (or adjacent word) as the tick that is either to the left (less than or equal to) or right (greater than) of the given tick

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

| Name          | Type                      | Description                                                                                           |
| ------------- | ------------------------- | ----------------------------------------------------------------------------------------------------- |
| `self`        | mapping(int16 => uint256) | The mapping in which to compute the next initialized tick                                             |
| `tick`        | int24                     | The starting tick                                                                                     |
| `tickSpacing` | int24                     | The spacing between usable ticks                                                                      |
| `lte`         | bool                      | Whether to search for the next initialized tick to the left (less than or equal to the starting tick) |

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

| Name          | Type  | Description                                                                                |
| ------------- | ----- | ------------------------------------------------------------------------------------------ |
| `next`        | int24 | The next initialized or uninitialized tick up to 256 ticks away from the current tick      |
| `initialized` | bool  | Whether the next tick is initialized, as the function only searches within up to 256 ticks |


---

# 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.dragonswap.app/dragonswap/resources/developer-resources/smart-contracts/dragonswapv2/core/libraries/tickbitmap.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.
