liquidity icon indicating copy to clipboard operation
liquidity copied to clipboard

Dynamic Batch Period

Open Hyung-bharvest opened this issue 5 years ago • 1 comments

Dynamic Batch Period

Introduction

Liquidity Module provides expanded ways to participate in the decentralized exchange. It combines traditional orderbook-based limit orders with AMM liquidity pool.

In case of significant price movements in a pool, sometimes, one block batch is not an enough time for market participants to react to the market situation. we need to have enough time for traders to submit orders in order to find more accurate price discovery in the batch.

So, we introduce “Dynamic Batch Period”, which extends the length of a batch when incoming orders suggest price movements larger than predefined magnitude.

Reference : Nasdaq Index

Nasdaq market has circuit breaker rule, which halts the market for 15 minutes when the index declines more than 7%/13%/20% from the close price of the last trading day. Other markets are having different triggering rates from 5% to 10%.

In our case, the purpose is not to stabilize the trading activity for extreme intraday price movements, but to encourage traders to participate in price discovery activities for short term price volatilities.

Because one batch will be 1~2 blocks, it will be around 10 seconds. Therefore, in one batch, even 1% price movement is not a frequent event. So, we suggest to have extended batch period for equal or more than 1% price movement from last pool price.

Batch Period Function

Batch period function determines the length of a batch from given swap price change rate from last pool price. Below is our suggestion for batch period function.

ExtendedBatchPeriod =(TRUNCATE(LN(abs(priceChangeRate*100))+1) * 5 + 1) * batchSize

For example, (assuming batchSize = 1 blocks and 1 block = 6 seconds)

  • when priceChangeRate < 1%, ExtendedBatchPeriod = batchSize = 6 seconds
  • when priceChangeRate = 1%, ExtendedBatchPeriod = 6*batchSize = 36 seconds
  • when priceChangeRate = 5.5%, ExtendedBatchPeriod = 13*batchSize = 78 seconds

image

ExtendedBatchPeriod is applied to this batch at the EndBlock, when calculated swap price implies priceChangeRate >= 1%.

ExtendedBatchPeriod can be updated multiple times for a batch when larger price movement is observed in the batch process. ExtendedBatchPeriod only can increase for a batch.

Hyung-bharvest avatar Nov 04 '20 08:11 Hyung-bharvest

this is for gravity dex v2

Hyung-bharvest avatar Mar 23 '21 11:03 Hyung-bharvest