Perpetual Trading
Trade perpetual futures contracts with up to 1001x leverage on LX DEX
Perpetual Trading
Specification: LP-9004 Perpetuals & Derivatives Protocol
Perpetual futures (perps) are derivative contracts that track an underlying asset's price without expiration. Unlike traditional futures, perpetuals never settle—positions can be held indefinitely.
Overview
| Feature | Value |
|---|---|
| Max Leverage | 1001x (tiered by position size) |
| Contract Type | Inverse & Linear |
| Settlement | USDT, USDC |
| Funding Interval | 8 hours |
| Liquidation | Automatic |
| Insurance Fund | Protocol-backed |
| TP/SL Orders | +300% targets supported |
| Referral System | Up to 30% rebates |
Tiered Leverage System
LX DEX supports up to 1001x leverage for micro-positions, with automatic leverage reduction as position size increases. This tiered system balances opportunity with risk management.
Leverage Tiers
| Tier | Position Size | Max Leverage | Maintenance Margin | Initial Margin |
|---|---|---|---|---|
| 1 | $0 - $200 | 1001x | 0.10% | 0.10% |
| 2 | $200 - $2,000 | 500x | 0.20% | 0.20% |
| 3 | $2,000 - $10,000 | 250x | 0.25% | 0.40% |
| 4 | $10,000 - $50,000 | 200x | 0.50% | 0.50% |
| 5 | $50,000 - $500,000 | 100x | 1.00% | 1.00% |
| 6 | $500,000 - $1,000,000 | 75x | 1.50% | 1.33% |
| 7 | $1,000,000 - $2,500,000 | 50x | 2.00% | 2.00% |
| 8 | $2,500,000 - $5,000,000 | 25x | 2.50% | 4.00% |
| 9 | $5,000,000 - $12,500,000 | 20x | 3.00% | 5.00% |
| 10 | $12,500,000 - $25,000,000 | 10x | 5.00% | 10.00% |
| 11 | $25,000,000 - $75,000,000 | 5x | 10.00% | 20.00% |
| 12 | $75,000,000 - $125,000,000 | 4x | 12.50% | 25.00% |
| 13 | $125,000,000 - $200,000,000 | 3x | 15.00% | 33.33% |
| 14 | $200,000,000 - $250,000,000 | 2x | 25.00% | 50.00% |
| 15 | $250,000,000+ | 1x | 50.00% | 100.00% |
How Tiered Leverage Works
Position Size → Leverage Tier → Max Leverage
Example 1: $100 position
Tier: 1 (micro)
Max Leverage: 1001x
Required Margin: $0.10 (0.1%)
Example 2: $100,000 position
Tier: 5 (standard)
Max Leverage: 100x
Required Margin: $1,000 (1%)
Example 3: $10,000,000 position
Tier: 9 (large)
Max Leverage: 20x
Required Margin: $500,000 (5%)Get Max Leverage for Position
import { DEX } from '@luxfi/trading'
const dex = await DEX({ rpcUrl: 'https://api.lux.network/rpc' })
// Check max leverage for position size
const maxLeverage = await dex.perpetual.getMaxLeverage({
symbol: 'BTC-USD-PERP',
notionalSize: '50000' // $50K position
})
console.log(`Max Leverage: ${maxLeverage}x`) // 200x
console.log(`Required Margin: ${50000 / maxLeverage}`) // $250How Perpetuals Work
Perpetual Price ≈ Spot Price (via Funding Rate)
When perp price > spot:
- Funding rate positive
- Longs pay shorts
- Encourages selling, brings price down
When perp price < spot:
- Funding rate negative
- Shorts pay longs
- Encourages buying, brings price upKey Concepts
| Term | Definition |
|---|---|
| Mark Price | Fair price used for liquidation (oracle-based) |
| Index Price | Spot price from major exchanges |
| Funding Rate | Payment between longs/shorts every 8h |
| Open Interest | Total value of outstanding positions |
| Unrealized PnL | Profit/loss if position closed now |
| Realized PnL | Actual profit/loss from closed trades |
Available Markets
Major Perpetuals
| Market | Max Leverage | Min Size | Tick Size | Maintenance |
|---|---|---|---|---|
| BTC-USD-PERP | 1001x* | $1 | $0.50 | 0.1% - 50% |
| ETH-USD-PERP | 1001x* | $1 | $0.10 | 0.1% - 50% |
| LUX-USD-PERP | 500x* | $1 | $0.0001 | 0.2% - 50% |
*Max leverage depends on position size (see tiered leverage table)
Alt Perpetuals
| Market | Max Leverage | Min Size | Tick Size | Maintenance |
|---|---|---|---|---|
| SOL-USD-PERP | 250x* | $1 | $0.01 | 0.25% - 50% |
| AVAX-USD-PERP | 250x* | $1 | $0.01 | 0.25% - 50% |
| ARB-USD-PERP | 100x* | $1 | $0.0001 | 1% - 50% |
| OP-USD-PERP | 100x* | $1 | $0.0001 | 1% - 50% |
Quick Start
Open a Long Position
import { DEX } from '@luxfi/trading'
const dex = await DEX({ rpcUrl: 'https://api.lux.network/rpc' })
// Long BTC perpetual with 100x leverage
const position = await dex.perpetual.openPosition({
symbol: 'BTC-USD-PERP',
side: 'long',
size: '10000', // $10,000 notional
leverage: 100, // 100x leverage (tier 5)
type: 'market'
})
console.log(`Position ID: ${position.id}`)
console.log(`Entry Price: $${position.entryPrice}`)
console.log(`Collateral: $${position.collateral}`)
console.log(`Liquidation: $${position.liquidationPrice}`)Open a Short Position
// Short ETH with limit order
const position = await dex.perpetual.openPosition({
symbol: 'ETH-USD-PERP',
side: 'short',
size: '5000',
leverage: 50,
type: 'limit',
price: '2500.00' // Enter short at $2,500
})With Take Profit and Stop Loss
const position = await dex.perpetual.openPosition({
symbol: 'BTC-USD-PERP',
side: 'long',
size: '10000',
leverage: 100,
type: 'market',
takeProfit: {
percent: 300, // +300% profit target
type: 'limit'
},
stopLoss: {
percent: 50, // -50% max loss
type: 'market'
}
})Take Profit / Stop Loss (TP/SL)
LX DEX supports advanced TP/SL orders with percentage-based targets, making it easy to set profit targets like "+300%" directly.
TP/SL Order Types
| Order Type | Description | Use Case |
|---|---|---|
| Take Profit | Close at profit target | Lock in gains at +X% |
| Stop Loss | Close at loss limit | Limit downside to -X% |
| Trailing Stop | Dynamic stop that follows price | Protect gains while allowing upside |
Trigger Types
| Trigger | Description |
|---|---|
| Mark Price | Trigger on oracle mark price (default) |
| Last Price | Trigger on last traded price |
| Index Price | Trigger on underlying index price |
Create TP/SL Orders
// Take Profit at +300% from entry
const tp = await dex.perpetual.createTPSL({
positionId: 'pos_123',
type: 'takeProfit',
percent: 300, // +300% from entry
triggerType: 'mark', // Trigger on mark price
orderType: 'limit', // Execute as limit order
closePercent: 100 // Close 100% of position
})
// Stop Loss at -50% from entry
const sl = await dex.perpetual.createTPSL({
positionId: 'pos_123',
type: 'stopLoss',
percent: 50, // -50% from entry
triggerType: 'mark',
orderType: 'market',
closePercent: 100
})
console.log(`TP Price: $${tp.triggerPrice}`) // Entry × 4 for +300%
console.log(`SL Price: $${sl.triggerPrice}`) // Entry × 0.5 for -50%TP/SL with Price Targets
// Take Profit at specific price
const tp = await dex.perpetual.createTPSL({
positionId: 'pos_123',
type: 'takeProfit',
price: '200000', // $200,000 BTC target
triggerType: 'mark',
orderType: 'limit'
})
// Stop Loss at specific price
const sl = await dex.perpetual.createTPSL({
positionId: 'pos_123',
type: 'stopLoss',
price: '45000',
triggerType: 'mark',
orderType: 'market'
})Trailing Stop Orders
// Trailing stop with fixed delta
const trailing = await dex.perpetual.createTPSL({
positionId: 'pos_123',
type: 'trailingStop',
trailingDelta: '1000', // $1,000 trail distance
triggerType: 'last'
})
// Trailing stop with percentage
const trailingPercent = await dex.perpetual.createTPSL({
positionId: 'pos_123',
type: 'trailingStop',
trailingPercent: 2, // 2% trail
activationPrice: '55000', // Activate when price hits $55K
triggerType: 'mark'
})Manage TP/SL Orders
// Get all TP/SL orders for position
const orders = await dex.perpetual.getTPSLOrders('pos_123')
orders.forEach(order => {
console.log(`${order.type}: $${order.triggerPrice}`)
console.log(` Status: ${order.status}`)
console.log(` Trigger: ${order.triggerType}`)
})
// Cancel specific order
await dex.perpetual.cancelTPSL(orders[0].id)
// Cancel all TP/SL for position
await dex.perpetual.cancelAllTPSL('pos_123')Funding Rate
Understanding Funding
Funding payments occur every 8 hours (00:00, 08:00, 16:00 UTC):
Funding Payment = Position Size × Funding Rate
Example:
- Long Position: $100,000
- Funding Rate: 0.01% (positive = longs pay)
- Payment: $100,000 × 0.01% = $10 (paid to shorts)Track Funding Rates
// Get current funding rate
const funding = await dex.perpetual.getFunding('BTC-USD-PERP')
console.log(`Symbol: ${funding.symbol}`)
console.log(`Current Rate: ${funding.rate}% per 8h`)
console.log(`Annualized: ${funding.rate * 3 * 365}%`)
console.log(`Next Settlement: ${funding.nextTime}`)
console.log(`Predicted Next: ${funding.predictedRate}%`)Funding History
// Get position funding history
const history = await dex.perpetual.getFundingHistory({
positionId: 'pos_123',
limit: 100
})
let totalFunding = 0
history.forEach(f => {
totalFunding += parseFloat(f.amount)
console.log(`${f.timestamp}: ${f.amount} USDT`)
})
console.log(`Total Funding Paid/Received: ${totalFunding} USDT`)Position Management
View Open Positions
const positions = await dex.perpetual.getPositions()
positions.forEach(pos => {
console.log(`${pos.symbol}:`)
console.log(` Side: ${pos.side}`)
console.log(` Size: $${pos.size}`)
console.log(` Entry: $${pos.entryPrice}`)
console.log(` Mark: $${pos.markPrice}`)
console.log(` Leverage: ${pos.leverage}x (Tier ${pos.tier})`)
console.log(` Unrealized PnL: $${pos.unrealizedPnl}`)
console.log(` ROE: ${pos.roe}%`)
})Increase Position
// Add to existing position
const result = await dex.perpetual.increasePosition({
positionId: 'pos_123',
additionalSize: '5000', // Add $5k to position
type: 'market'
})
console.log(`New Size: $${result.newSize}`)
console.log(`New Avg Price: $${result.newAvgPrice}`)
console.log(`New Tier: ${result.newTier}`)
console.log(`Max Leverage: ${result.maxLeverage}x`)Decrease Position (Partial Close)
// Reduce position by 50%
const result = await dex.perpetual.decreasePosition({
positionId: 'pos_123',
reduceSize: '5000',
type: 'market'
})
console.log(`Closed Size: $${result.closedSize}`)
console.log(`Realized PnL: $${result.realizedPnl}`)
console.log(`Remaining: $${result.remainingSize}`)Close Position
// Close entire position at market
const result = await dex.perpetual.closePosition({
positionId: 'pos_123',
type: 'market'
})
console.log(`Final PnL: $${result.realizedPnl}`)
console.log(`Collateral Returned: $${result.collateralReturned}`)Leverage and Margin
Adjust Leverage
// Check max leverage for current position size
const position = await dex.perpetual.getPosition('pos_123')
const maxLev = await dex.perpetual.getMaxLeverage({
symbol: position.symbol,
notionalSize: position.size
})
console.log(`Current Leverage: ${position.leverage}x`)
console.log(`Max Allowed: ${maxLev}x`)
// Increase leverage (if within tier limit)
await dex.perpetual.setLeverage({
positionId: 'pos_123',
leverage: Math.min(50, maxLev)
})Add/Remove Margin
// Add margin to reduce liquidation risk
await dex.perpetual.addMargin({
positionId: 'pos_123',
amount: '500'
})
// Remove excess margin
await dex.perpetual.removeMargin({
positionId: 'pos_123',
amount: '200'
})Liquidation
How Liquidation Works
Position is liquidated when:
Margin Ratio < Maintenance Margin (tiered)
Margin Ratio = (Collateral + Unrealized PnL) / Position Size
Liquidation Process:
1. Position force-closed at mark price
2. Remaining collateral covers losses
3. Liquidation fee (5%) to liquidator
4. Shortfall covered by insurance fundTiered Liquidation Price
Long Liquidation:
Liq = Entry × (1 - InitialMarginRate + MaintenanceMarginRate)
Short Liquidation:
Liq = Entry × (1 + InitialMarginRate - MaintenanceMarginRate)
Example (100x Long BTC at $50,000, $100K position):
Tier: 5 (1% maintenance margin)
Initial Margin = 1%
Maintenance = 1%
Liq = $50,000 × (1 - 0.01 + 0.01) = $50,000 × 1.0 = immediate risk
With 20x leverage (5% margin):
Liq = $50,000 × (1 - 0.05 + 0.01) = $50,000 × 0.96 = $48,000Monitor Liquidation Risk
const position = await dex.perpetual.getPosition('pos_123')
const liquidationRisk = {
marginRatio: position.marginRatio,
healthFactor: position.healthFactor,
liquidationPrice: position.liquidationPrice,
distanceToLiq: position.distanceToLiq,
tier: position.tier,
maintenanceMargin: position.maintenanceMargin
}
if (liquidationRisk.marginRatio < 5) {
console.log('WARNING: Position near liquidation!')
console.log(`Add margin or reduce position`)
}Order Types
Market Order
await dex.perpetual.placeOrder({
symbol: 'BTC-USD-PERP',
side: 'buy',
type: 'market',
size: '1000'
})Limit Order
await dex.perpetual.placeOrder({
symbol: 'BTC-USD-PERP',
side: 'buy',
type: 'limit',
price: '48000',
size: '1000',
postOnly: true // Ensure maker fee
})Stop Order
await dex.perpetual.placeOrder({
symbol: 'BTC-USD-PERP',
side: 'sell',
type: 'stop',
stopPrice: '45000', // Trigger price
size: '1000',
reduceOnly: true // Only close existing position
})Take Profit Order
await dex.perpetual.placeOrder({
symbol: 'BTC-USD-PERP',
side: 'sell',
type: 'takeProfit',
stopPrice: '55000',
size: '1000',
reduceOnly: true
})Fees
See Fee Schedule for complete fee information including VIP tiers.
Base Fees
| Fee Type | Rate |
|---|---|
| Maker | 0.10% |
| Taker | 0.50% |
| Liquidation | 0.50% |
| Funding | Variable |
VIP Fee Tiers
| VIP Tier | 30-Day Volume | Maker Fee | Taker Fee |
|---|---|---|---|
| VIP 0 | $0 | 0.10% | 0.50% |
| VIP 1 | $1M | 0.08% | 0.45% |
| VIP 2 | $5M | 0.06% | 0.42% |
| VIP 3 | $10M | 0.04% | 0.39% |
| VIP 4 | $25M | 0.02% | 0.36% |
| VIP 5 | $50M | 0.00% | 0.27% |
| VIP 6 | $100M | 0.00% | 0.24% |
| VIP 7 | $250M | 0.00% | 0.21% |
| VIP 8 | $500M | 0.00% | 0.18% |
| VIP 9 | $1B | 0.00% | 0.15% |
Risk Management
Perpetual trading carries significant risk. Leverage amplifies both gains and losses. With 1001x leverage, a 0.1% adverse move results in liquidation.
Best Practices
- Use appropriate leverage - Start with 2-10x, not 1001x
- Set stop losses - Always define max loss with TP/SL orders
- Monitor funding - Can erode profits on long holds
- Keep margin buffer - Don't use 100% available margin
- Track open interest - High OI can mean crowded trades
- Understand mark vs last - Liquidation uses mark price
- Know your tier - Larger positions have lower max leverage
Position Sizing Formula
Position Size = Account × Risk% / (Entry - Stop) × Entry
Example:
- Account: $10,000
- Risk: 1% ($100)
- Entry: $50,000
- Stop: $49,000 (2% away)
Size = $10,000 × 1% / 2% = $5,000 position
Leverage = $5,000 / $10,000 = 0.5x (conservative)Market Data
Real-time Prices
// Subscribe to perpetual ticker
dex.perpetual.subscribeTicker('BTC-USD-PERP', (ticker) => {
console.log(`Last: $${ticker.lastPrice}`)
console.log(`Mark: $${ticker.markPrice}`)
console.log(`Index: $${ticker.indexPrice}`)
console.log(`Funding: ${ticker.fundingRate}%`)
console.log(`Open Interest: $${ticker.openInterest}`)
})Order Book
// Get perpetual order book
const book = await dex.perpetual.getOrderBook('BTC-USD-PERP', {
depth: 20
})
console.log('Best Bid:', book.bids[0])
console.log('Best Ask:', book.asks[0])
console.log('Spread:', book.spread)Insurance Fund
The insurance fund covers liquidation shortfalls:
// Check insurance fund status
const fund = await dex.perpetual.getInsuranceFund()
console.log(`Total: $${fund.total}`)
console.log(`BTC Coverage: $${fund.btc}`)
console.log(`ETH Coverage: $${fund.eth}`)Fund Mechanics
When liquidation has shortfall:
1. Insurance fund covers the gap
2. If fund depleted, ADL triggered
3. Profitable traders auto-deleveragedRelated Documentation
- TP/SL Orders - Detailed Take Profit/Stop Loss guide
- Referral & Rebates - Earn rebates on trading fees
- Margin Trading - Margin modes and leverage
- Order Types - All supported orders
- Fees - Complete fee schedule with VIP tiers
- Limits - Position and leverage limits
- Risk Management - Risk controls