After studying the Drift Protocol, I fully understand why Solana is obsessed with CLOB, that is, the order book.

Because it is too difficult to implement perpetual contract AMM on-chain. So much so that we gave up and embraced centralized market makers.

Although the vAMM (virtual AMM) established by Perpetual Protocol addresses the issue of leverage on the basis of the spot AMM X * Y = K.

But without centralized market makers, the perpetual contract AMM must resolve issues such as counterparty (for example, all users going long without anyone shorting), depth, and price deviation (the perpetual contract price deviating from the spot) using predetermined numerical rules.

This makes Drift v1 appear exceptionally complex in terms of adjustable parameters and their formal expressions.

Complicated to the point where, based on the state of contract price deviation, market conditions must be defined, such as Healthiest Market for the healthiest market, Unhealthy Marker for sub-healthy market, etc. A total of four conditions must be evaluated for long and short imbalance states, determining whether to liquidate user positions in that state and the solution for adjusting coefficients.

After seeing this, do you feel overwhelmed? Comparing it to the order book, doesn’t it seem that centralized solutions also look quite appealing? Can you understand a bit of Solana's obsession with the order book now?

Later, Drift launched the limit order feature, but the experience is still somewhat different from the order book.

Currently, the trading on Drift is supported by three liquidity mechanisms:

1) JIT auction, liquidity provided by market makers;

2) Limit order book, liquidity provided by market makers;

3) AMM, if there is no MM intervention to provide liquidity, it will be provided by Drift's AMM.

However, after 0:00 UTC on August 7, Drift will abandon the AMM model and fully embrace centralized market makers.

vAMM faces the following core issues,

1) Funding rates continuously decline. The protocol's insurance fund is akin to shorting volatility— it will be slowly eaten away by arbitrageurs during times of high market volatility;

2) Unable to maintain price anchoring, requiring continuous subsidies to maintain consistency between futures and spot prices;

3) Path dependency issue. The further the price deviates, the higher the maintenance cost.

Even the ancestor of vAMM, Perpetual Protocol, is considering new directions, 'Perp V2 will adopt a more proactive market-making strategy to avoid the funding rate loss issues seen in V1. The new version will integrate the functionalities of Uniswap V3, and the team believes that the solution for decentralized perpetual contracts lies in the organic combination of CLOB and AMM models.'

This transformation essentially changes the vAMM, which relies on mathematical formula pricing, to a market maker actively quoting. The risk is transferred from the protocol to the market.

Currently, the AMM model may only be applicable to spot. On-chain contract trading still needs to maintain a balance between decentralization and centralization.

Next, let's talk about vAMM, which is also the most difficult part. This might be a good sleep aid.

vAMM (virtual AMM)

Perpetual Protocol's vAMM uses the same X * Y = K constant product formula as Uniswap.

For spot AMMs like Uniswap, users trade directly based on LP, and the price ratio of LP assets reflects the spot price.

The vAMM actually has a two-layer structure, where LP is the collateral, and real assets are stored in the smart contract vault. The vAMM is essentially a price discovery mechanism after users open leverage.

For example,

1/ Assume the current price of ETH is 4000 USDT, the initial vAMM pool is 100 ETH and 400,000 USDT.

2/ Alice uses 100 U as margin to go long ETH with 10x leverage,

1) Alice deposits 1000 U into the smart contract as margin.

2) Perpetual Protocol will record 10,000 U (100 U × 10x leverage) in vAMM, and vAMM will calculate the ETH Alice should receive based on the constant product formula X * Y = K.

Initial state X * Y = K 100 ETH * 400,000 U= 40,000,000

After Alice deposits 1000U, it becomes 410,000 U. X = K / Y 40,000,000 / 410,000 = 97.5609 ETH

Alice actually obtains about 2.44 ETH.

At this point, the state within the vAMM updates to 97.5609 ETH and 410,000 U.

3/ Bob subsequently uses 1000 U as margin to short ETH with 10x leverage,

1) Bob deposits 1000 U into the same contract. Perpetual Protocol will record -10,000 vDAI in vAMM, and vAMM will calculate Bob's short position size based on the constant product formula X * Y = K.

Bob shorted 2.4391 ETH, at this point the state within the vAMM returns to 100 ETH and 400,000 U.

The price mechanism also adopts a funding rate mechanism, similar to the funding payments of perpetual contracts on CEX.

Specific formula, using FTX Exchange's:

There is actually a point here that is very, very, very important for understanding the difference between vAMM and traditional CEX contracts.

