> For the complete documentation index, see [llms.txt](https://hakkafinance.gitbook.io/igain/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hakkafinance.gitbook.io/igain/protocol-1/built-in-dex.md).

# Built-in DEX

One of the major features of iGain is its **built-in secondary market**. There will be no need to integrate or launch on other protocols. The built-in secondary market of iGain protocol is a decentralized exchange (DEX) that supports the automated market making of Long and Short tokens. After minting Long and Short tokens with DAI, users can serve as liquidity providers of the market by adding liquidity. While there is liquidity, Long and Short token holders may swap them in between at the pool.

## Pricing Mechanism

The market prices of Long and Short tokens are determined by their real-time proportion. Given `a` Long tokens and `b` Short tokens in the pool, they will follow a **Constant Product Market Maker law**:

$$
a\ Long = b\ Short
$$

Given the condition of `1 Long + 1 Short = 1 DAI`, we can get the **marginal price** of the Long/Short token by solving simultaneous equations below:

$$
1\ Long = \frac{b}{a+b}\ DAI
$$

$$
1\ Short = \frac{a}{a+b}\ DAI
$$
