Ticks
Ticks are the fundamental unit of accounting within the dex. Each tick is an integer between 559,680 and -559,680. All tradeable liquidity, in the form of either PoolReserves
or LimitOrderTranche
s is stored at a specific tick. Price for liquidity held at a tick is stored in the form of PriceMakerToTaker
-- the rate at which the MakerDenom
(the liquidity stored at the tick) can be coverted to the TakerDenom
. The PriceMakerToTaker
of liquidity being stored at tick i
is determined by the function:
Some examples:
- Price of tick 0:
- Price of tick 1:
- Price of tick -1:
- Price of tick 4000:
- Price of tick -4000:
In this way, liquidity held at a tick can also be thought of as an offer to buy the opposing a token in the pair at a rate of PriceMakeToTaker
MakerDenom
s per TakerDenom
.
Conversely, price can also be thought of as the price of the MakerDenom
as denominated in the TakerDenom
, or the sell price for the MakerDenom
. This would be expressed as follows:
Both versions yeild the same result.
Given an intent to deposit ATOM
and USDC
into a pool (assuming no fee) with the Price of ATOM
set at 10 USDC
perATOM
and implying a reciprocal USDC
price of 0.1 ATOM
perUSDC
, the best tick index to deposit to will be +/-23027
given that the target price is 10. (1 ATOM
yields 10 USDC
)
USDC
liquidity will be placed at tick -23027
, which implies a price of = 10
ATOM
liquidity will be placed at tick +23027
, which implies a price of = 0.1
A good way to think about price in this context is how much of MakerDenom
Alice would receive if she swapped a single TakerDenom
and vice versa. In this case, she would receive 10 USDC
given an input of 1 ATOM
, and 0.1 ATOM
given an input of 1 USDC
.
From this, the simple price heuristic is How much output given unit input.
swapping 100 USDC for Atom:
swapping 100 Atom for USDC: