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

# List Markets

> List all active external securities lending markets for your instance

Returns every active market deployed under the instance bound to your API key, each enriched with live contract metrics. Archived and inactive markets are excluded.

Enrichment is best effort. If the RPC is unreachable for a given market, `onChain` is returned as `null` and the database fields are still served. Always check `onChain` before reading from it.

## Response Fields

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="markets" type="array">
      <Expandable>
        <ResponseField name="id" type="string">Market ID. Use this as `marketId` on every other endpoint.</ResponseField>
        <ResponseField name="marketAddress" type="string">Lending market contract.</ResponseField>
        <ResponseField name="oracleAddress" type="string">Price oracle contract.</ResponseField>
        <ResponseField name="insuranceFundAddress" type="string">Insurance fund contract.</ResponseField>
        <ResponseField name="adapterAddress" type="string">Collateral adapter. A freeze adapter in `FREEZE` mode, a custody adapter in `CUSTODY` mode.</ResponseField>
        <ResponseField name="liquidationRouterAddress" type="string">This market's dedicated liquidation router. Markets deployed before per-market routers fall back to the shared legacy router.</ResponseField>
        <ResponseField name="collateralAgent" type="string">Named pledgee recorded on the market and on every adapter lock.</ResponseField>
        <ResponseField name="liquidationOperator" type="string">Address holding `OPERATOR_ROLE` on this market's liquidation router.</ResponseField>
        <ResponseField name="priceSource" type="string">`NAV` or `MARKET`.</ResponseField>
        <ResponseField name="collateralTokenAddress" type="string">ERC-3643 security token accepted as collateral.</ResponseField>
        <ResponseField name="collateralTokenName" type="string">Collateral token name.</ResponseField>
        <ResponseField name="collateralTokenSymbol" type="string">Collateral token symbol.</ResponseField>
        <ResponseField name="collateralTokenIsin" type="string">ISIN of the underlying security, when recorded.</ResponseField>
        <ResponseField name="collateralMode" type="string">`FREEZE` or `CUSTODY`.</ResponseField>
        <ResponseField name="collateralFactor" type="string">Maximum loan to value in basis points.</ResponseField>
        <ResponseField name="liquidationThreshold" type="string">Liquidation trigger in basis points.</ResponseField>
        <ResponseField name="closeFactor" type="string">Maximum fraction of debt repayable in one liquidation, in basis points.</ResponseField>
        <ResponseField name="useDutchAuction" type="boolean">Whether liquidations open a Dutch auction.</ResponseField>
        <ResponseField name="totalDeposits" type="string">Last recorded pool deposits.</ResponseField>
        <ResponseField name="totalBorrows" type="string">Last recorded outstanding borrows.</ResponseField>
        <ResponseField name="utilizationRate" type="string">Last recorded utilization in basis points.</ResponseField>
        <ResponseField name="borrowRate" type="string">Last recorded borrow rate in basis points.</ResponseField>
        <ResponseField name="supplyRate" type="string">Last recorded supply rate in basis points.</ResponseField>
        <ResponseField name="active" type="boolean">Always true in this response.</ResponseField>
        <ResponseField name="createdAt" type="string">ISO 8601 timestamp.</ResponseField>
        <ResponseField name="onChain" type="object">Live contract metrics, or `null` if the read failed. See [Get Market Metrics](/endpoints/external-securities-lending/get-metrics) for the full field list.</ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<Note>
  Database totals on the market record are refreshed after write operations executed through this API. Treat the `onChain` block as authoritative for live figures.
</Note>

<RequestExample>
  ```bash cURL theme={null}
  curl "https://api.trusset.org/lending-external-securities/api/markets" \
    -H "X-API-Key: trusset_your_key_here"
  ```

  ```typescript TypeScript theme={null}
  const res = await fetch(
    'https://api.trusset.org/lending-external-securities/api/markets',
    { headers: { 'X-API-Key': 'trusset_your_key_here' } }
  );
  const { data } = await res.json();

  for (const m of data.markets) {
    const live = m.onChain?.isOnChain ? m.onChain : null;
    console.log(m.collateralTokenSymbol, m.collateralMode, live?.availableLiquidity ?? 'unavailable');
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "markets": [
        {
          "id": "clx_secmarket_001",
          "marketAddress": "0x70A0E25c7b768B87e658348B3b577678A173E038",
          "oracleAddress": "0x3b25752c1459C5Cf1b0bfcFdF0D56883c8047423",
          "insuranceFundAddress": "0x8f1a...9c22",
          "adapterAddress": "0x4d2b...77ae",
          "liquidationRouterAddress": "0x067a3feea46649adad8e31c33b3a4d8774b8d8cf",
          "collateralAgent": "0x555...666",
          "liquidationOperator": "0x777...888",
          "priceSource": "NAV",
          "collateralTokenAddress": "0xabc...def",
          "collateralTokenName": "Nyala Fund I",
          "collateralTokenSymbol": "NYF1",
          "collateralTokenIsin": "DE000A0F5UF5",
          "collateralMode": "FREEZE",
          "collateralFactor": "7500",
          "liquidationThreshold": "8500",
          "closeFactor": "5000",
          "useDutchAuction": false,
          "totalDeposits": "1000000",
          "totalBorrows": "250000",
          "utilizationRate": "2500",
          "borrowRate": "450",
          "supplyRate": "84",
          "active": true,
          "createdAt": "2025-06-01T09:00:00.000Z",
          "onChain": {
            "isOnChain": true,
            "paused": false,
            "totalDeposits": "1000000.000000",
            "totalBorrows": "250000.000000",
            "availableLiquidity": "750000.000000",
            "utilizationRate": "2500",
            "borrowRate": "450",
            "supplyRate": "84",
            "activeLoans": 4,
            "activeAuctions": 0,
            "pendingLiquidations": 0,
            "pendingLiquidationDebt": "0.000000"
          }
        }
      ]
    },
    "metadata": {
      "timestamp": "2025-06-15T12:00:00.000Z",
      "requestId": "a1b2c3d4-...",
      "instanceId": "inst_abc123"
    }
  }
  ```
</ResponseExample>
