Hedged Automated Market Making (**hAMM**) is the liquidity solution for contract calculation, which is inspired by Automated Market Making (**AMM**).

The goal for AMM is "**price discovery**", the key formula of which is $x*y=k$, presented as a *curve* of price (such as AMM for Uniswap) or *surface* of price (such as generalized-AMM for Balancer).

However, margin trading is significantly different from spot trading.

In spot trading, it means using $a$ amount of asset A to exchange for $b$ amount of asset B, while in margin trading, it means depositing $m$ amount of margin to withdraw $e$ amount of equity, which fluctuates over time.

Obviously, when $e>m$, the profit of a position comes from the loss of opposite positions.

Thus, the goal for hAMM is "**position hedged**", the formula is as follows:

$X+Y=0$

$X$

*is always positive as the sum of total long positions.*$Y$

*is always negetive as the sum of total short positions.*

The formula means that the sum of total long positions $X$ equals to the sum of total short positions $Y$ in certain derivative.

Both hAMM and AMM take the same path to achieve their goal, i.e., each deviation and imbalance of the system caused by transactions would create reasonable arbitrage possibilities, which would attract external arbitrageurs to trade for risk-free profits, therefore restore the system back to a *balanced* state.

All mechanisms pertaining to Derify protocol are centered around the key formula of $X+Y=0$.