Documentation
SUR Protocol Docs
Perpetual Futures DEX on Base L2
Overview
What is SUR Protocol?
SUR Protocol is a decentralized perpetual futures exchange built on Base L2. Trade BTC-USD and ETH-USD with up to 50x leverage (tiered by position size), near-instant settlement, and transparent on-chain execution.
Key Features
- βPerpetual futures with up to 50x leverage (tiered by position size)
- βOn-chain order matching with price-time priority
- βCross-margin trading with USDC collateral
- βYield-bearing collateral support (cbETH, wstETH, sUSDe)
- βPaper trading mode for risk-free practice
- βReal-time WebSocket price feeds
- βEIP-712 signed orders for gasless submission
Getting Started
1. Connect Your Wallet
Click 'Connect Wallet' in the top right. SUR supports MetaMask, Coinbase Wallet, WalletConnect, Rainbow, and most EVM-compatible wallets. Make sure you're on Base Sepolia (testnet).
2. Get Testnet USDC
Visit the Base Sepolia faucet to get testnet ETH for gas, then use our faucet integration or bridge testnet USDC to start trading.
3. Deposit Funds
Use the Deposit panel on the right side of the trading interface. Enter the amount of USDC you want to deposit into the vault. Your vault balance is used as margin for trades.
4. Place Your First Trade
Select Long or Short, choose Market or Limit order, set your size and leverage, then submit. For market orders, your trade executes immediately at the best available price.
Paper Trading
Not ready for real funds? Toggle Paper Trading mode to practice with $100,000 virtual USDC. All positions track real-time prices from Binance. Practice the full trading cycle risk-free: deposit, trade, manage positions, and track P&L.
Trading
Order Types
- βMarket β Executes immediately at best price. Pays taker fee (0.06%).
- βLimit β Rests on the book until filled at your price. Pays maker fee (0.02%) if Post Only.
- βStop Limit β Triggers a limit order when the mark price reaches your trigger price.
Time in Force
- βGTC (Good Til Cancelled) β Stays on book until filled or cancelled.
- βIOC (Immediate or Cancel) β Fills what it can immediately, cancels the rest.
- βFOK (Fill or Kill) β Must fill entirely or is cancelled.
- βPost Only β Rejected if it would match immediately. Guarantees maker fee.
Leverage
Both BTC-USD and ETH-USD support up to 50x leverage, tiered by position size. As notional size increases, max leverage decreases: 50x up to $100K, 25x up to $500K, 10x up to $2M, 5x above. The order panel automatically adjusts max leverage based on your position size.
Fees
Maker fee: 0.02% (2 bps). Taker fee: 0.06% (6 bps). Fees are calculated on the notional value (price x size) and deducted from your margin at execution.
Hidden Orders
Mark an order as 'Hidden' to keep it off the public orderbook. Hidden orders still match normally but protect your strategy from being front-run. Only available for limit orders.
Positions & P&L
Position Management
Open positions are shown in the Positions panel at the bottom. Each position displays: market, side (Long/Short), size, entry price, mark price, unrealized P&L (in $ and %), margin, leverage, and liquidation price.
P&L Calculation
- βLong P&L = (Mark Price - Entry Price) x Size
- βShort P&L = (Entry Price - Mark Price) x Size
- βP&L % = (P&L / Margin) x 100
Closing Positions
Click 'Close' on any position to close it at the current mark price. Realized P&L is added to your balance. A taker fee is charged on the close.
Liquidation
When a position's margin ratio falls below the maintenance requirement, the protocol partially liquidates 25% of the position per round. This tiered approach gives traders a chance to add margin before full closure. The liquidation price is shown on each position.
Architecture
Smart Contracts (Base L2)
- βPerpEngine.sol β Position management, tiered margin calculation, partial liquidation, funding rate application.
- βPerpVault.sol β USDC custody, deposits/withdrawals, margin accounting.
- βOrderSettlement.sol β EIP-712 order verification, trade settlement, dynamic spread fees.
- βLiquidator.sol β Permissionless liquidation engine, 25% partial close per round.
- βInsuranceFund.sol β Protocol backstop for bad debt from liquidations.
- βAutoDeleveraging.sol β Last-resort ADL when insurance fund is depleted.
Off-Chain Engine
The matching engine runs off-chain for performance. It maintains an in-memory orderbook with price-time priority matching. Matched trades are batched and settled on-chain.
WebSocket API
Real-time data flows via WebSocket on port 3002. Channels: orderbook:{marketId} for order book snapshots and deltas, trades:{marketId} for trade executions. Orders are submitted via the WebSocket with EIP-712 signatures.
Frontend Stack
- βNext.js 15 + React 19 + TypeScript
- βTailwind CSS for styling
- βlightweight-charts for TradingView-style charting
- βwagmi + RainbowKit for wallet connection
- βuseReducer pattern for state management
Contract Addresses
Base Sepolia (Testnet)
- βPerpEngine β Position management, tiered margin, liquidation
- βPerpVault β USDC custody, deposits/withdrawals
- βOrderSettlement β EIP-712 trade verification, dynamic spread
- βLiquidator β Permissionless partial liquidation (25% per round)
- βInsuranceFund β Protocol backstop for bad debt
- βAutoDeleveraging β Last-resort ADL when insurance fund depleted
- βOracleRouter β Pyth Network price feeds
Audits
Smart contracts are undergoing security review. Full audit reports will be published here before mainnet launch.
