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.
By Przemysław Paczoski, CEO & Founder at 23studio
Published 12 min read

To build a DEX, you pick a market design (an AMM such as constant product or concentrated liquidity, or an order book on a fast chain), write or fork the pool and router contracts, and build a swap frontend, an indexer, price feeds and a liquidity plan around them. A forked AMM MVP takes 6 to 10 weeks. A custom design takes 3 to 6 months plus an audit.
This guide covers the main DEX designs in use in 2026, what a production DEX is made of, when to fork and what the licences allow, realistic costs and timelines by scope, and the security work that keeps a DEX alive after launch.
Which kind of DEX are you building?
Most founders say "DEX" and mean a Uniswap-style swap app. The design choice decides your contracts, your liquidity strategy and most of your budget, so settle it first.
| Design | How prices form | Good for | Main weakness |
|---|---|---|---|
| Constant product AMM (x·y=k) | Pool reserves set the price along a fixed curve | Long-tail tokens, simple launches | Capital-inefficient, LPs carry impermanent loss |
| Concentrated liquidity (Uniswap v3 style) | LPs place liquidity in price ranges | Majors and stable pairs, deeper books per dollar | LP positions need active management, more complex math |
| Uniswap v4 with hooks | v4 pools plus custom logic at swap and liquidity events | Custom fees, oracles, limit orders, MEV capture without a new protocol | Every hook is new attack surface |
| ve(3,3) DEX (Velodrome, Aerodrome style) | AMM pools, with emissions directed by locked-token votes | Becoming the main liquidity hub on one or more chains | Tokenomics are the product; needs bribe markets and partners |
| Stable-swap curve | Curve-style invariant flat around the peg | Stablecoins and pegged assets | Narrow use case |
| Order book DEX | Bids and asks matched by price-time priority | Active trading, market makers, perps | Needs a fast chain or off-chain matching, plus market makers |
Constant product and concentrated liquidity
Constant product is the original Uniswap v2 model. It's the easiest to build and audit, and it works for any token pair from block one. The cost is capital efficiency: liquidity is spread from zero to infinity, so most of it never trades.
Concentrated liquidity lets LPs choose a price range. Uniswap describes it as liquidity allocated within a custom price range, which gives far deeper markets near the current price for the same capital. The trade-off is engineering. Tick math, fee growth tracking and position NFTs are where most v3 forks introduce bugs.
Uniswap v4 hooks
Uniswap v4 moved every pool into a single PoolManager contract and added hooks: external contracts that run code before or after swaps and liquidity changes. A hook can implement dynamic fees, on-chain limit orders, TWAMM orders, KYC gating or custom curves.
This changes the build-vs-fork question. You can often deploy a hook against the canonical v4 deployment on your chain instead of launching a whole DEX. You inherit Uniswap's audited core, its routing integrations and its liquidity, and you only own the hook. By September 2026, Crypto Briefing reported more than 90,000 hooks attached to live pools. That figure counts hooks linked to at least one pool, so many are trivial, but it shows the pattern has become normal.
ve(3,3) DEXs
The ve(3,3) model, popularized by Velodrome on Optimism and Aerodrome on Base, ties the AMM to tokenomics. Holders lock the DEX token, vote on which pools receive emissions, and receive fees and bribes from those pools. Protocols that want liquidity for their own token pay bribes to attract votes. It works when you can become the default liquidity venue on a chain and have partners willing to bribe. Without that, emissions just leak value.
The model keeps changing. Dromos Labs merged Aerodrome and Velodrome into a single DEX called Aero, which launched in October 2026 across seven networks, including Ethereum mainnet, Base and Arbitrum. If you plan a ve(3,3) launch, the contracts are the smaller job. Most of the work is token design, which we cover in how to design token economics that work.
Order book DEXs on fast chains
Order books need cheap, fast state updates. On most EVM chains that means off-chain matching with on-chain settlement. On chains built for trading, such as Hyperliquid's HyperCore, the order book is part of the chain itself. There, "building a DEX" can mean a trading frontend, market-making relationships and an integration with the native book, rather than new matching contracts. Our Hyperliquid DeFi ecosystem overview explains how HyperCore and HyperEVM fit together.
If you're comparing a DEX with a centralized exchange or an aggregator, our crypto exchange MVP guide walks through that decision first.
What a DEX is made of
A swap button hides a lot of moving parts. This is the component list we scope against.
| Component | What it does | Notes |
|---|---|---|
| Pool / pair contracts | Hold reserves, enforce the pricing curve, collect fees | The core risk. Smallest code, most review |
| Factory | Deploys pools, sets fee tiers, emits pool-creation events | Indexers and aggregators read these events |
| Router | Multi-hop swaps, slippage and deadline checks, native token wrapping | Users approve tokens to it, so treat it as high risk |
| Periphery | Position manager (LP NFTs for concentrated liquidity), quoter, permit support | Often more lines of code than the core |
| Governance and fees | Fee switch, protocol fee recipient, emissions and gauges for ve(3,3) | Admin keys decide your security and legal posture |
| Frontend | Swap, pools, positions, analytics, wallet connection | Most user complaints land here |
| Indexer | Pools, swaps, volumes, TVL, LP positions, charts | Subgraph or custom; see below |
| Oracles | Price data for analytics, TWAP for integrators, external feeds for hooks | Never use spot pool price as an oracle for lending |
| Liquidity bootstrapping | Seed pools, incentives, market makers, launch partners | Usually harder than the code |
| Monitoring | Alerts on large swaps, price deviation, admin actions, pausing | Set up before mainnet, not after the first incident |
For the indexer, The Graph vs a custom indexer covers the trade-offs. A DEX with concentrated liquidity positions usually outgrows a basic subgraph once you add per-position fee and PnL views.
Oracles deserve their own note. Your DEX will become a price source whether you plan it or not, and lending protocols that read raw pool prices get drained through flash-loan manipulation. Publish TWAP-friendly observations if your design supports them, and tell integrators clearly which price to use.
How to build a DEX, step by step
- Pick the chain and the design. The chain decides your users, tooling and competition. A new constant product AMM on a chain with three mature ones has no reason to exist. See which blockchain to build on if this is open.
- Decide fork, hook or custom. Covered in the next section. This decision moves the budget more than anything else.
- Write the spec and invariants. Fee math, rounding direction, who can change what, what happens with fee-on-transfer and rebasing tokens. Write the invariants you will later fuzz: "reserves never decrease without a matching transfer out", "k never decreases after a swap".
- Build contracts with tests from day one. Foundry unit tests, fuzz tests against the invariants, fork tests against real tokens on the target chain.
- Build the indexer and frontend in parallel. The frontend needs a quoting path (on-chain quoter or off-chain math), approvals that default to exact amounts or Permit2, and clear slippage settings.
- Run an internal review, then an external audit. Freeze the code before the audit. Every change after it needs a re-review.
- Plan liquidity before mainnet. Who seeds the first pools, with how much, and what keeps them there after incentives end. The token launch playbook covers pool seeding and launch-day mechanics.
- Launch with guarded limits. Caps on new pool types, a pause mechanism with a public policy, a bug bounty, and monitoring on admin actions.
- Get listed by aggregators. Much of your volume will arrive through routers like 1inch, 0x or chain-native aggregators. They need a clean factory event, a quoter and sometimes an adapter you help write.
Fork vs build: what the licences allow in 2026
Forking an audited AMM is the default for good reason. You skip the hardest maths and the audit focuses on your diff. The licence decides what you can fork.
| Codebase | Licence status (November 2026) | What it means for you |
|---|---|---|
| Uniswap v2 | GPL-3.0 | Free to fork. The most-forked DEX code in existence |
| Uniswap v3 core | Business Source License until April 1, 2023, then converted to GPL-2.0-or-later | Free to fork and deploy under GPL terms |
| Uniswap v4 core | Business Source License 1.1; production use needs a grant until the Change Date | Change Date is June 15, 2027 or earlier if governance sets one; then MIT |
| Building a v4 hook | Your hook is your code | No core fork needed; you deploy against the existing v4 deployment |
| Velodrome / Aerodrome contracts | Check each repo; older versions were forked widely | Read the licence of the exact version you copy |
We found no 2026 governance change that moved the v4 Change Date earlier, so as of this writing a production fork of v4 core still needs an Additional Use Grant from Uniswap governance or a commercial licence until mid-2027. Reading the licence file yourself before you commit is cheap. Our post on white-label DeFi: build, fork, license or buy goes through BUSL terms and white-label options in detail.
When to build custom instead:
- The pricing mechanism is your product, for example a new curve for a specific asset class.
- You need behaviour that hooks can't express, or the chain has no v4 deployment.
- You're on a non-EVM chain where no audited codebase fits.
When not to: if your differentiation is branding, fees or a token, fork or use a hook. Custom AMM math costs months and an expensive audit, and the market rarely pays for a slightly different curve.
How much does it cost to build a DEX?
These are our planning ranges for build work by scope, based on the DeFi products we've shipped. They exclude the external audit, liquidity capital, legal work and marketing.
| Scope | What it includes | Timeline | Build budget (USD) |
|---|---|---|---|
| PoC | Forked AMM on testnet, basic swap UI, no indexer | 2–4 weeks | $15k–$40k |
| MVP: fork of an audited AMM | Your fee and token changes, swap and pool UI, subgraph, mainnet deploy | 6–10 weeks | $40k–$100k |
| MVP: Uniswap v4 hook | One or two custom hooks, frontend, indexer, routing integration | 6–12 weeks | $50k–$150k |
| MVP: custom AMM or concentrated liquidity design | New math, position manager, custom indexer, analytics | 10–16 weeks | $120k–$300k |
| Order book DEX on a native book (e.g. HyperCore) | Trading UI, order management, integrations | 8–14 weeks | $80k–$200k |
| Production ve(3,3) or multi-chain DEX | Gauges, voting, bribes, emissions, multiple chains, full analytics | 4–6+ months | $250k–$500k+ |
On top of the build, budget for the audit. Sherlock's 2026 market reference puts a mid-complexity DeFi protocol audit at $40,000 to $100,000, with each re-audit pass after fixes adding $5,000 to $20,000. A fork with a small diff can come in lower; novel concentrated liquidity math or a ve(3,3) system sits at the top.
What moves the number:
- Novel maths. Any new curve or tick logic multiplies testing and audit time.
- Number of chains. The second chain is cheaper than the first, but each one adds deployment, indexing and monitoring.
- Tokenomics. Gauges, vote escrow and bribes are a protocol of their own.
- Analytics depth. LP PnL, fee APR and position history are a lot of indexer work.
- Liquidity. Not a build cost, but often the biggest line in the launch budget.
For a ballpark on your own scope, try our cost calculator. For costs across other project types, see blockchain app development cost.
DEX security: where they actually break
DEX exploits cluster in a few places. Plan reviews around them.
- Rounding and precision. Small rounding errors in favour of the user compound across thousands of swaps or can be looped in one transaction. Round against the user, consistently, and fuzz it.
- Reentrancy and callbacks. Concentrated liquidity and v4 both call back into user contracts during swaps. Every callback path needs a reentrancy model you can explain.
- Weird tokens. Fee-on-transfer, rebasing, tokens with hooks (ERC-777) and tokens that return no boolean. Decide which you support and test each.
- Router approvals. Users approve the router, so an arbitrary-call bug there drains wallets, not pools. Our DEX aggregator guide covers router design and the LI.FI approval incident.
- Hooks. A malicious or buggy hook can block withdrawals or skim swaps on its pool. Audit hooks as seriously as core contracts, and make their permissions visible to users.
- Admin keys. Use a multisig with a timelock for fee changes and upgrades. Fewer admin powers also help your regulatory position, since MiCA's carve-out only covers services provided in a fully decentralised manner.
- Price manipulation by integrators. Not your bug, but your pools will be used to attack lending markets that read spot prices. Offer a TWAP and document it.
After launch, run a bug bounty and real-time monitoring. Our smart contract audit checklist covers what to prepare before the audit starts.
What we learned building trading infrastructure
We built HyperBloom, a DEX aggregator on HyperEVM that routes across 12 exchanges, with auto-compounding vaults audited by Pashov and a public swap API. It has routed more than $300M in volume. Working on the routing side taught us what makes a new DEX easy or hard to integrate: clean factory events, a quoter that matches the pool math exactly, and no surprises in token handling. If your DEX is painful for aggregators to integrate, it loses the volume that would have come through them.
Frequently asked questions
How long does it take to build a DEX?
A forked AMM MVP with a frontend and indexer takes about 6 to 10 weeks of build time, plus 2 to 6 weeks for an audit and fixes. A custom AMM or concentrated liquidity design takes 3 to 4 months, and a ve(3,3) or multi-chain production DEX takes 4 to 6 months or more.
How much does it cost to build a DEX?
Our planning ranges run from $40,000 to $100,000 for a forked AMM MVP up to $250,000 to $500,000+ for a production ve(3,3) or multi-chain DEX. Add $40,000 to $100,000 for a typical DeFi audit, plus liquidity, which is often the largest launch cost.
Can I fork Uniswap legally?
Uniswap v2 (GPL-3.0) and v3 core (converted to GPL in April 2023) can be forked under GPL terms. Uniswap v4 core is under a Business Source License until June 15, 2027 unless governance sets an earlier date, so production forks need a grant or licence. Building a hook on the existing v4 deployment doesn't require a fork.
Should I build an AMM or an order book DEX?
An AMM works from day one without market makers and suits most new tokens and smaller chains. An order book suits active traders and professional market makers but needs a fast chain or off-chain matching. On chains with a native order book, like HyperCore, building on the book is usually cheaper than writing your own matching.
What is the hardest part of DEX development?
The contracts are hard to get right but well understood. Attracting and keeping liquidity is harder, and it decides whether anyone trades on your DEX. Plan liquidity, incentives and aggregator integrations alongside the code.
Building a DEX with us
We design and build DEXs, hooks, routers and the indexers and frontends around them, and we've shipped trading infrastructure that routed $300M+ in volume. If you're deciding between a fork, a hook and a custom design, we can scope it with you. See our DeFi product development services or contact us with your chain and target pairs.
Keep reading

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.

Crypto exchange MVP development: a founder's guide for 2026
What to build first when you launch a crypto exchange: which model to pick, what the MVP needs, how to handle audits, liquidity and MiCA, and what it costs.

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.