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 , 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 amount of asset A to exchange for amount of asset B, while in margin trading, it means depositing amount of margin to withdraw amount of equity, which fluctuates over time.
Obviously, when , 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:
is always positive as the sum of total long positions.
is always negetive as the sum of total short positions.
The formula means that the sum of total long positions equals to the sum of total short positions 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 .