“We adapt established TradFi derivatives pricing theory to derive an AMM automated market making strategy. This paper explores the historical roots of the technique and shows how we apply it to market making. With the resulting pricing mechanism, traders face lower slippage if the AMM is in balance. If the AMM is at risk, slippage increases and incentivizes traders to hedge the AMM net risk exposure.”
Merton’s bond pricing model (Merton, 1974) assumes that a company has a certain amount of debt with a maturity date of T. If the value of the company’s assets is less than the face value of the debt at time T, the company will default. In this model, the company’s equity is a European call option on the company’s assets, with an exercise price equal to the face value of the debt. This model can be used to estimate the company’s probability of default, as commercialized by Moody’s as the KMV Merton model [Bharat, Shumway, 2008], and can also be used to price the credit risk of a company’s debt [Moody’s, 2022].
Following Merton's 1974 paper, other default risk models emerged. In the [Black, Cox, 1976] model, the company can also default before the maturity date T, while the fixed default threshold in Merton's approach is now dynamic. Especially with the rise of credit derivatives in the late 1990s, models that abstract the company's balance sheet (called simplified models) began to attract attention. For details on structural models and simplified models, see Appendix A.
Both structural and simplified models are effective ways to simulate default risk and price credit. Both models can be calibrated from historical data, and sometimes they are combined into a "hybrid" form. When these models are used for pricing, they all follow the risk-neutral valuation principle.
Risk-neutral valuation
In short, this principle states that the value of an asset is equal to the value of its expected, discounted cash flows. The expected value is not calculated using real-world probabilities, but rather using constructed probabilities extracted from other asset prices. There is a lot more that can be said about this valuation method, but for the purposes of this article, the key point is that this is how derivatives such as European call and put options, CDS or structured products are priced. For the quantitative analysts we work with at D8X, a good reference for risk-neutral valuation is [Björk, 2009].
Perpetual AMM faces market risks
Automated market makers (AMMs) are the DeFi alternative to order book markets. Instead of matching limit and market orders in an order book-based system, AMMs use a formula to determine the price of a given trade.
Assume that there is only one trader who is long 1 ETH in a perpetual contract (see, for example, [Deribit 2022] for an explanation of perpetual contracts). If the price of ETH rises by 20%, the AMM owes the trader the amount of his profit. Similarly, if the price falls by 20%, the AMM reduces the trader's margin by the amount of the loss. In short, the AMM is exposed to market risk.
If there is another trader shorting 1 ETH and the price goes up 20%, the short trader loses 20% and the long trader gains 20%, and vice versa if the price goes down 20%. In this example, the AMM’s market risk offset is zero: no matter how the price moves, the AMM will not incur any losses or gains.
In summary, it is best for AMMs to have a net zero exposure. Strictly speaking, “zero” only applies to linear perpetual contracts. In this article, we focus on linear perpetual contracts where the collateral is in the quote currency held (e.g., for the ETH-USDC perpetual contract, the collateral is USDC).
AMM as Insurance Provider
To determine the price of the D8X perpetual contract, we assume that traders enter the contract at the spot price and that if they increase their exposure to the AMM, they also purchase credit insurance from the AMM. Credit insurance is intended to guarantee that when a trader closes their position, the amount due to the trader as specified in the contract is paid to them. If the trader reduces their exposure to the AMM, they will receive a refund. If the AMM does not have funds when the trader wants to settle, the amount due needs to be paid from the default fund (i.e., additional capital reserves). Therefore, trading with an AMM also includes the possibility of entering the insurance fund. Depending on the state of the AMM, the insurance costs more or, as we will see, traders get their insurance premium refunded if they reduce their exposure to the AMM.
In-depth discussion: The structural model of perpetual futures AMM
How do we price this credit insurance? Similar to Merton's bond pricing model, we assume a fixed time horizon T. To explain this concept, we first assume that the AMM has only one trader and a capital M expressed in the quote currency (e.g. USDC). The trader enters a (signed) position of size κ at the index price s. The trader's profit at the end of the fixed time period is
Where s is the entry price, s⋅exp(r̃) is the exit price, and r̃ is the log return. Now, the value of the premium is its discounted, expected value under a risk-neutral probability measure. Assuming the risk-free rate is zero and the discount term vanishes, the expected value is:
where M is the AMM capital, excluding the default fund capital. To gain an intuitive understanding of this term, first note that if the AMM capital M is large enough, then a payback is likely and the value of insurance is low (in this case, the first term of the max function is negative for most realizations of r̃, so the value of the max function is 0). Second, if M is 0, the value of insurance corresponds to the expected trader profit (because the insurance covers all profits). Finally, if M is relatively small, part of the trader's profit can be paid with the AMM capital and part of the profit must be paid with insurance. This hypothetical explanation should give us an intuitive understanding of formula (2).
For lognormal returns, we can use formula (2) to evaluate and analyze, if the collateral M is the quote currency or base currency (ETH or USD in the case of ETH-USD perpetual contract). If the collateral is a third currency (BTC in the case of ETH-USD perpetual contract), there is no closed form and the expected value needs to be calculated using Monte Carlo method. For details on this approximation, we refer to Appendix B of the white paper [Maire, Hernandez, 2022].
In summary, formula (2) gives us the insurance premium that the AMM wishes to charge traders to maintain the AMM default fund.
Because the pricing formula needs to be implemented on the blockchain, we simplify the insurance premium in the next section.
Banker's Estimates
The banking industry estimates expected credit losses as PD EAD LGD, see [BIS 2005] for details, where PD is the probability of default, EAD is the exposure at default (in monetary terms), and LGD is the loss after default (a relative term). In other words, this method does not estimate expected losses jointly like the above methods, but assumes that default losses, default exposures, and default probabilities are independent. This method is also used in credit pricing, see [Moody’s 2022] for details.
Following this line of thought, we assume that the dollar loss (EAD * LGD) is equal to the initial position value |κ|s. Now, the insurance premium becomes
The expected value of 1_θ is the probability of default, which we set to q. The default indicator is 0 when the AMM does not default and 1 when it defaults:
Therefore, our insurance premium, formula (2), now simplifies to the position value multiplied by the risk-neutral probability of default, q. The q value corresponds to the value of the digital option. In Appendix B, we provide an intuitive explanation of why this is a conservative assumption for AMMs. In fact, it is conservative as long as the probability of at least doubling the price in a period is low.
We estimate the insurance premium by multiplying the value of the digital option by the transaction size |κ|s. This leads to a closed-form solution that we can implement on-chain.
The value q of a digital option can be calculated analytically for all types of collateral M (base, quote, or quanto), so we can implement this approach entirely on-chain. Figure 1 compares the premium approximation with the expected loss given by Eq. (2) divided by κs.
As κs/M grows, the digital options approximation overestimates the premium. This is useful because if there is sufficient capital (κs/M ratio is low) we fully price the risk, and as capital decreases relative to trader exposure we begin to overprice the risk. Thus, pricing disincentivizes traders to take excessive risk on the AMM and incentivizes the opposite trade entry because the rebate is also overpriced (thus favoring traders), as we explain in detail in the next section.
Trader Incentives
We factor the premium q(κ) into the price p as follows:
Where, if the parameter of sgn(.) is positive, the calculation result is 1, otherwise the calculation result is -1, and κ is the transaction size that minimizes the risk of AMM. This means that, for example, if you are a short trader and κ is negative, you can make a short trade above the spot price s, so that you can make a profit when the price converges to the spot; on the contrary, a long trader enters above the spot, which is expensive compared to spot trading.
As we can see in Figure 1, for lower values of average transaction size per person (κs/M), the approximation ("digital option") remains close to the exact insurance value, and overestimates the insurance premium if the AMM faces higher risk. This premium is charged to traders who increase risk and returned to traders who reduce risk. Therefore, traders have an incentive to reduce the AMM net exposure to the lowest point κ-κ*. At κ-κ*, the AMM has the lowest market risk.
in conclusion
We propose a new perpetual contract AMM based on derivatives pricing theory. Our approach assumes that traders purchase credit insurance to ensure that their positions are paid out at the end of the contract. Our approach is conservative because we estimate the risk-neutral probability of default instead of jointly estimating the expected loss. Our approach can be implemented entirely on-chain and it leads to a closed-form solution.
This is a technical article, but we hope it provides interesting perspectives for those interested in DeFi and financial engineering. We believe that by combining the best practices of traditional finance with blockchain technology, we can provide better products and services to the DeFi community.
Original English material: https://medium.com/@d8x.exchange/applying-derivative-pricing-theory-to-automated-market-making-for-perpetual-futures-aba831c80ad1