A recap of Derify’s Risk Control Mechanism: Order Book vs. hAMM

Derivation Lab
6 min readAug 23, 2021

According to BitMEX’s definition, the perpetual contract is a type of product that likes traditional futures contracts when trading, but it does not expire, so positions can be held for any length of time. Trading perpetuals is much like spot trading, but the high leverage, high market volatility and margin trading make perpetual trading more demanding than spot in terms of risk management and clearing rules.

AMM vs. Order Book

The order book has been the most classic and proven trading model for traditional financial products, and it is also suits centralized exchanges in the digital asset area. In the order book model, the user’s trading costs (average transaction price/slippage) depend on the depth of the counter party’s orders (price , quantity, etc.). In addition, the depth of orders will also affect the marker price of the perpetual system (e.g. poor order depth can easily lead to liquidity squeeze), which may eventually blow up all positions in the system, so trading liquidity in the order book model is key to user experience and system security.

In order to provide better trading liquidity, exchanges often need to bring in as many professional market makers as possible to quote for trading orders (Derify’s founding team was the head market maker on several exchanges in the industry). However, due to the performance and cost of block chain, it is not possible to provide a better user experience by using traditional order book models in a decentralized trading product. With the success of Uniswap’s AMM mechanism, more and more people are recognizing the match between the AMM mechanism and decentralized products. Similar to spot trading, the liquidity problem of perpetual trading on DEX can also be solved by the AMM mechanism.

In contrast to the centralized exchange’s order book model, Derify uses the hAMM (hedged automatic market making mechanism). You can learn more about hAMM here: Understand hAMM and Position Mining of Derify

Order Book vs. hAMM overview

Compared to the order book model, hAMM provides easier access to liquidity and offers traders a superior experience including zero slippage, index price as the marker price, etc, but it also creates continuous risk exposures to the system (the order book model transfers the risk through market makers to order takers, the risk only exist when a liquidation happen without sufficient margin). The following mechanism is to solve the risk exposure problem.

Long/short Equilibrium: Position Change Fees & Dynamic Mining Gains vs. Funding Fees

For exchanges, maintaining a balance between the long/short position sides is key to keep the system safety and stable. In the order book model, when long/short positions are not balanced, the weaker side (e.g. short position side) will have less liquidity and a larger base difference (the deviation of perpetual price and spot index price) will happen. Such situation will not only bring poor user experience, but also high system risk, so a reliable risk control mechanism is needed. The main solution in the market is funding fees: the stronger position side is forced to pay a regular fee to the weaker position side (one reward and one penalty), so that the perpetual price can be as close as possible to the index price.

Funding fee is uncertain and need to be paid periodically. If the settlement period is too long, the price within a time period and the deviation before and after the settlement will fluctuate widely; if the time period is too short, a large number of short-term investors will have their strategies disrupted by the funding rate. In contrast to the funding fee, Derify takes a Position Change Fees + Dynamic Mining Reward mechanism to achieve a long/short position balance (detailed mechanism is here: What is Position Change Fees (PCF) and why it should replace Funding Fees). Under our mechanism, a different trading experience can be achieved while balancing long/short positions and controlling risk exposures:

Position Limit

In the order book model, if liquidity is not sufficient, a single trade with a too large position may have a large impact on the market price and trigger unwanted mandatory liquidation in other positions, also large slippage will be created. In the case of the hAMM mechanism, a single position may prompt the system to take a large naked position, thus creating a large risk exposure. Therefore, both in CEXs and DEXs need to control the overall system risk through a position limit mechanism.

Derify’s position limit mechanism depends primarily on the impact that a single position change to the system’s risk rate: if a single position change takes the system’s risk rate above a certain threshold, then the position will be limited, regardless of opening or closing. In this case the trader can finish the trade by reducing the amount of the individual position.

Insurance Funds

Insurance funds are mainly used to pay out users’ net profit, when the loss of losing traders is less than the profit of profitable traders. For the centralized perpetual exchanges based on order book models, this situation occurs mainly in the case of un-covered liquidation, where the price fluctuates so sharply in the short term that the system does not have time to close positions in time, ultimately resulting in some positions not having enough margin left to cover the position loss. When this situation happens, both traditional exchanges and Derify will compensate all traders’ net profit through the insurance fund; when all traders incur a net loss (short term sharp price fluctuations followed by a U-turn, the so-called pinned market), the net loss will be inject to the insurance pool, but Derify will add additional insurance funds including part of the trading fees. Compared with CEX, Derify’s insurance fund has a fair and stable sources (for specific rules, please refer to the article: How does the insurance pool in Derify work):

Bonds vs. Loss Distribution & ADL Auto Deleveraging

Although Derify has a much richer source of insurance funds, it is still not immune to extreme and unusual market conditions where the insurance does not fully cover the net profit of users. When this happens, the reaction system between the centralized exchanges and Derify is completely different.

When the insurance cannot cover users’ net profit, some exchanges choose to transfer the system loss that cannot be covered to profitable positions, they share the exchange’s loss based on their profit percentage. For example, Alice would have a profitable position with a profit of 1,000USD, but because of the sharing mechanism, the position can be closed earlier with profit of 950USD (loss distribution is often seen on the perpetual trading platforms).

Some platforms also adopt the auto deleveraging (ADL) mechanism: based on the order of profitability, the positions with the highest profitability will be closed first to reduce the profitability of users, thus sharing the risk of loss in the system.

In this extreme market, Derify adopts a model of short-term issuance with redeemable bonds (learn more details here: How does the insurance pool in Derify work). This mechanism allows you to redeem bond by discounting future earnings, thus hugely improve the user experience comparing to loss distribution or auto deleveraging.

Compared to the order book model that has been tested for hundreds of years, AMM is still new and has unavoidable shortcomings (e.g. impermanent losses in uniswap, high slippage due to low fund utilization rate, and Derify’s risk exposures). However, AMM also has its unique advantages and is naturally friendly to decentralized products, so Derify will continue to innovate on the design and operation of our hAMM.

Important Links & Docs:

Audit Report: https://www.certik.com/projects/derify-protocol

Website: https://derify.finance/

Whitepaper: https://docs.derify.finance/whitepaper/introduction

Tokenomics: https://docs.derify.finance/whitepaper/tokenomics

Twitter: https://twitter.com/DerifyProtocol

Github: https://github.com/derivationlab

Telegram: https://t.me/derifyprotocol_official

Discord: https://discord.com/invite/kSR6tz2pdm

You are more than welcome to share/like/comment this article. For the better future of DeFi!

--

--