In CEX, each long position has a corresponding short position, meaning there is a real counterparty, so holding users will pay funding rates. The exchange is merely a trading venue, bearing no holding risks. In vAMM, the situation is completely different.

It can be seen that the vAMM uses X * Y = K for pricing, and assets are collateralized into the contract. So essentially, it is trading based on the price curve, rather than a real counterparty.

Therefore, once facing long and short imbalances, the protocol needs to find ways to attract real counterparties, and the method of attraction is subsidies.

This makes the stability of subsidy sources and the fee pool extremely important, directly affecting the project's survival.

Especially in one-sided markets or during sharp price fluctuations, the fund pool acts like shorting volatility. The characteristics of shorting volatility are precisely small profits during normal times and large losses during fluctuations.

Drift innovated on the basis of Perpetual Protocol's vAMM and launched dAMM (dynamic AMM), with the distinction that parameters can be configured to address issues such as price deviation, asymmetric long and short counterparties, depth, etc. However, there are still some issues that cannot be resolved.

Drift AMM

Drift adopts a dynamic AMM, improving upon Perpetual Protocol's innovative virtual AMM (vAMM), but with the following configurable parameters:

  • Peg: Price multiplier. Controls the degree of deviation between contract price and spot price, almost through rigid control, anchoring the contract price to the spot price.

  • K: Controls the depth of liquidity, the larger the K value, the better the depth and the less slippage. Conversely, in cases where the contract price deviates significantly from the spot price, reducing the K value helps induce price fluctuations, bringing the contract price closer to the spot price.

  • Fee Pool: Income is mainly used to adjust Peg and K.

In conjunction with the four cases of oracle price (contract price) and marked price (spot price) deviation, the following table is provided.

1/ Peg (anchoring multiplier)

When the vAMM contract price deviates from the market spot price, it is used to quickly adjust the price to bring the underlying price closer to the real market price.

Formula:

Price = ( Y / X ) * Peg

Price = (Base Asset / Quoted Asset) * Peg multiplier

Adjustment plan

Check the oracle-marked price deviation after each transaction. If the deviation exceeds the LIQ_LIMIT value (currently 10%), there will be two options,

1) If the fee pool reserves are sufficient, directly adjust the Peg to re-anchor the price;

2) If the fee pool reserves are insufficient, we will compare two types of costs:

Fee subsidies, the cost of attracting arbitrage, and the cost of directly re-anchoring.

In general, it is considered to first lower the K value, reducing liquidity depth, making it easier to push the price.

After the adjustment, the positions of the losing party will be accurately marked for losses, while the positions of the profitable party will be supplemented by the fee pool.

2/ k (liquidity depth)

Control the size of slippage. This is actually easy to understand, because it is X * Y = K, a larger K value means more of both assets X and Y, naturally leading to less slippage.

Of course, because Drift is based on Perpetual Protocol's vAMM, where X * Y = K acts as the pricing mechanism after leverage, and not real LP assets, the K value can be adjusted.

To summarize,

The k value controls the sensitivity of price to trading volume;

Peg adjustment of the absolute price level

3/ Fee Pool

Not only income but also a market adjustment tool. Purpose: To adjust Peg and k values, and to replenish the profits of profitable traders while paying for funding rate imbalances.

The main source of income for the fee pool,

1) Taker eats order fee, base rate 0.05-0.1%;

2) Liquidation fees, 50% to the fee pool;

3) Funding rate income.

At this point, it can be seen that this model heavily relies on the health of the fee pool. This will cause Drift to lose an advantage in transaction fees, which is one.

Another more fundamental issue is that income growth is linear, with trading volume * transaction fees = income, but expenses may become exponential as the market moves unilaterally, while price deviation squared * position size * time = expenses.

Therefore, from a longer-term perspective, expenses cannot fully cover income.

This is also why Drift decided to abandon vAMM and embrace centralized market making.

To summarize,

In the vAMM model, users must deposit margin to trade perpetual contracts, which is used for potential liquidation. The X * Y = K formula is actually used as a pricing curve.

Thus, based on this formula, Drift changed the pricing method, adding the Peg anchoring multiplier, while also allowing the K value to be adjustable, in order to anchor the contract price to the spot price. During the adjustment process, any profits from user positions are supplemented by the fee pool.

Thus, this makes the fee pool extremely important, but in the long run, in extreme market conditions, expenses will grow exponentially while income can only grow linearly, leading to a net subsidy for unbalanced positions in the protocol.

Simply controlling on-chain AMM through mathematical formulas is currently unfeasible; centralized market makers are still needed to balance counterparties, which is the essence of perpetual contracts.