> For the complete documentation index, see [llms.txt](https://docs.curvance.com/app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.curvance.com/app/developer-docs/lending-protocol/market-manager.md).

# Market Manager

## Overview

The Market Manager is a core component of the Curvance protocol, responsible for risk management and orchestrating interactions between various protocol modules. Market Managers are designed as thesis-driven micro-ecosystems, each focusing on specific asset types (e.g., interest-bearing stablecoins, bluechip assets, volatile LP tokens), which helps minimize systemic risk across the protocol.

### Architecture

<figure><img src="/files/YWtbA0AJIwDdsXQu28Gq" alt=""><figcaption></figcaption></figure>

* **Market Manager:** Orchestrates listing, pausing, liquidation logic (including auctions), collateral/debt caps, and permissions for a single-ecosystem market.
* **Liquidity Manager:** Computes account liquidity, status, and hypothetical actions, including the `MIN_LOAN_SIZE` check used by borrow and collateral-removing flows. The 20-minute hold period is started and enforced through the Market Manager's collateral, borrow, repay, transfer, redeem, and withdraw review paths.
* **Dynamic Interest Rate Model:** External IRM module that updates borrow/supply rates based on utilization and configured parameters.
* **Oracle Manager:** Provides the prices used by Market Manager risk checks. For live external docs, describe Curvance pricing as single-source per asset with heartbeat validation and price guards where configured, not as a dual-oracle or price-divergence system.
* **cTokens:** ERC4626-like market tokens. `collateralCaps(cToken)` limits how many shares can be posted as collateral, while `debtCaps(cToken)` limits how much of that cToken's underlying asset can be borrowed. A zero debt cap disables borrowing for that asset in the market, and a zero collateral cap blocks additional collateral posting. Collateral support also depends on the cToken's collateral configuration, including a nonzero `collRatio`.

#### Market Tokens

**cTokens (Curvance tokens):** One listed per asset in a market.

* **Collateralization:** Collateralization: `collateralCaps[cToken]` in shares; zero disables posting.
* **Borrowable:** `debtCaps[cToken]` in underlying assets; zero disables borrowing of this asset.

### Data Flow

#### Collateral Flow

<figure><img src="/files/YiDA76NnmoiT2FpSAaaT" alt=""><figcaption></figcaption></figure>

1. Users deposit into a cToken to receive shares.
2. Users may post those cToken shares as collateral (subject to caps and pauses).
3. Posted collateral increases borrowing capacity, tracked in the Market Manager and cToken.

#### Liquidation (auction-aware) flow

1. The Market Manager supports auction-based liquidations using transient, per-tx config set by authorized auction callers.
2. Authorized callers set a temporary liquidation incentive and close factor; auctions receive an additional `AUCTION_BUFFER` priority on thresholds.
3. If no transient config is present, standard liquidations apply.

### Risk Management

#### Dynamic Liquidation Engine (DLE)

1. The Market Manager implements a three-tiered configuration per cToken:
   1. **Collateralization ratio (`collRatio`):** Base borrowing power while healthy.
   2. **Soft Liquidation Threshold (`collReqSoft`)**
      1. Initiates partial liquidations with base incentives.
      2. Minimal disruption to user positions.
   3. **Hard Liquidation Threshold (`collReqHard`)**
      1. Permits complete position liquidation.
      2. Maximum liquidation incentives within configured bounds.

#### Bad debt socialization

If a user's posted collateral cannot cover the debt plus liquidation compensation during liquidation, the shortfall is recognized as `badDebtRealized`. The Market Manager computes this amount during liquidation evaluation, and the debt cToken realizes the loss by reducing `_totalAssets`, passing the loss to lenders through the exchange rate.

#### Caps

* Collateral Caps: Per-cToken maximum posted collateral, measured in shares. Scales naturally with auto-compounding strategies.
* Debt Caps: Per-cToken maximum outstanding borrow, measured in underlying assets.
* Caps can be lowered without forcing immediate unwinds; posting/borrowing operations enforce caps at the time of action.

#### Position Cooldown (20 minutes)

* A 20-minute hold period mitigates flash-loan and short-term oracle manipulation. The cooldown starts (or resets) on:
  * Posting collateral
  * Borrowing

While an account's cooldown is active, `MarketManager__MinimumHoldPeriod` blocks:

* Repayment through `canRepayWithReview`.
* cToken transfers that route through `canTransfer`.
* Redeem and withdraw paths that call `canRedeemWithCollateralRemoval`, including collateral-removing redemptions and withdrawals.

The state transition looks like:

<figure><img src="/files/iDAikvwQxAaEG7SZSySq" alt=""><figcaption></figcaption></figure>

#### Minimum active loan size

* Each isolated market sets a minimum active loan size in USD terms at deployment (WAD), constrained within $10-100.
* Borrow checks enforce `MIN_LOAN_SIZE` through hypothetical liquidity evaluation. Partial repayments also enforce the minimum on the remaining debt, while a full repayment skips the residual-size check when `newNetDebt == 0`.

### Pausing and Permissions

**Global market toggles:** `liquidationPaused`, `redeemPaused`, and `transferPaused`.

**Per-token action toggles:** `mintPaused`, `collateralizationPaused`, and `borrowPaused`. Query them through `actionsPaused(cToken)`, which returns `(mintPaused, collateralizationPaused, borrowPaused)`.

**Listing:** Tokens must be listed a manager to be used for collateralization, borrowing, or liquidation.&#x20;

**Auction permissions:** Only addresses with auction permissions set in the `CentralRegistry` may set/reset transient auction liquidation config. Misconfigured or unauthorized auction attempts will revert.

**Position Managers:** The manager maintains an isPositionManager whitelist for advanced/leveraged workflows that require elevated privileges.

### State and Invariants

* **Collateral posted (per-account):** Tracked at the cToken layer. Query via `ICToken.collateralPosted(account)`. Market-wide posted collateral is available via `ICToken.marketCollateralPosted()`.
* **Collateral Caps:** `collateralCaps[cToken]` in shares.
* **Debt Caps:** `debtCaps[cToken]` in assets.
* **Per-token actions paused:** Visible via the manager's aggregate `actionsPaused(cToken)` view function.
* **Listing:** Manager-maintained listing state per cToken; operations revert if token is not listed.

### Cross-Contract Interactions

<figure><img src="/files/5wVzsWm4F7fPO4yEmcL5" alt=""><figcaption></figcaption></figure>

The Market Manager interacts with multiple other components:

* **Central Registry:** Role/permission checks (market manager, auction permissions, timelock-controlled updates).
* **Oracle Manager:** Price feeds for risk checks and liquidation.
* **cTokens:** Accounting for balances, shares, collateral posted, borrowing, seizures, and redemptions.
* **External auction controller:** Sets transient liquidation parameters per transaction when conducting auction liquidations.

### Security Measures

* 20-minute minimum hold period across sensitive actions.
* Auction-only privileges for transient liquidation overrides.
* Bad debt socialization to protect market solvency.
* Extensive pausing controls at market and token granularity.

## User Interaction Functions

### **Core Data Query Functions**

#### isListed()

**Contract:** MarketManager

**Description:** Checks if a cToken is listed in the lending market.

**Function signature:**

```solidity
function isListed(address cToken) external view returns (bool)
```

<table><thead><tr><th width="140">Type</th><th width="175">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>cToken</td><td>Address of the cToken.</td></tr></tbody></table>

**Return data:**

<table><thead><tr><th width="134">Type</th><th>Description</th></tr></thead><tbody><tr><td>bool</td><td>Whether the cToken is registered in the lending market.</td></tr></tbody></table>

***

#### queryTokensListed()

**Contract:** MarketManager

**Description:** Returns a list of all tokens inside this market for&#x20;offchain querying.

**Function signature:**

```solidity
function queryTokensListed() external view returns (address[] memory)
```

**Return Data:**

<table><thead><tr><th width="155.13333129882812">Type</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>Array of all cToken addresses listed in the market.</td></tr></tbody></table>

***

#### assetsOf()

**Contract:** MarketManager

**Description:** Returns the cToken addresses for the account's open positions in this isolated market.

**Function signature:**&#x20;

```solidity
function assetsOf(address account) external view returns (address[] memory)
```

<table><thead><tr><th width="109">Type</th><th width="112">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The address of the account to query.</td></tr></tbody></table>

**Return data:**

<table><thead><tr><th width="125">Type</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>Array of cTokens that the account has entered.</td></tr></tbody></table>

***

### Status and Liquidity

#### statusOf()

**Contract:** MarketManager

**Description:** Determines the account's current collateral value, maximum debt capacity, and current debt value.

**Function signature:**

```solidity
function statusOf(address account) external view returns (uint256, uint256, uint256)
```

<table><thead><tr><th width="104">Type</th><th width="112">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account </td><td>The account to determine liquidity for.</td></tr></tbody></table>

**Return data:**

<table><thead><tr><th width="119">Type</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>Total value of account collateral.</td></tr><tr><td>uint256</td><td>The maximum amount of debt the account could take on based on an account's collateral.</td></tr><tr><td>uint256</td><td>Total value of an account's debt.</td></tr></tbody></table>

***

### Permission and Validation

#### canMint()

**Contract:** MarketManager

**Description:** Checks whether minting is allowed for the cToken by verifying that minting is not paused and that the cToken is listed in this Market Manager. It does not take an account argument or validate account-specific state.

**Function signature:**

```solidity
function canMint(
    address cToken) external view
```

<table><thead><tr><th width="110">Type</th><th width="126">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>cToken</td><td>The Curvance token address to verify minting for.</td></tr></tbody></table>

***

#### canRedeemWithCollateralRemoval()

**Contract:** MarketManagerIsolated

**Description:** Called by a cToken to check whether an account can redeem or withdraw shares and to determine how many posted collateral shares must be removed. It checks the market-wide redeem pause, listing, transfer restrictions, hold period, and, when collateral would be removed, account liquidity.

**Function signature:**

```solidity
function canRedeemWithCollateralRemoval(
    address cToken,
    uint256 shares,
    address account,
    uint256 balanceOf,
    uint256 collateralPosted,
    bool forceRedeemCollateral
) external returns (uint256 collateralRedeemed)
```

<table><thead><tr><th width="122">Type</th><th width="139">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>cToken</td><td>The market token to verify redemption for.</td></tr><tr><td>uint256</td><td>amount</td><td>The number of tokens to redeem for the underlying asset.</td></tr><tr><td>address</td><td>account</td><td>The account which would redeem the tokens.</td></tr></tbody></table>

***

#### canRepayWithReview()

**Contract:** MarketManager

**Description:** Called by a borrowable cToken during repayment. It validates the cToken and account position, enforces the debt owner's hold period, and checks that a partial repayment does not leave a residual debt position below `MIN_LOAN_SIZE`. A full repayment with `newNetDebt == 0` skips the residual loan-size check.

**Function signature:**

```solidity
function canRepayWithReview(
    address cToken,
    uint256 newNetDebt,
    address debtAsset,
    uint256 decimals,
    address account
) external view
```

<table><thead><tr><th width="125">Type</th><th width="124">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>cToken</td><td>The market token to verify the repayment for.</td></tr><tr><td>address</td><td>account</td><td>The account who will have their loan repaid.</td></tr></tbody></table>

***

### Paused States

#### actionsPaused()

**Contract:** MarketManager

**Description:** Checks whether minting, collateralization, borrowing of cToken is paused.

```solidity
function actionsPaused(
    address cToken
) external view returns (bool, bool, bool);
```

**Inputs:**

<table><thead><tr><th width="109.20001220703125">Type</th><th width="469.98333740234375">Description</th></tr></thead><tbody><tr><td>address</td><td>Address of the cToken to check the pause statuses of.</td></tr></tbody></table>

**Return data:**

<table><thead><tr><th width="109.20001220703125">Type</th><th width="469.98333740234375">Description</th></tr></thead><tbody><tr><td>bool</td><td>Whether minting cToken is paused or not.</td></tr><tr><td>bool</td><td>Whether collateralization of cToken is paused or not.</td></tr><tr><td>bool</td><td>Whether borrowing cToken is paused or not.</td></tr></tbody></table>

***

### Market Invariants

**Contract:** cTokens

**Description:** Per-account posted collateral is tracked on each cToken, not on the Market Manager. Query `collateralPosted(account)` on the cToken for an account's posted shares. Query `marketCollateralPosted()` on the cToken for market-wide posted shares.

**Function signatures:**

```solidity
function collateralPosted(address account) external view returns (uint256);

function marketCollateralPosted() external view returns (uint256);
```

**collateralPosted inputs:**

<table><thead><tr><th width="109.20001220703125">Type</th><th width="469.98333740234375">Description</th></tr></thead><tbody><tr><td>address</td><td>The account to check for posted collateral shares.</td></tr></tbody></table>

**collateralPosted return data:**

<table><thead><tr><th width="109.20001220703125">Type</th><th width="469.98333740234375">Description</th></tr></thead><tbody><tr><td>uint256</td><td>Amount of cToken shares posted as collateral.</td></tr></tbody></table>

***

#### collateralCaps()

**Contract:** MarketManager

**Description:** Returns the amount of cToken that can be posted of collateral, in shares.

```solidity
mapping(address => uint256) public collateralCaps;
```

**Inputs:**

<table><thead><tr><th width="109.20001220703125">Type</th><th width="469.98333740234375">Description</th></tr></thead><tbody><tr><td>address</td><td>Address of the cToken to check the max amount of shares that can be posted as collateral.</td></tr></tbody></table>

**Return data:**

<table><thead><tr><th width="109.20001220703125">Type</th><th width="469.98333740234375">Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount of cTokens that has can be posted as collateral.</td></tr></tbody></table>

***

#### debtCaps()

**Contract:** MarketManager

**Description:** Returns the amount of cToken that can be borrowed, in underlying assets.

```solidity
mapping(address => uint256) public debtCaps;
```

**Inputs:**

<table><thead><tr><th width="109.20001220703125">Type</th><th width="469.98333740234375">Description</th></tr></thead><tbody><tr><td>address</td><td>Address of the cToken</td></tr></tbody></table>

**Return data:**

<table><thead><tr><th width="109.20001220703125">Type</th><th width="469.98333740234375">Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount of cTokens that can be borrowed.</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.curvance.com/app/developer-docs/lending-protocol/market-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
