Prerequisites
- Python 3.8 or higher
hyperliquid-python-sdk
installed (pip install hyperliquid-python-sdk
)- Chainstack Hyperliquid node endpoint (sign up for free)
Educational purposeThis article explores the mechanics, math, and risks of funding arbitrage as a learning exercise. The strategies discussed require careful risk management and may not be profitable under all market conditions.
Note on cross-exchange arbitrageFor simplicity, this article focuses on executing both spot and perp positions on Hyperliquid. However, developers can implement funding arbitrage across different venues—for example, holding spot on one DEX/CEX while shorting perps on another.
How funding arbitrage works
Perpetual contracts on Hyperliquid pay funding every hour. When the rate is positive (perp price > spot price), shorts receive payments from longs. The strategy:- Buy spot asset (for example, 1 BTC)
- Short equal amount on perp (for example, 1 BTC perp)
- Collect hourly funding payments
- Exit both positions when opportunity ends
Finding arbitrage opportunities
Not all assets exist in both spot and perp markets on Hyperliquid. BTC, ETH, SOL are available in both, but many altcoins only trade as perps. Check eligibility before attempting arbitrage:spotMeta
endpoint returns all spot-tradeable tokens. The meta()
SDK method returns perp universe data. Their intersection shows which assets support the strategy.
Calculating real profit after fees
Funding rates look attractive, but trading fees create a profitability threshold. Hyperliquid’s fee structure varies by maker/taker and volume tier: Base tier fees (0-30 day rolling volume):- Spot — 0.070% taker / 0.040% maker
- Perpetuals — 0.045% taker / 0.015% maker
This calculation assumes maker fees. If using taker orders (market orders), total fees increase to 0.23% (spot 0.070% × 2 + perps 0.045% × 2), requiring much higher funding rates to be profitable.
Minimum profitable funding rate
To make arbitrage worthwhile, you need funding to exceed fees. Let’s calculate the minimum: For 1-hour position:- Fees — 0.11% of position value
- Required funding rate — >0.11%/hour (just to break even)
- Realistic minimum — >0.15%/hour for meaningful profit
- Gross profit — $5.00/hour
- Total fees — $11.00
- Break-even — 2.2 hours
Getting current funding rates
ThemetaAndAssetCtxs
endpoint returns market metadata and current asset contexts, including live funding rates:
Checking market liquidity
High funding rates mean nothing if slippage destroys your profit margin. Thel2Book
endpoint returns level-2 order book data for spread and depth analysis:
- Spread — 0.02% → acceptable, minimal slippage impact
- Top 5 bid depth — 500 SOL → can enter 50 SOL position cleanly
- Spread — 0.15% → avoid, slippage exceeds funding gain
Predicted funding rates
ThepredictedFundings
endpoint shows estimated rates for the next funding period, calculated based on current spot-perp price divergence:
Execution strategy: tactical pre-funding short
The idea: Open positions 5-10 minutes before funding payment, collect the payment, then immediately close both positions. This minimizes price exposure while capturing funding. Advantages:- Minimal directional risk (short time window)
- Lower capital requirements (high position turnover)
- Reduced basis risk from spot-perp divergence
- Must overcome 0.11% fees with a single funding payment
- Requires funding rate > 0.11% to be profitable
- Timing is critical—miss the funding window and you pay fees for nothing
1
Set timing alarm
Set alarm for 10 minutes before next funding period (funding occurs at top of each hour)
2
Verify funding rate
Check current funding rate is > 0.11% (minimum to overcome fees)
3
Enter positions
Simultaneously enter spot long + perp short
4
Wait for funding
Wait for funding payment notification via WebSocket
5
Close positions
Immediately close both positions
6
Verify payment
Verify funding payment received via
userFunding
endpointFunding payment received and both positions closed successfully
If spot-perp spread widens during your 15-minute window, slippage can exceed your funding profit. Only use this when spreads are tight (<0.05%).
Summary
Funding rate arbitrage requires rates above 0.11%/hour (with maker orders) to overcome fees. The tactical approach—entering 10-15 minutes before funding—minimizes exposure but demands tight spreads and high rates (0.15%+). Only BTC, ETH, SOL and few other assets support spot-perp arbitrage on Hyperliquid. Monitor predicted funding rates to avoid compressed opportunities and test with small positions first. The complete implementation is available in the Chainstack Hyperliquid trading bot repository.Related resources
- Copy trading with spot orders — Build a copy trading bot that mirrors spot trades
- Order precision and metadata — Handle order precision dynamically across assets
- Authentication guide — Authenticate with Hyperliquid exchange API
- API reference — Explore the complete Hyperliquid API reference