# Tick

Tick-based pricing utilities for DEX price conversions.

Prices on Tempo's stablecoin DEX are discretized into integer ticks with a tick size of 0.1 bps
(where `price = PRICE_SCALE + tick` and `PRICE_SCALE = 100_000`). Orders must be placed at ticks
divisible by `TICK_SPACING = 10` (1 bp grid), within bounds of ±2000 ticks (±2%).

[Stablecoin DEX Pricing](https://docs.tempo.xyz/protocol/exchange/spec#key-concepts)

## Examples

```ts twoslash
import { Tick } from 'ox/tempo'

const price = Tick.toPrice(100) // "1.001" (0.1% above 1.0)
const tick = Tick.fromPrice('0.999') // -100
```

## Functions

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Tick.fromPrice`](/tempo/reference/Tick/fromPrice) | Converts a price string to a tick. |
| [`Tick.toPrice`](/tempo/reference/Tick/toPrice) | Converts a tick to a price string. |

## Errors

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Tick.InvalidPriceFormatError`](/tempo/reference/Tick/errors#tickinvalidpriceformaterror) | Error thrown when a price string has an invalid format. |
| [`Tick.PriceOutOfBoundsError`](/tempo/reference/Tick/errors#tickpriceoutofboundserror) | Error thrown when a price string results in an out-of-bounds tick. |
| [`Tick.TickOutOfBoundsError`](/tempo/reference/Tick/errors#ticktickoutofboundserror) | Error thrown when a tick value is out of the allowed bounds. |

## Types

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Tick.Tick`](/tempo/reference/Tick/types#ticktick) | Tick type. |
