Perpetual DEX development: how to build a perp DEX in 2026
How to build a perpetual DEX in 2026: order book chains, Hyperliquid HIP-3, GMX-style oracle pools, vAMMs and hybrid matching, plus the margin, liquidation and funding engines, costs and risks.
By Przemysław Paczoski, CEO & Founder at 23studio
Published 12 min read

To build a perpetual DEX, you choose where matching happens (your own order book chain, an existing one such as Hyperliquid via HIP-3, an oracle-priced liquidity pool like GMX, or off-chain matching with on-chain settlement), then build the risk core: a margin engine, liquidations, funding payments, oracles and an insurance fund. A HIP-3 or pool-based MVP takes 2 to 6 months. Your own chain takes a year or more.
This post walks through each architecture with its real trade-offs, the components every perp exchange needs, the risk events that broke real venues, cost and timeline ranges by scope, and a short regulatory note.
Pick the architecture before anything else
Perpetual futures exchange development is mostly a decision about who takes the other side of a trade and where orders are matched. Everything else follows.
| Architecture | Who is the counterparty | Examples | Build effort | Main risk |
|---|---|---|---|---|
| Own chain with on-chain order book | Other traders and market makers | Hyperliquid (HyperCore), dYdX v4 | Very high: consensus, matching, validators | Years of work before product-market fit |
| HIP-3 market on Hyperliquid | Other traders on your markets | Builder-deployed perp DEXs on HyperCore | Medium: oracle, risk ops, frontend | Stake slashing, deployer responsibilities |
| Oracle-priced pool | An LP pool | GMX v2 | Medium to high | Oracle manipulation, LP losses in trends |
| Virtual AMM (vAMM) | A virtual curve, backed by collateral | Perpetual Protocol v1 | Medium | Prices drift from the market; mostly abandoned |
| Hybrid: off-chain matching, on-chain settlement | Other traders | dYdX v3 (StarkEx) and several newer venues with ZK-proven matching | High | Operator trust, liveness, censorship questions |
| Frontend on an existing venue | The venue's order book | Third-party Hyperliquid frontends using builder codes | Low | You own no liquidity or risk engine |
An order book on your own chain
Hyperliquid showed that a fully on-chain order book can match centralized exchange speed if the chain is built for it. Its market share data, covered in our Hyperliquid market analysis, explains why this architecture is the one everyone now compares against.
It's also the most expensive path by an order of magnitude. You are building a blockchain: consensus, validator operations, bridges, a matching engine in the state machine, and the tooling market makers expect. Unless you have a team that has shipped L1 infrastructure and the budget to run it for years, skip this.
HIP-3: deploy your own perp market on Hyperliquid
HIP-3 went live on Hyperliquid mainnet in October 2025 and lets anyone who meets the staking requirement deploy their own perp DEX on HyperCore. According to the current HIP-3 documentation:
- Stake. A deployer must stake 500,000 HYPE on mainnet. The docs say this is expected to decrease over time. The stake must be kept for at least 183 days after the DEX is deployed, and it stays slashable during the 7-day unstaking queue.
- Slashing. Validators can slash by stake-weighted vote. Guideline maximums are up to 100% for invalid state transitions or prolonged downtime, 50% for brief downtime and 20% for network degradation. Slashed stake is burned, not paid to users.
- What the deployer controls. The oracle definition and contract specs, setting oracle prices, leverage limits, and settlement by halting a market at the mark price.
- Assets. The first three assets on a perp DEX need no auction. More assets go through a Dutch auction shared across all HIP-3 DEXs.
- Fees. Deployers configure an additional fee share of 0 to 300% (0 to 100% in growth mode). Above 100%, the protocol fee rises to match.
- Collateral. Any quote asset can be the collateral for a DEX.
At current HYPE prices the stake is worth tens of millions of dollars, so for most teams HIP-3 is a capital question first. What you get in return is Hyperliquid's matching engine, liquidation system, wallets, liquidity network and user base. Your engineering work becomes the oracle feeder (you are responsible for publishing prices), the market specs, risk monitoring, a frontend and the operational discipline to never let your price feed go stale. Downtime is a slashing event, so treat the oracle service like production trading infrastructure with redundancy and alerts.
HIP-3 suits teams with a market others don't list: equity perps, pre-launch tokens, indices, commodities. If you just want to list BTC with your branding, a frontend with builder codes is far cheaper. For the wider HyperEVM and HyperCore picture, see our HyperEVM builder guide.
Oracle-priced pools (the GMX model)
In a GMX-style design, traders open positions against a liquidity pool at an oracle price, and LPs earn fees while taking the other side. GMX v2 uses isolated per-market pools, Chainlink low-latency prices with bid and ask bounds, price impact fees that rise when a trade worsens open interest imbalance, funding between longs and shorts, and borrowing fees on pool utilization.
The appeal: no market makers needed on day one, and it works on any EVM chain with a fast oracle. The risks: the LP pool loses money when traders are right in a strong trend, and the oracle is the attack surface. Pricing must use a low-latency signed feed such as Chainlink Data Streams, with spread and price impact tuned so that latency arbitrage is unprofitable.
The pool's accounting is also a target. In July 2025 an attacker took about $42 million from GMX v1 on Arbitrum. Halborn's analysis traces it to a reentrancy path that bypassed the global average short price update, which fed directly into GLP pricing. The fix for an earlier bug, rewarded with a bounty in 2022, introduced the new flaw and went unaudited. Any change to pool accounting needs a full review, however small the diff.
vAMM
A virtual AMM prices perps on an x·y=k curve with virtual reserves, while real collateral sits in a vault. Perpetual Protocol popularized it in 2020 and 2021. It needs no LPs and no market makers, but the curve price drifts from the real market and funding has to pull it back, which traders exploit. We don't recommend a pure vAMM for a new venue. Parts of the idea survive inside hybrid designs as a backstop liquidity source.
Hybrid off-chain matching
An operator runs a matching engine off-chain and settles trades on-chain, sometimes with ZK proofs that matching and liquidations followed the rules. You get CEX-grade latency on any chain. You also take on the questions users will ask: can the operator front-run, censor or go offline, and can users exit if it does? A forced-withdrawal path that works without the operator is the minimum answer.
The components every perp DEX needs
Whatever the architecture, the risk core looks the same. This is where perpetual futures exchange development spends its time.
| Component | What it does | Hard parts |
|---|---|---|
| Margin engine | Tracks collateral, positions, unrealized PnL; enforces initial and maintenance margin; cross and isolated modes | Real-time accuracy under load, multi-collateral haircuts |
| Mark price and oracles | Fair price for liquidations and PnL, from external feeds plus own book | Manipulation of thin markets, stale feeds, fallback logic |
| Liquidation engine | Closes undercollateralized positions before equity turns negative | Liquidating into thin books, cascades, backstop liquidity |
| Funding | Periodic payments between longs and shorts to keep perp price near the index | Formula, caps, interest component, timing |
| Insurance fund or LP vault | Absorbs losses when liquidations close below bankruptcy price | Sizing, who funds it, what happens when empty |
| Auto-deleveraging (ADL) | Closes profitable opposing positions when the backstop runs out | Fair ranking, user communication |
| Keepers | Execute orders, liquidations, funding updates on pool and hybrid designs | Liveness, MEV, incentives |
| Matching engine | Price-time priority order book, order types | Latency, determinism, fairness |
| Risk parameters | Max leverage, open interest caps, position limits per asset | Per-asset tuning, change process |
| Trading frontend and APIs | Charts, order entry, positions, WebSocket and REST APIs for market makers | Latency, reliability, API compatibility |
| Indexer and analytics | Trade history, PnL, funding history, leaderboards | Volume of events |
Hyperliquid's documentation is a good reference implementation for several of these. Its liquidation rules set maintenance margin at half the initial margin at max leverage (1.25% for 40x assets up to 16.7% for 3x assets), use a mark price that combines external exchange prices with the book, try to close positions on the order book first, and only hand them to a backstop liquidator vault inside HLP if equity falls below two thirds of maintenance margin. Its funding is paid hourly, combines a premium sampled every 5 seconds with a fixed interest component of 0.01% per 8 hours, and is capped at 0.5% per hour.
Copying parameters from a venue with deep books onto a venue with thin books is a common mistake. Your maintenance margin, liquidation sizes and open interest caps have to reflect your own liquidity.
Risk: the incidents worth studying
Before writing a line of code, read how real venues got hurt.
- Thin-market manipulation (Hyperliquid JELLY, March 2025). A trader opened a large short on a thin memecoin perp, then pulled margin so the position was liquidated into Hyperliquid's HLP vault, which ended up holding millions in unrealized losses as the spot price was pumped. Validators voted to delist the market and settle it at $0.0095, as The Block reported. The lesson: open interest caps relative to spot liquidity, and a clear policy for emergency settlement.
- Oracle manipulation. Mango Markets lost over $100 million in October 2022 when a trader pumped the thin spot market its oracle read and borrowed against the inflated collateral. Use multi-source, liquidity-weighted prices and cap positions where the spot market is small.
- Liquidation cascades (October 10, 2025). Roughly $19 billion of positions were liquidated across the market in a day, the largest on record. On Hyperliquid, liquidations exceeded what the backstop could absorb and auto-deleveraging closed profitable positions. Your ADL logic will be tested on your worst day, in public.
- Pool accounting bugs (GMX v1, July 2025). Covered above. Global state updates must be atomic and audited after every change.
For a perp DEX, the audit is a minimum. Add invariant fuzzing on margin and PnL accounting, simulations of price shocks against your parameters, and a published emergency procedure. Our post on smart contract security ROI covers how to budget the security side.
How to build a perp DEX, step by step
- Pick the architecture. Use the table above. Most teams end up on HIP-3, a pool model on an EVM chain, or a frontend with builder codes.
- Define markets and risk parameters. Which assets, max leverage, margin tiers, OI caps, funding formula. Write them as a document before code.
- Choose oracles. Primary feed, fallback, staleness thresholds, and what happens when they disagree.
- Build the risk core. Margin, liquidations, funding, insurance fund and ADL, with invariant tests on accounting.
- Build trading infrastructure. Matching or keeper network, APIs for market makers, indexer.
- Build the frontend. Order entry, positions, liquidation price display, funding history. Traders forgive plain design, not wrong numbers.
- Simulate. Replay historical crashes against your parameters. Check insurance fund depth against the October 2025 kind of day.
- Audit and launch with caps. Low OI caps and leverage at launch, raised as liquidity grows.
- Line up liquidity. Market makers for order books, LP incentives for pools. Without them, the best engine trades nothing.
How much does it cost to build a perp DEX?
These are our planning ranges for build work, by scope. They exclude audits, the HIP-3 stake, liquidity incentives, legal and market-making deals.
| Scope | What it includes | Timeline | Build budget (USD) |
|---|---|---|---|
| PoC | Pool-based or vAMM perp on testnet, one market, basic UI | 3–6 weeks | $25k–$60k |
| Branded frontend on an existing venue | Trading UI, builder code fees, analytics | 4–8 weeks | $30k–$80k |
| HIP-3 perp DEX | Oracle feeder with redundancy, market specs, risk monitoring, frontend | 6–12 weeks | $60k–$150k, plus the stake |
| MVP: oracle-pool perp on an EVM chain | Pool contracts, margin, liquidations, funding, keepers, frontend, indexer | 4–6 months | $200k–$450k |
| Production hybrid exchange | Off-chain matching, on-chain settlement, forced withdrawals, MM APIs | 6–9 months | $400k–$800k+ |
| Own order book chain | Consensus, matching, validators, bridge, full stack | 12+ months | $1.5M+ |
Audit costs scale with the risk core. Sherlock's 2026 reference puts mid-complexity DeFi audits at $40,000 to $100,000 and enterprise multi-chain systems above $150,000. A custom perp protocol usually lands in the upper part of that range, often with two firms. For a ballpark on your scope, use our cost calculator.
What moves the number most: the architecture, multi-collateral margin, number of order types, cross-margin, and whether you need market-maker-grade APIs from day one. For a broader comparison of exchange types and what to cut from an MVP, see our crypto exchange MVP guide.
Regulation (not legal advice)
Perpetual futures are derivatives almost everywhere. In the EU they fall under MiFID II rather than MiCA, which covers crypto-asset services but not derivatives, so an EU-facing perp venue run by an identifiable operator is a licensing question. In the US, the CFTC approved the first perpetual contract on a regulated exchange in May 2026, a bitcoin perp listed by Kalshi, and set out a case-by-case policy for others, as CoinDesk reported. That opens a regulated route for US venues; it doesn't make offering perps to US users from a DeFi frontend legal. Most perp DEX frontends still geoblock the US and other restricted jurisdictions and screen wallets. Bring counsel in before you decide who controls admin keys, oracles and the frontend.
What we've built
For DeSwarm, we built an AI DeFi terminal, automated yield vaults on Berachain's Proof of Liquidity and a perpetual DEX. On HyperEVM we built HyperBloom, a DEX aggregator routing across 12 exchanges with $300M+ in volume, so we know the Hyperliquid stack from the integration side too. The Hyperliquid ecosystem overview shows what else is being built there.
Frequently asked questions
How long does it take to build a perpetual DEX?
A branded frontend on an existing venue takes 4 to 8 weeks. A HIP-3 deployment takes 6 to 12 weeks of engineering once the stake is in place. A custom oracle-pool perp takes 4 to 6 months plus audits, and your own order book chain takes a year or more.
How much does it cost to build a perp DEX?
Our planning ranges go from $60,000 to $150,000 for a HIP-3 deployment (plus 500,000 HYPE staked) to $200,000 to $450,000 for a custom pool-based MVP, before audits. A hybrid exchange or your own chain costs far more. Liquidity incentives and market making are separate and often large.
What do I need to launch a perp market with HIP-3?
You need 500,000 HYPE staked and kept for at least 183 days after deployment, a reliable oracle service that publishes prices for your markets, market specs and leverage limits, and a frontend. Validators can slash the stake for downtime or invalid behaviour, so operations matter as much as code.
Is a GMX-style pool or an order book better for a new perp DEX?
A pool works without market makers and fits a new chain or a small set of liquid assets. An order book gives better prices for active traders but needs market makers from day one. Many teams avoid the choice by deploying on an existing order book via HIP-3 or a builder-code frontend.
What is the biggest risk in running a perp DEX?
Thin markets. Manipulating a thinly traded asset's price, via the oracle or the book, has caused the largest losses across perp venues. Conservative open interest caps, multi-source oracles and a tested liquidation and ADL path matter more than any single feature.
Build a perp DEX with us
We build perp DEXs, HIP-3 deployments, trading frontends and the oracle and keeper services behind them. If you're weighing HIP-3 against a custom build, we can scope both and tell you which one fits your capital and timeline. See our DeFi product development services or contact us.
Keep reading

DEX development: how to build a decentralized exchange in 2026
How to build a DEX in 2026: AMM designs from constant product to Uniswap v4 hooks and ve(3,3), the full component list, fork vs build licensing, costs by scope and security.

DEX aggregator development: how to build one that routes well
How a DEX aggregator actually works: pool indexing, route search, split routes, quote APIs, gas-aware pricing, MEV protection and the router contract that holds it together.

White label DEX and DeFi: build, fork, license or buy?
Four ways to launch a DEX or lending product: fork open code, license BUSL code, use white-label infrastructure, or build custom. Licence terms, security, cost and time compared.