Below are good resources on the virtual AMM and perpetual swaps. This article will require some basic knowledge on AMMs, DeFi and derivatives. Feel free to dive into the source material below if you’d like a refresher! 👇🏽
- Drift DAMM Deep Dive — Drift Protocol (@bigz_pubkey)
- A Deep Dive into our Virtual AMM (vAMM) — Perpetual Protocol
- On vAMM’s Unnecessity for Liquidity Pool — Qmeasure
- vAMM Terminology — Drift Protocol Perpetual Swaps
- Derivatives Trading/Exchange Terminology — Drift Protocol
- Funding Rates/Capped Symmetric Funding — Drift Protocol
Drift and the Dynamic vAMM (DAMM)
What is Drift?
Drift Protocol is a decentralised, fully on-chain perpetual swap exchange built on Solana. Drift currently offers seven tradable markets, including: SOL, BTC, ETH, LUNA, AVAX, BNB and MATIC.
Drift Protocol launched on open mainnet in December 2021. Since then, Drift has traded over $700mm in cumulative volume and has launched at least one new market every week.
How is Drift different from other perpetual DEXs?
Drift uses a Dynamic Virtual AMM (DAMM) for price discovery and an on-chain clearinghouse program for margining and settlement of profits and losses on the platform. This combination allows for a censorship-resistant trading experience.
Dynamic vAMM: Drift uses a dynamic vAMM (virtual Automated Market Maker) rather than a traditional order-book used by other perpetual CEXs and DEXs. Drift’s DAMM adjusts virtual reserves that adapts to the demand for trading in the market.
On-chain Infrastructure: Drift’s trading infrastructure is entirely on-chain — everything from margining, order-matching and settlement is on-chain. This gives users a fully decentralised and non-custodial trading experience.
What is a Virtual AMM?
A virtual Automated Market Maker abstracts away swapping assets from the price curve, which serves purely for price discovery.
User collateral is first deposited into a vault which gives the user margin to open positions with leverage, the maximum of which is configurable by the protocol (Drift currently allows for max 5x leverage).
The user is “credited” margin to trade on the platform. This margin exists as a state variable, backed by collateral deposited on the platform and changes based on a user’s trading PnL. Each trade pushes the price of the vAMM curve up or down, with no collateral exchanged during the process. The margin settlement occurs outside of the vAMM, so no actual cash is swapped against the vAMM.
For more information around vAMM dynamics, we would recommend this seminal article by Perpetual Protocol on their v1 mechanism.
What is a Dynamic vAMM (DAMM)?
Drift’s Dynamic vAMM builds on the concept of a virtual AMM, with mechanisms to ensure optimal slippage and liquidity for traders by ensuring that prices are always trading at the part of the curve with the deepest liquidity and that the available virtual liquidity corresponds to the trading demand available.
It’s helpful to think of the Dynamic AMM as an optimisation problem to ensure that markets are always healthy, which is determined by a few conditions:
- Contract prices that track an underlying oracle price closely. This is ensured by a funding rate mechanism that charges interest for positions that push prices out of convergence.
- Deep liquidity for market orders shown by low slippage for traders. If slippage is too high, this means that the demand for trading was higher than the estimated demand implied by the amount of virtual assets.
The DAMM has two mechanisms in order to achieve these “ideal” conditions:
- Re-pegging — Re-pegging refers to modifying the peg multiplier to be closer to the oracle. Re-pegging effectively updates the quote asset reserves while still using the most liquid region of the curve, where the amount of quote assets equals the amount of base assets. Re-pegging is useful when the prices have moved far above or below the price at which the virtual pool initially started.
- Adjusting liquidity (k-factor) — Adjusting k-factor can be thought of as depositing or removing liquidity from the pool in a normal AMM. This means increasing or decreasing the amount of virtual assets (x and y, or base and quote reserves) that are allowed to be swapped within the pool, except that these reserves are virtual.
There are two important points to note within this optimisation problem:
- Adjusting liquidity and re-pegging is not free; there is a cost involved. This is paid out of the Fee Pool. This cost will be explained further in the “How are the trading parameters of a DAMM configured?” section below.
- How do we set the ideal k without jacking up funding rates?
There is a careful balance that needs to be made while adjusting k. While it seems like the right solution to simply set an unrealistically high k and grant infinitely low slippage to market participants, this means that the amount of capital needed to arbitrage prices back to the oracle price (condition #1 in the Ideal Market condition) will also grow. If there isn’t enough arbitraging capital, this could lead to sustained high funding payments that, in the event of long-short imbalances, will need to be paid out from the Insurance Fund.
Re-pegging and liquidity adjustments will be explained in more depth in Part 2 of this article series.
What’s the difference between a vAMM and a DAMM?
A virtual AMM is a negative-sum system; the maximum profits a trader can make is equal to the total collateral deposited by others into the pool, minus cumulative fees paid.
A dynamic virtual AMM (DAMM) is closer to a fair zero-sum game; the fees that traders pay to the system are given back to traders who hold positions in the system via adjusting the k-constant and the terminal price to incentivise longer-term growth in volume and open interest over time.
This means that in a DAMM, slippage should remain dynamically low even as trading interest in the vAMM grows. In a DAMM, the virtual reserves in a pool grows as demand to trade grows. Drift’s DAMM also runs curve re-pegging operations to keep liquidity centred at the deepest part of the curve, with the lowest slippage.
Why would anyone want to trade on a DAMM?
- A vAMM is a designated on chain market maker (a maker that will never pull liquidity). This means that pricing is always transparent, and can reflect depth that traders are willing to pay.
- Takers can swap risk asynchronously (number of longs doesn’t have to equal number of shorts). In other words, liquidity is always present.
- Takers don’t have to risk giving makers value that can be extracted from the pool (term: market maker extractable value or MMEV). An example of MMEV is market makers who eventually extract spread profits from the available liquidity pool.
- Instead of giving makers value, takers can act like a co-op; the fees they pay go into a fee pool and are rebated across takers and the insurance fund. Put another way, paying fees itself is a way to contribute to liquidity. The protocol fees are used to backstop positions as well as to contribute to future liquidity.
Who’s my counter-party in a DAMM?
Drift’s system is peer-to-pool. Settlement is trader-to-trader while liquidations are secured by the platform’s Insurance Fund. One long trade pushes the price curve up; another short trade of the same magnitude pushes the price down by the same amount. Prices moves based on how much capital is placed to move the curve and profits can only be realised when there are other traders who trade in your direction after you’ve traded.
Are there any Liquidity Providers in a DAMM?
In a virtual AMM, there is technically no liquidity provider and there is no impermanent loss. While a virtual AMM can exist entirely without any external liquidity — all that is required is a trader who shows up and wishes to trade against it — our Dynamic vAMM (DAMM) is built with the backstop protocol as a liquidity provider benefiting traders.
On our DAMM, the protocol is technically the liquidity provider, with fees collected from taker orders improving liquidity on the platform by using it for curve adjustments. As the protocol insures against leveraged losses, the protocol is the backstop of the last resort.
How are the trading parameters of a DAMM configured?
Drift’s DAMM is the first completely configurable vAMM (hence, dynamic vAMM or DAMM).
The parameters of the DAMM directly determine market depth, which determines how much slippage is paid by a trader. By slippage, we mean the price impact of entering a position. For instance, if entering a 10 ETH trade in the platform pushes the price by .3%, we consider the slippage of the trade .3%, or 30bps.
The DAMM price is configured by the:
- Peg: A price multiplier, which is defined as the oracle price at the initialisation of the curve. The peg can be changed via re-pegging operations, which alters the quote asset amount of the pool to keep trading happening at the most liquid part of the curve.
- k: The invariant of the x*y=k curve; this is the liquidity depth parameter, as it determines the amount of available liquidity at any price point.
- Fee Pool: This is the fee pool that pools together total fees paid from traders to the platform. Rebates and payments are paid from the fee pool to adjust the curve.
- Tranches: Percentage allocations from the Fee Pool to be distributed amongst the following operations: (1) peg adjustments (alternatively, “re-peg”), (2) k/depth adjustments, and (3) (capped) funding payments
To summarise the DAMM:
- when a trader takes a position, they pay a fee to the protocol. Rather than immediately being paid back to token holders or stakers, this fee is used to move the market towards its optimal state — meaning that the demand for trading is matched by the virtual liquidity offered by the exchange, giving the ideal price depth demanded by the market; and
- given the DAMM is configurable, it aims to optimally allocate the fee pool to incentivise more and more volume so that allocations between funding payments, re-pegging and depth-adjustments are entirely adaptable to current market conditions.
The research goal is for the entire process to be systematised and transparent.
Why will Drift succeed?
Drift works because there is a positive feedback loop between fees collected and volume — thereby incentivising more volume growth over time.
This results in traders taking liquidity → paying a taker fee → taker fee being rebated/redistributed back to position holders.
The position holders are incentivised for the protocol to collect even more fees since it:
- Lowers the imbalance risk; and
- Reduces slippage to exit their positions.
The next article in this series will focus on the pitfalls of an OG virtual AMM and how the DAMM keeps it in line with the oracle price by introducing two operations in detail: re-pegging and k-adjustment. We’ll discuss the ideal conditions of the DAMM, and how to achieve depth-demand parity in a perpetual market.
Later in the series, we’ll end with some open questions about the DAMM, and discuss limitations of the DAMM and how we can improve the DAMM by adding the concept of a decentralised limit order framework.