Comment on page

# 2. Phezzan uses vAMM model, how does it work?

Written by the Phezzan team

First, what is an AMM? From the website of Uniswap (first ever AMM in the world):

- An automated market maker (AMM) is a smart contract on blockchain that holds on-chain liquidity reserves. Users can trade against these reserves at prices set by an automated market making formula.

When you buy ETH from ETH-USDC pool from AMM, an on-chain algorithm will determine how much ETH you can get.

In most Automated Market Maker (AMM) DEX, its pools hold a x * y = k invariant, where x and y are the amount of quote token and base token of the market. For example, in a ETH-USDC pool, if the initial ETH amount is 10, and initial USDC amount is 1000, then k = x * y = 10 * 1000 = 10000. Unless someone add or remove liquidity, k stays constant.

**Phezzan Protocol uses virtual AMM (vAMM). That is, there is no real liquidity in the pool.**When you want to 2x long ETH from ETH-USDC pool, our on-chain algorithm will determine how much virtual ETH can you get. Since these ETH are virtual, it is not worth anything outside of Phezzan.

**Since the asset is virtual in liquidity pool, as an LP, as long as you have enough collateral (regardless of USDC, ETH, stETH, etc.), you can provide liquidity to any pool. You don't actually need to own underlying token of the pool.**For example, you don't necessarily need neither ETH nor USDC to provide liquidity for ETH-USDC. As long as you have enough free collateral, you can provide liquidity.

There is no better way to illustrate the trading process other than giving a concrete example. Since there are many kind of AMM algorithm, for simplicity, let's assume the AMM use xy=k algorithm.

In this example, Alice will trade with ETH-USDC pool. The initial state of ETH-USDC virtual AMM will be at 100 virtual ETH (vETH) and 10,000 virtual USDC (vUSDC).

Alice deposits 100 USDC and market buy ETH with 2x leverage.

Since she 2x long, clearing house will mint 100 x 2 = 200 vUSDC. Clearing house will also record Alice contributed 100 USDC and has a cost basis of 200 vUSDC.

The amount of virtual ETH in AMM after Alice's order can be calculated from xy=k invariant.

`100 vETH x 10,000 vUSDC = x * (10,000 + 200) vUSDC`

x= 98.04 vETH (rounded to hundredth decimal for simplicity in this example. In reality, it won't be rounded)

So Alice will receive 100 - 98.04 = 1.96 vETH.

After three days, ETH's price goes up. Now in AMM, there is 11,000 vUSDC and 90.91 vETH. Alice sends her 1.96 vETH to clearing house, to close here position.

The amount of virtual vUSDC in AMM after Alice's order can be calculated from xy=k invariant.

`90.91 vETH x 11,000 vUSDC = (90.91 + 1.96) vETH x `

x = 10767.85 vUSDC (again, rounded to hundredth decimal for simplicity)

So the change of vUSDC is 11,000 - 10767.85 = 232.15 vUSDC. Since Alice's cost basis is 200 vUSDC, Alice's PnL is 232.15 vUSDC - 200 vUSDC = 32.15 vUSDC. So, Alice can get back 32.15 USDC as her profit, along with her 100 USDC for collateral.

So, Alice now has a balance of: 32.15 USDC + 100 USDC = 132.15 USDC

Last modified 1yr ago