> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monolith.market/llms.txt
> Use this file to discover all available pages before exploring further.

# Stablecoin Factory

> How stablecoins are created in the Monolith protocol

## Overview

The Stablecoin Factory enables anyone to create new Monolith instances. Each instance is a synthetic asset (e.g., a USD‑pegged stablecoin) consisting of a `Lender` (core instance logic), a `Coin` (the ERC‑20 synthetic token), and a `Vault` (an yield-bearing ERC‑4626). The Factory is also the entry-point for the protocol fee operator.

## How to create an instance

1. Choose your inputs: collateral token, price feed, branding (name/symbol), and risk posture (e.g., collateral factor, minimum debt). Optionally connect a PSM asset/vault for direct convertibility.
2. Submit a single, permissionless transaction to deploy. The Factory creates three contracts (Lender, Coin, Vault) in a fixed, pre‑computable way.
3. Announce the addresses and begin distribution, integrations, and liquidity programs as needed. The instance will also be displayed on Monolith UI.

## Architecture

### Per‑instance Components

After deployment, the three following contracts will be created:

* **Lender**: Core instance contract and main entry-point for borrowers, liquidators and instance operators.
* **Coin**: ERC‑20 synthetic asset token (e.g., stablecoin) minted/redeemed by the `Lender` for the instance.
* **Vault**: Yield-bearing ERC‑4626 tokenized wrapper linked to the `Lender` and branded with the instance `(Staked) name`/`(s)symbol`.

## Deploy Parameters

`DeployParams` expected by `Factory.deploy`:

* **name**: Instance display name used for `Vault`/`Coin` branding.
* **symbol**: Instance symbol used for `Vault`/`Coin` branding.
* **collateral**: ERC‑20 address used as collateral.
* **psmAsset**: ERC‑20 asset used by the PSM (Peg Stability Module), if applicable.
* **psmVault**: ERC‑4626 vault used by the PSM, if applicable.
* **feed**: Price feed implementing a Chainlink‑style interface.
* **collateralFactor**: Risk parameter in basis points controlling maximum borrow against collateral.
* **minDebt**: Minimum debt per position or market constraint (enforced by `Lender`).
* **timeUntilImmutability**: Relative time window after which select `Lender` parameters become immutable. Set to 0 for immediate immutability.
* **operator**: Instance‑level operator for the `Lender` (Optional. Set to `address(0)` for none).
* **manager**: Instance‑level manager for the `Lender`. (Optional. Set to `address(0)` for none).
* **halfLife**: Interest rate half‑life for the exponential rate model. Must be between 12 hours and 30 days.
* **targetFreeDebtRatioStartBps**: Lower bound of the target free‑debt ratio band in basis points. Must be ≥500 and ≤ `targetFreeDebtRatioEndBps`.
* **targetFreeDebtRatioEndBps**: Upper bound of the target free‑debt ratio band in basis points. Must be ≤9500.
* **redeemFeeBps**: Redemption fee in basis points. Must be ≤500 (5%).
* **stalenessThreshold**: Maximum acceptable age of an oracle update, in seconds. Prices older than this enter reduce‑only mode and decay linearly to zero over an additional 24 hours.
* **maxBorrowDeltaBps**: Maximum acceptable rounding error when share accounting converts between debt and shares, in basis points. Must be between 50 and 200 (0.5%–2%).
* **psmVaultMinTotalSupply**: Minimum total supply required in the PSM vault to allow PSM buys. Must be greater than 0 whenever `psmVault` is set; unused otherwise.

## Integration tips

* Treat the `Lender` address as the canonical identifier for an instance; `Coin` and `Vault` addresses can be fetched from it.
* Indexing: watch the Factory’s deployment events or `deployments` registry to discover new instances.
* Wallets/exchanges: list the `Coin` address; staking/earn products can use the `Vault` for deposit/withdraw flows.
* Dashboards: read instance configuration (feed, collateral, factors) and status (debt, supply, reserves) from the `Lender` to present risk and performance metrics.

If you need implementation details and ABI-level specifics, see the Factory contract reference:

* [Factory contract reference](/reference/Factory)

## Operator role

* The Factory includes an operator role which only controls fee-related parameters.
* Capabilities:
  * Choose or rotate the fee recipient that collects protocol reserves from instances.
  * Set a global protocol fee (bounded by a 10% cap) applied to borrower interest.
  * Define per‑instance fee overrides bounded by the same cap.
  * Perform a two‑step operator handoff to safely transfer control when needed.
* Limitations:
  * Cannot upgrade contracts, mint tokens, move user funds, or pause instances.
  * Cannot change risk parameters of instances.
