Trading Principles & Pricing

Trading Principles

For each trading pair, there is a fund pool on VFX V2. The fund pool is the direct counterparty to traders. If traders make a profit that comes from the fund pool. On the other hand, liquidity providers will make a profit if the LP token's net value when removing liquidity is higher than that when adding liquidity.
YFX offers linear, inverse, and mixed contracts for trading.

Transaction Process

There are two steps involved in opening/closing/editing a position:
  1. 1.
    The user sends a transaction request to the blockchain, including parameters like margin amount and leverage.
  2. 2.
    Keepers observe the blockchain for the request, retrieve the price feed from the centralized oracle, then execute the request.
The price feed from the centralized oracle is the weighted average of three major centralized exchanges.

Oracle Design

There are many ways to obtain prices on the blockchain, but each has some problems.
Price Feeds
Existing Problems
Chainlink & other oracles
  1. 1.
    Time lag
  2. 2.
    Inaccurate feeds
  3. 3.
    Not available on some chains
Uniswap AMM protocol
  1. 1.
    Time lag
  2. 2.
    Price is prone to short-term fluctuations
The weighted average price on centralized exchanges
  1. 1.
    Price feeds may be inaccessible during system downtime
  2. 2.
    Inaccurate feeds
YFX V1 and V2 take the weighted average price on centralized exchanges.
V3 mainly uses Chainlink price feeds, supplemented by the latest price on centralized exchanges.

Price Selection

The index price is the weighted average price on centralized exchanges. The USD index price comes from USD exchanges like Coinbase, Kraken, and Bitstamp, and the USDT index price mainly comes from USDT exchanges like Binance, Huobi, OKX, and Gate.
// Some code
Index Price = (A's Quotation × A's Weight) + (B's Quotation × B's Weight) + (C's Quotation × C's Weight)
YFX will temporarily remove exchanges from index price calculation when the following conditions are met:
  1. 1.
    The latest exchange quotation has not changed for more than 1 minute.
  2. 2.
    The exchange quotation deviates more than 3% from the average of the other four quotations.
CopyRight @YFX.COM