DPerp - Perpetual Trading

DPerp enables leveraged perpetual trading of synthetic assets using a CEX-style order book model with trader-to-trader matching. The system provides up to 50x leverage with cross-margin support and direct counterparty trading without liquidity pools.

Overview

DPerp provides:

  • Central limit order book (CLOB) trading like traditional exchanges

  • Trader-to-trader counterparty matching (no LP pools)

  • Oracle-anchored mark pricing for fair liquidations

  • Cross-margin system for capital efficiency

  • Price-deviation based funding rates

  • Professional trading features and order types

Architecture

User Interface (Trading API)

    Order Book Engine (Off-chain)

    Trade Matching & Settlement (On-chain)

┌─────────────────────────────────────────┐
│  MarketRegistry │ PositionManager       │
│  OracleModule   │ MarginAccount         │
│  FundingEngine  │ OrderBook             │
└─────────────────────────────────────────┘

Core Components

  • OrderBook: CEX-style order matching with price-time priority

  • PositionManager: Cross-margin position tracking and PnL

  • MarginAccount: Unified collateral management across positions

  • FundingEngine: Oracle-anchored funding between traders

  • MarketRegistry: Market configuration and trading parameters

  • TradeEngine: Batch settlement of matched trades

Key Features

CEX-Style Order Book Trading

  • Central Limit Order Book: Price-time priority matching like Binance/Bybit

  • Trader-to-Trader: Direct counterparty matching without LP intermediaries

  • Professional Orders: Limit, Market, Stop, Take-Profit, IOC, FOK

  • Partial Fills: Large orders filled incrementally across multiple counterparties

  • Real-Time Matching: Sub-second order execution and matching

No Liquidity Pool Model

  • Direct Trading: Traders trade directly against each other

  • No LP Risk: No liquidity providers acting as counterparties

  • Market-Driven Pricing: Order book determines execution prices

  • Zero Protocol Directional Risk: Protocol never takes trading positions

  • Pure Matching: Protocol only facilitates trade matching and settlement

Oracle-Anchored Risk Management

  • Mark Price = Oracle Price: Liquidations and funding use oracle prices

  • Fair Liquidations: Prevent manipulation through order book pricing

  • Funding Mechanism: Based on price deviation from oracle

  • Risk Calculations: All margin and health checks use oracle data

Cross-Margin System

  • Shared Collateral: Single margin pool across all positions

  • Portfolio Margining: Offsetting positions reduce margin requirements

  • Capital Efficiency: Maximize leverage with available margin

  • Unified Risk: Holistic portfolio risk management

Supported Markets

Cryptocurrency Perpetuals

  • BTC/USD: Bitcoin perpetual (up to 50x leverage)

  • ETH/USD: Ethereum perpetual (up to 50x leverage)

  • BNB/USD: Binance Coin perpetual (up to 25x leverage)

  • SOL/USD: Solana perpetual (up to 25x leverage)

  • AVAX/USD: Avalanche perpetual (up to 25x leverage)

Equity Perpetuals

  • AAPL/USD: Apple perpetual (up to 10x leverage)

  • TSLA/USD: Tesla perpetual (up to 5x leverage)

  • GOOGL/USD: Google perpetual (up to 10x leverage)

  • AMZN/USD: Amazon perpetual (up to 10x leverage)

  • MSFT/USD: Microsoft perpetual (up to 10x leverage)

Commodity Perpetuals

  • GOLD/USD: Gold perpetual (up to 20x leverage)

  • SILVER/USD: Silver perpetual (up to 20x leverage)

  • OIL/USD: Crude Oil perpetual (up to 20x leverage)

Forex Perpetuals

  • EUR/USD: Euro perpetual (up to 100x leverage)

  • GBP/USD: British Pound perpetual (up to 100x leverage)

  • JPY/USD: Japanese Yen perpetual (up to 100x leverage)

Position Operations

Opening Positions via Order Book

Position Management

Position Structure

CEX-Style Trading Model

Order Book Mechanics

  • Price-Time Priority: Best price first, then earliest timestamp

  • Continuous Matching: Real-time order matching as orders arrive

  • Depth Aggregation: Multiple orders at same price level

  • Spread Management: Natural bid-ask spread from trader orders

  • Market Impact: Large orders move through multiple price levels

Trade Execution Flow

No Liquidity Pool Counterparty

Unlike GMX/GLP model:

  • ❌ No LP tokens or liquidity providers

  • ❌ No protocol acting as counterparty

  • ❌ No pool-based PnL calculations

  • ✅ Direct trader-to-trader matching

  • ✅ Market-driven price discovery

  • ✅ Zero protocol directional exposure

Margin System

Cross-Margin Benefits

  • Capital Efficiency: Use same collateral for multiple positions

  • Risk Netting: Offsetting positions reduce margin requirements

  • Simplified Management: Single margin balance to monitor

  • Portfolio Approach: Holistic risk assessment

Margin Calculations

Leverage Limits by Asset Category

Asset Category
Max Leverage
Maintenance Margin

Major Crypto

50x

2%

Minor Crypto

25x

4%

Major Equities

10x

10%

Volatile Equities

5x

20%

Commodities

20x

5%

Forex

100x

1%

Funding Mechanism (Trader-to-Trader)

CEX-Style Funding

Funding flows directly between traders, not through liquidity pools:

Direct Payment System

  • Long Positions: Pay funding when order book price > oracle price

  • Short Positions: Receive funding when order book price > oracle price

  • No Protocol Capture: 100% of funding flows between traders

  • Hourly Settlement: Funding applied every hour automatically

