Technical Documentation

Futures Contract Specifications

Open Mandi offers perpetual futures contracts for gold (XAU) and silver (XAG), collateralized with USDT or USDC. This document details the contract parameters, margin model, and liquidation mechanics.

Gold Futures (XAU/USD)

ParameterValue
SymbolXAU-PERP
UnderlyingGold spot price (USD)
Contract TypePerpetual (no expiry)
Contract Size0.001 troy ounce per contract
Tick Size$0.01
CollateralUSDT or USDC
Maximum Leverage50x
Initial Margin2% of position notional
Maintenance Margin1% of position notional
Maker Fee0.02%
Taker Fee0.05%

Silver Futures (XAG/USD)

ParameterValue
SymbolXAG-PERP
UnderlyingSilver spot price (USD)
Contract TypePerpetual (no expiry)
Contract Size0.1 troy ounce per contract
Tick Size$0.001
CollateralUSDT or USDC
Maximum Leverage50x
Initial Margin2% of position notional
Maintenance Margin1% of position notional
Maker Fee0.02%
Taker Fee0.05%

Price Feed Integration

The mark price for each futures contract is derived from an external price oracle providing real-time spot prices for gold and silver in USD. Two prices are maintained:

  • Index Price — the external reference price from the oracle, representing the global spot market consensus
  • Mark Price — a weighted combination of the index price and the order book mid-price, used for liquidation calculations and unrealized PnL
markPrice = (indexPrice * 0.7) + (orderBookMidPrice * 0.3)

// If order book is empty or illiquid:
markPrice = indexPrice

Margin Model

Initial Margin

The initial margin is the collateral required to open a position. It is calculated as:

initialMargin = (quantity * contractSize * markPrice) / leverage

Example (Gold, 10x leverage):
  quantity = 100 contracts
  contractSize = 0.001 oz
  markPrice = $2,850
  initialMargin = (100 * 0.001 * 2850) / 10 = $28.50

Maintenance Margin

The maintenance margin is the minimum collateral required to keep a position open. If unrealized losses cause the remaining margin to fall below this threshold, liquidation is triggered.

maintenanceMargin = quantity * contractSize * markPrice * 0.01

// Liquidation occurs when:
// margin + unrealizedPnL < maintenanceMargin

Liquidation Mechanism

Liquidation is the forced closure of a position when the trader's margin can no longer sustain the position. The process:

  1. The liquidation engine continuously monitors all open positions against the current mark price
  2. When a position breaches the maintenance margin threshold, a liquidation order is placed as a market order on the opposite side
  3. The position is closed at the best available market price
  4. Remaining margin (if any) is returned to the trader's wallet
  5. If the liquidation results in a shortfall (negative equity), the insurance fund absorbs the loss

Liquidation Price Calculation

// For long positions:
liquidationPrice = entryPrice * (1 - (initialMarginRate - maintenanceMarginRate))

// For short positions:
liquidationPrice = entryPrice * (1 + (initialMarginRate - maintenanceMarginRate))

Funding Rate

As perpetual contracts have no expiry date, a funding rate mechanism keeps the futures price anchored to the index price:

  • When the futures price trades above the index, longs pay shorts
  • When the futures price trades below the index, shorts pay longs
  • Funding payments are exchanged every 8 hours
fundingRate = clamp(
  (futuresMidPrice - indexPrice) / indexPrice,
  -0.01,  // max -1% per interval
  +0.01   // max +1% per interval
)

payment = positionNotional * fundingRate