All posts

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 , CEO & Founder at 23studio

Published 12 min read

DEX development: how to build a decentralized exchange in 2026

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.

DesignHow prices formGood forMain weakness
Constant product AMM (x·y=k)Pool reserves set the price along a fixed curveLong-tail tokens, simple launchesCapital-inefficient, LPs carry impermanent loss
Concentrated liquidity (Uniswap v3 style)LPs place liquidity in price rangesMajors and stable pairs, deeper books per dollarLP positions need active management, more complex math
Uniswap v4 with hooksv4 pools plus custom logic at swap and liquidity eventsCustom fees, oracles, limit orders, MEV capture without a new protocolEvery hook is new attack surface
ve(3,3) DEX (Velodrome, Aerodrome style)AMM pools, with emissions directed by locked-token votesBecoming the main liquidity hub on one or more chainsTokenomics are the product; needs bribe markets and partners
Stable-swap curveCurve-style invariant flat around the pegStablecoins and pegged assetsNarrow use case
Order book DEXBids and asks matched by price-time priorityActive trading, market makers, perpsNeeds 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.

ComponentWhat it doesNotes
Pool / pair contractsHold reserves, enforce the pricing curve, collect feesThe core risk. Smallest code, most review
FactoryDeploys pools, sets fee tiers, emits pool-creation eventsIndexers and aggregators read these events
RouterMulti-hop swaps, slippage and deadline checks, native token wrappingUsers approve tokens to it, so treat it as high risk
PeripheryPosition manager (LP NFTs for concentrated liquidity), quoter, permit supportOften more lines of code than the core
Governance and feesFee switch, protocol fee recipient, emissions and gauges for ve(3,3)Admin keys decide your security and legal posture
FrontendSwap, pools, positions, analytics, wallet connectionMost user complaints land here
IndexerPools, swaps, volumes, TVL, LP positions, chartsSubgraph or custom; see below
OraclesPrice data for analytics, TWAP for integrators, external feeds for hooksNever use spot pool price as an oracle for lending
Liquidity bootstrappingSeed pools, incentives, market makers, launch partnersUsually harder than the code
MonitoringAlerts on large swaps, price deviation, admin actions, pausingSet 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

  1. 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.
  2. Decide fork, hook or custom. Covered in the next section. This decision moves the budget more than anything else.
  3. 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".
  4. Build contracts with tests from day one. Foundry unit tests, fuzz tests against the invariants, fork tests against real tokens on the target chain.
  5. 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.
  6. Run an internal review, then an external audit. Freeze the code before the audit. Every change after it needs a re-review.
  7. 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.
  8. Launch with guarded limits. Caps on new pool types, a pause mechanism with a public policy, a bug bounty, and monitoring on admin actions.
  9. 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.

CodebaseLicence status (November 2026)What it means for you
Uniswap v2GPL-3.0Free to fork. The most-forked DEX code in existence
Uniswap v3 coreBusiness Source License until April 1, 2023, then converted to GPL-2.0-or-laterFree to fork and deploy under GPL terms
Uniswap v4 coreBusiness Source License 1.1; production use needs a grant until the Change DateChange Date is June 15, 2027 or earlier if governance sets one; then MIT
Building a v4 hookYour hook is your codeNo core fork needed; you deploy against the existing v4 deployment
Velodrome / Aerodrome contractsCheck each repo; older versions were forked widelyRead 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.

ScopeWhat it includesTimelineBuild budget (USD)
PoCForked AMM on testnet, basic swap UI, no indexer2–4 weeks$15k–$40k
MVP: fork of an audited AMMYour fee and token changes, swap and pool UI, subgraph, mainnet deploy6–10 weeks$40k–$100k
MVP: Uniswap v4 hookOne or two custom hooks, frontend, indexer, routing integration6–12 weeks$50k–$150k
MVP: custom AMM or concentrated liquidity designNew math, position manager, custom indexer, analytics10–16 weeks$120k–$300k
Order book DEX on a native book (e.g. HyperCore)Trading UI, order management, integrations8–14 weeks$80k–$200k
Production ve(3,3) or multi-chain DEXGauges, voting, bribes, emissions, multiple chains, full analytics4–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

Ready when you are

Tell us what you are building and where you are stuck. You get a reply from an engineer and a scoped estimate for a PoC, MVP or full launch. We reply within 24 hours, usually the same business day.

23stud.ioWeb3 and blockchain development studio. Advice, development, team extension or complete project delivery.
Copyright © 2026 23stud.io. All rights reserved