# Limits

Limits are similar to ticks on Uniswap V3.

To optimise gas efficiency, prices on Haiko are partitioned into price intervals called `limits`

. Limits define valid price points at which liquidity positions and limit orders can be placed.

Limits work in the same way as Uniswap's ticks, except they have a minimum increment of `1.00001`

(rather than `1.0001`

) to allow for more precise price points.

### Converting limits to prices

Limits are stored as (positive or negative) integers that must be exponentiated to convert them to a regular price. Specifically:

$price = 1.00001^{limit}$

For instance:

price=1.00001^{720,000}=$1339.38 where $limit =720,000$

price=1.00001^{0}=$1 where $limit = 0$

price=1.00001^{-12,000}=$0.887 where $limit = -12,000$

### Limit width

The interval of valid limits can be configured through a `width`

parameter, on a per-market basis. Valid limits must be a multiple of `width`

. For example:

a market with

`width`

of 1 has limits of 25, 26, 27, 28 etc (the minimum width)a market with

`width`

of 10 has limits of 10, 20, 30, 40 etca market with

`width`

of 2500 has limits of -2500, 0, 2500, 5000 etc.

### Valid range of limits

The range of valid price limits spans from `-7,906,625`

to `7,906,625`

for markets of `width`

1. This is a total of `15,813,251`

(`251 ** 3`

) limits.

At the smart contract level, limits are shifted to range from `0`

to `15,813,250`

, avoiding the need for signed integers which are not currently natively supported in Cairo. This allows them to fit inside a single `u32`

slot.

For markets of other widths, the range of valid limits becomes `-R`

to `R`

, where `R`

is the greatest multiple of `width`

such that `R ≤ 7,906,625`

.

For example:

markets with

`width`

10 range from`-7,906,620`

to`7,906,620`

markets with

`width`

50 range from`-7,906,600`

to`7,906,600`

markets with

`width`

500 range from`-7,906,500`

to`7,906,500`

Last updated