Choose cross or isolated margin mode

Selecting the correct margin mode is the first step in managing onchain perp margin. The choice determines how much capital you can deploy and how far your liquidation price sits from the current market price.

Cross margin links your entire wallet balance to a single position. This setup offers higher capital efficiency because idle assets act as collateral, pushing your liquidation threshold further away. Isolated margin assigns a fixed amount of collateral to a specific trade. If the position goes against you, only that allocated portion is lost, protecting the rest of your portfolio.

FeatureCross MarginIsolated Margin
Liquidation ScopeEntire wallet balanceAssigned collateral only
Capital EfficiencyHighLow
Risk ExposureFull portfolio riskLimited to position
Best ForLarge portfolios, low volatilityHigh leverage, volatile assets

The right choice depends on your risk tolerance. If you are trading with high leverage or in volatile markets, isolated margin limits your downside. If you are managing a large portfolio with stable positions, cross margin maximizes your buying power.

Deposit collateral and select leverage

Funding your margin account is the first technical step to opening a position. You must transfer approved assets—typically stablecoins like USDC or ETH—to the specific on-chain margin account provided by the perp DEX. This collateral acts as your guarantee against potential losses. Without this deposit, your margin balance remains zero, and the interface will not allow you to open any trades.

Once your funds are confirmed on-chain, you can adjust your leverage slider. Leverage determines the multiplier applied to your collateral, effectively expanding your buying power. For example, with 10x leverage, $1,000 in collateral allows you to control a $10,000 position. However, higher leverage increases your risk of liquidation. Most cross-margin perpetual DEXs offer leverage up to 50x, but starting with lower leverage (2x–5x) is safer for managing volatility.

onchain perp margin
1
Connect your wallet and select a chain

Open your preferred perp DEX interface and connect your Web3 wallet. Ensure your wallet is on the correct network (e.g., Solana, Arbitrum, or Hyperliquid) that matches the perp market you intend to trade. Mismatched chains will prevent you from accessing the correct margin account.

onchain perp margin
2
Deposit collateral into the margin account

Navigate to the "Deposit" or "Vault" section. Transfer your chosen collateral asset (e.g., USDC, ETH) from your external wallet into the protocol's margin account. Wait for the blockchain confirmation to ensure the balance updates in the interface before proceeding.

onchain perp margin
3
Adjust leverage and margin mode

Locate the leverage slider or input field in the trading terminal. Set your desired leverage ratio (e.g., 5x). Choose between "Cross Margin" (using all account balance as collateral) or "Isolated Margin" (risking only a specific portion). Lower leverage reduces liquidation risk but requires more capital for the same position size.

to Onchain Perp Margin
4
Verify margin ratio and open position

Check your initial margin ratio and available balance. Ensure you have enough free collateral to cover entry fees and potential price swings. Once satisfied, input your trade size and execute the order. Your deposited collateral is now locked as margin for the active position.

Monitor funding rates and liquidation prices

Managing onchain perp margin requires more than just setting leverage; you must actively track the ongoing cost of holding a position and the distance to liquidation. Funding rates and liquidation thresholds shift with every trade on the exchange, meaning your risk profile changes by the second.

Track funding rates to manage holding costs

Perpetual contracts do not have an expiry date, so they rely on funding rates to keep the contract price tethered to the underlying spot price. These rates are periodic payments exchanged between long and short traders. If the funding rate is positive, longs pay shorts; if negative, shorts pay longs.

A high funding rate signals that the market is heavily leveraged in one direction. If you are holding a long position during a period of high positive funding, those payments can erode your margin balance even if the price remains flat. Conversely, negative funding rates benefit long holders. You should check the current rate on your DEX interface or a dedicated aggregator before entering or maintaining a position.

Set alerts for liquidation thresholds

Liquidation occurs when your margin balance falls below the maintenance requirement, forcing the protocol to close your position to cover losses. On most onchain perpetuals, this threshold is typically 50% or less of your initial margin. If your position moves against you significantly, you risk losing your entire deposited collateral.

Because onchain markets can be volatile, manual monitoring is often insufficient. Set up price alerts at your liquidation price and at a safety buffer above it. Most trading interfaces allow you to set these notifications via email or push. Treat these alerts as your primary risk management tool; do not rely on the protocol to warn you after the liquidation engine has already triggered.

Close positions and withdraw margin

Exiting a perpetual futures position requires a specific sequence to ensure you realize your profit or limit your loss accurately. Unlike spot trading, where selling is immediate, onchain perps involve closing a leveraged contract and then extracting the underlying collateral from the protocol's smart contract back to your main wallet.

The process involves three distinct phases: closing the open position to realize PnL, settling any funding rates or fees, and withdrawing the remaining margin. Rushing the withdrawal step can leave funds exposed to protocol risk or liquidity constraints.

onchain perp margin
1
Review open positions and PnL

Before initiating a close, verify the current unrealized PnL and margin ratio. Onchain perpetuals use smart contracts to track these metrics in real-time. Ensure your account health is stable; attempting to close a position with insufficient margin to cover fees can trigger a liquidation event instead of a simple exit.

onchain perp margin
2
Close the position

Navigate to the "Positions" tab and select "Close" or "Market Close." This action sends a transaction to the decentralized exchange's smart contract, matching your exit order against available liquidity. Because you are exiting a leveraged position, this transaction settles the price difference into your margin balance. Confirm the gas fees and slippage tolerance before signing.

onchain perp margin
3
Withdraw collateral to main wallet

Once the position is closed, your margin balance (principal + realized PnL) sits in the perp protocol's smart contract. Navigate to the "Withdraw" or "Transfer" section. Input the amount you wish to move and select your destination wallet address. This transaction moves the assets off the trading platform and back to your self-custody wallet, completing the cycle.

  • Verify account health ratio is above 1.0x
  • Confirm position size is zero after close
  • Check for any pending funding rate payments
  • Ensure withdrawal amount covers network gas fees
  • Transfer funds to a secure, non-trading wallet

Common onchain perp margin mistakes

Trading onchain introduces friction that centralized exchanges hide. Gas fees erode small profits, and oracle delays can trigger unfair liquidations. Understanding these mechanics is essential for protecting your capital.

Ignoring gas fee erosion

On Ethereum, a single swap or margin update can cost more than the profit on a small position. Traders often overlook how transaction costs compound across multiple rebalances. Always estimate gas in the same currency as your margin to avoid unexpected losses.

Over-leveraging during volatility

High leverage amplifies gains but also accelerates liquidation. During market crashes, price slippage can exceed your maintenance margin requirements. As noted by MetaMask, cross-margin modes can expose your entire wallet to liquidation cascades if one position fails. Keep leverage conservative when volatility spikes.

Oracle manipulation risks

Onchain perpetuals rely on price oracles. If an oracle is slow or manipulated, your position may liquidate at a distorted price. This risk is higher on less liquid chains. Monitor the oracle source and avoid trading immediately after major news events where price discovery is chaotic.

Frequently asked questions about perp margin