Why AMM is Crucial to Decentralized Perpetual Contracts

Image for post
Image for post
On-chain AMM & Off-chain Orderbook

Last week, MCDEX launched the first-ever decentralized perpetual contract and integrated it with AMM (Automatic Market Maker). We believe AMM is fundamentally vital to decentralized perpetual contracts in two ways:

A. To apply on-chain funding rate to decentralized perpetual contracts, instead of off-chain funding rate.

B. A fully decentralized structure acts as a brick of the DeFi Lego.

On-chain funding rate

A key feature of perpetual contracts is the funding rate, employed to balance out the long orders and short orders for keeping the trading price soft-pegged to the index price. The funding rate is decided by market demand. If the demand for longs is more than that for shorts, longs will pay to shorts so as to encourage traders to exit longs or enter into shorts. Similarly, if the demand for shorts is more than the demand for longs, shorts will pay to longs so as to encourage traders to exit shorts or enter into longs. In this way, the demands for longs and shorts can be balanced and trading prices can be soft-pegged to index prices.

In centralized exchanges, the depth of the order book can perfectly reflects the market demand, even though there’s a spread between the buy and sell sides. For example, when the average bid price, let’s say for 1 ETH, is higher than the index price, that means a premium on account of stronger demand from the longs. Thus, the funding rate in centralized exchanges is derived from the order book depth.

When we design our perpetual contracts, it’s simple to follow the mechanism of centralized exchanges — to derive the funding rate from the order book. But there are several obvious disadvantages of doing so — funding rate that depends on the off-chain order book will largely increase centralization. When the off-chain order book doesn’t work, not only the new trades will not be made, but also the funding rate will not be updated, leading to the crashing of the whole system. Therefore, we firmly believe that the funding rate of a decentralized perpetual contract must be derived on-chain. Moreover, the whole mechanism can work without any central infrastructure.

With profound and comprehensive thoughts, we believe AMM solves the above-mentioned problem. AMM provides an order book in logic. On the one hand, AMM provides a set of continuous “logic orders” according to the pricing formula just like a market maker. The orders will be adjusted according to the trades — a reflection of the longs and shorts. On the other hand, arbitragers will transfer the liquidity of the order book to the AMM for AMM to reflect the complete market demand. Hence, we use the mid-price of AMM as a fair price and leverage Deribit’s formula for calculating the funding rate. In this way, we succeed in deriving funding rate on-chain and making our decentralized perpetual contracts work independently and fully on-chain.

On-chain trading interface

Due to the current inefficiency of blockchain, the Hybrid model of off-chain matching and the on-chain transactions is one of the solutions to achieve efficiency. Like MCDEX V1, we have kept the off-chain order book for V2. However, we profoundly understand the importance of an on-chain trading interface, which means that anyone can call the interface function of the smart contract to trade without relying on any off-chain facilities. AMM provides the on-chain interface we are talking about.

The on-chain trading interface is the only way other smart contracts can interact with the decentralized perpetual contract. Not only the end users but also other smart contracts can call the interface function of the Perpetual smart contract to trade, arbitrage, hedge, and fulfill their investment portfolio. If not, usage will be largely limited.

In the current DeFi ecosystem, we see that some smart contracts (like Uniswap, MakerDAO, and Compound) can be called by other smart contracts. That’s how many new products are built.

We aim to make MCDEX a brick of the DeFi lego. We expect many other projects to build exciting new products based on Mai2 protocol. All in all, the introduction of AMM will diversify the use cases of decentralized perpetual contracts.

Stay tuned



Building MCDEX V3 (Decentralized Perpetual) | Trade #PerpetualContracts - $ETH $LINK $SNX $COMP $LEND

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store