> For the complete documentation index, see [llms.txt](https://guide.dem.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.dem.exchange/earn/liquidity-pools/liquidity-pools.md).

# Spot Pools

No 👙 required.

### **Overview** <a href="#overview" id="overview"></a>

Powered by the [Hybrid Liquidity Engine](https://docs.carbon.network/carbon-core/trading-modules/liquidity-pools), Demex was the first protocol to combine AMMs with order books on spot markets. This means that the liquidity pool module is able to interoperate with the order books to display AMM liquidity on the orderbook DEX in real-time.

As such, trading of spot markets is supported by liquidity pools. Liquidity providers (LPs) can earn fees from market maker rebates, spread, and protocol incentives.

### How it Works <a href="#how-it-works" id="how-it-works"></a>

An order book is available for each coin pair. Users can submit both limit and market orders and transparently observe existing limit orders on order books. The orderbook helps to facilitate a good onboarding process for users who are familiar with orderbooks on CEXs.

Next, liquidity pools offer permissionless liquidity via smart contracts, bypassing the need for intermediaries.

When a user is swapping tokens, they are depositing tokens into the pool to remove a market rate amount of the other token. **The effective price for the swap is determined by the ratio of tokens in the pool.**

<figure><img src="https://docs.carbon.network/~gitbook/image?url=https%3A%2F%2F973379612-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MW8gDIAbhDIzD88opzA%252Fuploads%252FlEcf4WENtDrbqetnxFfj%252FAMM%2520Gitbook%2520Guide-1.png%3Falt%3Dmedia%26token%3D2e0d9858-53ac-4e72-a786-2592b981a293&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=5f7c4a53&#x26;sv=2" alt=""><figcaption></figcaption></figure>

For a token pair, a liquidity pool can be created by anyone on Demex. By simply depositing a pair of coins (in corresponding ratios) into a pool, anyone can become a liquidity provider.

Let us imagine trading ETH tokens for SWTH tokens on [Demex](https://app.dem.exchange/). After swapping the tokens, the algorithm calculates how much the trade impacts the liquidity pool’s reserves, after which a price quote is given.

<figure><img src="https://docs.carbon.network/~gitbook/image?url=https%3A%2F%2F973379612-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MW8gDIAbhDIzD88opzA%252Fuploads%252FCX3p7Ok0bu5gbUpij1Bc%252FAMM%2520Gitbook%2520Guide-2.png%3Falt%3Dmedia%26token%3D0e590f44-2cbf-4edc-b673-b0d197961a76&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=a126e8d7&#x26;sv=2" alt=""><figcaption></figcaption></figure>

After approving the transaction, the AMM sends SWTH tokens into the ETH-SWTH pool. Finally, it sends the quoted amount of ETH from the pool to the user’s wallet.

<figure><img src="https://docs.carbon.network/~gitbook/image?url=https%3A%2F%2F973379612-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MW8gDIAbhDIzD88opzA%252Fuploads%252FhS0e1oRoUNrC4eJV1Qs9%252FAMM%2520Gitbook%2520Guide-3.png%3Falt%3Dmedia%26token%3D349ec35c-7050-414d-91ba-edc77cf5dc49&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=c48ea266&#x26;sv=2" alt=""><figcaption></figcaption></figure>

To buy ETH (x) on Demex, users need to add SWTH (y) tokens to the pool. Note that k demands that the amount of liquidity remains constant. Therefore, by adding SWTH tokens, users increase one side of the pool and decrease the other (removing ETH).

The pool price is defined as the ratio of the number of quote coins and the number of base coins in the pool. For the coin pair `A-B`, the pool price is the number of coin `B` divided by the number of coin `A` in the pool.

<figure><img src="https://docs.carbon.network/~gitbook/image?url=https%3A%2F%2F973379612-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MW8gDIAbhDIzD88opzA%252Fuploads%252FOzdaqlQE8cyt4EJhQ0TX%252FAMM%2520Gitbook%2520Guide-4.png%3Falt%3Dmedia%26token%3Dc867d402-55e1-4efd-8659-3cb54d7fd571&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=71337b2b&#x26;sv=2" alt=""><figcaption></figcaption></figure>

In our example, the algorithm divides the pool's total liquidity by the new amount of SWTH in the pool, then divides that by the new amount of ETH in the pool so that (k / y) / x = price. This is how the protocol determines the price paid for ETH (and other tokens), which will increase the more ETH is bought from the pool.

#### AMM-Orderbook Hybrid <a href="#amm-orderbook-hybrid" id="amm-orderbook-hybrid"></a>

Under the hybrid model, users can play several roles:

* Trader
* Liquidity provider

The liquidity of a token pair automatically makes orders in the orderbook of the token pair by the [Constant Product Market Maker (CPMM) model](https://docs.carbon.network/carbon-core/trading-modules/liquidity-pools/spot-pools/uneven-pool-weights).

<figure><img src="https://docs.carbon.network/~gitbook/image?url=https%3A%2F%2F973379612-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MW8gDIAbhDIzD88opzA%252Fuploads%252F4N9vylwVUl4SgobZQgjs%252FAMM%2520Gitbook%2520Guide-9.png%3Falt%3Dmedia%26token%3Dad541d38-0109-42cd-a8d6-775fd7ff05f0&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=735f7a66&#x26;sv=2" alt=""><figcaption></figcaption></figure>

As illustrated above, liquidity in the pool is automatically converted to orders to be submitted to the orderbook.

<figure><img src="https://docs.carbon.network/~gitbook/image?url=https%3A%2F%2F973379612-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MW8gDIAbhDIzD88opzA%252Fuploads%252Fni9nYljvUdGUgJ7IDLyQ%252FAMM%2520Gitbook%2520Guide-10.png%3Falt%3Dmedia%26token%3D5b84b7ff-2509-453c-963a-dd38181b7959&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=aa84d015&#x26;sv=2" alt=""><figcaption></figcaption></figure>

The AMM provided by the liquidity pool coexists with traditional market makers. This facilitates greater capital efficiency for traders who can enjoy the effectively abundant liquidity on the orderbook.

Liquidity pools also feature flexible bonding curves via [Uneven Pool Weights](https://docs.carbon.network/carbon-core/trading-modules/liquidity-pools/spot-pools/uneven-pool-weights) and [Amplification](https://docs.carbon.network/carbon-core/trading-modules/liquidity-pools/spot-pools/amplified-pools). On top of that, [multiple pools](https://docs.carbon.network/carbon-core/trading-modules/liquidity-pools/spot-pools/multi-pool-routing) can route to a single market.

This allows liquidity to be used as efficiently as possible by the AMM so that LP earnings are maximized.

The protocol also [rewards](https://docs.carbon.network/carbon-core/trading-modules/liquidity-pools/spot-pools/liquidity-rewards) certain core pools with additional incentives.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://guide.dem.exchange/earn/liquidity-pools/liquidity-pools.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