Funding Calculation Example

Funding Rate Caps

  • Crypto: ±10% daily maximum

  • Equities: ±5% daily maximum (market hours), ±1% (after hours)

  • Commodities: ±8% daily maximum

  • Forex: ±15% daily maximum

Order Types & Execution

Professional Order Types

  1. Limit Orders: Execute at specified price or better

  2. Market Orders: Execute immediately against best available orders

  3. Stop Orders: Trigger market order when price reaches stop level

  4. Take Profit: Close position when profit target reached

  5. IOC (Immediate or Cancel): Execute immediately or cancel remainder

  6. FOK (Fill or Kill): Execute completely or cancel entire order

  7. Post-Only: Only add liquidity (reject if would match immediately)

  8. Reduce-Only: Only reduce existing position size

Order Matching Engine

  • Price Priority: Better prices matched first

  • Time Priority: Earlier orders at same price matched first

  • Pro-Rata: Large orders split across multiple counterparties

  • Self-Trade Prevention: Users cannot trade against themselves

  • Minimum Size: Prevent dust orders and spam

Execution Examples

Liquidation System

Liquidation Triggers

A position is liquidatable when:

  • Margin Ratio: Below maintenance margin requirement

  • Oracle-Based: Uses mark price (oracle) for calculations

  • Cross-Margin: Considers entire portfolio health

Liquidation Process

  1. Health Monitoring: Continuous position health checks

  2. Liquidation Call: Liquidator calls liquidatePosition()

  3. Price Validation: Confirm position is liquidatable at oracle price

  4. Position Closure: Close position at mark price

  5. Liquidator Reward: 0.5% of position size + fixed fee

Auto-Deleveraging (ADL)

When liquidations cannot be filled:

  1. Ranking: Rank profitable positions by PnL and leverage

  2. Selection: Choose highest-ranked positions for ADL

  3. Execution: Force close positions at mark price

  4. Compensation: ADL participants receive small compensation

Risk Management

Oracle Security

  • Primary Source: Pyth Network for real-time prices

  • Fallback: Chainlink for established assets

  • Validation: Staleness and deviation checks

  • Circuit Breakers: Pause trading on extreme price moves

Position Limits

  • Max Position Size: Per-market position size limits

  • Open Interest Caps: Maximum total long/short per market

  • Concentration Limits: Prevent excessive exposure to single asset

  • User Limits: Per-user position size restrictions

Market Hours Logic (Equity-Specific)

Market State
Funding Behavior
Trading

Market Open

Normal funding rates

Full trading

Market Closed

Capped funding (±1%)

Limited trading

Trading Halt

Funding paused

Trading paused

Extreme Volatility

Emergency clamp

Circuit breaker

Fee Structure

Trading Fees (Maker/Taker Model)

Asset Category
Maker Fee
Taker Fee

Major Crypto

-0.01% (rebate)

0.05%

Minor Crypto

0.00%

0.08%

Equities

0.02%

0.10%

Commodities

0.01%

0.07%

Forex

-0.005% (rebate)

0.03%

Other Fees

  • Funding Fees: Variable, paid between traders

  • Liquidation Fee: 0.5% of position + $5 fixed

  • ADL Compensation: 0.1% of ADL'd position

DUSD Staking Integration

Protocol Backstop

DUSD staking provides the economic backbone:

  • Insurance Fund: Staked DUSD backs the insurance fund

  • Bad Debt Coverage: Stakers absorb losses after insurance fund

  • Revenue Sharing: Stakers earn from trading fees and liquidations

  • Governance Rights: Participate in risk parameter decisions

Staking Tiers

Lock Period
Reward Multiplier
Risk Level

Flexible

1.0x

Low

3 months

1.1x

Low

6 months

1.25x

Medium

12 months

1.5x

High

Loss Waterfall

Integration Examples

Perpetual Trading

Position Monitoring

Order Book Monitoring

Liquidation Bot

Smart Contract Architecture

Core Contracts

Security Features

Access Control

  • Role-Based Permissions: Admin, Liquidator, Keeper roles

  • Multi-Signature: Critical functions require multiple signatures

  • Timelock: Parameter changes have execution delay

  • Emergency Pause: Immediate trading halt capability

Oracle Protection

  • Multiple Sources: Pyth + Chainlink redundancy

  • Staleness Checks: Reject outdated price data

  • Deviation Limits: Maximum price movement per update

  • Circuit Breakers: Automatic pause on extreme moves

Economic Security

  • Insurance Fund: Protocol-owned reserves for bad debt

  • DUSD Staking: Community-backed insurance mechanism

  • Position Limits: Prevent excessive concentration risk

  • Liquidation Incentives: Ensure timely liquidation execution

Benefits

For Traders

  • CEX-Like Experience: Familiar order book trading interface

  • Direct Counterparty: Trade directly against other traders

  • Professional Tools: Advanced order types and execution options

  • Fair Pricing: Market-driven price discovery through order book

  • High Leverage: Up to 100x on forex, 50x on crypto

  • Cross-Margin: Efficient capital utilization across positions

For Market Makers

  • Maker Rebates: Earn fees for providing liquidity to order book

  • Professional APIs: High-frequency trading support

  • Risk Management: Sophisticated position and risk controls

  • Institutional Features: Large order handling and execution

For the Protocol

  • Zero Directional Risk: Never acts as counterparty to trades

  • Sustainable Model: Earn fees from trade facilitation only

  • Scalable Architecture: Order book model supports unlimited throughput

  • Market Neutral: Protocol success independent of trader PnL

Last updated