Liquidity Provider Model

Due to the high delay, high network fees, and poor blockchain performance, the traditional order-matching mechanism is almost impossible to implement on the blockchain.
Therefore, most protocols have abandoned the order-matching mechanism and adopted PvPool (PvP) Trading Mechanism.
In light of the underlying mechanism of Uniswap and others, YFX adopts the liquidity provider system common in traditional finance, and traders are the direct counterparty to the liquidity pools.
For each trading pair, there is a fund pool. Users can choose to be either traders or liquidity providers. Traders can make a profit from highly leveraged perpetual trading, while liquidity providers earn transaction fees and profit from selling LP tokens at a higher price.
Note: There will be a 0.1% fee for removing liquidity from the fund pool.

LP Token

When the user adds liquidity to the fund pool, he will get the corresponding amount of LP tokens. The LP tokens are ERC20 tokens representing the right to earn LP rewards. Please do not transfer them to others.
YFX's fund pool is like a mutual fund. Swapping for LP tokens is equivalent to purchasing a share of the fund pool. The PnL for liquidity providers is determined by the LP tokens' price (net value).
Simply put, if the LP token's price when removing liquidity is higher than that when adding liquidity, liquidity providers make a profit. If the price of the LP token when removing liquidity is lower than that when adding liquidity, liquidity providers suffer a loss.

The calculation of the number of LP tokens obtained by adding liquidity:

// Some code
// net_value or Lp_price net value
LP_price = PoolTotalValue / TotalShares.
My_LP_amount = MyDeposit / Lp_price.
Assuming that the current fund pool has 1100 USDC and the total number of LP tokens is 1000, the current price of the LP token is
1100 / 1000 = 1.1 USDC
Assuming Bob adds 110 USDC into the fund pool, the number of LP tokens that Bob should get is
110 / 1.1 = 100 LP tokens

The calculation of the number of LP tokens obtained by removing liquidity:

Assuming Bob wants to redeem all of his LP tokens when the price (net value) of LP tokens increases to 1.5. The amount of USDC that Bob can redeem is:
100 x 1.5 = 150 USDC
Automatic Market Maker global risk parameters and boundary settings
When the index price is outside the bankruptcy price of overall net current positions, the protocol will suspend adding and removing liquidity.
When the available balance of the LP pool is less than 40% of the total market value of the LP pool, users will no longer be able to place new orders.
CopyRight @YFX.COM