Initial Margin = Position Size / Leverage
Maintenance Margin = Position Size × Maintenance Rate
Liquidation occurs when: Account Value < Maintenance MarginFunding Rate = (Interest Rate + Premium) / Funding Interval
Where:
- Interest Rate ≈ 0% for crypto markets
- Premium = TWAP(Futures Price - Spot Price) / Spot Price
- Funding Interval = 8 hours (typically)ETH Spot Price: $2,000
ETH Perpetual Price: $2,010 (0.5% premium)
Funding Rate: +0.05% (8-hour rate)
Long Position: Pays 0.05% of position size
Short Position: Receives 0.05% of position size// Simplified example
function openShortPosition(uint256 size) external {
// Calculate required margin
uint256 margin = size / leverage;
// Transfer margin to exchange
transferToExchange(margin);
// Open short position
hyperliquid.openShort(asset, size);
// Update portfolio delta
updateDelta();
}