Hyperliquid L1 API vs dYdX v4: Building Perp Trading Bots
Hyperliquid vs dYdX v4 API compared for perp bot builders: on-chain L1 matching vs Cosmos appchain, latency, fees, and SDKs.
Two chains, two trust models for your order book
Two liquid perp venues, two completely different answers to the question that matters most to a bot that quotes every 50-200ms: who do you actually trust to match your order, and how fast do they tell you it happened?
Hyperliquid runs its own purpose-built L1. Every order, cancel, and fill goes through HyperBFT, a HotStuff-derived consensus the team wrote specifically for a fully on-chain central limit order book. dYdX v4 went the opposite direction: it's a Cosmos SDK appchain where validators hold the order book in memory, off-chain, and only settle net state changes through the Tendermint/CometBFT consensus layer. Both call themselves "decentralized perps." The engineering tradeoffs underneath are not close to the same.
If you're building an automated strategy — market making, funding arb, liquidation sniping — this difference shows up directly in your latency budget, your infra bill, and how much you need to trust a third-party indexer versus running your own node.
How orders actually get matched
Hyperliquid: everything on the L1
Hyperliquid's order book lives entirely on its custom L1. Placing, modifying, and cancelling orders are all L1 transactions processed by validators running HyperBFT, which the team benchmarks at sub-second finality (block times commonly land under a second, often in the 100-300ms range depending on network load). There's no separate "indexer" you need to trust for order state — the book itself is the canonical state.
Practically, this means:
- You talk to Hyperliquid's REST/WebSocket gateway, which is a thin layer over the L1 state — not a third-party aggregator.
- Fills, cancels, and book updates arrive over WebSocket with latency in the tens of milliseconds from the API node, though L1 finality itself is the harder bound if you care about reorg safety.
- Trading uses "agent wallets" (API wallets) that you approve once from your main wallet, so your hot key for the bot never touches your actual funds directly.
dYdX v4: matching happens before consensus even runs
dYdX v4 validators each maintain their own in-memory order book. When you submit a short-term order, it propagates through the validator's mempool like a normal Cosmos transaction, gets matched against other validators' local books during block proposal, and only the resulting state diff gets committed on-chain. Long-lived (stateful) orders like TWAPs or long-dated limits are handled differently, going through the chain's state machine directly.
The catch for bot builders: because matching is happening in each validator's local memory before consensus finalizes anything, you're dependent on the specific full node you're connected to for a consistent view of the book. dYdX runs an official Indexer (Postgres + Kafka pipeline) that reads chain events and exposes REST/WebSocket APIs, and most bots use that rather than talking to a Cosmos full node's gRPC endpoint directly. That Indexer is a separate piece of infrastructure with its own uptime and lag characteristics — it's genuinely useful, but it's one more thing that can fall behind or hiccup independently of the chain itself.
What your bot actually talks to
A minimal Hyperliquid order via the official Python SDK:
from hyperliquid.exchange import Exchange
from hyperliquid.utils import constants
exchange = Exchange(wallet, constants.MAINNET_API_URL)
exchange.order(
"ETH", is_buy=True, sz=0.5, limit_px=3400,
order_type={"limit": {"tif": "Gtc"}}, reduce_only=False
)
The equivalent on dYdX v4 using the TypeScript client goes through a Cosmos transaction under the hood:
const tx = await client.placeShortTermOrder(
subaccount, "ETH-USD", OrderSide.BUY,
3400, 0.5, clientId, goodTilBlock, TimeInForce.GTC, false
);
Both are ergonomic once set up. The real difference is what happens between the call and the fill: Hyperliquid gives you a single API surface backed by validator consensus; dYdX v4 gives you a Cosmos transaction plus a downstream Indexer you query separately for book state and fills. If you've built anything against a Cosmos chain before (order routing on Osmosis, IBC relayers), the dYdX v4 pattern will feel familiar. If you haven't, budget real time for learning short-term vs stateful order semantics, goodTilBlock windows, and sequence number management for your subaccount.
Fees, rate limits, and node ops
Hyperliquid rate-limits by address weight, roughly proportional to your trading volume and open orders, with a hard IP-level cap underneath. There's no gas fee for trading actions specifically — you pay maker/taker fees, and HYPE is only needed for a subset of non-trading L1 actions. For a market maker quoting hundreds of orders a minute, this fee model is simpler to reason about than a chain where every action is technically a transaction.
dYdX v4 markets itself as gasless for trading — short-term orders don't cost gas in the traditional sense, but they're still bounded by a per-block, per-subaccount order rate limit enforced at the validator level, and you'll want to run or pay for a reliable full node if you're latency-sensitive, because public RPC endpoints get congested and rate-limited during volatile periods exactly when your strategy needs them most.
Comparison table
| Dimension | Hyperliquid L1 | dYdX v4 |
|---|---|---|
| Chain type | Custom L1 (HyperBFT) | Cosmos SDK appchain |
| Order matching | Fully on-chain CLOB | Validator in-memory book, off-chain match |
| Canonical book source | The L1 itself | Indexer (Postgres/Kafka) reading chain events |
| Typical finality | Sub-second | ~1s block time, short-term orders faster |
| SDKs | Python, Rust, TS (official) | TS, Python (official) |
| Self-hosting burden | Low — API gateway is thin | Higher — full node or reliable Indexer needed |
| Fee model | Maker/taker, no trading gas | Gasless orders, per-block rate limits |
| EVM composability | Yes, via HyperEVM | No native EVM |
| Best for | Low-latency market making, single-venue focus | Multi-chain/Cosmos-native strategies, sovereignty priorities |
Which to pick when
Build on Hyperliquid if your strategy is latency-sensitive market making or arbitrage where every millisecond between quote and fill matters, and where you want one API surface with no separate indexer to trust or maintain. This is the same reasoning that applies when comparing Jito bundles against standard Solana RPC for trade landing — fewer hops between your signal and settlement wins.
Build on dYdX v4 if you're already operating in the Cosmos ecosystem, need IBC composability with other appchains, or have a genuine philosophical requirement for validator-level decentralization over raw speed. Just plan for the extra ops burden of running or paying for reliable node access, the same calculus you'd apply when weighing Yellowstone gRPC against standard Solana WebSocket RPC for feed reliability.
Either way, the order-routing logic in your bot deserves the same scrutiny as swap routing decisions between Jupiter and Raydium — get the execution layer wrong and your edge disappears into slippage and missed fills regardless of which chain you picked. If you're still scoping which venue fits your strategy's latency and capital requirements, a strategy consultation upfront saves weeks of rebuilding once you hit a wall neither API's docs warned you about. Before shipping either integration to real capital, run it through a proper code review and audit — nonce handling, order-type edge cases, and reconnect logic are where most perp bots actually lose money, not the strategy itself.
Need a market maker built directly for Hyperliquid's order book and fee structure? That's what we do — see our Hyperliquid market maker service for the build.
Need a bot like this built?
We design, build and run trading bots on Solana, Hyperliquid and Polymarket.
Start a projectMore from the blog
Public vs Paid RPC: How to Run a Fair Benchmark
A fair comparison of public and paid RPC endpoints must account for quotas, workload, freshness and support guarantees.
Read articleRPC Benchmark Percentiles Explained: p50, p95 and p99
Why averages hide the latency spikes that break trading bots, wallets and production blockchain applications.
Read articleHyperliquid REST vs WebSocket Benchmark: What to Measure
A benchmark plan for Hyperliquid market data that separates request latency from streaming freshness and recovery.
Read article