# How Concentrated Liquidity & Modular Architecture Work

{% hint style="info" %}
**Note for DEX Teams:**

**Understanding the engine behind your DEX.** This section outlines the mechanics of concentrated liquidity & modularity, the core innovations Algebra brings to decentralized exchanges. Grasping how liquidity is deployed and interacts with trades helps users to evaluate capital efficiency.
{% endhint %}

## Introduction to Concentrated Liquidity

Decentralized exchanges (DEXes) are evolving. If you’ve used a V2 AMM (like Uniswap V2), you’re used to a simple system: you deposit two tokens into a liquidity pool, and the AMM spreads your funds evenly across the full price curve — from zero to infinity. This is simple, but not very efficient.

That’s where concentrated liquidity, introduced in V3-style AMMs comes in.

### **The Problem with V2 Liquidity**

In a V2 pool, all liquidity providers (LPs) share one big pool. Your capital is spread across all possible prices, even if most trading happens within a narrow range. This means:

* Much of your liquidity sits unused
* Capital is inefficient — large deposits don’t add much trading depth where it’s needed
* Traders face higher price impact unless the pool is over-capitalized

### **How Concentrated Liquidity Solves It**

In V3/V4, LPs can choose the price range where their liquidity is active. This means:

* You only provide liquidity in the range you expect trades to happen (e.g., $1,500–$2,000 for ETH)
* Your capital is used more effectively — you earn more fees with less money
* Liquidity is concentrated, not diluted, around active price points

Think of it like zooming in on the part of the price chart that matters most.

### **Key Differences: V2 liquidity vs V3/V4 liquidity**

| Feature                | V2 (Classic AMM)  | V3/V4 (Concentrated Liquidity) |
| ---------------------- | ----------------- | ------------------------------ |
| Liquidity distribution | Across all prices | Within chosen price ranges     |
| Capital efficiency     | Low               | High                           |
| Fee earning range      | Always active     | Only when price is in range    |
| Custom strategies      | Not possible      | Fully customizable             |

### **What This Means for Users**

With concentrated liquidity, users get more control and better rewards — but also more responsibility. If the market price leaves your chosen range, your position becomes inactive (out-of-range) and stops earning fees until it returns.

In short: Concentrated liquidity makes your capital work smarter, not harder — a powerful upgrade from the V2 experience.

## How Modular Architecture Enhances It Further

Decentralized‑exchange infrastructure is entering its next phase. Traditional AMM codebases—whether V2 or V3—ship as **single, immutable deployments**: once the contracts are live, every pool, fee rule, or incentive mechanism is frozen in stone. If the market demands a new feature, a DEX has only two choices: hard‑fork the entire protocol and migrate liquidity, or fall behind. **Algebra Integral** turns that dilemma on its head with a **plugin‑based, modular architecture** that lets a DEX upgrade safely and on‑chain, while its pools keep running.

### The Problem with Immutable Protocols

In a monolithic design, **core logic, fee math, liquidity storage, and incentives all live in one contract suite**. Any change—from a better fee formula to a new farming program—means redeploying everything and asking LPs to move funds. As a result:

|                         |                                                                            |
| ----------------------- | -------------------------------------------------------------------------- |
| **Pain Point**          | **Impact on a Classic (Immutable) DEX**                                    |
| **Slow Iteration**      | Feature requests take months and a new audit cycle.                        |
| **Liquidity Migration** | Users must withdraw and redeposit, risking downtime and slippage.          |
| **One‑Size‑Fits‑All**   | Every pool inherits the same fee logic, even if assets behave differently. |
| **Upgrade Risk**        | A bug in an upgrade can jeopardize the entire protocol.                    |

***

### How Modular Architecture Solves It

Algebra Integral splits the DEX into two layers — Immutable core and interchangeable Plugins:

| **Feature**        | **Monolithic AMM**               | **Algebra Integral (Modular)**                                           |
| ------------------ | -------------------------------- | ------------------------------------------------------------------------ |
| **Core Contracts** | Immutable **and** feature‑rich   | Immutable *only* for swap & storage—minimal attack surface               |
| **New Logic**      | Requires full redeploy           | Added as **plug‑in modules** (Dynamic Fee, Farming, Safety Switch, etc.) |
| **Upgrades**       | Liquidity migration + new audits | Hot‑swap or time‑box a plugin; no liquidity moves                        |
| **Customization**  | Same rules for every pool        | Each pool chooses its own plugin set                                     |

With this model, a DEX can:

* Turn on dynamic fees during high volatility, then switch back to static fees to save gas.
* Add an NFT‑based fee‑discount plugin for a marketing campaign, disable it later without touching core liquidity.
* Introduce JIT‑liquidity protection or LVR mitigation only on the pairs that need it.

All while LP capital stays exactly where it is.

### What It Means for Users

* **Better Features, Faster** – Traders and LPs see new tools (VIP tiers, limit orders, security switches) without waiting for a protocol fork.
* **Zero Liquidity Migration** – Your positions remain intact; no forced withdrawals, no downtime.
* **Granular Pool Choices** – Each trading pair can advertise the plugins it runs, letting you pick pools that match your risk and reward profile.
* **Future‑Proof Experience** – As DeFi innovates, the DEX you use can adopt the latest mechanics with a simple plugin upgrade—not a disruptive relaunch.

In short, **modular architecture keeps the protocol agile while keeping your capital safe and productive**—a decisive upgrade over the immutable designs of the past.<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.algebra.finance/algebra-integral-documentation/user-guide-template-for-dexes/concentrated-liquidity-and-modular-architecture-basics/how-concentrated-liquidity-and-modular-architecture-work.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
