As AMM (Automated Market Maker) is accepted by more and more traders, the problems it implies are infinitely magnified.
As a pure technology contributor and node operator, B-Harvest added a DeFi module to the Cosmos SDK. In this DeFi module, B-Harvest improves the AMM of the existing fixed product model and solves its existing problems.
The general solutions proposed in this module can be applied in different environments, for decentralized exchange developers Said to be of great reference value.
The Rhythm Research Institute has translated the white paper for readers’ reference:
Block Chain: Decentralized Computing Database
-Provide trustless infrastructure for automation performance
-transparent operating environment
-can Expanded blockchain technology
AMM: Automated Market Maker
-Let market makers participate more freely
-Create a digital asset market without middlemen
-A minimalist exchange without an order book
Use the IBC protocol Interconnecting Wanchain
-IBC is ready
p>
-Many transition bridges are under development
-Heterogeneous chains will be available Interconnect
miners’ absolute control over transaction ordering
-miners have 100% order control over all transactions in the block
< p line="QZEP">-The order of transactions has a great impact on the execution price
Senseless Gas wars and Delay Wars
- Traders scramble to prioritize trades
-Gas prices are high, miners are monopolized
-Unnecessarily low Low Latency
-Possible risk of "running away" attack
"Fixed product" problem:
Exchange price = (X token reserve + X token transaction volume)/Y token reserve
pool price = (X token reserve + 2*X generation currency trading volume)/Y token reserve
The disequilibrium between the exchange price and the pool price will amplify the exchanged price of slippage.
Side effects of inconsistent prices:
< p line="4pYc">Repeated price fluctuations will create unnecessary arbitrage opportunities.
Arbitrageurs take profits from the pool, while liquidity providers will suffer losses.
Buy or fail:
-The order can only take effect within one block, otherwise the transaction fails
p>
-Orders can only be filled in real time, otherwise the transaction will fail
< /p>
-Orders cannot be placed, advanced order mode is not provided
-Orders cannot be partially Closing
These factors will prevent market makers from participating:
- Different pending order modes will create more liquidity.
-In each batch period, trading orders will continue to accumulate in the liquidity pool
-After each batching period, all transactions accumulated in the pool will be processed together
-The duration of the batch period can be one block or multiple blocks
< p line="EGs6">Batch execution can effectively reduce unnecessary competition &n bsp;
- No order ordering issues: all The executed orders are processed after being batched
-There is no delay war: to provide a better
-There is no problem of miners manipulating the order of transactions: preventing front-running
-There is no problem of gas war
-There is no miner monopoly problem
Dynamic batching period
-The binding period can be extended when the price fluctuates sharply
-Longer tranches provide traders with more opportunities for price discovery
-Price Discovery The process will be more balanced and smooth
p>
The exchange price equivalence model will redefine the fixed product model so that the exchange price is equal to the price in the pool after exchange:
p>
Pool price = (X token reserve + X token order volume) / (Y token reserve - X token transaction volume / exchange price) = exchange price
Through the above formula, we can get:
Exchange price=(X token reserve + 2*X token transaction volume)/Y token reserve
Note: The fixed product formula is in this model Invalid
Prevent price fluctuation after exchange
p>
-After the exchange is completed, the pool price remains the same as the exchange price
-There is no price fluctuation amplification caused by fixed product in this model

From the above figure, we can see that the fixed product model will amplify price fluctuations, while the exchange price equivalence model can effectively prevent the amplification of fluctuations.

Note: Figure 1 is the order book model, Figure 2 is the liquidity pool model, and Figure 3 is the hybrid model
-Allow limit pending orders
- Every time a batch is executed, the order book will use the traditional matching mechanism
-in this process, the liquidity pool will use The quantity of limit orders calculated by the exchange price peer-to-peer model participates in order matching
- Limit orders in each liquidity pool will be accumulated in the order book
  ;
-Every time a batch transaction is processed, the order book performs order matching through the traditional matching mechanism
-During this process, the liquidity pool will participate in order matching and provide limit orders based on the order volume calculated by the exchange price peer-to-peer model
-AMM model for traders Provides very stable liquidity support
-However, the liquidity in the pool has a delay for real-time trading volume
-Limit orders can provide sufficient liquidity support for immediate liquidity needs

-Different from centralized exchanges and ordinary AMMs, the transaction exchange of batch transactions is discontinuous
- Orders are accumulated in the order book and then batches are matched
- Each batch Unmatched transactions in the order book will be kept in the order book and will be matched with transactions in other batches in the future
Unified exchange price for each batch
-There is a unified exchange price for each batch
-The transactions in a batch will be executed according to the uniform exchange price, regardless of the order status
- Unlike other AMM models, Hybrid Exchange The model will allow partial execution based on order book and liquidity pool conditions
-partial execution will only occur when the order price When it is the same as the exchange price
< p line="ODBP">-Different from traditional algorithms, the liquidity pool will affect the order matching results
- The liquidity pool performs order matching under the condition of following the exchange price peer-to-peer model
When the order book and the exchange price are known Order Matching Rules
-If the order price>When exchanging the price, all orders must be matched and executed
-If the order price ==When the price is exchanged, the order will be fully/partially executed
-If the order price is <when the price is exchanged, The order will not be executed
-If the order price < exchange price, all orders must be matched and executed
- If the order price == the exchange price, the order will be fully/partially executed
-if the order price>exchange
< /p>
This model determines the total amount of orders that the liquidity pool will provide at a certain exchange price
-Situation 1) When the exchange price == the middle price of the current pool
In this case, the liquidity pool Orders will not be provided
-Case 2) when the exchange price>
The total amount of Y token orders in the pool = (exchange price Y reserve - X reserve) / (2 times the exchange price)
-Case 3) When the exchange price < the middle price of the current pool, the liquidity pool provides X Tokens
The total amount of X token orders in the pool = (X reserve amount - exchange price * Y reserve amount) / 2

White Paper Link< p>
Welcome to join the official BlockBeats community:
Telegram Subscription Group: https://t.me/theblockbeats
Telegram Discussion Group: https://t.me/BlockBeats_App
Official Twitter Account: https://twitter.com/BlockBeatsAsia