# How AMM Decentralized Exchanges Work?

![](/files/MA64eBwOr10TDAZMCqtg)

Uniswap is an AMM *protocol* that acts like a robot waiter serving up trades between you and a liquidity pool bootstrapped by liquidity providers (LPs). Under the AMM model, you can play several roles: trader, liquidity provider, and protocol governor. The protocol itself achieves two things:

1. Prices assets
2. Executes trades via smart contracts

For instance, let us imagine trading ETH tokens for UNI tokens on Uniswap. After clicking the *swap* button, the algorithm calculates how much the trade impacts the liquidity pool's reserves - after which a price quote is given.

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

AMMs use a constant product formula to price assets, which states:

***x \* y = k***

X and *y* are equal amounts of a liquidity pool’s assets while *k* is the total or constant amount of pool liquidity. Now, let us view the ETH-UNI trade from the perspective of our new formula.

![](/files/nu4KMvjomndwrO6El2q7)

The way AMMs handle liquidity is similar to smart order routing systems. Both track the best paths for gathering liquidity at the best price possible.


---

# 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://unimatebotteam.gitbook.io/amm-unimate-bot/how-amm-decentralized-exchanges-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.
