The vAMM Powering nftperp: Exploring and Explaining Design Choices
NFT Financialization
In our last article, we explored the “why” behind nftperp, detailing the various use cases envisioned for JPEG traders, funds, collectors, and more. Now it’s time to address the “how” as we take a look under the hood at the innovative vAMM model that allows nftperp to provide liquidity and solvency for perpetual futures on an expanding selection of NFT collections.
Herein we’ll explore the origin and purpose of a virtual AMM, highlighting the reasoning behind this design choice and modifications that have been made to tailor it for nftperp. Most importantly, we’ll walk through some example trades to showcase how the execution works. Let’s dive in.
Virtual AMM Advantages
The vAMM model was pioneered by Perpetual Protocol, and later iterated upon by Drift Protocol, which then became the basis for nftperp. While a traditional AMM like Uniswap uses a liquidity pool to facilitate trading, a vAMM settles trades inside a smart contract vault containing the collateral of all traders for a specific asset. Essentially, one trader’s profit is another trader’s loss in this system, plus there’s no need to attract LPs and maintain a liquidity pool by directing fees to those LPs. This is a particularly advantageous model for perpetual futures trading since it allows for leverage and shorting without risking impermanent loss to the LPs. Perpetuals on traditional AMMs are also bound by how much open interest can be created by the amount of liquidity in the pool, another issue that is avoided with the vAMM model.
Under the hood of a vAMM
Like a traditional AMM such as Uniswap, vAMMs use a constant product formula x*y=k, where x is the asset being traded and y is the quote/collateral asset. In nftperp’s case x is the synthetic asset representative of a collection’s floor price and y is ETH. Initial x and y values are set by the AMM creator, split to have an equal value between both assets.
When creating a perpetual futures position in a vAMM the user is depositing collateral (the y asset) into the vault, and is credited with an equivalent value of the asset they wish to trade (the x asset). X and y values in the vault are changed, but the constant (k) does not, and when you graph all the combinations of x and y that satisfy the constant product formula (multiply together to equal k) you get what is known as a bonding curve. This bonding curve determines the execution price for each trade, varying based on the amounts of the x and y assets in the vault.
Funding Rates
When open interest leans heavily towards either longs or short, the position on the bonding curve moves farther from the center. This means the execution price for trade will deviate more from the actual oracle price of the underlying assets, which is known as slippage. For this reason a Funding Rate is introduced, where position holders on the more heavily weighted side of the trade periodically pay a fee to those on the lighter side. This mechanism incentivizes balance in open interest between longs and shorts, thus keeping execution in the center of the bonding curve where slippage is lowest. In the simplest of terms, when there is a larger volume of longs the holders of those positions pay the holders of short positions, and vice versa.
vAMM Disadvantages and Nftperp’s Unique Changes to the Model
As useful as the original vAMM model is for perp trading, some changes were necessary to more strongly enforce equilibrium. In previous iterations, the fixed nature of virtual liquidity (amounts of x and y assets) put the system at risk of large long vs short and funding payment imbalance, as well as high slippage on trades. Nftperp has introduced more flexibility to the vAMM model, with the main adjustments being:
- Convergence Events — when the price of a perpetual futures contract deviates from the oracle price of the underlying asset by over 5% for more than 8 hours (length of 1 funding period) a convergence multiplier is introduced to match the execution price of the contract to the oracle price. Once a convergence event is triggered virtual liquidity resets to the center of the bonding curve.
- Dynamic k contraction/expansion — dependent on the level of open interest, the constant k is allowed to contract or expand, while maintaining the same ratio of x to y. This allows nftperp to handle varying levels of open interest with low slippage
- Dynamic Funding Rate — whereas a standard funding rate takes into account position size, contract mark price, and oracle price, nftperp takes into account the total ratio between longs and shorts as well to better balance open interest
- Fluctuation Limiting — this sets a limit of +-2% change in contract price per block, safeguarding the protocol against manipulation via flash loan attacks and insurance fund draining during periods of high volatility. Drift v1 experienced an exploit of this nature where large fluctuations in LUNA price led to an imbalance of unrealized losses and gains within the system, and the excess gains were able to be withdrawn from the insurance fund unchecked.
Nftperp also designed a unique mechanism for floor price calculations to prevent price manipulation through flash attacks and wash trading, both key concerns when dealing with a volatile and illiquid asset class like NFTs. The True Floor Price used within nftperp takes steps to filter out manipulation and outliers, as outlined in this excerpt from the documentation.
The data involved in True Floor Price calculation is collected through a nftperp operated oracle pulling sale data from the Opensea, LooksRare, and X2Y2 APIs. The calculated price is updated each time a qualified public sale occurs, ensuring prices are up to date while protecting users from manipulation. This process has been backtested on real sets of blue chip NFT sale data to demonstrate efficacy, as can be seen below.
Everything Else to Know Before Trading
Collateral
As nftperp will be launched on Arbitrum, wETH will be the form of collateral required to engage in trading. Once a user has wETH on Arbitrum they simply connect their wallet to the platform and approve use of their wETH balance. From there selecting the collection they wish to long or short, entering the amount of capital they wish to trade with, and choosing an amount of leverage anywhere from 1 to 5x.
Leverage
Any experienced trader will tell you that leverage is a double edged sword, amplifying both gains and losses. When trading with leverage on nftperp it is important to be aware of your margin ratio, since collateral will be liquidated if it gets too low. Margin ratio (MR) is calculated by adding your initial collateral and unrealized PnL then dividing by your notional position size. With 2x leverage your MR upon opening a position will start at 50%, and at max leverage of 5x MR will start at 20%. While a position is open the MR will change depending on PnL of the position, so for a long position if the price of the underlying asset (NFT collection) goes up MR will increase, and if asset price goes down MR will decrease. The inverse will occur for short positions, and the higher a position’s MR, the safer it is from liquidation.
Liquidations
Liquidations on nftperp occur at two MR thresholds, with the first being a partial (25% of collateral) liquidation at 12.5% MR, followed by a full (all remaining collateral) liquidation at 10% MR. With this being the case there exists a corresponding liquidation price for the underlying asset at which the liquidation stages will be triggered. Nftperp will provide traders with their MR and liquidation price for a trade prior to them confirming the transaction, so it will be quite clear what risks are for any given position. Liquidations are conducted by keeper bots, which earn 1.25% of the notional position size at liquidation, with the remainder going into the protocol’s insurance fund.
Insurance Fund
The insurance fund is used to offset unexpected losses from liquidations and is also filled by half of the protocol’s .3% transaction fee intake. The other half of transaction fees are evenly split between nftperp token staking rewards and a fund for covering convergence event costs.
Transaction Fees
While base fees are set at .3% this number also scales dynamically with mark price deviations to incentivize balance between shorts and longs. The full schedule for fee scaling is presented below.
Example Trade #1 — Short Position to Hedge
Finally, let’s run through some example trades to give a sense of what this looks like all put together. First, let’s imagine an NFT collector, we’ll call him Jack, who owns a floor-level Bored Ape. Jack notices a couple below floor listings for BAYC going up on marketplaces and wishes to protect his investment with a hedge. In order to fully hedge his Bored Ape against downside risk, Jack goes on nftperp and creates a short position equal in value to the current BAYC floor price, 56.05 ETH.
Since Jack didn’t use leverage his MR is 100%, meaning the BAYC floor would have to reach a price of 105 ETH before his collateral would begin to be liquidated by the protocol. Even in the case of the floor price rising by any amount here, the BAYC Jack owns would go up in value, offsetting the losses in the short. Let’s say over the next week BAYC’s floor price does go down as Jack expected, falling 10% to 50.4 ETH. As a result, the value of his short position is now up 10%, and he is able to offset the losses on his Ape while retaining ownership, giving him a delta-neutral hedge that wouldn’t have been possible without nftperp! If the BAYC floor starts to rise again, Jack can simply close his short, and the profit will be deposited to his wallet, minus the .03% transaction fees, and plus or minus any funding payments he made or received while the position was open.
Example Trade #2 — Unable to Afford NFT But Still Can Trade
For the next example let’s look at a degen NFT trader, we’ll call him Tom, who sees some positive momentum in the market for Moonbirds, but doesn’t have the liquidity on hand to purchase one outright. Tom is confident in the short-term upside here and also more risk-friendly, so he goes to nftperp and creates a long position with 3x leverage.
With 3x leverage, Tom’s initial MR is 33.3%, and at a Moonbirds floor price of 5.62 ETH his position would reach the first liquidation level. Fortunately for our example trader, Moonbirds price appreciates significantly over the next few days, and once it reaches 12 ETH Tom decides to close the position and pocket his gains. At a Moonbirds floor price of 12 ETH, Tom’s PnL is a solid 2.07 ETH before accounting for the funding payments and small transaction fees.
Conclusion
Nftperp has been meticulously designed for robustness in a variety of market conditions, which is extremely important when dealing with NFTs, which as an asset class are quite illiquid and volatile. The Dynamic Virtual Liquidity model, True Floor Price, and various safeguarding mechanisms have all been implemented with the goal of protecting the protocol and its users from manipulation and exploits. All smart contracts have been audited by PeckShield, and the contracts will be open source after the beta closes.
In addition to these safety measures, the protocol is built on Arbitum to provide users with fast transactions at extremely low fees. If you’d like to explore any of the components in further detail please check out the documentation.
Transparency is one of the key selling points for DeFi, and knowing the inner workings of a protocol is essential to using it effectively. Hopefully this article has given you, as a potential user, a meaningful understanding of how the vAMM model powering nftperp works, and why each design choice was made.
Article Written by @Rxndy444