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

# Managers & Risk Universes

> How margin managers and risk universes shape what a subaccount can trade and hold.

Every subaccount is bound to a **manager** and, through it, to a **risk universe**. Together they
decide the margin model you get, which instruments you can trade, and which assets you can post as
collateral. You never set the universe directly — you pick a `manager_id`, and everything else
follows.

<CardGroup cols={2}>
  <Card title="Manager" icon="scale-balanced">
    The margin model applied to your subaccount — **Standard** (cross collateral margin) or
    **Portfolio** (scenario-based netting).
  </Card>

  <Card title="Risk universe" icon="layer-group">
    Restricted set of instruments, collaterals and lending rules, aimed at containing risk. Losses are socialized only **within** it.
  </Card>
</CardGroup>

## How they relate

* A subaccount can only have **one** manager.
* A manager belongs to **exactly one** universe.
* A universe exposes **at most one Standard and one Portfolio** manager.
* You choose a `manager_id`; that fixes both your **margin model** and your **universe**.

<Frame>
  <img className="bg-black" src="https://mintcdn.com/derive-a0490cef/BhszcT-bQHpTuFnc/trading/risk-universes-grid.png?fit=max&auto=format&n=BhszcT-bQHpTuFnc&q=85&s=ba1fc44194d70bb5b6b2736f2992ca42" alt="Diagram of the breakdown of managers, currencies, instruments, and collaterals in each risk universe. The latest values can be taken from the public/get_risk_universes endpoint." width="1800" height="1976" data-path="trading/risk-universes-grid.png" />
</Frame>

This breakdown is exactly what `public/get_risk_universes` returns — see
[Reading `public/get_risk_universes`](#reading-public-get-risk-universes) below.

## Managers

A manager is the margin engine that risk-prices your subaccount. There are two:

| Manager       | Wire label | Margin model                                                                     | Best for                                                            |
| ------------- | ---------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| **Standard**  | `SM`       | Cross-collateral: collaterals contribute margin but options margined separately. | Simple/directional positions and collateral-style holding.          |
| **Portfolio** | `PM2`      | Scenario-based: a whole book netted across a grid of shocks.                     | Complex option/perp books that benefit from cross-position offsets. |

Each manager has a numeric **`manager_id`**. A subaccount stores its `manager_id` and derives its
universe, tradeable instruments, and accepted collateral from it. Picking Standard vs Portfolio for
the same book changes your margin requirement, not what you can hold.

## Risk universes

A risk universe is a set of assets and managers that share a single risk boundary. It exists so
that an insolvency in one universe can only ever be absorbed by that universe's own Security Module
and, if needed, socialized to solvent accounts **inside the same universe** — never across the
whole exchange. As a direct consequence, **a trade, RFQ, or liquidation is rejected if the two
sides sit in different universes.**

Everything risk-related is keyed by `(asset, risk_universe_id)`: collateral discounts, OI caps, and
lending pools can all differ per universe for the very same asset.

## Two ways to find a manager

* **By risk universe — `public/get_risk_universes`**. Break down all trade-able instruments and supported collaterals by universe and manager.
* **By currency — `public/get_all_currencies`**. Similar to above but broken down by currency. This route also includes market summary data such as APYs, borrow headroom, OI details and caps.

## Reading `public/get_risk_universes`

```json Response (abridged, one universe) theme={null}
{
  "risk_universe_id": 1,
  "name": "PRIME",
  "description": "Blue chip universe",
  "managers": [
    {
      "manager_id": 3,
      "margin_type": "SM",
      "instruments": ["BTC-OPTION", "BTC-PERP", "ETH-OPTION", "ETH-PERP"],
      "collaterals": [
        {
          "name": "USDC",
          "address": "0x…",
          "erc20": { "decimals": 6, "underlying_erc20": "0x…" },
          "min_deposit_usd": "1",
          "im_discount": "1",
          "mm_discount": "1"
        },
        {
          "name": "ETH",
          "address": "0x…",
          "erc20": { "decimals": 18, "underlying_erc20": "0x…" },
          "min_deposit_usd": "1",
          "im_discount": "0.72",
          "mm_discount": "0.8"
        }
      ]
    },
    { "manager_id": 12, "margin_type": "PM2", "instruments": ["…"], "collaterals": ["…"] }
  ],
  "security_module": { "subaccount_id": 48291, "cash_asset": "0x…", "cash_currency": "USDC" }
}
```

| To determine…                                  | Read…                                                                                                   |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| Which universes exist, and what they're called | one entry per universe; `name`/`description` are display metadata (absent until set)                    |
| Which `manager_id` to use                      | pick a manager by `margin_type` (`SM` = Standard, `PM2` = Portfolio); its `manager_id` is what you pass |
| What you can trade under a manager             | `managers[].instruments[]` — the live perp/option asset names (an option entry names the family)        |
| What you can deposit as **collateral**         | `managers[].collaterals[]` — `address` is the deposit `asset`, `erc20` the token to send + decimals     |
| How much margin a collateral earns             | `collaterals[].im_discount` / `mm_discount` under that manager (`"1"` = par credit — the cash asset)    |
| Who absorbs losses                             | `security_module` — the universe's SM subaccount and its cash asset                                     |

<Note>
  For app builders, `public/get_all_currencies` carries useful market data that can be useful for onboarding such as open interest caps, lending limits, APYs.
</Note>

### Picking your manager

<Steps>
  <Step title="Decide what you'll trade and post">
    Settle on the instruments you want to trade (e.g. `ETH-OPTION`) and the collateral you'll post
    (e.g. `USDC`). If you care about the margin model, decide `SM` (Standard cross-collateral) or
    `PM2` (Portfolio) too.
  </Step>

  <Step title="Find the manager">
    Call `public/get_risk_universes` and scan its managers for the one whose `instruments[]` include
    what you want to trade and whose `collaterals[]` include what you'll post (add a `margin_type`
    filter if you want a specific model). Its `manager_id` is the id you pass everywhere.
  </Step>

  <Step title="Confirm the collateral earns margin">
    Check your collateral's `im_discount` under that manager is non-zero — `"0"` means the manager
    holds it but grants no margin against it.
  </Step>

  <Step title="Create the subaccount">
    Pass the chosen id as `manager_id` when depositing to a new subaccount (see [Depositing](/getting-started/depositing)) —
    the collateral entry's `address` is the deposit `asset`. Universe, instruments, and collateral
    set all follow from it. You can read them back on `private/get_subaccount` via its `manager_id`
    and `risk_universe_id`.
  </Step>
