UniDex implements a sophisticated fee structure designed to maintain market equilibrium, manage risk, and ensure long-term protocol sustainability. This document outlines the various components of our fee system.

Position Fees

Position fees are applied when opening, increasing, or decreasing a position. The fee is calculated based on the position size and an asset-specific trading rate:

Fee=Size×RateassetFee = Size \times Rate_{asset}

Fee percentage is determined by the asset’s historical volatility and market depth. Because of this, fees can vary between assets and are subject to periodic review. These values are dynamic to encourage more balanced markets and reduce costs for traders taking minority positions.

Dynamic Funding Fees

UniDex utilizes an innovative velocity-based funding fee mechanism. This system balances open interest while providing stability for market makers and reducing costs for traders.

Key variables in the funding fee calculation:

  • targetRatetargetRate: Equilibrium funding rate
  • skewRatioskewRatio: Normalized difference between long and short open interest
  • velocityFactorvelocityFactor: Rate of change towards the target rate
  • riskFactorriskFactor: Based on 14-day average volatility

Dynamic Funding Rate Mechanism

UniDex employs a sophisticated funding rate system to maintain balance in the market. This mechanism adjusts the funding rate based on the difference between long and short open interest:

  1. Long-Dominated Market: When long positions exceed short positions, the funding rate that longs pay to shorts gradually increases. This continues until:

    • The imbalance between longs and shorts falls below a set threshold, or
    • The funding rate reaches its upper limit
  2. Balancing Act: If more short positions open or long positions close, reducing the long-short imbalance, the funding rate begins to decrease. This adjustment continues until the open interest difference falls below the threshold.

  3. Short-Dominated Market: If short positions surpass long positions, the funding rate reverses direction:

    • Shorts start paying longs
    • The rate gradually increases as the imbalance grows
    • This continues until the open interest difference falls below the threshold or the rate hits its upper limit

This dynamic system incentivizes traders to balance the market naturally, promoting stability and liquidity in the UniDex ecosystem.

Borrowing Fees

Borrowing fees mitigate the vault’s risk in taking the opposite side of each trade:

borrowFee=positionSize×borrowRate×durationborrowFee = positionSize \times borrowRate \times duration

The borrowRateborrowRate is asset-specific, based on historical volatility, and periodically reviewed.

Spread Mechanism

To simulate order book dynamics, UniDex implements a spread mechanism:

deltaPercent=Penalty×2×totalOI+positionSize2×vaultTVLdeltaPercent = Penalty \times \sqrt{\frac{2 \times totalOI + positionSize}{2 \times vaultTVL}}
executionPrice=markPrice×(1±deltaPercent)executionPrice = markPrice \times (1 \pm deltaPercent)

Where the ++ sign is used for LONG positions and the - sign for SHORT positions.

The pairPenaltypairPenalty is asset-specific, correlating with historical volatility and market depth.

For assets like BTC/USD and ETH/USD, pairPenaltypairPenalty is 0 due to high liquidity. For less liquid assets, the penalty is higher to encourage more balanced markets and increase the cost of exploitive trading strategies.