tendermint / liquidity

Cosmos SDK Liquidity module
Apache License 2.0
136 stars 56 forks source link

Dynamic Batch Period #35

Open Hyung-bharvest opened 4 years ago

Hyung-bharvest commented 4 years ago

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(priceChangeRate100))+1) 5 + 1) * batchSize

For example, (assuming batchSize = 1 blocks and 1 block = 6 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 commented 3 years ago

this is for gravity dex v2