> For the complete documentation index, see [llms.txt](https://docs.divergence-protocol.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.divergence-protocol.com/technical-reference/core/libraries/tickmath.md).

# TickMath

As digital calls and puts are priced between \[0.01, 0.99] per collateral, per put-call parity, the sqrtPrice is the sqrt ratio of shieldPrice/spearPrice is between \[sqrt(1/99), sqrt(99)].  sqrtPrice is computed for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers.

## getSqrtRatioAtTick

Calculates and returns the square root ratio at the given tick.

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

**Params:**

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

**Returns:**

| **Name**     | **Type** | **Description**                                                                          |
| ------------ | -------- | ---------------------------------------------------------------------------------------- |
| sqrtPriceX96 | uint160  | A fixed point Q64.96 number representing the sqrt of the ratio of shieldPrice/spearPrice |

## getTickAtSqrtRatio

Calculates and returns the tick value at the given square root ratio.

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

**Params:**

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

**Returns:**

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