</Steps>

<CodeGroup>
  ```typescript TypeScript (SDK) theme={null}
  import { DeriveClient } from '@derivexyz/derive-ts';

  // Public read — no login required.
  const client = new DeriveClient({ network: 'mainnet', wallet: process.env.PRIVATE_KEY! });

  // Universe-first: pick the manager that trades ETH options and accepts USDC.
  const universes = await client.marketData.getRiskUniverses();
  const manager = universes
    .flatMap((u) => u.managers)
    .find((m) => m.instruments.includes('ETH-OPTION') && m.collaterals.some((c) => c.name === 'USDC'))!;
  const usdc = manager.collaterals.find((c) => c.name === 'USDC')!;
  console.log(manager.manager_id, manager.margin_type, usdc.address);
  ```

  ```python Python (SDK) theme={null}
  import asyncio

  from derive_py import WebSocketClient


  async def main():
      client = WebSocketClient.from_env()
      await client.connect()

      # Universe-first: pick the manager that trades ETH options and accepts USDC.
      universes = await client.markets.get_risk_universes()
      manager = next(
          m
          for u in universes
          for m in u.managers
          if "ETH-OPTION" in m.instruments and any(c.name == "USDC" for c in m.collaterals)
      )
      usdc = next(c for c in manager.collaterals if c.name == "USDC")
      print(manager.manager_id, manager.margin_type, usdc.address)

      await client.disconnect()


  asyncio.run(main())
  ```

  ```rust Rust (SDK) theme={null}
  use derive_rs::{Environment, WsClient};

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      // Public read — no login required.
      let client = WsClient::new_public(Environment::Mainnet).await?;
      let universes = client.rpc().market_data().get_risk_universes().await?;

      // Universe-first: pick the manager that trades ETH options and accepts USDC.
      let manager = universes
          .iter()
          .flat_map(|u| &u.managers)
          .find(|m| {
              m.instruments.contains(&"ETH-OPTION".to_string())
                  && m.collaterals.iter().any(|c| c.name == "USDC")
          })
          .expect("no manager trades ETH options against USDC");
      let usdc = manager
          .collaterals
          .iter()
          .find(|c| c.name == "USDC")
          .expect("USDC collateral missing");

      println!("{} {:?} {}", manager.manager_id, manager.margin_type, usdc.address);
      Ok(())
  }
  ```
</CodeGroup>

<Warning>
  Choosing the wrong id has consequences at deposit and trade time:

  * **Fallback routing** — depositing to a non-existant manager or one that doesn't support your asset sends the funds to the fallback subaccount (universe `0`).
  * **Cross-universe trade** — a subaccount can't trade against a counterparty in a different universe; the order is
    rejected.
</Warning>

## The fallback universe

Universe **`0`** is a special **fallback** ("lost-and-found") universe: a no-margin holding area whose
only job is to safely custody collateral that has nowhere else to go. It registers every spot asset
but supports **no trading, borrowing, options, or perps**.

Every wallet is given a single fallback subaccount when its account is created. A deposit lands there —
instead of the subaccount you intended — whenever it can't be honoured as requested:

* it targets the fallback manager (`manager_id` `0`),
* the asset isn't registered in the target manager's universe, or
* the amount is below the subaccount-creation fee.

Funds in the fallback subaccount are safe but idle — you can't trade against them. To put them to work,
move the spot out to a real subaccount with `private/transfer_spot`.

The fallback appears in `public/get_risk_universes` like any other universe (as id `0`, listed
first) — with no tradeable instruments. Skip it when choosing where to deposit.


## Related topics

- [Error Codes](/error-codes.md)
- [New features](/migrating/new-features.md)
- [Programmatic Onboarding](/getting-started/depositing.md)
