Book a free call

DEX Best Practices for Teams That Run One

A DEX holds user funds in code, so safe operation matters more than features. Learn the audit, key, liquidity, fee and incident practices that keep it running.

Hertiv engineering teamReviewed by a senior engineer
5 min read
DEX Best Practices for Teams That Run One
On this page

Short answer

A DEX best practice is an operating habit that protects user funds and keeps trading fair: audited contracts, multisignature admin keys with a timelock, deep liquidity, published fees, slippage limits and a tested incident plan with a pause function.

What are DEX best practices?

DEX best practices are the operating habits that keep a decentralised exchange safe, liquid and usable: audited contracts, guarded admin keys, honest fees, deep liquidity and a tested plan for when something goes wrong.

A DEX is software that holds user funds and moves them on rules written in code. Unlike a centralised exchange, there is no support desk that can reverse a bad trade, so the practices that matter are the ones that prevent losses and limit damage when a bug or an attack appears.

Area Practice Why it matters
Smart contracts Audit before launch, re-audit after changes Bugs lock or drain funds
Admin keys Multisig plus timelock One stolen key cannot move funds
Liquidity Incentives and depth targets Thin pools mean high slippage
Fees Clear tiers, oracle-based pricing Hidden costs drive traders away
Monitoring Alerts on large moves Fast response limits damage
Incident plan Pause function, tested runbook A rehearsed team acts in minutes

These practices are not one-off tasks. They are routines that run every week the exchange is live. If you are new to the topic, what a DEX is and how it works covers the basics first.

How do you protect user funds?

You protect user funds by making the contracts hard to break and the admin keys hard to steal. That means an independent audit before launch, a bug bounty that pays researchers to find flaws, and a re-audit after any material change.

Admin functions, such as upgrading contracts, changing fees or pausing trading, should sit behind a multisignature wallet with a timelock, so no single person can act alone and users have time to react to an announced change. Keep admin keys on hardware devices, never on a shared laptop or in a chat log.

Limit what any one contract can hold. Route fees to a separate treasury, cap the size of a single pool where you can, and test the upgrade path on a test network before touching production.

If you are planning the build, how to implement a DEX step by step covers the construction side before these operating practices take over.

How do you keep liquidity healthy?

Liquidity stays healthy when traders can swap without moving the price much, which needs depth across the price range and incentives that reward providers for staying through quiet periods.

Watch depth, not just total value locked. A pool with a large headline number but thin depth near the current price will still give bad fills. Set a depth target for your busiest pairs and check it daily.

Pay providers fairly and transparently. Fee tiers should match the pair: stable pairs need low fees and tight ranges, while volatile pairs need higher fees to cover the risk of price moves. Change incentives with notice, not overnight.

Plan for a large provider leaving. If one wallet supplies half the depth, its exit is a single point of failure. Spread incentives so no provider dominates a pool.

How do you handle fees and pricing?

Fees and pricing should be visible before a trader confirms, and the price a trade executes at should be close to the price shown. Surprises here are the fastest way to lose traders.

Use a reliable price feed for reference prices and set a maximum slippage that protects traders from sandwich attacks, where a bot trades ahead of a large order. Let traders set their own slippage limit rather than hiding it.

Keep fee tiers simple and publish them. A trader who cannot work out what a swap will cost will go to an exchange where they can. Review fees when volumes or volatility change, and announce changes in advance. Traders compare exchanges on fees and fills, and how DEXs differ from centralised exchanges explains what they weigh.

Test the fee math on small trades first. A rounding error in a fee calculation is cheap to catch in testing and expensive to fix after launch.

How do you monitor and respond to incidents?

You monitor a DEX by watching the numbers that signal trouble: sudden outflows, unusual trade sizes, oracle prices that jump, and admin actions that nobody expected. Alerts should reach a human within minutes, day or night.

Keep a pause function that can halt trading or withdrawals, and test it regularly. A pause that has never been tested is a hope, not a control. The runbook should name who decides, who acts, and how users are told what happened.

After any incident, write down what happened, what the fix was, and what changes so it cannot repeat. Publish a summary to users when funds or trades were affected; silence after an incident damages trust more than the incident itself.

Rehearse the plan with the whole team at least twice a year. The first time you run an incident should not be the real one.

Example (hypothetical): a small token market opens

Example (hypothetical): a team launches a DEX for a new token with a $100,000 pool. In the first week, daily volume is $20,000 and the 0.3% fee earns $60 a day, or about $1,800 a month. The launch sequence is covered in how to build a DEX.

A single provider supplies $60,000 of the pool. When that provider withdraws, depth halves and a $5,000 trade that used to move the price 0.5% now moves it 1.1%. Traders notice and volume falls to $12,000 a day, cutting fee income to $36 a day.

The team responds by splitting incentives across five providers and setting a depth target of $40,000 within 1% of the price. Within a month, no provider holds more than 25% of the pool and volume recovers to $18,000 a day.

What are the common mistakes?

The most common DEX mistakes are launching without an audit, letting one provider dominate a pool, and having no tested way to stop trading when something goes wrong.

  • Skipping the audit to save time. A bug found after launch costs far more than the audit did.
  • Admin keys held by one person on one device. One theft or loss can move all funds.
  • Fee tiers copied from another exchange. They may not fit your pairs or your volumes.
  • No slippage limit. Traders get sandwiched by bots trading ahead of them.
  • Monitoring that nobody watches outside office hours. Attacks do not keep office hours.
  • No pause function, or one never tested. The team cannot stop a bad situation.
  • Changing incentives overnight. Providers leave and depth collapses.

Key takeaways

  • Audit contracts before launch and re-audit after any material change
  • Put admin functions behind a multisig wallet with a timelock, on hardware keys
  • Watch depth near the price, not just total value locked, and spread incentives
  • Publish fee tiers and let traders set their own slippage limit
  • Alert on unusual moves within minutes and rehearse the incident runbook twice a year
  • No single provider should dominate a pool, and no pause function should go untested

Frequently asked questions

Do small DEXs need an audit?

Yes. Size does not protect a contract: attackers scan small pools too, and a bug in a small pool still drains it. A scoped audit of the core contracts plus a bug bounty is the minimum before launch, and any change to those contracts should be reviewed again before it ships.

What is a timelock, and why does it matter?

A timelock is a delay between announcing an admin action and it taking effect, often 24 to 48 hours. It matters because it gives users time to react if a malicious or mistaken change is proposed. Without it, a compromised admin key can move funds or change fees instantly.

How much liquidity does a new DEX need?

There is no fixed number, but depth near the current price matters more than the headline total. A useful target is enough depth that a typical trade moves the price by less than 1%. Track depth daily and set incentives so no single provider supplies most of it.

What slippage limit should traders use?

It depends on the pair and the trade size. Stable pairs can use a low limit, such as 0.1% to 0.5%, while volatile pairs need more room, often 1% or higher. The key point is that the trader sets the limit and sees it before confirming, rather than the exchange hiding it.

Can a DEX pause trading?

Yes, if the contracts include a pause function and the team has tested it. A pause halts swaps or withdrawals while the team investigates, which limits damage during an attack or a bug. The function itself must be guarded by the same multisig and timelock as other admin actions.

How often should a DEX re-audit its contracts?

After every material change to the audited code, and at least once a year even without changes, because new attack patterns appear over time. A re-audit can be narrower than the first one, focused on what changed, but skipping it leaves the newest code unchecked.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: blockchain systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning a DEX and want the audit, key and liquidity setup done right? Talk to Hertiv.

A senior engineer replies within one business day. Or see our DEX Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call