# StableSwap DEX

This page explains what **StableSwap** is and how to use the **StableSwap DEX** for swapping and liquidity provision (LP) with a focus on safety.

{% hint style="info" %}
**Not investment advice** — DEX usage involves depegs, slippage, and smart contract risk. LP positions can lose value.
{% endhint %}

## At a glance

* StableSwap is optimized for **stable-to-stable** (or near-stable) swaps.
* It aims to reduce slippage compared to regular AMMs, when assets stay near the same price.
* You can: **swap**, **add liquidity**, **remove liquidity**, and sometimes **stake LP** (if enabled).
* Hann Finance’s automation stack can route stable swaps via a **pool allowlist** (for safety).

## One diagram: swap and LP

{% @mermaid/diagram content="flowchart LR
U\[User] -->|Swap| R\[StableSwap Router]
R --> P\[StableSwap Pool]
P -->|Token out| U

U -->|Add liquidity| R
R -->|Mint| LP\[LP token]
LP -->|Optional| S\[Reward Staker]
S -->|Rewards| U

style U fill:#B0BBF4,color:#333,stroke:#4C5FD5,stroke-width:2px
style R fill:#4C5FD5,color:#fff,stroke:#3A49C5,stroke-width:2px
style P fill:#EEFBA0,color:#333,stroke:#D1F24A,stroke-width:2px
style LP fill:#D1F24A,color:#333,stroke:#B8DA2C,stroke-width:2px
style S fill:#3A49C5,color:#fff,stroke:#4C5FD5,stroke-width:2px" %}

## Why StableSwap exists

In a typical AMM, swapping $1 of token A into token B can create meaningful price impact if liquidity is thin.

StableSwap designs generally aim to:

* keep prices closer to 1:1 when both assets remain “stable”
* reduce slippage for stable pairs
* provide a dedicated venue for stablecoin liquidity (which is important for stablecoin pegs)

## Slippage and `minOut` (plain explanation)

When you swap, you usually set a minimum amount you are willing to receive (`minOut`). If the swap would return less, the transaction reverts.

A common way to think about it:

$$
minOut \approx quote \times \left(1 - \frac{slippageBps}{10{,}000}\right)
$$

Where `slippageBps` is slippage in basis points (bps).

{% hint style="warning" %}
A too-tight `minOut` can cause frequent reverts. A too-loose `minOut` can cause bad execution. Use caution during volatility.
{% endhint %}

## How to use StableSwap

{% tabs %}
{% tab title="Swap" %}
{% stepper %}
{% step %}

#### Step 1: Choose the pair and route

For stable assets, prefer StableSwap routes where liquidity is deep.

{% hint style="warning" %}
**\[TBD] Supported pools list** — The official UI and on-chain allowlist are the source of truth for supported pools.
{% endhint %}
{% endstep %}

{% step %}

#### Step 2: Set slippage and deadline

Set:

* a realistic slippage tolerance
* a short deadline (to reduce MEV / price drift risk)
  {% endstep %}

{% step %}

#### Step 3: Confirm and verify outputs

Double-check:

* token in/out
* expected amount out
* minimum amount out
  {% endstep %}
  {% endstepper %}
  {% endtab %}

{% tab title="Add liquidity (LP)" %}
Adding liquidity typically requires depositing both pool tokens in some ratio. You receive LP tokens representing your pool share.

{% stepper %}
{% step %}

#### Step 1: Decide how much you want to LP

Make sure you understand LP value can change if one asset depegs or liquidity dries up.
{% endstep %}

{% step %}

#### Step 2: Add liquidity via router (or a Zapper, if available)

Some flows support one-click LP via a dedicated zapper.
{% endstep %}

{% step %}

#### Step 3: Optionally stake LP (if configured)

If a reward staker is configured, LP tokens may be stakeable to earn additional rewards.
{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Remove liquidity" %}
Removing liquidity burns LP tokens and returns the underlying pool tokens, subject to pool conditions.

{% hint style="warning" %}
During stress, removing liquidity can be expensive (slippage) and sometimes constrained by pool state.
{% endhint %}
{% endtab %}
{% endtabs %}

## Safety notes

* **Depeg risk:** StableSwap assumes assets stay close in value. If one asset depegs, slippage and LP losses can be severe.
* **Pool selection:** Prefer allowlisted pools and official routes.
* **Automation risk:** Zappers can simplify, but they also increase composability risk. Understand the manual flow first.

## Deep dives (optional)

* StableSwap mechanics (slippage, `minOut`, deadlines, LP risk): [StableSwap Deep Dive](https://hann-finance.gitbook.io/hann-finance/resources/deep-dives/stableswap)

## Next reads

* One-click flows: [Zapper Guide](https://hann-finance.gitbook.io/hann-finance/protocol/zapper)
* USDHN fundamentals: [USDHN & Earn](https://hann-finance.gitbook.io/hann-finance/protocol/usdhn-and-earn)
* Full risk list: [Risk Disclosure](https://hann-finance.gitbook.io/hann-finance/risks/risk-disclosure)
