Protocol Documentation
PerpX Non-Custodial Perpetual DEX Architecture, Mathematical Specifications & Integration Guide
1. Smart Contract Architecture
PerpX is built around modular Solidity smart contracts compiled with Solidity 0.8.24 via Foundry. Accounting, positions, leverage, and liquidations are enforced strictly on-chain.
Holds ERC-20 collateral (USDC), maintains internal balances, locks isolated margin, and processes deposits/withdrawals.
Opens, tracks, increases, reduces, and closes perpetual positions. Computes weighted average entry prices and realizes PnL.
Maintains cumulative funding indices for continuous settlement based on mark vs index price premium.
Evaluates isolated & cross-margin health on-chain, executes 50% partial liquidations, and rewards liquidator keepers.
Holds protocol reserves to absorb bad-debt deficits if a position is liquidated past negative equity.
Enforces slippage protection for market orders and verifies EIP-712 structured signatures for off-chain limit orders.