<!-- tempo-docs-context -->
> Source: [/docs/protocol/exchange](https://tempo.xyz/developers/docs/protocol/exchange.md)
> Section: [Tempo EVM](https://tempo.xyz/developers/docs/development.md). Build on Tempo EVM: wallets and keys, transactions and fees, TIP-20 Tokens, contracts, exchange, network details, nodes, protocol specifications, and changelog.
> [Documentation index](https://tempo.xyz/developers/llms.txt) · [Docs skill](https://tempo.xyz/developers/SKILL.md)

> Tempo MCP: Use `search`, `find_pages`, `read_page`, and `code` at `https://mcp.tempo.xyz` for Tempo and related documentation.
> If an indexed page is missing or reflects an older site, read this site’s [documentation index](https://tempo.xyz/developers/llms.txt) and Markdown pages directly.

# Exchanging stablecoins: DEX vs. Fee AMM

<span id="exchanging-stablecoins-exchange-vs-fee-amm" />

Tempo features an enshrined decentralized exchange (DEX) designed specifically for trading between stablecoins of the same underlying asset (e.g., USDG to USDT). The DEX provides optimal pricing for cross-stablecoin payments while minimizing chain load from excessive market activity.

The DEX operates as a singleton precompiled contract at address `0xdec0000000000000000000000000000000000000`. It maintains an onchain orderbook with separate queues for each price tick, using price-time priority for order matching.

:::info
**DEX vs. Fee AMM** — these are two different systems. The DEX is the user-facing market: you (or your app) trade stablecoins at market prices via swaps and orders against an onchain orderbook. The [Fee AMM](https://tempo.xyz/developers/docs/protocol/fees/fee-amm) is protocol fee-conversion liquidity: it converts users' transaction-fee payments into validators' preferred tokens at a fixed price through protocol-driven swaps, and is not a trading venue. See [DEX vs. Fee AMM](#exchange-vs-fee-amm) below.
:::

Trading pairs are determined by each token's quote token. All TIP-20 tokens specify a quote token for trading on the DEX. See [Quote Tokens](https://tempo.xyz/developers/docs/protocol/exchange/quote-tokens) for more information on quote token selection and the optional [pathUSD](https://tempo.xyz/developers/docs/protocol/exchange/quote-tokens#pathusd) stablecoin. [OUSD](https://tempo.xyz/developers/docs/guide/ousd), the recommended stablecoin on Tempo, uses pathUSD as its quote token, so any USD stablecoin can route to and from OUSD through the DEX. See the [Stablecoin DEX Specification](https://tempo.xyz/developers/docs/protocol/exchange/spec) for detailed information on the DEX structure.

The DEX supports three types of orders, each with different execution behavior:

| Order Type | Description |
|------------|-------------|
| [**Limit Orders**](https://tempo.xyz/developers/docs/protocol/exchange/providing-liquidity#limit-orders) | Place orders at specific price levels that wait in the book until matched or cancelled. Orders are added to the book immediately when placed. |
| [**Flip Orders**](https://tempo.xyz/developers/docs/protocol/exchange/providing-liquidity#flip-orders) | Special orders that automatically reverse to the opposite side when completely filled, acting like a perpetual liquidity pool. When a flip order is fully filled, the same `orderId` is rewritten on the opposite side and emits `OrderFlipped`. |
| [**Market Orders**](https://tempo.xyz/developers/docs/protocol/exchange/executing-swaps#swap-functions) | Execute immediately against the best available orders in the book (via swap functions). Swaps and cancellations execute immediately within the transaction. |

For the complete execution mechanics, see the [Stablecoin DEX Specification](https://tempo.xyz/developers/docs/protocol/exchange/spec).

<span id="exchange-vs-fee-amm" />

## DEX vs. Fee AMM

Tempo has two stablecoin-swapping systems that are easy to confuse. They serve different purposes:

| | Stablecoin DEX | [Fee AMM](https://tempo.xyz/developers/docs/protocol/fees/fee-amm) |
|---|---|---|
| **Purpose** | User-facing stablecoin trading | Converting transaction fees into validators' preferred tokens |
| **Who initiates swaps** | Users and apps | The protocol, automatically (plus arbitrageurs rebalancing) |
| **Pricing** | Market-driven onchain orderbook (price-time priority) | Fixed conversion price |
| **Liquidity** | Limit and flip orders resting in the onchain orderbook | LP deposits into per-pair fee pools |
| **Contract** | Stablecoin DEX precompile (`0xdec0…0000`) | `FeeManager` precompile (`0xfeec…0000`) |
| **Use it for** | Swaps, prices, onchain orderbook depth, fills | Letting users pay fees in any stablecoin |

If you want to **trade** stablecoins or read market data (pairs, swaps, orders, prices), use the DEX. If you want to **enable fee payments** in your stablecoin or provide fee-conversion liquidity, see the [Fee AMM](https://tempo.xyz/developers/docs/protocol/fees/fee-amm).

To get started with the DEX, explore these guides:

* [Executing Swaps](https://tempo.xyz/developers/docs/protocol/exchange/executing-swaps) — Quote prices and swap between stablecoins
* [Providing Liquidity](https://tempo.xyz/developers/docs/protocol/exchange/providing-liquidity) — Place orders and flip orders to earn spreads
* [DEX Balance](https://tempo.xyz/developers/docs/protocol/exchange/exchange-balance) — Manage token balances on the DEX to save gas costs

:::info
For a more complete technical specification including design decisions and details of execution semantics, see the [Stablecoin DEX Specification](https://tempo.xyz/developers/docs/protocol/exchange/spec).
:::
