Why Accurate PnL Calculation Matters
Perpetual futures trading on decentralized exchanges like Hyperliquid, Lighter DEX, and Aster DEX introduces multiple cost layers that centralized exchanges simplify. On a CEX, your PnL is typically: exit price minus entry price, minus fees. On a DEX, you must also account for funding rate payments (or receipts), gas fees for on-chain actions, and sometimes price impact on entry and exit.
Many traders are surprised when their "obvious profit" shrinks after accounting for all these factors. This guide gives you the complete formula set so you can calculate your real return — not just the number on the screen.
The Core PnL Formula for Perpetuals
For a simple long position, the basic unrealized PnL at any point is:
Unrealized PnL = (Current Mark Price − Entry Price) × Position Size
For a short position, reverse the subtraction:
Unrealized PnL = (Entry Price − Current Mark Price) × Position Size
Position size is measured in the base asset. For example, if you are long 1 ETH-PERP at an entry price of $3,200 and the current mark price is $3,300, your unrealized PnL is ($3,300 − $3,200) × 1 = $100.
Adding Leverage to the Calculation
Leverage magnifies both gains and losses. The formula with leverage becomes:
PnL = (Price Change %) × Leverage × Collateral
Example: You open a 1 ETH long at $3,200 with 10x leverage. Your collateral is $320 (10% of position value). If ETH rises to $3,392 — a 6% increase — your PnL is 6% × 10 × $320 = $192. That is a 60% return on your $320 collateral, matching the 6% price move multiplied by 10x leverage.
This is why leverage is both powerful and dangerous: a 10% adverse move wipes out your entire collateral at 10x leverage.
Funding Rate Impact on PnL
Funding payments are the most overlooked PnL factor on perpetuals. Every 8 hours, if the funding rate is positive, longs pay shorts. If negative, shorts pay longs. The payment is calculated as:
Funding Payment = Position Size × Mark Price × Funding Rate
For example: You hold a 1 BTC long position at $72,000. The 8-hour funding rate is +0.01% (0.0001). Your funding payment is 1 × $72,000 × 0.0001 = $7.20. That is $7.20 you pay, not receive. Over 21 funding intervals in a week, that is $151.20 in funding costs — real money that comes out of your PnL.
To calculate net PnL including funding, use:
Net PnL = Price PnL + Sum of All Funding Payments − Total Trading Fees − Gas Costs
Trading Fees: Maker vs Taker
Every perpetual exchange charges fees based on whether you add liquidity (maker) or remove liquidity (taker). Hyperliquid charges a 0.02% taker fee and typically offers a 0.01% maker rebate on most pairs. Lighter DEX charges competitive taker fees around 0.025-0.05% depending on the pair. Aster DEX fees vary by tier but are competitive with the market.
Fee calculation is straightforward:
Fee = Position Size × Entry Price × Fee Rate
For a 1 BTC position at $72,000 with a 0.02% taker fee: Fee = 1 × $72,000 × 0.0002 = $14.40 per side. A round-trip trade costs $28.80 in fees. Using a limit order (maker) reduces this significantly or even earns you a rebate.
Realized vs Unrealized PnL
Unrealized PnL is the profit or loss on an open position — it exists on paper but has not been booked. Realized PnL is locked in when you close the position or partially reduce it. Only realized PnL affects your actual account balance.
When you close part of a position, calculate the realized portion proportionally. For example, if you close 50% of a 1 ETH position that has $200 in unrealized gain, your realized gain is $100, and the remaining $100 stays as unrealized on the open portion.
Worked Example: Full PnL Calculation
Let us calculate the complete PnL for a trade on Hyperliquid:
- You open a 2 ETH long at $3,200 with 5x leverage (collateral: $1,280)
- Taker fee on entry: 2 × $3,200 × 0.0002 = $12.80
- You hold for 3 days (9 funding intervals) — average funding rate +0.015% per 8h
- Total funding paid: 9 × (2 × $3,250 × 0.00015) = approximately $8.78
- You close at $3,400 — price PnL: ($3,400 − $3,200) × 2 = $400
- Taker fee on exit: 2 × $3,400 × 0.0002 = $13.60
- Gas costs (Arbitrum L2): approximately $0.01 per transaction
- Net PnL = $400 − $12.80 − $8.78 − $13.60 = $364.82
Your return on $1,280 collateral is 28.5%, but the "gross" return before costs was 31.25%. Fees and funding ate $35.18 — more than 10% of your gross profit.
Trade With Lower Fees Across All DEXes
Reduce your trading costs with these referral codes:
Hyperliquid: Code HOLYGRAIL — Join Hyperliquid
Lighter DEX: Code 718610TD — Join Lighter DEX
Aster DEX: Code 4474ca — Join Aster DEX
Summary
Calculating your true PnL on DEX perpetuals requires tracking four components: price movement, funding payments, trading fees, and gas costs. Most platforms show only unrealized price PnL, which can be misleading if you are bleeding funding every 8 hours. Keep a simple spreadsheet with these four columns for every trade, and your "mystery losses" will disappear — replaced by a clear understanding of exactly where your money goes.