BR Group
Article wallpaper
Home / Blog / DEX market making: code, gas & dynamic fees

DEX market making: code, gas & dynamic fees

INTRODUCTION

Decentralized exchanges have evolved from vanilla Uniswap v2 pools to today’s powerhouses with concentrated liquidity, private auctions, and HFT bots on L2. A smart-contract AMM once looked like a self-driving market maker, but reality flipped the script: without active market makers (MMs) even the prettiest pool bleeds liquidity providers (LPs) and feeds front-runners.
In 2025 an on-chain MM writes code, pays gas, hunts micro-slippage, and still has to explain to regulators why its bot is not an unlicensed broker. Below is a practical map of modern DEX market making—what works, what still hurts, and where the data gaps lie.

WHY A DEX NEEDS MARKET MAKERS

• An idle range drains liquidity: price breaks out, capital sits uselessly in one token.
• Passive LPs donate fees to fast arbitrageurs; traders pay wide spreads, pools shrink.
• Active MMs keep prices tight, cut impermanent loss, and raise trust in the protocol.

FACT BOX
— In January 2025 the average ETH/USDC spread on top DEXes with active MM was 0.28 %, versus 1.1 % on “passive” rivals.
— Addresses running Uniswap v3 rebalance bots jumped 5× year-on-year.

AMM MECHANICS AND CONCENTRATED LIQUIDITY

PREDICTABLE LP LOSS

Classic x·y = k pools expose LPs to impermanent loss and the “informed-trader tax.”
As soon as price exits the range, LPs sell assets at stale quotes and hand hidden profit to arbitrageurs.

RANGE REBALANCE AND “BREATHING” FEES

The winning combo is:

Frequent rebalance—bot recenters the range every ±0.3 % move.

Dynamic fee—contract raises fees when volatility spikes and lowers them in calm periods.
Together they cut predictable loss by roughly one-third and almost double fee revenue share.

ADVANCED ON-CHAIN MM TOOLS

HOOKS ON UNISWAP V4

Version 4 turns a pool into Lego: add a hook for auto-range shift, formula-based fees, or auto-farm of earned fees. Great control, bigger gas bill—plus a smart-contract audit.

JIT LIQUIDITY—BOON OR VAMPIRE?

Just-in-Time bots inject liquidity for a single block, collect the fee, and vanish.
Traders love the tighter price; passive LPs hate the stolen revenue.

FACT BOX
— Paradigm data: on popular pairs JIT activity captures up to 85 % of fees that would otherwise go to passive LPs.

ON-CHAIN HFT ON L2

Optimism and Arbitrum now finalize blocks in under a second.
With a private relay and self-hosted node pushing round-trip below 250 ms, micro-arbitrage between chains—and even against CEX quotes—becomes viable.

INCENTIVES AND “PURCHASED” LIQUIDITY

KPI: ONE DOLLAR GRANT → FOUR DOLLARS STICKY TVL

Best programs enforce the 1-to-4 rule. Without hard KPIs, liquidity tourism erupts: farmers grab the airdrop and flee.

GAS, MEV, AND PRIVATE AUCTIONS

FLASHBOTS RELAY AND PRIVATE MEMPOOLS

Public mempools invite sandwich attacks. Private relays route orders directly to block builders, pay a tip, and skip MEV. The trade-off: extra latency and reliance on a centralized relay.

REGULATORY FRONT

CFTC ON “PSEUDO BROKERS” IN SMART-CONTRACTS

US regulators may classify automated LP contracts as broker-dealers, forcing risk disclosure and rebalance logs. Protocols might need a new disclaimer layer and standard LP-loss reports.

KEY TAKEAWAYS FOR MARKET MAKERS

• Auto-rebalance plus dynamic fees are survival basics, not luxuries.
• Code is the new alpha: faster hooks capture more fees.
• Incentives without KPIs burn treasury; pay only for working liquidity.
• Private relays and own nodes tame MEV; without them on-chain HFT is just a gas donor.

BLIND SPOTS AND OPEN RESEARCH

• No public 12-month PnLs for custom hooks—do they repay audits and gas?
• No agreed fairness metric for private auctions.
• Conflicting data on whether rising TVL always deepens DEX books.
• Regulatory thresholds still draft notes—industry must join the debate.

CONCLUSION AND ACTION PLAN

On-chain market making is a race of code and gas. Static liquidity loses to dynamic code; the “deposit and chill” era is over. Winners will:

  • Automate range shifts based on real-time volatility.
  • Let fees breathe, protecting LP income in rough seas.
  • Use private relays for big trades and publish saved-slippage stats.
  • Demand the 1→4 KPI before accepting incentive grants.

 

Like this post? Share it:

Read More