# TickMath

Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports prices between &#x32;**-128 and 2**128

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

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

```solidity
  function getSqrtRatioAtTick(
    int24 tick
  ) internal pure returns (uint160 sqrtPriceX96)
```

Calculates sqrt(1.0001^tick) \* 2^96

Throws if |tick| > max tick

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

| Name   | Type  | Description                          |
| ------ | ----- | ------------------------------------ |
| `tick` | int24 | The input tick for the above formula |

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

| Name           | Type    | Description                                                                                      |
| -------------- | ------- | ------------------------------------------------------------------------------------------------ |
| `sqrtPriceX96` | uint160 | A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) |

at the given tick

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

```solidity
  function getTickAtSqrtRatio(
    uint160 sqrtPriceX96
  ) internal pure returns (int24 tick)
```

Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio

Throws in case sqrtPriceX96 < MIN\_SQRT\_RATIO, as MIN\_SQRT\_RATIO is the lowest value getRatioAtTick may ever return.

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

| Name           | Type    | Description                                              |
| -------------- | ------- | -------------------------------------------------------- |
| `sqrtPriceX96` | uint160 | The sqrt ratio for which to compute the tick as a Q64.96 |

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

| Name   | Type  | Description                                                                    |
| ------ | ----- | ------------------------------------------------------------------------------ |
| `tick` | int24 | The greatest tick for which the ratio is less than or equal to the input ratio |
