# Providing Liquidity

Stable-pool liquidity is fungible: deposit either or both coins, receive
`StableSwapLP` tokens, and your share compounds automatically as the pool
earns fees.

## Adding liquidity

:::steps
### Choose amounts

You can deposit **any ratio** — both coins, or just one. Depositing
imbalanced amounts implicitly swaps part of your deposit into the scarcer
coin, so a small fee applies to the imbalanced portion.

### Preview LP tokens

The pool quotes your expected LP amount:

```solidity
function calc_token_amount(uint256[2] memory amounts, bool deposit)
    external view returns (uint256);
```

### Deposit

```solidity
function add_liquidity(uint256[2] memory amounts, uint256 min_mint_amount)
    external;
```

`min_mint_amount` is your slippage guard — the transaction reverts if fees or
front-running would leave you with fewer LP tokens.
:::

:::tip[Balanced deposits are free]
A deposit at the pool's current ratio pays no imbalance fee. The app shows
the fee impact before you confirm.
:::

## How value accrues: virtual price

Stable-pool fees compound into the pool itself. The metric to watch is the
**virtual price** — the value of 1 LP token measured in the pool's invariant:

```solidity
function get_virtual_price() external view returns (uint256); // 1e18 scale
```

Virtual price only moves **up** as fees accrue (absent an `A` ramp). Your LP
value = `lpBalance × virtualPrice`. This is also how the app computes the
fee APR of a pool.

## Removing liquidity

Three withdrawal modes:

```solidity
/// Balanced: burn LP, receive both coins pro-rata (no fee)
function remove_liquidity(uint256 _amount, uint256[2] memory min_amounts)
    external;

/// Imbalanced: specify exact coin amounts out (imbalance fee applies)
function remove_liquidity_imbalance(
    uint256[2] memory amounts, uint256 max_burn_amount
) external;

/// Single-sided: burn LP, receive one coin (implicit-swap fee applies)
function remove_liquidity_one_coin(
    uint256 _token_amount, uint256 i, uint256 min_amount
) external;

/// Preview for single-sided withdrawal
function calc_withdraw_one_coin(uint256 _token_amount, uint256 i)
    external view returns (uint256);
```

## Earning BSCT on top

Stake your `StableSwapLP` tokens in the corresponding
[classic farm](/farms/classic-farms) to earn BSCT emissions while still
accruing swap fees — LP tokens keep compounding virtual price even while
staked.

## Risks

:::warning
* **Peg risk** — if one asset permanently de-pegs, arbitrage drains the pool
  toward the failing asset and LPs end up holding mostly that asset.
* **Amplification ramps** — governance can ramp `A` (bounded to 10× per ramp,
  gradual by construction), which slightly shifts the curve.
* **Smart-contract risk** — pools are immutable but unaudited on testnet; see
  [Security Notes](/developers/security).
:::
