Did you know that when you’re providing liquidity or trading on Perp v2, you’re actually trading virtual tokens through pools on Uniswap v3? Read on to learn more about how virtual tokens are used to represent your positions.
Simply put, a virtual token (or vToken) is a synthetic asset with no intrinsic value, used for accounting purposes. The base asset, also known as vBase, is the underlying asset you’re trading and the quote asset is always USD. For example, when trading ETH-USD on Perp v2, you are actually trading virtual ETH (or vETH) against vUSD via the Uniswap v3 pool.
In traditional markets, a clearinghouse is an intermediary that validates transactions between buyers and sellers, however for Perp v2, it is actually a smart contract! For all positions on Perp v2, the clearinghouse manages all trades for users, which you can see executed in real time here.
Uniswap v3 is used as the backend Automated Market Maker (AMM), which takes virtual tokens so that only the clearinghouse owns these tokens and can interact with the AMM. The vTokens are non-transferable outside of the clearinghouse and do not have any real value. And as all tokens in these pools are minted by the clearinghouse, Uniswap transaction fees can be ignored.
If you go to DEX Screener and look at the data for Uniswap v3 on Optimism, you’ll discover that five out of the ten top markets by trading volume are vToken pairs traded on Perp v2!
Source: DEX Screener
Let’s say you deposit $100 in USDC as collateral, then a total of 1,000 vUSD tokens will be minted allowing you to obtain 10x leverage. You can then get exposure to the asset of your choice by interacting with the corresponding Uniswap v3 pool. The same thing applies to makers who can provide liquidity of up to $1,000.
When trading ETH-USD, what’s happening in the background is that you’re swapping tokens in the vETH-vUSD pool. The difference between this vToken pool and other Uniswap v3 pools is that the vTokens are custodied by Perp’s clearinghouse contract, so they can only be transferred between the clearinghouse and the corresponding Uniswap v3 pool. Also, the clearinghouse mints additional tokens to abstract away from Uniswap’s fees.
Links to all of Perp’s vToken pools on Uniswap v3 are listed here.
If you navigate to the vETH-vUSD pool and go to transactions, you can see the trades happening in real time as vETH is swapped for vUSD (or vice versa). When vETH is swapped for vUSD, then a trader initiates a long position in ETH. However, whenever vUSD is swapped for vETH, then that trader went short on ETH.
Funding rates are used to ensure that the value of the base virtual tokens remains in line with the price of the underlying asset.
To see how vTokens enable long exposure, consider the following example. If the trader opens a long position of $500 in the ETH-USD market, 500 vUSD is minted and then swapped for vETH to get long exposure. To achieve this, the clearinghouse contract swaps 500 vUSD for 0.25 vETH via the ETH-USD AMM’s vault, with the cost basis of $2,000 stored.
The clearinghouse receives 0.25 vETH, which represents the trader’s long position, and manages it on their behalf, while the 500 vUSD minted by the trader is added to the AMM’s vault.
What happens when the trader closes the long position?
The vETH is sold and deposited back into the vault, while the vUSD is burned and the cost basis is set to zero.
If the long position was closed once the price of vETH reached $2,500, then the trader returns 0.25 vETH, which is now worth $625 but their cost basis was just $500. So the difference between these two figures is $125, which is approximately equal to their profit and is returned to the trader along with their collateral.
But if the price falls after the trader takes on a long, then to close out the position they must return the 0.25 vETH at a lower price than their entry price. For example, if 0.25 vETH is only worth $400 when closing the long position, they’ll still have to return an additional $100 in vUSD to the pool and is taken from their collateral.
What if a trader wants to short ETH-USD at a price of $2,000 instead?
In this case, the clearinghouse mints 0.25 vETH and registers a debt of $500. The virtual ETH tokens are added to the ETH-USD AMM vault and swapped for 500 vUSD, which results in a vETH position of -0.25. This negative position in the base token represents a leveraged short.
Let’s say the price of ETH falls to $1,500, and the trader closes the short position. The clearinghouse returns 500 vUSD to the ETH-USD AMM while 0.3333 vETH is removed and burned.
Since the difference between the vETH received after closing the trade and the vETH borrowed to open the short position is equal to 0.08333 vETH, at a price of $1,500, this amounts to a profit of $125. The trader can then withdraw their collateral and profit from this trade, totalling $225.
When providing liquidity as a maker, the process is similar, but instead you are minting vETH and vUSD tokens into the pool.
For the same example of $100 USDC in collateral and where ETH-USD is trading at $2,000, a maker can add liquidity to both sides of the pool by minting 250 vUSD and 0.125 vETH. The vETH lent to the maker is recorded as debt and the exact same amount must be paid back once the liquidity position is closed.
The maker can then place their virtual tokens along the price curve in a range where it can then be traded. Traders can then use these virtual tokens to enter positions while makers earn fees for providing liquidity. Whenever someone swaps virtual tokens within the maker’s range, the earned fees are automatically added to the maker’s free collateral.
As the price of ETH-USD fluctuates, the maker’s vToken positions will also change accordingly, since they act as counterparties to positions that are opened by traders within their price range. For example, if the price of ETH increased to $2,500, then the maker’s vETH holdings would fall while their vUSD balance would increase. When the price of ETH decreases, the maker’s vETH holdings increase and their vUSD balance falls.
Whenever the maker wants to remove their liquidity, the clearinghouse repays the 0.125 vETH in debt, unlocks the maker’s USDC in the vault and sends it back to them, as well as adding their profit or deducting their loss. In the case where the ETH price rises above $2,000, then the maker’s debt will be higher in dollar terms and they’ll incur a loss when returning the 0.125 vETH (unless their income from trading fees is enough to outweigh this amount).
Note that makers can also provide single-sided liquidity, in which case they would only supply either vETH or vUSD to the pool. For example, if a maker wanted to provide liquidity below the current price, their liquidity position would be entirely made up of vUSD, whereas for the case where liquidity is provided above the current price, the position would be made up of just vETH.
In summary, trading on Perp v2 is facilitated by Uniswap v3 pools that allow takers to swap vTokens to establish long or short positions, while makers can use their collateral to mint vTokens and then add them to the pool to earn trading fees.
Virtual tokens do not hold any value and can only be transferred via the clearinghouse, enabling Perp to track on-chain derivatives positions utilizing the Uniswap v3 infrastructure that DeFi users are familiar with.