Price-discovery mechanism

The pricing is determined by the frequency and the accumulated amount of observations that a market intends to have.

Observations

When an observation for a market happens, it is going to check whether the market can be updated or not based on the following checks:

  • The amount of time since last update is more than the minimum minutes.

  • The market payer is not insolvent.

Passed the checks, the Keeper can update the market price.

For Alcor Exchange-based implementations, the current tick of the market is stored by summing it with the cumulated ticks. (See client-side integration to learn how pricing can be calculated with ticks). Then the cumulated value can be divided by the total amount of ticks stored to achieve the average tick - which represents the current average price of an asset.

Common cases:

The market has already cumulated enough ticks

Consider a scenario of a market that wants to store 24 hourly observations. By the time the 25th observation happens, we cannot just sum the 25th tick value, as this will end up displaying falsy prices. Our algorithm first subtracts the amount of 1 average tick then sums the new tick:

newCumulatedTick=cumulatedTick(n1)/nnewCumulatedTick = cumulatedTick *(n - 1) / n

newCumulatedTick=newCumulatedTick+newTicknewCumulatedTick =newCumulatedTick +newTick

This mechanics ensures price variation on a single observation only affects a small fraction of the price.

The market doesn`t have enough ticks

Consider the same scenario as described before, but there are only 6 ticks stored. By the time the 7th observation happens, the tick cumulation will happens normally as the cumulated ticks limit has not been reached yet.

newCumulatedTick=cumulatedTick+newTicknewCumulatedTick =cumulatedTick +newTick

Next steps

The cumulated ticks can then be utilized to calculate price. For in-depth explaining, do check out our integration tutorials:

Price calculation

Contract integration

Client-side integration

Last updated